diff options
-rw-r--r-- | lib/common.php | 1 | ||||
-rw-r--r-- | lib/connectsettingsaction.php | 49 | ||||
-rw-r--r-- | lib/router.php | 6 | ||||
-rw-r--r-- | plugins/TwitterBridge/TwitterBridgePlugin.php | 101 | ||||
-rwxr-xr-x | plugins/TwitterBridge/daemons/synctwitterfriends.php (renamed from scripts/synctwitterfriends.php) | 3 | ||||
-rwxr-xr-x | plugins/TwitterBridge/daemons/twitterqueuehandler.php (renamed from scripts/twitterqueuehandler.php) | 7 | ||||
-rwxr-xr-x | plugins/TwitterBridge/daemons/twitterstatusfetcher.php (renamed from scripts/twitterstatusfetcher.php) | 5 | ||||
-rw-r--r-- | plugins/TwitterBridge/twitter.php (renamed from lib/twitter.php) | 0 | ||||
-rw-r--r-- | plugins/TwitterBridge/twitterauthorization.php (renamed from actions/twitterauthorization.php) | 25 | ||||
-rw-r--r-- | plugins/TwitterBridge/twitterbasicauthclient.php (renamed from lib/twitterbasicauthclient.php) | 0 | ||||
-rw-r--r-- | plugins/TwitterBridge/twitteroauthclient.php (renamed from lib/twitteroauthclient.php) | 0 | ||||
-rw-r--r-- | plugins/TwitterBridge/twittersettings.php (renamed from actions/twittersettings.php) | 9 |
12 files changed, 162 insertions, 44 deletions
diff --git a/lib/common.php b/lib/common.php index ce33c871b..e29456ed4 100644 --- a/lib/common.php +++ b/lib/common.php @@ -223,7 +223,6 @@ require_once INSTALLDIR.'/lib/theme.php'; require_once INSTALLDIR.'/lib/mail.php'; require_once INSTALLDIR.'/lib/subs.php'; require_once INSTALLDIR.'/lib/Shorturl_api.php'; -require_once INSTALLDIR.'/lib/twitter.php'; require_once INSTALLDIR.'/lib/clientexception.php'; require_once INSTALLDIR.'/lib/serverexception.php'; diff --git a/lib/connectsettingsaction.php b/lib/connectsettingsaction.php index 2095a7ceb..e5fb8727b 100644 --- a/lib/connectsettingsaction.php +++ b/lib/connectsettingsaction.php @@ -98,34 +98,37 @@ class ConnectSettingsNav extends Widget function show() { - # action => array('prompt', 'title') - $menu = array(); - if (common_config('xmpp', 'enabled')) { - $menu['imsettings'] = - array(_('IM'), - _('Updates by instant messenger (IM)')); - } - if (common_config('sms', 'enabled')) { - $menu['smssettings'] = - array(_('SMS'), - _('Updates by SMS')); - } - if (common_config('twitter', 'enabled')) { - $menu['twittersettings'] = - array(_('Twitter'), - _('Twitter integration options')); - } - $action_name = $this->action->trimmed('action'); $this->action->elementStart('ul', array('class' => 'nav')); - foreach ($menu as $menuaction => $menudesc) { - $this->action->menuItem(common_local_url($menuaction), - $menudesc[0], - $menudesc[1], - $action_name === $menuaction); + if (Event::handle('StartConnectSettingsNav', array(&$this->action))) { + + # action => array('prompt', 'title') + $menu = array(); + if (common_config('xmpp', 'enabled')) { + $menu['imsettings'] = + array(_('IM'), + _('Updates by instant messenger (IM)')); + } + if (common_config('sms', 'enabled')) { + $menu['smssettings'] = + array(_('SMS'), + _('Updates by SMS')); + } + + foreach ($menu as $menuaction => $menudesc) { + $this->action->menuItem(common_local_url($menuaction), + $menudesc[0], + $menudesc[1], + $action_name === $menuaction); + } + + Event::handle('EndConnectSettingsNav', array(&$this->action)); } $this->action->elementEnd('ul'); } + } + + diff --git a/lib/router.php b/lib/router.php index b9a45d867..a5b6a9a30 100644 --- a/lib/router.php +++ b/lib/router.php @@ -86,10 +86,6 @@ class Router $m->connect('doc/:title', array('action' => 'doc')); - // Twitter - - $m->connect('twitter/authorization', array('action' => 'twitterauthorization')); - // facebook $m->connect('facebook', array('action' => 'facebookhome')); @@ -136,7 +132,7 @@ class Router // settings foreach (array('profile', 'avatar', 'password', 'im', - 'email', 'sms', 'twitter', 'userdesign', 'other') as $s) { + 'email', 'sms', 'userdesign', 'other') as $s) { $m->connect('settings/'.$s, array('action' => $s.'settings')); } diff --git a/plugins/TwitterBridge/TwitterBridgePlugin.php b/plugins/TwitterBridge/TwitterBridgePlugin.php new file mode 100644 index 000000000..a8de1c664 --- /dev/null +++ b/plugins/TwitterBridge/TwitterBridgePlugin.php @@ -0,0 +1,101 @@ +<?php +/** + * Laconica, the distributed open-source microblogging tool + * + * PHP version 5 + * + * LICENCE: This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @category Plugin + * @package Laconica + * @author Zach Copley <zach@controlyourself.ca> + * @copyright 2009 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/ + */ + +if (!defined('LACONICA')) { + exit(1); +} + +/** + * Plugin for sending and importing Twitter statuses + * + * This class allows users to link their Twitter accounts + * + * @category Plugin + * @package Laconica + * @author Zach Copley <zach@controlyourself.ca> + * @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/ + */ + +class TwitterBridgePlugin extends Plugin +{ + /** + * Initializer for the plugin. + */ + + function __construct() + { + parent::__construct(); + } + + /** + * Add Twitter-related paths to the router table + * + * Hook for RouterInitialized event. + * + * @return boolean hook return + */ + + function onRouterInitialized(&$m) + { + $m->connect('twitter/authorization', array('action' => 'twitterauthorization')); + $m->connect('settings/twitter', array('action' => 'twittersettings')); + + return true; + } + + function onEndConnectSettingsNav(&$action) + { + $action_name = $action->trimmed('action'); + + $action->menuItem(common_local_url('twittersettings'), + _('Twitter'), + _('Twitter integration options'), + $action_name === 'twittersettings'); + + return true; + } + + function onAutoload($cls) + { + switch ($cls) + { + case 'TwittersettingsAction': + case 'TwitterauthorizationAction': + require_once(INSTALLDIR.'/plugins/TwitterBridge/' . strtolower(mb_substr($cls, 0, -6)) . '.php'); + return false; + case 'TwitterOAuthClient': + require_once(INSTALLDIR.'/plugins/TwitterBridge/twitteroauthclient.php'); + return false; + default: + return true; + } + } + + +}
\ No newline at end of file diff --git a/scripts/synctwitterfriends.php b/plugins/TwitterBridge/daemons/synctwitterfriends.php index b30e700a1..0668c6222 100755 --- a/scripts/synctwitterfriends.php +++ b/plugins/TwitterBridge/daemons/synctwitterfriends.php @@ -18,7 +18,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); +define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); $shortoptions = 'di::'; $longoptions = array('id::', 'debug'); @@ -32,6 +32,7 @@ END_OF_TRIM_HELP; require_once INSTALLDIR . '/scripts/commandline.inc'; require_once INSTALLDIR . '/lib/parallelizingdaemon.php'; +require_once INSTALLDIR . '/plugins/TwitterBridge/twitter.php'; /** * Daemon to sync local friends with Twitter friends diff --git a/scripts/twitterqueuehandler.php b/plugins/TwitterBridge/daemons/twitterqueuehandler.php index ce4d824d0..f0e76bb74 100755 --- a/scripts/twitterqueuehandler.php +++ b/plugins/TwitterBridge/daemons/twitterqueuehandler.php @@ -18,7 +18,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); +define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); $shortoptions = 'i::'; $longoptions = array('id::'); @@ -30,10 +30,9 @@ Daemon script for pushing new notices to Twitter. END_OF_ENJIT_HELP; -require_once INSTALLDIR.'/scripts/commandline.inc'; - -require_once INSTALLDIR . '/lib/twitter.php'; +require_once INSTALLDIR . '/scripts/commandline.inc'; require_once INSTALLDIR . '/lib/queuehandler.php'; +require_once INSTALLDIR . '/plugins/TwitterBridge/twitter.php'; class TwitterQueueHandler extends QueueHandler { diff --git a/scripts/twitterstatusfetcher.php b/plugins/TwitterBridge/daemons/twitterstatusfetcher.php index 3cdf1867a..4752ada7c 100755 --- a/scripts/twitterstatusfetcher.php +++ b/plugins/TwitterBridge/daemons/twitterstatusfetcher.php @@ -18,7 +18,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); +define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); // Tune number of processes and how often to poll Twitter // XXX: Should these things be in config.php? @@ -36,8 +36,9 @@ Batch script for retrieving Twitter messages from foreign service. END_OF_TRIM_HELP; -require_once INSTALLDIR .'/scripts/commandline.inc'; +require_once INSTALLDIR . '/scripts/commandline.inc'; require_once INSTALLDIR . '/lib/daemon.php'; +require_once INSTALLDIR . '/plugins/TwitterBridge/twitter.php'; /** * Fetcher for statuses from Twitter diff --git a/lib/twitter.php b/plugins/TwitterBridge/twitter.php index afc3f55ba..afc3f55ba 100644 --- a/lib/twitter.php +++ b/plugins/TwitterBridge/twitter.php diff --git a/actions/twitterauthorization.php b/plugins/TwitterBridge/twitterauthorization.php index 630ac426f..2a93ff13e 100644 --- a/actions/twitterauthorization.php +++ b/plugins/TwitterBridge/twitterauthorization.php @@ -31,9 +31,32 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } +require_once INSTALLDIR . '/plugins/TwitterBridge/twitter.php'; + +/** + * Class for doing OAuth authentication against Twitter + * + * Peforms the OAuth "dance" between StatusNet and Twitter -- requests a token, + * authorizes it, and exchanges it for an access token. It also creates a link + * (Foreign_link) between the StatusNet user and Twitter user and stores the + * access token and secret in the link. + * + * @category Twitter + * @package StatusNet + * @author Zach Copley <zach@status.net> + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + * + */ class TwitterauthorizationAction extends Action { - + /** + * Initialize class members. Looks for 'oauth_token' parameter. + * + * @param array $args misc. arguments + * + * @return boolean true + */ function prepare($args) { parent::prepare($args); diff --git a/lib/twitterbasicauthclient.php b/plugins/TwitterBridge/twitterbasicauthclient.php index 1040d72fb..1040d72fb 100644 --- a/lib/twitterbasicauthclient.php +++ b/plugins/TwitterBridge/twitterbasicauthclient.php diff --git a/lib/twitteroauthclient.php b/plugins/TwitterBridge/twitteroauthclient.php index bad2b74ca..bad2b74ca 100644 --- a/lib/twitteroauthclient.php +++ b/plugins/TwitterBridge/twitteroauthclient.php diff --git a/actions/twittersettings.php b/plugins/TwitterBridge/twittersettings.php index 89169941e..2afa85ba4 100644 --- a/actions/twittersettings.php +++ b/plugins/TwitterBridge/twittersettings.php @@ -31,8 +31,8 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } -require_once INSTALLDIR.'/lib/connectsettingsaction.php'; -require_once INSTALLDIR.'/lib/twitter.php'; +require_once INSTALLDIR . '/lib/connectsettingsaction.php'; +require_once INSTALLDIR . '/plugins/TwitterBridge/twitter.php'; /** * Settings for Twitter integration @@ -82,11 +82,6 @@ class TwittersettingsAction extends ConnectSettingsAction function showContent() { - if (!common_config('twitter', 'enabled')) { - $this->element('div', array('class' => 'error'), - _('Twitter is not available.')); - return; - } $user = common_current_user(); |