]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/TwitterBridge/TwitterBridgePlugin.php
The overloaded DB_DataObject function staticGet is now called getKV
[quix0rs-gnu-social.git] / plugins / TwitterBridge / TwitterBridgePlugin.php
index d7c895d9cf4e8e7d401db4bd345e91bffa57ee31..6dc8ae8b76545eba81db84ad958de72ee37534ca 100644 (file)
@@ -148,8 +148,10 @@ class TwitterBridgePlugin extends Plugin
         if (self::hasKeys() && common_config('twitter', 'signin')) {
             $action->menuItem(
                 common_local_url('twitterlogin'),
-                _m('Twitter'),
-                _m('Login or register using Twitter'),
+                // TRANS: Menu item in login navigation.
+                _m('MENU','Twitter'),
+                // TRANS: Title for menu item in login navigation.
+                _m('Login or register using Twitter.'),
                 'twitterlogin' === $action_name
             );
         }
@@ -171,7 +173,9 @@ class TwitterBridgePlugin extends Plugin
 
             $action->menuItem(
                 common_local_url('twittersettings'),
-                _m('Twitter'),
+                // TRANS: Menu item in connection settings navigation.
+                _m('MENU','Twitter'),
+                // TRANS: Title for menu item in connection settings navigation.
                 _m('Twitter integration options'),
                 $action_name === 'twittersettings'
             );
@@ -200,6 +204,7 @@ class TwitterBridgePlugin extends Plugin
             return false;
         case 'TwitterOAuthClient':
         case 'TwitterQueueHandler':
+        case 'TweetInQueueHandler':
         case 'TwitterImport':
         case 'JsonStreamReader':
         case 'TwitterStreamReader':
@@ -228,7 +233,7 @@ class TwitterBridgePlugin extends Plugin
      */
     function onStartEnqueueNotice($notice, &$transports)
     {
-        if (self::hasKeys() && $notice->isLocal()) {
+        if (self::hasKeys() && $notice->isLocal() && $notice->inScope(null)) {
             // Avoid a possible loop
             if ($notice->source != 'twitter') {
                 array_push($transports, 'twitter');
@@ -244,7 +249,7 @@ class TwitterBridgePlugin extends Plugin
      *
      * @return boolean hook return
      */
-    function onGetValidDaemons($daemons)
+    function onGetValidDaemons(&$daemons)
     {
         if (self::hasKeys()) {
             array_push(
@@ -283,6 +288,18 @@ class TwitterBridgePlugin extends Plugin
         return true;
     }
 
+    /**
+     * If the plugin's installed, this should be accessible to admins
+     */
+    function onAdminPanelCheck($name, &$isOK)
+    {
+        if ($name == 'twitter') {
+            $isOK = true;
+            return false;
+        }
+        return true;
+    }
+
     /**
      * Add a Twitter tab to the admin panel
      *
@@ -299,8 +316,10 @@ class TwitterBridgePlugin extends Plugin
 
             $nav->out->menuItem(
                 common_local_url('twitteradminpanel'),
+                // TRANS: Menu item in administrative panel that leads to the Twitter bridge configuration.
                 _m('Twitter'),
-                _m('Twitter bridge configuration'),
+                // TRANS: Menu item title in administrative panel that leads to the Twitter bridge configuration.
+                _m('Twitter bridge configuration page.'),
                 $action_name == 'twitteradminpanel',
                 'nav_twitter_admin_panel'
             );
@@ -321,10 +340,10 @@ class TwitterBridgePlugin extends Plugin
         $versions[] = array(
             'name' => 'TwitterBridge',
             'version' => self::VERSION,
-            'author' => 'Zach Copley, Julien C',
+            'author' => 'Zach Copley, Julien C, Jean Baptiste Favre',
             'homepage' => 'http://status.net/wiki/Plugin:TwitterBridge',
-            'rawdescription' => _m(
-                'The Twitter "bridge" plugin allows integration ' .
+            // TRANS: Plugin description.
+            'rawdescription' => _m('The Twitter "bridge" plugin allows integration ' .
                 'of a StatusNet instance with ' .
                 '<a href="http://twitter.com/">Twitter</a>.'
             )
@@ -422,7 +441,7 @@ class TwitterBridgePlugin extends Plugin
      */
     function onStartDeleteOwnNotice(User $user, Notice $notice)
     {
-        $n2s = Notice_to_status::staticGet('notice_id', $notice->id);
+        $n2s = Notice_to_status::getKV('notice_id', $notice->id);
 
         if (!empty($n2s)) {
 
@@ -530,4 +549,41 @@ class TwitterBridgePlugin extends Plugin
 
         return true;
     }
+
+    function onStartGetProfileUri($profile, &$uri)
+    {
+        if (preg_match('!^https?://twitter.com/!', $profile->profileurl)) {
+            $uri = $profile->profileurl;
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Add links in the user's profile block to their Twitter profile URL.
+     *
+     * @param Profile $profile The profile being shown
+     * @param Array   &$links  Writeable array of arrays (href, text, image).
+     *
+     * @return boolean hook value (true)
+     */
+
+    function onOtherAccountProfiles($profile, &$links)
+    {
+        $fuser = null;
+
+        $flink = Foreign_link::getByUserID($profile->id, TWITTER_SERVICE);
+
+        if (!empty($flink)) {
+            $fuser = $flink->getForeignUser();
+
+            if (!empty($fuser)) {
+                $links[] = array("href" => $fuser->uri,
+                                 "text" => sprintf(_("@%s on Twitter"), $fuser->nickname),
+                                 "image" => $this->path("icons/twitter-bird-white-on-blue.png"));
+            }
+        }
+
+        return true;
+    }
 }