3 * StatusNet, the distributed open-source microblogging tool
7 * LICENCE: This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 * @author Zach Copley <zach@status.net>
23 * @copyright 2009 Control Yourself, Inc.
24 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
25 * @link http://laconi.ca/
28 if (!defined('STATUSNET')) {
33 * Plugin for sending and importing Twitter statuses
35 * This class allows users to link their Twitter accounts
39 * @author Zach Copley <zach@status.net>
40 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
41 * @link http://laconi.ca/
42 * @link http://twitter.com/
45 class TwitterBridgePlugin extends Plugin
48 * Initializer for the plugin.
51 function __construct()
53 parent::__construct();
57 * Add Twitter-related paths to the router table
59 * Hook for RouterInitialized event.
61 * @param Net_URL_Mapper &$m path-to-action mapper
63 * @return boolean hook return
66 function onRouterInitialized(&$m)
68 $m->connect('twitter/authorization',
69 array('action' => 'twitterauthorization'));
70 $m->connect('settings/twitter', array('action' => 'twittersettings'));
76 * Add the Twitter Settings page to the Connect Settings menu
78 * @param Action &$action The calling page
80 * @return boolean hook return
82 function onEndConnectSettingsNav(&$action)
84 $action_name = $action->trimmed('action');
86 $action->menuItem(common_local_url('twittersettings'),
88 _('Twitter integration options'),
89 $action_name === 'twittersettings');
95 * Automatically load the actions and libraries used by the Twitter bridge
97 * @param Class $cls the class
99 * @return boolean hook return
102 function onAutoload($cls)
105 case 'TwittersettingsAction':
106 case 'TwitterauthorizationAction':
107 include_once INSTALLDIR.'/plugins/TwitterBridge/' .
108 strtolower(mb_substr($cls, 0, -6)) . '.php';
110 case 'TwitterOAuthClient':
111 include_once INSTALLDIR.'/plugins/TwitterBridge/twitteroauthclient.php';
119 * Add a Twitter queue item for each notice
121 * @param Notice $notice the notice
122 * @param array $transports the list of transports (queues)
124 * @return boolean hook return
126 function onStartEnqueueNotice($notice, $transports)
128 array_push($transports, 'twitter');
133 * Add Twitter bridge daemons to the list of daemons to start
135 * @param array $daemons the list fo daemons to run
137 * @return boolean hook return
140 function onGetValidDaemons($daemons)
142 array_push($daemons, INSTALLDIR .
143 '/plugins/TwitterBridge/daemons/twitterqueuehandler.php');
144 array_push($daemons, INSTALLDIR .
145 '/plugins/TwitterBridge/daemons/synctwitterfriends.php');
147 if (common_config('twitterimport', 'enabled')) {
148 array_push($daemons, INSTALLDIR
149 . '/plugins/TwitterBridge/daemons/twitterstatusfetcher.php');