require_once INSTALLDIR . '/plugins/TwitterBridge/twitter.php';
+define('TWITTERBRIDGEPLUGIN_VERSION', '0.9');
+
/**
* Plugin for sending and importing Twitter statuses
*
$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 Twitter Connect
+ *
+ * @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;
}
+
/**
* Add the Twitter Settings page to the Connect Settings menu
$action_name = $action->trimmed('action');
$action->menuItem(common_local_url('twittersettings'),
- _('Twitter'),
- _('Twitter integration options'),
+ _m('Twitter'),
+ _m('Twitter integration options'),
$action_name === 'twittersettings');
return true;
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;
*/
function onStartEnqueueNotice($notice, &$transports)
{
- array_push($transports, 'twitter');
- return true;
- }
+ // Avoid a possible loop
- /**
- * broadcast the message when not using queuehandler
- *
- * @param Notice &$notice the notice
- * @param array $queue destination queue
- *
- * @return boolean hook return
- */
- function onUnqueueHandleNotice(&$notice, $queue)
- {
- if (($queue == 'twitter') && ($this->_isLocal($notice))) {
- broadcast_twitter($notice);
- return false;
+ if ($notice->source != 'twitter') {
+ array_push($transports, 'twitter');
}
- return true;
- }
- /**
- * Determine whether the notice was locally created
- *
- * @param Notice $notice
- *
- * @return boolean locality
- */
- function _isLocal($notice)
- {
- return ($notice->is_local == Notice::LOCAL_PUBLIC ||
- $notice->is_local == Notice::LOCAL_NONPUBLIC);
+ return true;
}
/**
* @param array $daemons the list fo daemons to run
*
* @return boolean hook return
- *
*/
function onGetValidDaemons($daemons)
{
- array_push($daemons, INSTALLDIR .
- '/plugins/TwitterBridge/daemons/twitterqueuehandler.php');
array_push($daemons, INSTALLDIR .
'/plugins/TwitterBridge/daemons/synctwitterfriends.php');
return true;
}
+ /**
+ * Register Twitter notice queue handler
+ *
+ * @param QueueManager $manager
+ *
+ * @return boolean hook return
+ */
+ function onEndInitializeQueueManager($manager)
+ {
+ $manager->connect('twitter', 'TwitterQueueHandler');
+ return true;
+ }
+
+ function onPluginVersion(&$versions)
+ {
+ $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;
+ }
+
}