]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/TwitterBridge/TwitterBridgePlugin.php
Merge branch 'master' of git@gitorious.org:statusnet/mainline into testing
[quix0rs-gnu-social.git] / plugins / TwitterBridge / TwitterBridgePlugin.php
index de1181903e805142da3b3538687644a6c5847fd7..c7f57ffc7753066f29b86d4020b072fe41ddd928 100644 (file)
@@ -20,7 +20,8 @@
  * @category  Plugin
  * @package   StatusNet
  * @author    Zach Copley <zach@status.net>
- * @copyright 2009 Control Yourself, Inc.
+ * @author    Julien C <chaumond@gmail.com>
+ * @copyright 2009-2010 Control Yourself, Inc.
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link      http://laconi.ca/
  */
@@ -31,6 +32,8 @@ if (!defined('STATUSNET')) {
 
 require_once INSTALLDIR . '/plugins/TwitterBridge/twitter.php';
 
+define('TWITTERBRIDGEPLUGIN_VERSION', '0.9');
+
 /**
  * Plugin for sending and importing Twitter statuses
  *
@@ -39,6 +42,7 @@ require_once INSTALLDIR . '/plugins/TwitterBridge/twitter.php';
  * @category Plugin
  * @package  StatusNet
  * @author   Zach Copley <zach@status.net>
+ * @author   Julien C <chaumond@gmail.com>
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link     http://laconi.ca/
  * @link     http://twitter.com/
@@ -70,6 +74,27 @@ class TwitterBridgePlugin extends Plugin
         $m->connect('twitter/authorization',
                     array('action' => 'twitterauthorization'));
         $m->connect('settings/twitter', array('action' => 'twittersettings'));
+        $m->connect('main/twitterlogin', array('action' => 'twitterlogin'));
+
+        return true;
+    }
+
+    /*
+     * Add a login tab for 'Sign in with Twitter'
+     *
+     * @param Action &action the current action
+     *
+     * @return void
+     */
+    function onEndLoginGroupNav(&$action)
+    {
+
+        $action_name = $action->trimmed('action');
+
+        $action->menuItem(common_local_url('twitterlogin'),
+                                           _('Twitter'),
+                                           _('Login or register using Twitter'),
+                                             'twitterlogin' === $action_name);
 
         return true;
     }
@@ -106,11 +131,14 @@ class TwitterBridgePlugin extends Plugin
         switch ($cls) {
         case 'TwittersettingsAction':
         case 'TwitterauthorizationAction':
+        case 'TwitterloginAction':
             include_once INSTALLDIR . '/plugins/TwitterBridge/' .
               strtolower(mb_substr($cls, 0, -6)) . '.php';
             return false;
         case 'TwitterOAuthClient':
-            include_once INSTALLDIR . '/plugins/TwitterBridge/twitteroauthclient.php';
+        case 'TwitterQueueHandler':
+            include_once INSTALLDIR . '/plugins/TwitterBridge/' .
+              strtolower($cls) . '.php';
             return false;
         default:
             return true;
@@ -137,55 +165,48 @@ class TwitterBridgePlugin extends Plugin
     }
 
     /**
-     * broadcast the message when not using queuehandler
+     * Add Twitter bridge daemons to the list of daemons to start
      *
-     * @param Notice &$notice the notice
-     * @param array  $queue   destination queue
+     * @param array $daemons the list fo daemons to run
      *
      * @return boolean hook return
      */
-    function onUnqueueHandleNotice(&$notice, $queue)
+    function onGetValidDaemons($daemons)
     {
-        if (($queue == 'twitter') && ($this->_isLocal($notice))) {
-            broadcast_twitter($notice);
-            return false;
+        array_push($daemons, INSTALLDIR .
+                   '/plugins/TwitterBridge/daemons/synctwitterfriends.php');
+
+        if (common_config('twitterimport', 'enabled')) {
+            array_push($daemons, INSTALLDIR
+                . '/plugins/TwitterBridge/daemons/twitterstatusfetcher.php');
         }
+
         return true;
     }
 
     /**
-     * Determine whether the notice was locally created
+     * Register Twitter notice queue handler
      *
-     * @param Notice $notice
+     * @param QueueManager $manager
      *
-     * @return boolean locality
+     * @return boolean hook return
      */
-    function _isLocal($notice)
+    function onEndInitializeQueueManager($manager)
     {
-        return ($notice->is_local == Notice::LOCAL_PUBLIC ||
-                $notice->is_local == Notice::LOCAL_NONPUBLIC);
+        $manager->connect('twitter', 'TwitterQueueHandler');
+        return true;
     }
 
-    /**
-     * Add Twitter bridge daemons to the list of daemons to start
-     *
-     * @param array $daemons the list fo daemons to run
-     *
-     * @return boolean hook return
-     *
-     */
-    function onGetValidDaemons($daemons)
+    function onPluginVersion(&$versions)
     {
-        array_push($daemons, INSTALLDIR .
-                   '/plugins/TwitterBridge/daemons/twitterqueuehandler.php');
-        array_push($daemons, INSTALLDIR .
-                   '/plugins/TwitterBridge/daemons/synctwitterfriends.php');
-
-        if (common_config('twitterimport', 'enabled')) {
-            array_push($daemons, INSTALLDIR
-                . '/plugins/TwitterBridge/daemons/twitterstatusfetcher.php');
-        }
-
+        $versions[] = array('name' => 'TwitterBridge',
+                            'version' => TWITTERBRIDGEPLUGIN_VERSION,
+                            'author' => 'Zach Copley',
+                            'homepage' => 'http://status.net/wiki/Plugin:TwitterBridge',
+                            'rawdescription' =>
+                            _m('The Twitter "bridge" plugin allows you to integrate ' .
+                               'your StatusNet instance with ' .
+                               '<a href="http://twitter.com/">Twitter</a>.'));
         return true;
     }