]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/omb.php
Revert "fixed up some invalid comment syntax - this is ANSI SQL"
[quix0rs-gnu-social.git] / lib / omb.php
index befcf4666a85bef45296aad94b84e8b1303e614b..7dca760c6951da3c72e2e71132d7c6c133d12400 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, Controlez-Vous, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as published by
@@ -17,7 +17,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-if (!defined('LACONICA')) { exit(1); }
+if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
 
 require_once('OAuth.php');
 require_once(INSTALLDIR.'/lib/oauthstore.php');
@@ -66,7 +66,7 @@ function omb_oauth_datastore()
 {
     static $store = null;
     if (!$store) {
-        $store = new LaconicaOAuthDataStore();
+        $store = new StatusNetOAuthDataStore();
     }
     return $store;
 }
@@ -135,7 +135,7 @@ function omb_broadcast_remote_subscribers($notice)
     $posted = array();
 
     while ($rp->fetch()) {
-        if (!$posted[$rp->postnoticeurl]) {
+        if (!array_key_exists($rp->postnoticeurl, $posted)) {
             common_log(LOG_DEBUG, 'Posting to ' . $rp->postnoticeurl);
             if (omb_post_notice_keys($notice, $rp->postnoticeurl, $rp->token, $rp->secret)) {
                 common_log(LOG_DEBUG, 'Finished to ' . $rp->postnoticeurl);
@@ -159,13 +159,9 @@ function omb_post_notice($notice, $remote_profile, $subscription)
 
 function omb_post_notice_keys($notice, $postnoticeurl, $tk, $secret)
 {
-
-    common_debug('Posting notice ' . $notice->id . ' to ' . $postnoticeurl, __FILE__);
-
     $user = User::staticGet('id', $notice->profile_id);
 
     if (!$user) {
-        common_debug('Failed to get user for notice ' . $notice->id . ', profile = ' . $notice->profile_id, __FILE__);
         return false;
     }
 
@@ -206,9 +202,7 @@ function omb_post_notice_keys($notice, $postnoticeurl, $tk, $secret)
 
     $result = $fetcher->post($req->get_normalized_http_url(),
                              $req->to_postdata(),
-                             array('User-Agent: Laconica/' . LACONICA_VERSION));
-
-    common_debug('Got HTTP result "'.print_r($result,true).'"', __FILE__);
+                             array('User-Agent: StatusNet/' . STATUSNET_VERSION));
 
     if ($result->status == 403) { # not authorized, don't send again
         common_debug('403 result, deleting subscription', __FILE__);
@@ -251,7 +245,6 @@ function omb_broadcast_profile($profile)
 
 function omb_update_profile($profile, $remote_profile, $subscription)
 {
-    global $config; # for license URL
     $user = User::staticGet($profile->id);
     $con = omb_oauth_consumer();
     $token = new OAuthToken($subscription->token, $subscription->secret);
@@ -287,15 +280,11 @@ function omb_update_profile($profile, $remote_profile, $subscription)
 
     $fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
 
-    common_debug('request URL = '.$req->get_normalized_http_url(), __FILE__);
-    common_debug('postdata = '.$req->to_postdata(), __FILE__);
     $result = $fetcher->post($req->get_normalized_http_url(),
                              $req->to_postdata(),
-                             array('User-Agent: Laconica/' . LACONICA_VERSION));
+                             array('User-Agent: StatusNet/' . STATUSNET_VERSION));
 
-    common_debug('Got HTTP result "'.print_r($result,true).'"', __FILE__);
-
-    if (empty($result) || $result) {
+    if (empty($result) || !$result) {
         common_debug("Unable to contact " . $req->get_normalized_http_url());
     } else if ($result->status == 403) { # not authorized, don't send again
         common_debug('403 result, deleting subscription', __FILE__);
@@ -306,7 +295,7 @@ function omb_update_profile($profile, $remote_profile, $subscription)
         return false;
     } else { # success!
         parse_str($result->body, $return);
-        if ($return['omb_version'] == OMB_VERSION_01) {
+        if (isset($return['omb_version']) && $return['omb_version'] === OMB_VERSION_01) {
             return true;
         } else {
             return false;