]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/jabber.php
Merge branch 'master' of git://gitorious.org/laconica/mainline into 0.7.x
[quix0rs-gnu-social.git] / lib / jabber.php
index 84d2a562cecccbb64791a158f1f88ec3ff66d4da..3fbb3e1ab9ee0c04c9ad263cc3ba43654b97a39b 100644 (file)
@@ -114,7 +114,7 @@ function jabber_connect($resource=null)
         try {
             $conn->connect(true); // true = persistent connection
         } catch (XMPPHP_Exception $e) {
-            common_log(LOG_ERROR, $e->getMessage());
+            common_log(LOG_ERR, $e->getMessage());
             return false;
         }
 
@@ -178,7 +178,7 @@ function jabber_format_entry($profile, $notice)
     $entry .= "<link href='" . htmlspecialchars($profile->profileurl) . "'/>\n";
     $entry .= "<link rel='self' type='application/rss+xml' href='" . $self_url . "'/>\n";
     $entry .= "<author><name>" . $profile->nickname . "</name></author>\n";
-    $entry .= "<icon>" . common_profile_avatar_url($profile, AVATAR_PROFILE_SIZE) . "</icon>\n";
+    $entry .= "<icon>" . $profile->avatarUrl(AVATAR_PROFILE_SIZE) . "</icon>\n";
     $entry .= "</source>\n";
     $entry .= "<title>" . htmlspecialchars($msg) . "</title>\n";
     $entry .= "<summary>" . htmlspecialchars($msg) . "</summary>\n";
@@ -186,6 +186,11 @@ function jabber_format_entry($profile, $notice)
     $entry .= "<id>". $notice->uri . "</id>\n";
     $entry .= "<published>".common_date_w3dtf($notice->created)."</published>\n";
     $entry .= "<updated>".common_date_w3dtf($notice->modified)."</updated>\n";
+    if ($notice->reply_to) {
+        $replyurl = common_local_url('shownotice',
+                                     array('notice' => $notice->reply_to));
+        $entry .= "<link rel='related' href='" . $replyurl . "'/>\n";
+    }
     $entry .= "</entry>\n";
 
     $html  = "\n<html xmlns='http://jabber.org/protocol/xhtml-im'>\n";
@@ -354,12 +359,13 @@ function jabber_broadcast_notice($notice)
 
     // First, get users to whom this is a direct reply
     $user = new User();
-    $user->query('SELECT user.id, user.jabber ' .
-                 'FROM user JOIN reply ON user.id = reply.profile_id ' .
+    $UT = common_config('db','type')=='pgsql'?'"user"':'user';
+    $user->query("SELECT $UT.id, $UT.jabber " .
+                 "FROM $UT JOIN reply ON $UT.id = reply.profile_id " .
                  'WHERE reply.notice_id = ' . $notice->id . ' ' .
-                 'AND user.jabber is not null ' .
-                 'AND user.jabbernotify = 1 ' .
-                 'AND user.jabberreplies = 1 ');
+                 "AND $UT.jabber is not null " .
+                 "AND $UT.jabbernotify = 1 " .
+                 "AND $UT.jabberreplies = 1 ");
 
     while ($user->fetch()) {
         common_log(LOG_INFO,
@@ -375,12 +381,12 @@ function jabber_broadcast_notice($notice)
     // Now, get users subscribed to this profile
 
     $user = new User();
-    $user->query('SELECT user.id, user.jabber ' .
-                 'FROM user JOIN subscription ' .
-                 'ON user.id = subscription.subscriber ' .
+    $user->query("SELECT $UT.id, $UT.jabber " .
+                 "FROM $UT JOIN subscription " .
+                 "ON $UT.id = subscription.subscriber " .
                  'WHERE subscription.subscribed = ' . $notice->profile_id . ' ' .
-                 'AND user.jabber is not null ' .
-                 'AND user.jabbernotify = 1 ' .
+                 "AND $UT.jabber is not null " .
+                 "AND $UT.jabbernotify = 1 " .
                  'AND subscription.jabber = 1 ');
 
     while ($user->fetch()) {
@@ -399,11 +405,13 @@ function jabber_broadcast_notice($notice)
     // Now, get users who have it in their inbox because of groups
 
     $user = new User();
-    $user->query('SELECT user.id, user.jabber ' .
-                 'FROM user JOIN notice_inbox ' .
-                 'ON user.id = notice_inbox.user_id ' .
+    $user->query("SELECT $UT.id, $UT.jabber " .
+                 "FROM $UT JOIN notice_inbox " .
+                 "ON $UT.id = notice_inbox.user_id " .
                  'WHERE notice_inbox.notice_id = ' . $notice->id . ' ' .
-                 'AND notice_inbox.source = 2 ');
+                 'AND notice_inbox.source = 2 ' .
+                 'AND user.jabber is not null ' .
+                 'AND user.jabbernotify = 1 ');
 
     while ($user->fetch()) {
         if (!array_key_exists($user->id, $sent_to)) {