diff --git a/plugins/TwitterBridge/TwitterBridgePlugin.php b/plugins/TwitterBridge/TwitterBridgePlugin.php index 34b82ef83a..94d4d9e475 100644 --- a/plugins/TwitterBridge/TwitterBridgePlugin.php +++ b/plugins/TwitterBridge/TwitterBridgePlugin.php @@ -45,7 +45,6 @@ require_once INSTALLDIR . '/plugins/TwitterBridge/twitter.php'; * @link http://status.net/ * @link http://twitter.com/ */ - class TwitterBridgePlugin extends Plugin { @@ -55,7 +54,6 @@ class TwitterBridgePlugin extends Plugin /** * Initializer for the plugin. */ - function initialize() { // Allow the key and secret to be passed in @@ -86,7 +84,6 @@ class TwitterBridgePlugin extends Plugin * * @return boolean result */ - static function hasKeys() { $ckey = common_config('twitter', 'consumer_key'); @@ -113,7 +110,6 @@ class TwitterBridgePlugin extends Plugin * * @return boolean hook return */ - function onRouterInitialized($m) { $m->connect('admin/twitter', array('action' => 'twitteradminpanel')); @@ -310,7 +306,6 @@ class TwitterBridgePlugin extends Plugin * * @return boolean hook value */ - function onPluginVersion(&$versions) { $versions[] = array( @@ -319,8 +314,8 @@ class TwitterBridgePlugin extends Plugin 'author' => 'Zach Copley, Julien C', 'homepage' => 'http://status.net/wiki/Plugin:TwitterBridge', 'rawdescription' => _m( - 'The Twitter "bridge" plugin allows you to integrate ' . - 'your StatusNet instance with ' . + 'The Twitter "bridge" plugin allows integration ' . + 'of a StatusNet instance with ' . 'Twitter.' ) ); @@ -374,7 +369,6 @@ class TwitterBridgePlugin extends Plugin * * @return boolean hook value; true means continue processing, false means stop. */ - function onCheckSchema() { $schema = Schema::get(); @@ -416,7 +410,6 @@ class TwitterBridgePlugin extends Plugin * * @return boolean hook value */ - function onStartDeleteOwnNotice(User $user, Notice $notice) { $n2s = Notice_to_status::staticGet('notice_id', $notice->id); @@ -452,7 +445,6 @@ class TwitterBridgePlugin extends Plugin * @param Notice $notice being favored * @return hook return value */ - function onEndFavorNotice(Profile $profile, Notice $notice) { $flink = Foreign_link::getByUserID($profile->id, @@ -489,7 +481,6 @@ class TwitterBridgePlugin extends Plugin * * @return hook return value */ - function onEndDisfavorNotice(Profile $profile, Notice $notice) { $flink = Foreign_link::getByUserID($profile->id, diff --git a/plugins/TwitterBridge/Twitter_synch_status.php b/plugins/TwitterBridge/Twitter_synch_status.php index 2a5f1fd605..a8337862c8 100644 --- a/plugins/TwitterBridge/Twitter_synch_status.php +++ b/plugins/TwitterBridge/Twitter_synch_status.php @@ -48,7 +48,6 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php'; * * @see DB_DataObject */ - class Twitter_synch_status extends Memcached_DataObject { public $__table = 'twitter_synch_status'; // table name @@ -67,7 +66,6 @@ class Twitter_synch_status extends Memcached_DataObject * @return Twitter_synch_status object found, or null for no hits * */ - function staticGet($k, $v=null) { throw new Exception("Use pkeyGet() for this class."); @@ -81,7 +79,6 @@ class Twitter_synch_status extends Memcached_DataObject * @return Twitter_synch_status object found, or null for no hits * */ - function pkeyGet($kv) { return Memcached_DataObject::pkeyGet('Twitter_synch_status', $kv); @@ -95,7 +92,6 @@ class Twitter_synch_status extends Memcached_DataObject * * @return array array of column definitions */ - function table() { return array('foreign_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL, @@ -115,7 +111,6 @@ class Twitter_synch_status extends Memcached_DataObject * * @return array list of key field names */ - function keys() { return array_keys($this->keyTypes()); @@ -133,7 +128,6 @@ class Twitter_synch_status extends Memcached_DataObject * 'K' for primary key: for compound keys, add an entry for each component; * 'U' for unique keys: compound keys are not well supported here. */ - function keyTypes() { return array('foreign_id' => 'K', @@ -150,7 +144,6 @@ class Twitter_synch_status extends Memcached_DataObject * * @return array magic three-false array that stops auto-incrementing. */ - function sequenceKey() { return array(false, false, false); @@ -174,7 +167,6 @@ class Twitter_synch_status extends Memcached_DataObject 'timeline' => $timeline)); if (empty($tss)) { - $tss = new Twitter_synch_status(); $tss->foreign_id = $foreign_id; @@ -186,9 +178,7 @@ class Twitter_synch_status extends Memcached_DataObject $tss->insert(); return true; - } else { - $orig = clone($tss); $tss->last_id = $last_id; diff --git a/plugins/TwitterBridge/daemons/synctwitterfriends.php b/plugins/TwitterBridge/daemons/synctwitterfriends.php index 02546a02ca..38a8b89ebb 100755 --- a/plugins/TwitterBridge/daemons/synctwitterfriends.php +++ b/plugins/TwitterBridge/daemons/synctwitterfriends.php @@ -45,7 +45,6 @@ require_once INSTALLDIR . '/plugins/TwitterBridge/twitteroauthclient.php'; * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ - class SyncTwitterFriendsDaemon extends ParallelizingDaemon { /** @@ -59,7 +58,6 @@ class SyncTwitterFriendsDaemon extends ParallelizingDaemon * @return void * **/ - function __construct($id = null, $interval = 60, $max_children = 2, $debug = null) { @@ -71,7 +69,6 @@ class SyncTwitterFriendsDaemon extends ParallelizingDaemon * * @return string Name of the daemon. */ - function name() { return ('synctwitterfriends.' . $this->_id); @@ -110,12 +107,10 @@ class SyncTwitterFriendsDaemon extends ParallelizingDaemon } function childTask($flink) { - // Each child ps needs its own DB connection // Note: DataObject::getDatabaseConnection() creates // a new connection if there isn't one already - $conn = &$flink->getDatabaseConnection(); $this->subscribeTwitterFriends($flink); @@ -127,7 +122,6 @@ class SyncTwitterFriendsDaemon extends ParallelizingDaemon // XXX: Couldn't find a less brutal way to blow // away a cached connection - global $_DB_DATAOBJECT; unset($_DB_DATAOBJECT['CONNECTIONS']); } @@ -277,4 +271,3 @@ if (have_option('d') || have_option('debug')) { $syncer = new SyncTwitterFriendsDaemon($id, 60, 2, $debug); $syncer->runOnce(); - diff --git a/plugins/TwitterBridge/daemons/twitterstatusfetcher.php b/plugins/TwitterBridge/daemons/twitterstatusfetcher.php index f1305696b3..31129b96d9 100755 --- a/plugins/TwitterBridge/daemons/twitterstatusfetcher.php +++ b/plugins/TwitterBridge/daemons/twitterstatusfetcher.php @@ -62,7 +62,6 @@ require_once INSTALLDIR . '/plugins/TwitterBridge/twitteroauthclient.php'; * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ - class TwitterStatusFetcher extends ParallelizingDaemon { /** @@ -87,7 +86,6 @@ class TwitterStatusFetcher extends ParallelizingDaemon * * @return string Name of the daemon. */ - function name() { return ('twitterstatusfetcher.'.$this->_id); @@ -99,7 +97,6 @@ class TwitterStatusFetcher extends ParallelizingDaemon * * @return array flinks an array of Foreign_link objects */ - function getObjects() { global $_DB_DATAOBJECT; @@ -133,12 +130,10 @@ class TwitterStatusFetcher extends ParallelizingDaemon } function childTask($flink) { - // Each child ps needs its own DB connection // Note: DataObject::getDatabaseConnection() creates // a new connection if there isn't one already - $conn = &$flink->getDatabaseConnection(); $this->getTimeline($flink); @@ -150,7 +145,6 @@ class TwitterStatusFetcher extends ParallelizingDaemon // XXX: Couldn't find a less brutal way to blow // away a cached connection - global $_DB_DATAOBJECT; unset($_DB_DATAOBJECT['CONNECTIONS']); } @@ -201,9 +195,7 @@ class TwitterStatusFetcher extends ParallelizingDaemon // Reverse to preserve order foreach (array_reverse($timeline) as $status) { - // Hacktastic: filter out stuff coming from this StatusNet - $source = mb_strtolower(common_config('integration', 'source')); if (preg_match("/$source/", mb_strtolower($status->source))) { @@ -214,7 +206,6 @@ class TwitterStatusFetcher extends ParallelizingDaemon // Don't save it if the user is protected // FIXME: save it but treat it as private - if ($status->user->protected) { continue; } @@ -232,7 +223,6 @@ class TwitterStatusFetcher extends ParallelizingDaemon } // Okay, record the time we synced with Twitter for posterity - $flink->last_noticesync = common_sql_now(); $flink->update(); } @@ -250,7 +240,6 @@ class TwitterStatusFetcher extends ParallelizingDaemon $statusUri = $this->makeStatusURI($status->user->screen_name, $status->id); // check to see if we've already imported the status - $n2s = Notice_to_status::staticGet('status_id', $status->id); if (!empty($n2s)) { @@ -263,7 +252,6 @@ class TwitterStatusFetcher extends ParallelizingDaemon } // If it's a retweet, save it as a repeat! - if (!empty($status->retweeted_status)) { common_log(LOG_INFO, "Status {$status->id} is a retweet of {$status->retweeted_status->id}."); $original = $this->saveStatus($status->retweeted_status); @@ -273,7 +261,7 @@ class TwitterStatusFetcher extends ParallelizingDaemon $author = $original->getProfile(); // TRANS: Message used to repeat a notice. RT is the abbreviation of 'retweet'. // TRANS: %1$s is the repeated user's name, %2$s is the repeated notice. - $content = sprintf(_('RT @%1$s %2$s'), + $content = sprintf(_m('RT @%1$s %2$s'), $author->nickname, $original->content); @@ -365,7 +353,6 @@ class TwitterStatusFetcher extends ParallelizingDaemon * * @return string URI */ - function makeStatusURI($username, $id) { return 'http://twitter.com/' @@ -383,7 +370,6 @@ class TwitterStatusFetcher extends ParallelizingDaemon * * @return mixed value the first Profile with that url, or null */ - function getProfileByUrl($nickname, $profileurl) { $profile = new Profile(); @@ -407,7 +393,6 @@ class TwitterStatusFetcher extends ParallelizingDaemon * * @return mixed value a matching Notice or null */ - function checkDupe($profile, $statusUri) { $notice = new Notice(); @@ -426,7 +411,6 @@ class TwitterStatusFetcher extends ParallelizingDaemon function ensureProfile($user) { // check to see if there's already a profile for this user - $profileurl = 'http://twitter.com/' . $user->screen_name; $profile = $this->getProfileByUrl($user->screen_name, $profileurl); @@ -440,7 +424,6 @@ class TwitterStatusFetcher extends ParallelizingDaemon return $profile; } else { - common_debug($this->name() . ' - Adding profile and remote profile ' . "for Twitter user: $profileurl."); @@ -472,7 +455,6 @@ class TwitterStatusFetcher extends ParallelizingDaemon $remote_pro = Remote_profile::staticGet('uri', $profileurl); if (empty($remote_pro)) { - $remote_pro = new Remote_profile(); $remote_pro->id = $id; @@ -619,7 +601,6 @@ class TwitterStatusFetcher extends ParallelizingDaemon $avatar = $profile->getAvatar($sizes[$size]); // Delete the avatar, if present - if ($avatar) { $avatar->delete(); } @@ -644,10 +625,8 @@ class TwitterStatusFetcher extends ParallelizingDaemon $avatar->height = 48; break; default: - // Note: Twitter's big avatars are a different size than // StatusNet's (StatusNet's = 96) - $avatar->width = 73; $avatar->height = 73; } @@ -822,4 +801,3 @@ if (have_option('d') || have_option('debug')) { $fetcher = new TwitterStatusFetcher($id, 60, 2, $debug); $fetcher->runOnce(); - diff --git a/plugins/TwitterBridge/twitter.php b/plugins/TwitterBridge/twitter.php index 90b0f0f14f..3bff0af72d 100644 --- a/plugins/TwitterBridge/twitter.php +++ b/plugins/TwitterBridge/twitter.php @@ -69,7 +69,6 @@ function save_twitter_user($twitter_id, $screen_name) { // Check to see whether the Twitter user is already in the system, // and update its screen name and uri if so. - $fuser = Foreign_user::getForeignUser($twitter_id, TWITTER_SERVICE); if (!empty($fuser)) { @@ -87,9 +86,7 @@ function save_twitter_user($twitter_id, $screen_name) } } else { - // Kill any old, invalid records for this screen name - $fuser = Foreign_user::getByNickname($screen_name, TWITTER_SERVICE); if (!empty($fuser)) { @@ -110,13 +107,11 @@ function save_twitter_user($twitter_id, $screen_name) } function is_twitter_bound($notice, $flink) { - // Check to see if notice should go to Twitter if (!empty($flink) && ($flink->noticesync & FOREIGN_NOTICE_SEND)) { // If it's not a Twitter-style reply, or if the user WANTS to send replies, // or if it's in reply to a twitter notice - if (!preg_match('/^@[a-zA-Z0-9_]{1,15}\b/u', $notice->content) || ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) || is_twitter_notice($notice->reply_to)) { @@ -242,7 +237,6 @@ function broadcast_oauth($notice, $flink) { } // Notice crossed the great divide - $msg = sprintf('Twitter bridge - posted notice %d to Twitter using ' . 'OAuth for User %s (user id %d).', $notice->id, @@ -378,4 +372,3 @@ function mail_twitter_bridge_removed($user) common_switch_locale(); return mail_to_user($user, $subject, $body); } - diff --git a/plugins/TwitterBridge/twitteradminpanel.php b/plugins/TwitterBridge/twitteradminpanel.php index 69f8da078a..d05a2c6b3e 100644 --- a/plugins/TwitterBridge/twitteradminpanel.php +++ b/plugins/TwitterBridge/twitteradminpanel.php @@ -40,7 +40,6 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ - class TwitteradminpanelAction extends AdminPanelAction { /** @@ -48,7 +47,6 @@ class TwitteradminpanelAction extends AdminPanelAction * * @return string page title */ - function title() { return _m('Twitter'); @@ -59,7 +57,6 @@ class TwitteradminpanelAction extends AdminPanelAction * * @return string instructions */ - function getInstructions() { return _m('Twitter bridge settings'); @@ -70,7 +67,6 @@ class TwitteradminpanelAction extends AdminPanelAction * * @return void */ - function showForm() { $form = new TwitterAdminPanelForm($this); @@ -83,7 +79,6 @@ class TwitteradminpanelAction extends AdminPanelAction * * @return void */ - function saveSettings() { static $settings = array( @@ -173,7 +168,6 @@ class TwitterAdminPanelForm extends AdminForm * * @return int ID of the form */ - function id() { return 'twitteradminpanel'; @@ -184,7 +178,6 @@ class TwitterAdminPanelForm extends AdminForm * * @return string class of the form */ - function formClass() { return 'form_settings'; @@ -195,7 +188,6 @@ class TwitterAdminPanelForm extends AdminForm * * @return string URL of the action */ - function action() { return common_local_url('twitteradminpanel'); @@ -206,7 +198,6 @@ class TwitterAdminPanelForm extends AdminForm * * @return void */ - function formData() { $this->out->elementStart( @@ -239,7 +230,7 @@ class TwitterAdminPanelForm extends AdminForm if (!empty($globalConsumerKey) && !empty($globalConsumerSec)) { $this->li(); - $this->out->element('p', 'form_guide', _('Note: a global consumer key and secret are set.')); + $this->out->element('p', 'form_guide', _m('Note: a global consumer key and secret are set.')); $this->unli(); } @@ -292,9 +283,8 @@ class TwitterAdminPanelForm extends AdminForm * * @return void */ - function formActions() { - $this->out->submit('submit', _('Save'), 'submit', null, _('Save Twitter settings')); + $this->out->submit('submit', _m('Save'), 'submit', null, _m('Save Twitter settings')); } } diff --git a/plugins/TwitterBridge/twitterauthorization.php b/plugins/TwitterBridge/twitterauthorization.php index 7a896e1687..931a037230 100644 --- a/plugins/TwitterBridge/twitterauthorization.php +++ b/plugins/TwitterBridge/twitterauthorization.php @@ -117,13 +117,13 @@ class TwitterauthorizationAction extends Action $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { - $this->showForm(_('There was a problem with your session token. Try again, please.')); + $this->showForm(_m('There was a problem with your session token. Try again, please.')); return; } if ($this->arg('create')) { if (!$this->boolean('license')) { - $this->showForm(_('You can\'t register if you don\'t agree to the license.'), + $this->showForm(_m('You can\'t register if you don\'t agree to the license.'), $this->trimmed('newname')); return; } @@ -132,7 +132,7 @@ class TwitterauthorizationAction extends Action $this->connectNewUser(); } else { common_debug('Twitter bridge - ' . print_r($this->args, true)); - $this->showForm(_('Something weird happened.'), + $this->showForm(_m('Something weird happened.'), $this->trimmed('newname')); } } else { @@ -231,7 +231,6 @@ class TwitterauthorizationAction extends Action } if (common_logged_in()) { - // Save the access token and Twitter user info $user = common_current_user(); @@ -298,7 +297,7 @@ class TwitterauthorizationAction extends Action if (empty($flink_id)) { common_log_db_error($flink, 'INSERT', __FILE__); - $this->serverError(_('Couldn\'t link your Twitter account.')); + $this->serverError(_m('Couldn\'t link your Twitter account.')); } return $flink_id; @@ -310,13 +309,13 @@ class TwitterauthorizationAction extends Action $this->element('div', array('class' => 'error'), $this->error); } else { $this->element('div', 'instructions', - sprintf(_('This is the first time you\'ve logged into %s so we must connect your Twitter account to a local account. You can either create a new account, or connect with your existing account, if you have one.'), common_config('site', 'name'))); + sprintf(_m('This is the first time you\'ve logged into %s so we must connect your Twitter account to a local account. You can either create a new account, or connect with your existing account, if you have one.'), common_config('site', 'name'))); } } function title() { - return _('Twitter Account Setup'); + return _m('Twitter Account Setup'); } function showForm($error=null, $username=null) @@ -349,7 +348,7 @@ class TwitterauthorizationAction extends Action 'class' => 'form_settings', 'action' => common_local_url('twitterauthorization'))); $this->elementStart('fieldset', array('id' => 'settings_twitter_connect_options')); - $this->element('legend', null, _('Connection options')); + $this->element('legend', null, _m('Connection options')); $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->element('input', array('type' => 'checkbox', @@ -358,7 +357,7 @@ class TwitterauthorizationAction extends Action 'name' => 'license', 'value' => 'true')); $this->elementStart('label', array('class' => 'checkbox', 'for' => 'license')); - $message = _('My text and files are available under %s ' . + $message = _m('My text and files are available under %s ' . 'except this private data: password, ' . 'email address, IM address, and phone number.'); $link = '