From add126bc6c6eb574e00f171c2107b0406b7015e5 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 8 Dec 2009 14:56:11 -0500 Subject: [PATCH 01/45] add forward table --- db/statusnet.sql | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/db/statusnet.sql b/db/statusnet.sql index 18abcdfdb2..b500b81f2d 100644 --- a/db/statusnet.sql +++ b/db/statusnet.sql @@ -585,3 +585,14 @@ create table login_token ( constraint primary key (user_id) ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; +create table forward ( + + profile_id integer not null comment 'profile who forwarded the notice' references profile (id), + notice_id integer not null comment 'notice they forwarded' references notice (id), + + created datetime not null comment 'date this record was created', + + constraint primary key (profile_id, notice_id) + +) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; + From 4b5e977a7b1c390555d880d3dc7f8b8c6744646c Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 8 Dec 2009 12:17:11 -0800 Subject: [PATCH 02/45] New _m() gettext wrapper with smart detection of plugin domains. Plugin base class registers your gettext files if present at initialization. update_pot.sh replaced with update_po_templates.php which can do core, plugins, or all (default). Top-level Makefile added to build .mo files for plugins as well as core. As described on list: http://lists.status.net/pipermail/statusnet-dev/2009-December/002869.html --- Makefile | 18 + lib/language.php | 125 +++++- lib/plugin.php | 19 + plugins/Facebook/FBConnectAuth.php | 62 +-- plugins/Facebook/FBConnectLogin.php | 6 +- plugins/Facebook/FBConnectSettings.php | 30 +- plugins/Facebook/FacebookPlugin.php | 10 +- plugins/Facebook/facebookaction.php | 34 +- plugins/Facebook/facebookhome.php | 20 +- plugins/Facebook/facebookinvite.php | 12 +- plugins/Facebook/facebooklogin.php | 2 +- plugins/Facebook/facebookremove.php | 2 +- plugins/Facebook/facebooksettings.php | 20 +- plugins/Facebook/facebookutil.php | 4 +- plugins/Facebook/locale/Facebook.po | 394 ++++++++++++++++++ plugins/FeedSub/FeedSubPlugin.php | 5 +- plugins/FeedSub/actions/feedsubsettings.php | 40 +- plugins/FeedSub/feedmunger.php | 2 +- plugins/FeedSub/locale/FeedSub.po | 104 +++++ .../FeedSub/locale/fr/LC_MESSAGES/FeedSub.po | 106 +++++ plugins/FeedSub/tests/gettext-speedtest.php | 78 ++++ plugins/Mapstraction/MapstractionPlugin.php | 4 +- plugins/Mapstraction/allmap.php | 4 +- plugins/Mapstraction/locale/Mapstraction.po | 48 +++ plugins/Mapstraction/map.php | 4 +- plugins/Mapstraction/usermap.php | 2 +- plugins/OpenID/OpenIDPlugin.php | 8 +- plugins/OpenID/finishaddopenid.php | 16 +- plugins/OpenID/finishopenidlogin.php | 62 +-- plugins/OpenID/locale/OpenID.po | 344 +++++++++++++++ plugins/OpenID/openid.php | 18 +- plugins/OpenID/openidlogin.php | 22 +- plugins/OpenID/openidserver.php | 4 +- plugins/OpenID/openidsettings.php | 30 +- plugins/OpenID/openidtrust.php | 10 +- plugins/Sample/SamplePlugin.php | 59 +++ plugins/TwitterBridge/TwitterBridgePlugin.php | 4 +- plugins/TwitterBridge/locale/TwitterBridge.po | 128 ++++++ plugins/TwitterBridge/twitter.php | 4 +- .../TwitterBridge/twitterauthorization.php | 10 +- plugins/TwitterBridge/twittersettings.php | 42 +- scripts/update_po_templates.php | 211 ++++++++++ scripts/update_pot.sh | 13 - 43 files changed, 1873 insertions(+), 267 deletions(-) create mode 100644 Makefile create mode 100644 plugins/Facebook/locale/Facebook.po create mode 100644 plugins/FeedSub/locale/FeedSub.po create mode 100644 plugins/FeedSub/locale/fr/LC_MESSAGES/FeedSub.po create mode 100644 plugins/FeedSub/tests/gettext-speedtest.php create mode 100644 plugins/Mapstraction/locale/Mapstraction.po create mode 100644 plugins/OpenID/locale/OpenID.po create mode 100644 plugins/Sample/SamplePlugin.php create mode 100644 plugins/TwitterBridge/locale/TwitterBridge.po create mode 100755 scripts/update_po_templates.php delete mode 100755 scripts/update_pot.sh diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..6f45c1b83e --- /dev/null +++ b/Makefile @@ -0,0 +1,18 @@ +# Warning: do not transform tabs to spaces in this file. + +all : translations + +core_mo = $(patsubst %.po,%.mo,$(wildcard locale/*/LC_MESSAGES/statusnet.po)) +plugin_mo = $(patsubst %.po,%.mo,$(wildcard plugins/*/locale/*/LC_MESSAGES/*.po)) + +translations : $(core_mo) $(plugin_mo) + +clean : + rm -f $(core_mo) $(plugin_mo) + +updatepo : + php scripts/update_po_templates.php --all + +%.mo : %.po + msgfmt -o $@ $< + diff --git a/lib/language.php b/lib/language.php index 4fc45bafe9..ab46f1a656 100644 --- a/lib/language.php +++ b/lib/language.php @@ -36,6 +36,33 @@ if (!function_exists('gettext')) { require_once("php-gettext/gettext.inc"); } + +if (!function_exists('dpgettext')) { + /** + * Context-aware dgettext wrapper; use when messages in different contexts + * won't be distinguished from the English source but need different translations. + * The context string will appear as msgctxt in the .po files. + * + * Not currently exposed in PHP's gettext module; implemented to be compat + * with gettext.h's macros. + * + * @param string $domain domain identifier, or null for default domain + * @param string $context context identifier, should be some key like "menu|file" + * @param string $msgid English source text + * @return string original or translated message + */ + function dpgettext($domain, $context, $msg) + { + $msgid = $context . "\004" . $msg; + $out = dcgettext($domain, $msgid, LC_MESSAGES); + if ($out == $msgid) { + return $msg; + } else { + return $out; + } + } +} + if (!function_exists('pgettext')) { /** * Context-aware gettext wrapper; use when messages in different contexts @@ -50,9 +77,31 @@ if (!function_exists('pgettext')) { * @return string original or translated message */ function pgettext($context, $msg) + { + return dpgettext(textdomain(NULL), $context, $msg); + } +} + +if (!function_exists('dnpgettext')) { + /** + * Context-aware dngettext wrapper; use when messages in different contexts + * won't be distinguished from the English source but need different translations. + * The context string will appear as msgctxt in the .po files. + * + * Not currently exposed in PHP's gettext module; implemented to be compat + * with gettext.h's macros. + * + * @param string $domain domain identifier, or null for default domain + * @param string $context context identifier, should be some key like "menu|file" + * @param string $msg singular English source text + * @param string $plural plural English source text + * @param int $n number of items to control plural selection + * @return string original or translated message + */ + function dnpgettext($domain, $context, $msg, $plural, $n) { $msgid = $context . "\004" . $msg; - $out = dcgettext(textdomain(NULL), $msgid, LC_MESSAGES); + $out = dcngettext($domain, $msgid, $plural, $n, LC_MESSAGES); if ($out == $msgid) { return $msg; } else { @@ -78,14 +127,78 @@ if (!function_exists('npgettext')) { */ function npgettext($context, $msg, $plural, $n) { - $msgid = $context . "\004" . $msg; - $out = dcngettext(textdomain(NULL), $msgid, $plural, $n, LC_MESSAGES); - if ($out == $msgid) { - return $msg; + return dnpgettext(textdomain(NULL), $msgid, $plural, $n, LC_MESSAGES); + } +} + +/** + * Shortcut for *gettext functions with smart domain detection. + * + * If calling from a plugin, this function checks which plugin was + * being called from and uses that as text domain, which will have + * been set up during plugin initialization. + * + * Also handles plurals and contexts depending on what parameters + * are passed to it: + * + * gettext -> _m($msg) + * ngettext -> _m($msg1, $msg2, $n) + * pgettext -> _m($ctx, $msg) + * npgettext -> _m($ctx, $msg1, $msg2, $n) + * + * @fixme may not work properly in eval'd code + * + * @param string $msg + * @return string + */ +function _m($msg/*, ...*/) +{ + $domain = _mdomain(debug_backtrace(false)); + $args = func_get_args(); + switch(count($args)) { + case 1: return dgettext($domain, $msg); + case 2: return dpgettext($domain, $args[0], $args[1]); + case 3: return dngettext($domain, $args[0], $args[1], $args[2]); + case 4: return dnpgettext($domain, $args[0], $args[1], $args[2], $args[3]); + default: throw new Exception("Bad parameter count to _m()"); + } +} + +/** + * Looks for which plugin we've been called from to set the gettext domain. + * + * @param array $backtrace debug_backtrace() output + * @return string + * @private + * @fixme could explode if SN is under a 'plugins' folder or share name. + */ +function _mdomain($backtrace) +{ + /* + 0 => + array + 'file' => string '/var/www/mublog/plugins/FeedSub/FeedSubPlugin.php' (length=49) + 'line' => int 77 + 'function' => string '_m' (length=2) + 'args' => + array + 0 => &string 'Feeds' (length=5) + */ + static $cached; + $path = $backtrace[0]['file']; + if (!isset($cached[$path])) { + if (DIRECTORY_SEPARATOR !== '/') { + $path = strtr($path, DIRECTORY_SEPARATOR, '/'); + } + $cut = strpos($path, '/plugins/') + 9; + $cut2 = strpos($path, '/', $cut); + if ($cut && $cut2) { + $cached[$path] = substr($path, $cut, $cut2 - $cut); } else { - return $out; + return null; } } + return $cached[$path]; } diff --git a/lib/plugin.php b/lib/plugin.php index 2c77c3e120..de7313e59e 100644 --- a/lib/plugin.php +++ b/lib/plugin.php @@ -65,6 +65,8 @@ class Plugin Event::addHandler(mb_substr($method, 2), array($this, $method)); } } + + $this->setupGettext(); } function initialize() @@ -77,6 +79,22 @@ class Plugin return true; } + /** + * Checks if this plugin has localization that needs to be set up. + * Gettext localizations can be called via the _m() helper function. + */ + protected function setupGettext() + { + $class = get_class($this); + if (substr($class, -6) == 'Plugin') { + $name = substr($class, 0, -6); + $path = INSTALLDIR . "/plugins/$name/locale"; + if (file_exists($path) && is_dir($path)) { + bindtextdomain($name, $path); + } + } + } + protected function log($level, $msg) { common_log($level, get_class($this) . ': '.$msg); @@ -87,3 +105,4 @@ class Plugin $this->log(LOG_DEBUG, $msg); } } + diff --git a/plugins/Facebook/FBConnectAuth.php b/plugins/Facebook/FBConnectAuth.php index b909a49771..51bfc38657 100644 --- a/plugins/Facebook/FBConnectAuth.php +++ b/plugins/Facebook/FBConnectAuth.php @@ -48,8 +48,8 @@ class FBConnectauthAction extends Action common_log(LOG_WARNING, 'Facebook Connect Plugin - ' . "Failed auth attempt, proxy = $proxy, ip = $ip."); - $this->clientError(_('You must be logged into Facebook to ' . - 'use Facebook Connect.')); + $this->clientError(_m('You must be logged into Facebook to ' . + 'use Facebook Connect.')); } return true; @@ -74,7 +74,7 @@ class FBConnectauthAction extends Action // We don't want these cookies getFacebook()->clear_cookie_state(); - $this->clientError(_('There is already a local user linked with this Facebook.')); + $this->clientError(_m('There is already a local user linked with this Facebook.')); } else { @@ -87,12 +87,12 @@ class FBConnectauthAction 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; } @@ -102,7 +102,7 @@ class FBConnectauthAction extends Action } else { common_debug('Facebook Connect Plugin - ' . print_r($this->args, true)); - $this->showForm(_('Something weird happened.'), + $this->showForm(_m('Something weird happened.'), $this->trimmed('newname')); } } else { @@ -116,13 +116,13 @@ class FBConnectauthAction 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 Facebook 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 Facebook 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 _('Facebook Account Setup'); + return _m('Facebook Account Setup'); } function showForm($error=null, $username=null) @@ -150,7 +150,7 @@ class FBConnectauthAction extends Action 'class' => 'form_settings', 'action' => common_local_url('FBConnectAuth'))); $this->elementStart('fieldset', array('id' => 'settings_facebook_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', @@ -159,10 +159,10 @@ class FBConnectauthAction extends Action 'name' => 'license', 'value' => 'true')); $this->elementStart('label', array('class' => 'checkbox', 'for' => 'license')); - $this->text(_('My text and files are available under ')); + $this->text(_m('My text and files are available under ')); $this->element('a', array('href' => common_config('license', 'url')), common_config('license', 'title')); - $this->text(_(' except this private data: password, email address, IM address, phone number.')); + $this->text(_m(' except this private data: password, email address, IM address, phone number.')); $this->elementEnd('label'); $this->elementEnd('li'); $this->elementEnd('ul'); @@ -170,33 +170,33 @@ class FBConnectauthAction extends Action $this->elementStart('fieldset'); $this->hidden('token', common_session_token()); $this->element('legend', null, - _('Create new account')); + _m('Create new account')); $this->element('p', null, - _('Create a new user with this nickname.')); + _m('Create a new user with this nickname.')); $this->elementStart('ul', 'form_data'); $this->elementStart('li'); - $this->input('newname', _('New nickname'), + $this->input('newname', _m('New nickname'), ($this->username) ? $this->username : '', - _('1-64 lowercase letters or numbers, no punctuation or spaces')); + _m('1-64 lowercase letters or numbers, no punctuation or spaces')); $this->elementEnd('li'); $this->elementEnd('ul'); - $this->submit('create', _('Create')); + $this->submit('create', _m('Create')); $this->elementEnd('fieldset'); $this->elementStart('fieldset'); $this->element('legend', null, - _('Connect existing account')); + _m('Connect existing account')); $this->element('p', null, - _('If you already have an account, login with your username and password to connect it to your Facebook.')); + _m('If you already have an account, login with your username and password to connect it to your Facebook.')); $this->elementStart('ul', 'form_data'); $this->elementStart('li'); - $this->input('nickname', _('Existing nickname')); + $this->input('nickname', _m('Existing nickname')); $this->elementEnd('li'); $this->elementStart('li'); - $this->password('password', _('Password')); + $this->password('password', _m('Password')); $this->elementEnd('li'); $this->elementEnd('ul'); - $this->submit('connect', _('Connect')); + $this->submit('connect', _m('Connect')); $this->elementEnd('fieldset'); $this->elementEnd('fieldset'); @@ -212,7 +212,7 @@ class FBConnectauthAction extends Action function createNewUser() { if (common_config('site', 'closed')) { - $this->clientError(_('Registration not allowed.')); + $this->clientError(_m('Registration not allowed.')); return; } @@ -221,14 +221,14 @@ class FBConnectauthAction extends Action if (common_config('site', 'inviteonly')) { $code = $_SESSION['invitecode']; if (empty($code)) { - $this->clientError(_('Registration not allowed.')); + $this->clientError(_m('Registration not allowed.')); return; } $invite = Invitation::staticGet($code); if (empty($invite)) { - $this->clientError(_('Not a valid invitation code.')); + $this->clientError(_m('Not a valid invitation code.')); return; } } @@ -238,17 +238,17 @@ class FBConnectauthAction extends Action if (!Validate::string($nickname, array('min_length' => 1, 'max_length' => 64, 'format' => NICKNAME_FMT))) { - $this->showForm(_('Nickname must have only lowercase letters and numbers and no spaces.')); + $this->showForm(_m('Nickname must have only lowercase letters and numbers and no spaces.')); return; } if (!User::allowed_nickname($nickname)) { - $this->showForm(_('Nickname not allowed.')); + $this->showForm(_m('Nickname not allowed.')); return; } if (User::staticGet('nickname', $nickname)) { - $this->showForm(_('Nickname already in use. Try another one.')); + $this->showForm(_m('Nickname already in use. Try another one.')); return; } @@ -266,7 +266,7 @@ class FBConnectauthAction extends Action $result = $this->flinkUser($user->id, $this->fbuid); if (!$result) { - $this->serverError(_('Error connecting user to Facebook.')); + $this->serverError(_m('Error connecting user to Facebook.')); return; } @@ -286,7 +286,7 @@ class FBConnectauthAction extends Action $password = $this->trimmed('password'); if (!common_check_user($nickname, $password)) { - $this->showForm(_('Invalid username or password.')); + $this->showForm(_m('Invalid username or password.')); return; } @@ -300,7 +300,7 @@ class FBConnectauthAction extends Action $result = $this->flinkUser($user->id, $this->fbuid); if (!$result) { - $this->serverError(_('Error connecting user to Facebook.')); + $this->serverError(_m('Error connecting user to Facebook.')); return; } @@ -320,7 +320,7 @@ class FBConnectauthAction extends Action $result = $this->flinkUser($user->id, $this->fbuid); if (empty($result)) { - $this->serverError(_('Error connecting user to Facebook.')); + $this->serverError(_m('Error connecting user to Facebook.')); return; } diff --git a/plugins/Facebook/FBConnectLogin.php b/plugins/Facebook/FBConnectLogin.php index d2bb8054c9..20c409f3ea 100644 --- a/plugins/Facebook/FBConnectLogin.php +++ b/plugins/Facebook/FBConnectLogin.php @@ -30,7 +30,7 @@ class FBConnectLoginAction extends Action parent::handle($args); if (common_is_real_login()) { - $this->clientError(_('Already logged in.')); + $this->clientError(_m('Already logged in.')); } $this->showPage(); @@ -38,7 +38,7 @@ class FBConnectLoginAction extends Action function getInstructions() { - return _('Login with your Facebook Account'); + return _m('Login with your Facebook Account'); } function showPageNotice() @@ -52,7 +52,7 @@ class FBConnectLoginAction extends Action function title() { - return _('Facebook Login'); + return _m('Facebook Login'); } function showContent() { diff --git a/plugins/Facebook/FBConnectSettings.php b/plugins/Facebook/FBConnectSettings.php index 911c567873..590dffd8a9 100644 --- a/plugins/Facebook/FBConnectSettings.php +++ b/plugins/Facebook/FBConnectSettings.php @@ -53,7 +53,7 @@ class FBConnectSettingsAction extends ConnectSettingsAction function title() { - return _('Facebook Connect Settings'); + return _m('Facebook Connect Settings'); } /** @@ -64,7 +64,7 @@ class FBConnectSettingsAction extends ConnectSettingsAction function getInstructions() { - return _('Manage how your account connects to Facebook'); + return _m('Manage how your account connects to Facebook'); } /** @@ -89,7 +89,7 @@ class FBConnectSettingsAction extends ConnectSettingsAction if (!$flink) { $this->element('p', 'instructions', - _('There is no Facebook user connected to this account.')); + _m('There is no Facebook user connected to this account.')); $this->element('fb:login-button', array('onlogin' => 'goto_login()', 'length' => 'long')); @@ -97,7 +97,7 @@ class FBConnectSettingsAction extends ConnectSettingsAction } else { $this->element('p', 'form_note', - _('Connected Facebook user')); + _m('Connected Facebook user')); $this->elementStart('p', array('class' => 'facebook-user-display')); $this->elementStart('fb:profile-pic', @@ -116,18 +116,18 @@ class FBConnectSettingsAction extends ConnectSettingsAction $this->elementStart('fieldset'); - $this->element('legend', null, _('Disconnect my account from Facebook')); + $this->element('legend', null, _m('Disconnect my account from Facebook')); if (!$user->password) { $this->elementStart('p', array('class' => 'form_guide')); - $this->text(_('Disconnecting your Faceboook ' . - 'would make it impossible to log in! Please ')); + $this->text(_m('Disconnecting your Faceboook ' . + 'would make it impossible to log in! Please ')); $this->element('a', array('href' => common_local_url('passwordsettings')), - _('set a password')); + _m('set a password')); - $this->text(_(' first.')); + $this->text(_m(' first.')); $this->elementEnd('p'); } else { @@ -139,7 +139,7 @@ class FBConnectSettingsAction extends ConnectSettingsAction $this->element('p', 'instructions', sprintf($note, $site, $site)); - $this->submit('disconnect', _('Disconnect')); + $this->submit('disconnect', _m('Disconnect')); } $this->elementEnd('fieldset'); @@ -161,8 +161,8 @@ class FBConnectSettingsAction extends ConnectSettingsAction // CSRF protection $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; } @@ -175,7 +175,7 @@ class FBConnectSettingsAction extends ConnectSettingsAction if ($result === false) { common_log_db_error($user, 'DELETE', __FILE__); - $this->serverError(_('Couldn\'t delete link to Facebook.')); + $this->serverError(_m('Couldn\'t delete link to Facebook.')); return; } @@ -191,10 +191,10 @@ class FBConnectSettingsAction extends ConnectSettingsAction $e->getMessage()); } - $this->showForm(_('You have disconnected from Facebook.'), true); + $this->showForm(_m('You have disconnected from Facebook.'), true); } else { - $this->showForm(_('Not sure what you\'re trying to do.')); + $this->showForm(_m('Not sure what you\'re trying to do.')); return; } diff --git a/plugins/Facebook/FacebookPlugin.php b/plugins/Facebook/FacebookPlugin.php index 40c911cce3..39b2ef2876 100644 --- a/plugins/Facebook/FacebookPlugin.php +++ b/plugins/Facebook/FacebookPlugin.php @@ -406,9 +406,9 @@ class FacebookPlugin extends Plugin $action_name = $action->trimmed('action'); $action->menuItem(common_local_url('FBConnectLogin'), - _('Facebook'), - _('Login or register using Facebook'), - 'FBConnectLogin' === $action_name); + _m('Facebook'), + _m('Login or register using Facebook'), + 'FBConnectLogin' === $action_name); return true; } @@ -426,8 +426,8 @@ class FacebookPlugin extends Plugin $action_name = $action->trimmed('action'); $action->menuItem(common_local_url('FBConnectSettings'), - _('Facebook'), - _('Facebook Connect Settings'), + _m('Facebook'), + _m('Facebook Connect Settings'), $action_name === 'FBConnectSettings'); return true; diff --git a/plugins/Facebook/facebookaction.php b/plugins/Facebook/facebookaction.php index b090e9bd9a..705bb2780d 100644 --- a/plugins/Facebook/facebookaction.php +++ b/plugins/Facebook/facebookaction.php @@ -168,7 +168,7 @@ class FacebookAction extends Action $this->elementStart('li', array('class' => ($this->action == 'facebookhome') ? 'current' : 'facebook_home')); $this->element('a', - array('href' => 'index.php', 'title' => _('Home')), _('Home')); + array('href' => 'index.php', 'title' => _m('Home')), _m('Home')); $this->elementEnd('li'); if (common_config('invite', 'enabled')) { @@ -176,7 +176,7 @@ class FacebookAction extends Action array('class' => ($this->action == 'facebookinvite') ? 'current' : 'facebook_invite')); $this->element('a', - array('href' => 'invite.php', 'title' => _('Invite')), _('Invite')); + array('href' => 'invite.php', 'title' => _m('Invite')), _m('Invite')); $this->elementEnd('li'); } @@ -185,7 +185,7 @@ class FacebookAction extends Action ($this->action == 'facebooksettings') ? 'current' : 'facebook_settings')); $this->element('a', array('href' => 'settings.php', - 'title' => _('Settings')), _('Settings')); + 'title' => _m('Settings')), _m('Settings')); $this->elementEnd('li'); $this->elementEnd('ul'); @@ -225,15 +225,15 @@ class FacebookAction extends Action $this->elementStart('dl', array('class' => 'system_notice')); $this->element('dt', null, 'Page Notice'); - $loginmsg_part1 = _('To use the %s Facebook Application you need to login ' . + $loginmsg_part1 = _m('To use the %s Facebook Application you need to login ' . 'with your username and password. Don\'t have a username yet? '); - $loginmsg_part2 = _(' a new account.'); + $loginmsg_part2 = _m(' a new account.'); $this->elementStart('dd'); $this->elementStart('p'); $this->text(sprintf($loginmsg_part1, common_config('site', 'name'))); $this->element('a', - array('href' => common_local_url('register')), _('Register')); + array('href' => common_local_url('register')), _m('Register')); $this->text($loginmsg_part2); $this->elementEnd('p'); $this->elementEnd('dd'); @@ -246,7 +246,7 @@ class FacebookAction extends Action { $this->elementStart('div', array('id' => 'content')); - $this->element('h1', null, _('Login')); + $this->element('h1', null, _m('Login')); if ($msg) { $this->element('fb:error', array('message' => $msg)); @@ -265,20 +265,20 @@ class FacebookAction extends Action $this->elementStart('ul', array('class' => 'form_datas')); $this->elementStart('li'); - $this->input('nickname', _('Nickname')); + $this->input('nickname', _m('Nickname')); $this->elementEnd('li'); $this->elementStart('li'); - $this->password('password', _('Password')); + $this->password('password', _m('Password')); $this->elementEnd('li'); $this->elementEnd('ul'); - $this->submit('submit', _('Login')); + $this->submit('submit', _m('Login')); $this->elementEnd('fieldset'); $this->elementEnd('form'); $this->elementStart('p'); $this->element('a', array('href' => common_local_url('recoverpassword')), - _('Lost or forgotten password?')); + _m('Lost or forgotten password?')); $this->elementEnd('p'); $this->elementEnd('div'); @@ -383,7 +383,7 @@ class FacebookAction extends Action // Does a little before-after block for next/prev page if ($have_before || $have_after) { $this->elementStart('dl', 'pagination'); - $this->element('dt', null, _('Pagination')); + $this->element('dt', null, _m('Pagination')); $this->elementStart('dd', null); $this->elementStart('ul', array('class' => 'nav')); } @@ -392,7 +392,7 @@ class FacebookAction extends Action $newargs = $args ? array_merge($args, $pargs) : $pargs; $this->elementStart('li', array('class' => 'nav_prev')); $this->element('a', array('href' => "$this->app_uri/$action?page=$newargs[page]", 'rel' => 'prev'), - _('After')); + _m('After')); $this->elementEnd('li'); } if ($have_after) { @@ -400,7 +400,7 @@ class FacebookAction extends Action $newargs = $args ? array_merge($args, $pargs) : $pargs; $this->elementStart('li', array('class' => 'nav_next')); $this->element('a', array('href' => "$this->app_uri/$action?page=$newargs[page]", 'rel' => 'next'), - _('Before')); + _m('Before')); $this->elementEnd('li'); } if ($have_before || $have_after) { @@ -418,13 +418,13 @@ class FacebookAction extends Action $content = $this->trimmed('status_textarea'); if (!$content) { - $this->showPage(_('No notice content!')); + $this->showPage(_m('No notice content!')); return; } else { $content_shortened = common_shorten_links($content); if (Notice::contentTooLong($content_shortened)) { - $this->showPage(sprintf(_('That\'s too long. Max notice size is %d chars.'), + $this->showPage(sprintf(_m('That\'s too long. Max notice size is %d chars.'), Notice::maxContent())); return; } @@ -520,7 +520,7 @@ class FacebookNoticeList extends NoticeList function show() { $this->out->elementStart('div', array('id' =>'notices_primary')); - $this->out->element('h2', null, _('Notices')); + $this->out->element('h2', null, _m('Notices')); $this->out->elementStart('ul', array('class' => 'notices')); $cnt = 0; diff --git a/plugins/Facebook/facebookhome.php b/plugins/Facebook/facebookhome.php index ea141c2c2d..60782f63c9 100644 --- a/plugins/Facebook/facebookhome.php +++ b/plugins/Facebook/facebookhome.php @@ -108,7 +108,7 @@ class FacebookhomeAction extends FacebookAction $user = User::staticGet('nickname', $nickname); if (!$user) { - $this->showLoginForm(_("Server error - couldn't get user!")); + $this->showLoginForm(_m("Server error - couldn't get user!")); } $flink = DB_DataObject::factory('foreign_link'); @@ -128,7 +128,7 @@ class FacebookhomeAction extends FacebookAction return; } else { - $msg = _('Incorrect username or password.'); + $msg = _m('Incorrect username or password.'); } } @@ -155,9 +155,9 @@ class FacebookhomeAction extends FacebookAction function title() { if ($this->page > 1) { - return sprintf(_("%s and friends, page %d"), $this->user->nickname, $this->page); + return sprintf(_m("%s and friends, page %d"), $this->user->nickname, $this->page); } else { - return sprintf(_("%s and friends"), $this->user->nickname); + return sprintf(_m("%s and friends"), $this->user->nickname); } } @@ -186,7 +186,7 @@ class FacebookhomeAction extends FacebookAction $this->elementStart('div', array('class' => 'facebook_guide')); - $instructions = sprintf(_('If you would like the %s app to automatically update ' . + $instructions = sprintf(_m('If you would like the %s app to automatically update ' . 'your Facebook status with your latest notice, you need ' . 'to give it permission.'), $this->app_name); @@ -210,13 +210,13 @@ class FacebookhomeAction extends FacebookAction $this->elementStart('span', array('class' => 'facebook-button')); $this->element('a', array('href' => $auth_url), - sprintf(_('Okay, do it!'), $this->app_name)); + sprintf(_m('Okay, do it!'), $this->app_name)); $this->elementEnd('span'); $this->elementEnd('li'); $this->elementStart('li', array('id' => 'fb-permissions-item')); - $this->submit('skip', _('Skip')); + $this->submit('skip', _m('Skip')); $this->elementEnd('li'); $this->elementEnd('ul'); @@ -245,7 +245,7 @@ class FacebookhomeAction extends FacebookAction if ($have_before || $have_after) { $this->elementStart('dl', 'pagination'); - $this->element('dt', null, _('Pagination')); + $this->element('dt', null, _m('Pagination')); $this->elementStart('dd', null); $this->elementStart('ul', array('class' => 'nav')); } @@ -254,7 +254,7 @@ class FacebookhomeAction extends FacebookAction $newargs = $args ? array_merge($args, $pargs) : $pargs; $this->elementStart('li', array('class' => 'nav_prev')); $this->element('a', array('href' => "$action?page=$newargs[page]", 'rel' => 'prev'), - _('After')); + _m('After')); $this->elementEnd('li'); } if ($have_after) { @@ -262,7 +262,7 @@ class FacebookhomeAction extends FacebookAction $newargs = $args ? array_merge($args, $pargs) : $pargs; $this->elementStart('li', array('class' => 'nav_next')); $this->element('a', array('href' => "$action?page=$newargs[page]", 'rel' => 'next'), - _('Before')); + _m('Before')); $this->elementEnd('li'); } if ($have_before || $have_after) { diff --git a/plugins/Facebook/facebookinvite.php b/plugins/Facebook/facebookinvite.php index 3380b4c857..e02c7bf3ed 100644 --- a/plugins/Facebook/facebookinvite.php +++ b/plugins/Facebook/facebookinvite.php @@ -69,9 +69,9 @@ class FacebookinviteAction extends FacebookAction function showSuccessContent() { - $this->element('h2', null, sprintf(_('Thanks for inviting your friends to use %s'), + $this->element('h2', null, sprintf(_m('Thanks for inviting your friends to use %s'), common_config('site', 'name'))); - $this->element('p', null, _('Invitations have been sent to the following users:')); + $this->element('p', null, _m('Invitations have been sent to the following users:')); $friend_ids = $_POST['ids']; // XXX: Hmm... is this the best way to access the list? @@ -91,7 +91,7 @@ class FacebookinviteAction extends FacebookAction function showFormContent() { - $content = sprintf(_('You have been invited to %s'), common_config('site', 'name')) . + $content = sprintf(_m('You have been invited to %s'), common_config('site', 'name')) . htmlentities(''); $this->elementStart('fb:request-form', array('action' => 'invite.php', @@ -100,7 +100,7 @@ class FacebookinviteAction extends FacebookAction 'type' => common_config('site', 'name'), 'content' => $content)); $this->hidden('invite', 'true'); - $actiontext = sprintf(_('Invite your friends to use %s'), common_config('site', 'name')); + $actiontext = sprintf(_m('Invite your friends to use %s'), common_config('site', 'name')); $multi_params = array('showborder' => 'false'); $multi_params['actiontext'] = $actiontext; @@ -122,7 +122,7 @@ class FacebookinviteAction extends FacebookAction if ($exclude_ids) { - $this->element('h2', null, sprintf(_('Friends already using %s:'), + $this->element('h2', null, sprintf(_m('Friends already using %s:'), common_config('site', 'name'))); $this->elementStart('ul', array('id' => 'facebook-friends')); @@ -140,7 +140,7 @@ class FacebookinviteAction extends FacebookAction function title() { - return sprintf(_('Send invitations')); + return sprintf(_m('Send invitations')); } } diff --git a/plugins/Facebook/facebooklogin.php b/plugins/Facebook/facebooklogin.php index f77aecca36..7a173ddaeb 100644 --- a/plugins/Facebook/facebooklogin.php +++ b/plugins/Facebook/facebooklogin.php @@ -88,7 +88,7 @@ class FacebookinviteAction extends FacebookAction function title() { - return sprintf(_('Login')); + return sprintf(_m('Login')); } function redirectHome() diff --git a/plugins/Facebook/facebookremove.php b/plugins/Facebook/facebookremove.php index 8531a8e6ea..09cb333428 100644 --- a/plugins/Facebook/facebookremove.php +++ b/plugins/Facebook/facebookremove.php @@ -55,7 +55,7 @@ class FacebookremoveAction extends FacebookAction if (!$result) { common_log_db_error($flink, 'DELETE', __FILE__); - $this->serverError(_('Couldn\'t remove Facebook user.')); + $this->serverError(_m('Couldn\'t remove Facebook user.')); return; } diff --git a/plugins/Facebook/facebooksettings.php b/plugins/Facebook/facebooksettings.php index d1269f1013..766d0e1996 100644 --- a/plugins/Facebook/facebooksettings.php +++ b/plugins/Facebook/facebooksettings.php @@ -71,9 +71,9 @@ class FacebooksettingsAction extends FacebookAction $trimmed); if ($result === false) { - $this->showForm(_('There was a problem saving your sync preferences!')); + $this->showForm(_m('There was a problem saving your sync preferences!')); } else { - $this->showForm(_('Sync preferences saved.'), true); + $this->showForm(_m('Sync preferences saved.'), true); } } @@ -96,14 +96,14 @@ class FacebooksettingsAction extends FacebookAction $this->elementStart('li'); - $this->checkbox('noticesync', _('Automatically update my Facebook status with my notices.'), + $this->checkbox('noticesync', _m('Automatically update my Facebook status with my notices.'), ($this->flink) ? ($this->flink->noticesync & FOREIGN_NOTICE_SEND) : true); $this->elementEnd('li'); $this->elementStart('li'); - $this->checkbox('replysync', _('Send "@" replies to Facebook.'), + $this->checkbox('replysync', _m('Send "@" replies to Facebook.'), ($this->flink) ? ($this->flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) : true); $this->elementEnd('li'); @@ -112,15 +112,15 @@ class FacebooksettingsAction extends FacebookAction $prefix = trim($this->facebook->api_client->data_getUserPreference(FACEBOOK_NOTICE_PREFIX)); - $this->input('prefix', _('Prefix'), + $this->input('prefix', _m('Prefix'), ($prefix) ? $prefix : null, - _('A string to prefix notices with.')); + _m('A string to prefix notices with.')); $this->elementEnd('li'); $this->elementStart('li'); - $this->submit('save', _('Save')); + $this->submit('save', _m('Save')); $this->elementEnd('li'); @@ -130,7 +130,7 @@ class FacebooksettingsAction extends FacebookAction } else { - $instructions = sprintf(_('If you would like %s to automatically update ' . + $instructions = sprintf(_m('If you would like %s to automatically update ' . 'your Facebook status with your latest notice, you need ' . 'to give it permission.'), $this->app_name); @@ -143,7 +143,7 @@ class FacebooksettingsAction extends FacebookAction $this->elementStart('fb:prompt-permission', array('perms' => 'publish_stream', 'next_fbjs' => 'document.setLocation(\'' . "$this->app_uri/settings.php" . '\')')); $this->element('span', array('class' => 'facebook-button'), - sprintf(_('Allow %s to update my Facebook status'), common_config('site', 'name'))); + sprintf(_m('Allow %s to update my Facebook status'), common_config('site', 'name'))); $this->elementEnd('fb:prompt-permission'); $this->elementEnd('li'); $this->elementEnd('ul'); @@ -153,7 +153,7 @@ class FacebooksettingsAction extends FacebookAction function title() { - return _('Sync preferences'); + return _m('Sync preferences'); } } diff --git a/plugins/Facebook/facebookutil.php b/plugins/Facebook/facebookutil.php index 2abcbb14e2..2ec6db6b8d 100644 --- a/plugins/Facebook/facebookutil.php +++ b/plugins/Facebook/facebookutil.php @@ -277,10 +277,10 @@ function mail_facebook_app_removed($user) $site_name = common_config('site', 'name'); $subject = sprintf( - _('Your %1$s Facebook application access has been disabled.', + _m('Your %1$s Facebook application access has been disabled.', $site_name)); - $body = sprintf(_("Hi, %1\$s. We're sorry to inform you that we are " . + $body = sprintf(_m("Hi, %1\$s. We're sorry to inform you that we are " . 'unable to update your Facebook status from %2$s, and have disabled ' . 'the Facebook application for your account. This may be because ' . 'you have removed the Facebook application\'s authorization, or ' . diff --git a/plugins/Facebook/locale/Facebook.po b/plugins/Facebook/locale/Facebook.po new file mode 100644 index 0000000000..5b313c8c53 --- /dev/null +++ b/plugins/Facebook/locale/Facebook.po @@ -0,0 +1,394 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2009-12-07 20:38-0800\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: facebookaction.php:171 +msgid "Home" +msgstr "" + +#: facebookaction.php:179 +msgid "Invite" +msgstr "" + +#: facebookaction.php:188 +msgid "Settings" +msgstr "" + +#: facebookaction.php:228 +#, php-format +msgid "" +"To use the %s Facebook Application you need to login with your username and " +"password. Don't have a username yet? " +msgstr "" + +#: facebookaction.php:230 +msgid " a new account." +msgstr "" + +#: facebookaction.php:236 +msgid "Register" +msgstr "" + +#: facebookaction.php:249 facebookaction.php:275 facebooklogin.php:91 +msgid "Login" +msgstr "" + +#: facebookaction.php:268 +msgid "Nickname" +msgstr "" + +#: facebookaction.php:271 FBConnectAuth.php:196 +msgid "Password" +msgstr "" + +#: facebookaction.php:281 +msgid "Lost or forgotten password?" +msgstr "" + +#: facebookaction.php:386 facebookhome.php:248 +msgid "Pagination" +msgstr "" + +#: facebookaction.php:395 facebookhome.php:257 +msgid "After" +msgstr "" + +#: facebookaction.php:403 facebookhome.php:265 +msgid "Before" +msgstr "" + +#: facebookaction.php:421 +msgid "No notice content!" +msgstr "" + +#: facebookaction.php:427 +#, php-format +msgid "That's too long. Max notice size is %d chars." +msgstr "" + +#: facebookaction.php:523 +msgid "Notices" +msgstr "" + +#: facebookutil.php:280 +#, php-format +msgid "Your %1$s Facebook application access has been disabled." +msgstr "" + +#: facebookutil.php:283 +#, php-format +msgid "" +"Hi, %1$s. We're sorry to inform you that we are unable to update your " +"Facebook status from %2$s, and have disabled the Facebook application for " +"your account. This may be because you have removed the Facebook " +"application's authorization, or have deleted your Facebook account. You can " +"re-enable the Facebook application and automatic status updating by re-" +"installing the %2$s Facebook application.\n" +"\n" +"Regards,\n" +"\n" +"%2$s" +msgstr "" + +#: FBConnectLogin.php:33 +msgid "Already logged in." +msgstr "" + +#: FBConnectLogin.php:41 +msgid "Login with your Facebook Account" +msgstr "" + +#: FBConnectLogin.php:55 +msgid "Facebook Login" +msgstr "" + +#: facebookhome.php:111 +msgid "Server error - couldn't get user!" +msgstr "" + +#: facebookhome.php:131 +msgid "Incorrect username or password." +msgstr "" + +#: facebookhome.php:158 +#, php-format +msgid "%s and friends, page %d" +msgstr "" + +#: facebookhome.php:160 +#, php-format +msgid "%s and friends" +msgstr "" + +#: facebookhome.php:189 +#, php-format +msgid "" +"If you would like the %s app to automatically update your Facebook status " +"with your latest notice, you need to give it permission." +msgstr "" + +#: facebookhome.php:213 +msgid "Okay, do it!" +msgstr "" + +#: facebookhome.php:219 +msgid "Skip" +msgstr "" + +#: facebooksettings.php:74 +msgid "There was a problem saving your sync preferences!" +msgstr "" + +#: facebooksettings.php:76 +msgid "Sync preferences saved." +msgstr "" + +#: facebooksettings.php:99 +msgid "Automatically update my Facebook status with my notices." +msgstr "" + +#: facebooksettings.php:106 +msgid "Send \"@\" replies to Facebook." +msgstr "" + +#: facebooksettings.php:115 +msgid "Prefix" +msgstr "" + +#: facebooksettings.php:117 +msgid "A string to prefix notices with." +msgstr "" + +#: facebooksettings.php:123 +msgid "Save" +msgstr "" + +#: facebooksettings.php:133 +#, php-format +msgid "" +"If you would like %s to automatically update your Facebook status with your " +"latest notice, you need to give it permission." +msgstr "" + +#: facebooksettings.php:146 +#, php-format +msgid "Allow %s to update my Facebook status" +msgstr "" + +#: facebooksettings.php:156 +msgid "Sync preferences" +msgstr "" + +#: facebookinvite.php:72 +#, php-format +msgid "Thanks for inviting your friends to use %s" +msgstr "" + +#: facebookinvite.php:74 +msgid "Invitations have been sent to the following users:" +msgstr "" + +#: facebookinvite.php:94 +#, php-format +msgid "You have been invited to %s" +msgstr "" + +#: facebookinvite.php:103 +#, php-format +msgid "Invite your friends to use %s" +msgstr "" + +#: facebookinvite.php:125 +#, php-format +msgid "Friends already using %s:" +msgstr "" + +#: facebookinvite.php:143 +msgid "Send invitations" +msgstr "" + +#: facebookremove.php:58 +msgid "Couldn't remove Facebook user." +msgstr "" + +#: FBConnectSettings.php:56 FacebookPlugin.php:430 +msgid "Facebook Connect Settings" +msgstr "" + +#: FBConnectSettings.php:67 +msgid "Manage how your account connects to Facebook" +msgstr "" + +#: FBConnectSettings.php:92 +msgid "There is no Facebook user connected to this account." +msgstr "" + +#: FBConnectSettings.php:100 +msgid "Connected Facebook user" +msgstr "" + +#: FBConnectSettings.php:119 +msgid "Disconnect my account from Facebook" +msgstr "" + +#: FBConnectSettings.php:124 +msgid "" +"Disconnecting your Faceboook would make it impossible to log in! Please " +msgstr "" + +#: FBConnectSettings.php:128 +msgid "set a password" +msgstr "" + +#: FBConnectSettings.php:130 +msgid " first." +msgstr "" + +#: FBConnectSettings.php:142 +msgid "Disconnect" +msgstr "" + +#: FBConnectSettings.php:164 FBConnectAuth.php:90 +msgid "There was a problem with your session token. Try again, please." +msgstr "" + +#: FBConnectSettings.php:178 +msgid "Couldn't delete link to Facebook." +msgstr "" + +#: FBConnectSettings.php:194 +msgid "You have disconnected from Facebook." +msgstr "" + +#: FBConnectSettings.php:197 +msgid "Not sure what you're trying to do." +msgstr "" + +#: FBConnectAuth.php:51 +msgid "You must be logged into Facebook to use Facebook Connect." +msgstr "" + +#: FBConnectAuth.php:77 +msgid "There is already a local user linked with this Facebook." +msgstr "" + +#: FBConnectAuth.php:95 +msgid "You can't register if you don't agree to the license." +msgstr "" + +#: FBConnectAuth.php:105 +msgid "Something weird happened." +msgstr "" + +#: FBConnectAuth.php:119 +#, php-format +msgid "" +"This is the first time you've logged into %s so we must connect your " +"Facebook to a local account. You can either create a new account, or connect " +"with your existing account, if you have one." +msgstr "" + +#: FBConnectAuth.php:125 +msgid "Facebook Account Setup" +msgstr "" + +#: FBConnectAuth.php:153 +msgid "Connection options" +msgstr "" + +#: FBConnectAuth.php:162 +msgid "My text and files are available under " +msgstr "" + +#: FBConnectAuth.php:165 +msgid "" +" except this private data: password, email address, IM address, phone number." +msgstr "" + +#: FBConnectAuth.php:173 +msgid "Create new account" +msgstr "" + +#: FBConnectAuth.php:175 +msgid "Create a new user with this nickname." +msgstr "" + +#: FBConnectAuth.php:178 +msgid "New nickname" +msgstr "" + +#: FBConnectAuth.php:180 +msgid "1-64 lowercase letters or numbers, no punctuation or spaces" +msgstr "" + +#: FBConnectAuth.php:183 +msgid "Create" +msgstr "" + +#: FBConnectAuth.php:188 +msgid "Connect existing account" +msgstr "" + +#: FBConnectAuth.php:190 +msgid "" +"If you already have an account, login with your username and password to " +"connect it to your Facebook." +msgstr "" + +#: FBConnectAuth.php:193 +msgid "Existing nickname" +msgstr "" + +#: FBConnectAuth.php:199 +msgid "Connect" +msgstr "" + +#: FBConnectAuth.php:215 FBConnectAuth.php:224 +msgid "Registration not allowed." +msgstr "" + +#: FBConnectAuth.php:231 +msgid "Not a valid invitation code." +msgstr "" + +#: FBConnectAuth.php:241 +msgid "Nickname must have only lowercase letters and numbers and no spaces." +msgstr "" + +#: FBConnectAuth.php:246 +msgid "Nickname not allowed." +msgstr "" + +#: FBConnectAuth.php:251 +msgid "Nickname already in use. Try another one." +msgstr "" + +#: FBConnectAuth.php:269 FBConnectAuth.php:303 FBConnectAuth.php:323 +msgid "Error connecting user to Facebook." +msgstr "" + +#: FBConnectAuth.php:289 +msgid "Invalid username or password." +msgstr "" + +#: FacebookPlugin.php:409 FacebookPlugin.php:429 +msgid "Facebook" +msgstr "" + +#: FacebookPlugin.php:410 +msgid "Login or register using Facebook" +msgstr "" diff --git a/plugins/FeedSub/FeedSubPlugin.php b/plugins/FeedSub/FeedSubPlugin.php index 36d4e78023..857a9794d5 100644 --- a/plugins/FeedSub/FeedSubPlugin.php +++ b/plugins/FeedSub/FeedSubPlugin.php @@ -51,7 +51,6 @@ class FeedSubPlugin extends Plugin * @param Net_URL_Mapper $m path-to-action mapper * @return boolean hook return */ - function onRouterInitialized($m) { $m->connect('feedsub/callback/:feed', @@ -74,8 +73,8 @@ class FeedSubPlugin extends Plugin $action_name = $action->trimmed('action'); $action->menuItem(common_local_url('feedsubsettings'), - dgettext('FeebSubPlugin', 'Feeds'), - dgettext('FeedSubPlugin', 'Feed subscription options'), + _m('Feeds'), + _m('Feed subscription options'), $action_name === 'feedsubsettings'); return true; diff --git a/plugins/FeedSub/actions/feedsubsettings.php b/plugins/FeedSub/actions/feedsubsettings.php index 242224fac0..0fba20a393 100644 --- a/plugins/FeedSub/actions/feedsubsettings.php +++ b/plugins/FeedSub/actions/feedsubsettings.php @@ -38,7 +38,7 @@ class FeedSubSettingsAction extends ConnectSettingsAction function title() { - return dgettext('FeedSubPlugin', 'Feed subscriptions'); + return _m('Feed subscriptions'); } /** @@ -49,9 +49,8 @@ class FeedSubSettingsAction extends ConnectSettingsAction function getInstructions() { - return dgettext('FeedSubPlugin', - 'You can subscribe to feeds from other sites; ' . - 'updates will appear in your personal timeline.'); + return _m('You can subscribe to feeds from other sites; ' . + 'updates will appear in your personal timeline.'); } /** @@ -94,9 +93,9 @@ class FeedSubSettingsAction extends ConnectSettingsAction $this->elementEnd('ul'); if ($this->preview) { - $this->submit('subscribe', dgettext('FeedSubPlugin', 'Subscribe')); + $this->submit('subscribe', _m('Subscribe')); } else { - $this->submit('validate', dgettext('FeedSubPlugin', 'Continue')); + $this->submit('validate', _m('Continue')); } $this->elementEnd('fieldset'); @@ -149,8 +148,7 @@ class FeedSubSettingsAction extends ConnectSettingsAction $feedurl = trim($this->arg('feedurl')); if ($feedurl == '') { - $this->showForm(dgettext('FeedSubPlugin', - 'Empty feed URL!')); + $this->showForm(_m('Empty feed URL!')); return; } $this->feedurl = $feedurl; @@ -160,26 +158,26 @@ class FeedSubSettingsAction extends ConnectSettingsAction $discover = new FeedDiscovery(); $uri = $discover->discoverFromURL($feedurl); } catch (FeedSubBadURLException $e) { - $this->showForm(dgettext('FeedSubPlugin', 'Invalid URL or could not reach server.')); + $this->showForm(_m('Invalid URL or could not reach server.')); return false; } catch (FeedSubBadResponseException $e) { - $this->showForm(dgettext('FeedSubPlugin', 'Cannot read feed; server returned error.')); + $this->showForm(_m('Cannot read feed; server returned error.')); return false; } catch (FeedSubEmptyException $e) { - $this->showForm(dgettext('FeedSubPlugin', 'Cannot read feed; server returned an empty page.')); + $this->showForm(_m('Cannot read feed; server returned an empty page.')); return false; } catch (FeedSubBadHTMLException $e) { - $this->showForm(dgettext('FeedSubPlugin', 'Bad HTML, could not find feed link.')); + $this->showForm(_m('Bad HTML, could not find feed link.')); return false; } catch (FeedSubNoFeedException $e) { - $this->showForm(dgettext('FeedSubPlugin', 'Could not find a feed linked from this URL.')); + $this->showForm(_m('Could not find a feed linked from this URL.')); return false; } catch (FeedSubUnrecognizedTypeException $e) { - $this->showForm(dgettext('FeedSubPlugin', 'Not a recognized feed type.')); + $this->showForm(_m('Not a recognized feed type.')); return false; } catch (FeedSubException $e) { // Any new ones we forgot about - $this->showForm(dgettext('FeedSubPlugin', 'Bad feed URL.')); + $this->showForm(_m('Bad feed URL.')); return false; } @@ -187,7 +185,7 @@ class FeedSubSettingsAction extends ConnectSettingsAction $this->feedinfo = $this->munger->feedInfo(); if ($this->feedinfo->huburi == '') { - $this->showForm(dgettext('FeedSubPlugin', 'Feed is not PuSH-enabled; cannot subscribe.')); + $this->showForm(_m('Feed is not PuSH-enabled; cannot subscribe.')); return false; } @@ -207,7 +205,7 @@ class FeedSubSettingsAction extends ConnectSettingsAction $ok = $this->feedinfo->subscribe(); common_log(LOG_INFO, __METHOD__ . ": sub was $ok"); if (!$ok) { - $this->showForm(dgettext('FeedSubPlugin', 'Feed subscription failed! Bad response from hub.')); + $this->showForm(_m('Feed subscription failed! Bad response from hub.')); return; } } @@ -217,11 +215,11 @@ class FeedSubSettingsAction extends ConnectSettingsAction $profile = $this->feedinfo->getProfile(); if ($user->isSubscribed($profile)) { - $this->showForm(dgettext('FeedSubPlugin', 'Already subscribed!')); + $this->showForm(_m('Already subscribed!')); } elseif ($user->subscribeTo($profile)) { - $this->showForm(dgettext('FeedSubPlugin', 'Feed subscribed!')); + $this->showForm(_m('Feed subscribed!')); } else { - $this->showForm(dgettext('FeedSubPlugin', 'Feed subscription failed!')); + $this->showForm(_m('Feed subscription failed!')); } } } @@ -230,7 +228,7 @@ class FeedSubSettingsAction extends ConnectSettingsAction { if ($this->validateFeed()) { $this->preview = true; - $this->showForm(dgettext('FeedSubPlugin', 'Previewing feed:')); + $this->showForm(_m('Previewing feed:')); } } diff --git a/plugins/FeedSub/feedmunger.php b/plugins/FeedSub/feedmunger.php index bb8075da95..f3618b8eb0 100644 --- a/plugins/FeedSub/feedmunger.php +++ b/plugins/FeedSub/feedmunger.php @@ -212,7 +212,7 @@ class FeedMunger // try adding #hashtags from the categories/tags on a post. // @todo Should we force a language here? - $format = dgettext("FeedSubPlugin", 'New post: "%1$s" %2$s'); + $format = _m('New post: "%1$s" %2$s'); $title = $entry->title; $link = $this->getAltLink($entry); $out = sprintf($format, $title, $link); diff --git a/plugins/FeedSub/locale/FeedSub.po b/plugins/FeedSub/locale/FeedSub.po new file mode 100644 index 0000000000..dedc018e3f --- /dev/null +++ b/plugins/FeedSub/locale/FeedSub.po @@ -0,0 +1,104 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2009-12-07 20:38-0800\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: tests/gettext-speedtest.php:57 FeedSubPlugin.php:76 +msgid "Feeds" +msgstr "" + +#: FeedSubPlugin.php:77 +msgid "Feed subscription options" +msgstr "" + +#: feedmunger.php:215 +#, php-format +msgid "New post: \"%1$s\" %2$s" +msgstr "" + +#: actions/feedsubsettings.php:41 +msgid "Feed subscriptions" +msgstr "" + +#: actions/feedsubsettings.php:52 +msgid "" +"You can subscribe to feeds from other sites; updates will appear in your " +"personal timeline." +msgstr "" + +#: actions/feedsubsettings.php:96 +msgid "Subscribe" +msgstr "" + +#: actions/feedsubsettings.php:98 +msgid "Continue" +msgstr "" + +#: actions/feedsubsettings.php:151 +msgid "Empty feed URL!" +msgstr "" + +#: actions/feedsubsettings.php:161 +msgid "Invalid URL or could not reach server." +msgstr "" + +#: actions/feedsubsettings.php:164 +msgid "Cannot read feed; server returned error." +msgstr "" + +#: actions/feedsubsettings.php:167 +msgid "Cannot read feed; server returned an empty page." +msgstr "" + +#: actions/feedsubsettings.php:170 +msgid "Bad HTML, could not find feed link." +msgstr "" + +#: actions/feedsubsettings.php:173 +msgid "Could not find a feed linked from this URL." +msgstr "" + +#: actions/feedsubsettings.php:176 +msgid "Not a recognized feed type." +msgstr "" + +#: actions/feedsubsettings.php:180 +msgid "Bad feed URL." +msgstr "" + +#: actions/feedsubsettings.php:188 +msgid "Feed is not PuSH-enabled; cannot subscribe." +msgstr "" + +#: actions/feedsubsettings.php:208 +msgid "Feed subscription failed! Bad response from hub." +msgstr "" + +#: actions/feedsubsettings.php:218 +msgid "Already subscribed!" +msgstr "" + +#: actions/feedsubsettings.php:220 +msgid "Feed subscribed!" +msgstr "" + +#: actions/feedsubsettings.php:222 +msgid "Feed subscription failed!" +msgstr "" + +#: actions/feedsubsettings.php:231 +msgid "Previewing feed:" +msgstr "" diff --git a/plugins/FeedSub/locale/fr/LC_MESSAGES/FeedSub.po b/plugins/FeedSub/locale/fr/LC_MESSAGES/FeedSub.po new file mode 100644 index 0000000000..f17dfa50a5 --- /dev/null +++ b/plugins/FeedSub/locale/fr/LC_MESSAGES/FeedSub.po @@ -0,0 +1,106 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2009-12-07 14:14-0800\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: FeedSubPlugin.php:77 +msgid "Feeds" +msgstr "Flux" + +#: FeedSubPlugin.php:78 +msgid "Feed subscription options" +msgstr "Préférences pour abonnement flux" + +#: feedmunger.php:215 +#, php-format +msgid "New post: \"%1$s\" %2$s" +msgstr "Nouveau: \"%1$s\" %2$s" + +#: actions/feedsubsettings.php:41 +msgid "Feed subscriptions" +msgstr "Abonnements aux fluxes" + +#: actions/feedsubsettings.php:52 +msgid "" +"You can subscribe to feeds from other sites; updates will appear in your " +"personal timeline." +msgstr "" +"Abonner aux fluxes RSS ou Atom des autres sites web; les temps se trouverair" +"en votre flux personnel." + +#: actions/feedsubsettings.php:96 +msgid "Subscribe" +msgstr "Abonner" + +#: actions/feedsubsettings.php:98 +msgid "Continue" +msgstr "Prochaine" + +#: actions/feedsubsettings.php:151 +msgid "Empty feed URL!" +msgstr "" + +#: actions/feedsubsettings.php:161 +msgid "Invalid URL or could not reach server." +msgstr "" + +#: actions/feedsubsettings.php:164 +msgid "Cannot read feed; server returned error." +msgstr "" + +#: actions/feedsubsettings.php:167 +msgid "Cannot read feed; server returned an empty page." +msgstr "" + +#: actions/feedsubsettings.php:170 +msgid "Bad HTML, could not find feed link." +msgstr "" + +#: actions/feedsubsettings.php:173 +msgid "Could not find a feed linked from this URL." +msgstr "" + +#: actions/feedsubsettings.php:176 +msgid "Not a recognized feed type." +msgstr "" + +#: actions/feedsubsettings.php:180 +msgid "Bad feed URL." +msgstr "" + +#: actions/feedsubsettings.php:188 +msgid "Feed is not PuSH-enabled; cannot subscribe." +msgstr "" + +#: actions/feedsubsettings.php:208 +msgid "Feed subscription failed! Bad response from hub." +msgstr "" + +#: actions/feedsubsettings.php:218 +msgid "Already subscribed!" +msgstr "" + +#: actions/feedsubsettings.php:220 +msgid "Feed subscribed!" +msgstr "" + +#: actions/feedsubsettings.php:222 +msgid "Feed subscription failed!" +msgstr "" + +#: actions/feedsubsettings.php:231 +msgid "Previewing feed:" +msgstr "" diff --git a/plugins/FeedSub/tests/gettext-speedtest.php b/plugins/FeedSub/tests/gettext-speedtest.php new file mode 100644 index 0000000000..8bbdf5e899 --- /dev/null +++ b/plugins/FeedSub/tests/gettext-speedtest.php @@ -0,0 +1,78 @@ + $bits) { + list($time, $result) = $bits; + $ms = $time * 1000.0; + printf("%10s %2.4fms %s\n", $func, $ms, $result); +} + + +function fake($str) { + return $str; +} + diff --git a/plugins/Mapstraction/MapstractionPlugin.php b/plugins/Mapstraction/MapstractionPlugin.php index f20e81b0ea..93679e56c2 100644 --- a/plugins/Mapstraction/MapstractionPlugin.php +++ b/plugins/Mapstraction/MapstractionPlugin.php @@ -177,7 +177,7 @@ class MapstractionPlugin extends Plugin $action->elementStart('div', array('id' => 'entity_map', 'class' => 'section')); - $action->element('h2', null, _('Map')); + $action->element('h2', null, _m('Map')); $action->element('div', array('id' => 'map_canvas', 'class' => 'gray smallmap', @@ -188,7 +188,7 @@ class MapstractionPlugin extends Plugin array('nickname' => $action->trimmed('nickname'))); $action->element('a', array('href' => $mapUrl), - _("Full size")); + _m("Full size")); $action->elementEnd('div'); } diff --git a/plugins/Mapstraction/allmap.php b/plugins/Mapstraction/allmap.php index 0c4f03b31c..e73aa76e8e 100644 --- a/plugins/Mapstraction/allmap.php +++ b/plugins/Mapstraction/allmap.php @@ -68,10 +68,10 @@ class AllmapAction extends MapAction } if ($this->page == 1) { - return sprintf(_("%s friends map"), + return sprintf(_m("%s friends map"), $base); } else { - return sprintf(_("%s friends map, page %d"), + return sprintf(_m("%s friends map, page %d"), $base, $this->page); } diff --git a/plugins/Mapstraction/locale/Mapstraction.po b/plugins/Mapstraction/locale/Mapstraction.po new file mode 100644 index 0000000000..c1c50bf506 --- /dev/null +++ b/plugins/Mapstraction/locale/Mapstraction.po @@ -0,0 +1,48 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2009-12-07 20:38-0800\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: allmap.php:71 +#, php-format +msgid "%s friends map" +msgstr "" + +#: allmap.php:74 +#, php-format +msgid "%s friends map, page %d" +msgstr "" + +#: map.php:72 +msgid "No such user." +msgstr "" + +#: map.php:79 +msgid "User has no profile." +msgstr "" + +#: usermap.php:71 +#, php-format +msgid "%s map, page %d" +msgstr "" + +#: MapstractionPlugin.php:180 +msgid "Map" +msgstr "" + +#: MapstractionPlugin.php:191 +msgid "Full size" +msgstr "" diff --git a/plugins/Mapstraction/map.php b/plugins/Mapstraction/map.php index 734e480884..a33dfc7360 100644 --- a/plugins/Mapstraction/map.php +++ b/plugins/Mapstraction/map.php @@ -69,14 +69,14 @@ class MapAction extends OwnerDesignAction $this->user = User::staticGet('nickname', $nickname); if (!$this->user) { - $this->clientError(_('No such user.'), 404); + $this->clientError(_m('No such user.'), 404); return false; } $this->profile = $this->user->getProfile(); if (!$this->profile) { - $this->serverError(_('User has no profile.')); + $this->serverError(_m('User has no profile.')); return false; } diff --git a/plugins/Mapstraction/usermap.php b/plugins/Mapstraction/usermap.php index 3e517ee864..ff47b6adaf 100644 --- a/plugins/Mapstraction/usermap.php +++ b/plugins/Mapstraction/usermap.php @@ -68,7 +68,7 @@ class UsermapAction extends MapAction if ($this->page == 1) { return $base; } else { - return sprintf(_("%s map, page %d"), + return sprintf(_m("%s map, page %d"), $base, $this->page); } diff --git a/plugins/OpenID/OpenIDPlugin.php b/plugins/OpenID/OpenIDPlugin.php index e86725d70d..a37d5465e8 100644 --- a/plugins/OpenID/OpenIDPlugin.php +++ b/plugins/OpenID/OpenIDPlugin.php @@ -120,8 +120,8 @@ class OpenIDPlugin extends Plugin $action_name = $action->trimmed('action'); $action->menuItem(common_local_url('openidlogin'), - _('OpenID'), - _('Login or register with OpenID'), + _m('OpenID'), + _m('Login or register with OpenID'), $action_name === 'openidlogin'); return true; @@ -132,8 +132,8 @@ class OpenIDPlugin extends Plugin $action_name = $action->trimmed('action'); $action->menuItem(common_local_url('openidsettings'), - _('OpenID'), - _('Add or remove OpenIDs'), + _m('OpenID'), + _m('Add or remove OpenIDs'), $action_name === 'openidsettings'); return true; diff --git a/plugins/OpenID/finishaddopenid.php b/plugins/OpenID/finishaddopenid.php index 7cd9165231..991e6584ee 100644 --- a/plugins/OpenID/finishaddopenid.php +++ b/plugins/OpenID/finishaddopenid.php @@ -64,7 +64,7 @@ class FinishaddopenidAction extends Action { parent::handle($args); if (!common_logged_in()) { - $this->clientError(_('Not logged in.')); + $this->clientError(_m('Not logged in.')); } else { $this->tryLogin(); } @@ -85,11 +85,11 @@ class FinishaddopenidAction extends Action $response = $consumer->complete(common_local_url('finishaddopenid')); if ($response->status == Auth_OpenID_CANCEL) { - $this->message(_('OpenID authentication cancelled.')); + $this->message(_m('OpenID authentication cancelled.')); return; } else if ($response->status == Auth_OpenID_FAILURE) { // Authentication failed; display the error message. - $this->message(sprintf(_('OpenID authentication failed: %s'), + $this->message(sprintf(_m('OpenID authentication failed: %s'), $response->message)); } else if ($response->status == Auth_OpenID_SUCCESS) { @@ -109,9 +109,9 @@ class FinishaddopenidAction extends Action if ($other) { if ($other->id == $cur->id) { - $this->message(_('You already have this OpenID!')); + $this->message(_m('You already have this OpenID!')); } else { - $this->message(_('Someone else already has this OpenID.')); + $this->message(_m('Someone else already has this OpenID.')); } return; } @@ -123,12 +123,12 @@ class FinishaddopenidAction extends Action $result = oid_link_user($cur->id, $canonical, $display); if (!$result) { - $this->message(_('Error connecting user.')); + $this->message(_m('Error connecting user.')); return; } if ($sreg) { if (!oid_update_user($cur, $sreg)) { - $this->message(_('Error updating profile')); + $this->message(_m('Error updating profile')); return; } } @@ -167,7 +167,7 @@ class FinishaddopenidAction extends Action function title() { - return _('OpenID Login'); + return _m('OpenID Login'); } /** diff --git a/plugins/OpenID/finishopenidlogin.php b/plugins/OpenID/finishopenidlogin.php index e5551b4126..987fa92138 100644 --- a/plugins/OpenID/finishopenidlogin.php +++ b/plugins/OpenID/finishopenidlogin.php @@ -31,16 +31,16 @@ class FinishopenidloginAction extends Action { parent::handle($args); if (common_is_real_login()) { - $this->clientError(_('Already logged in.')); + $this->clientError(_m('Already logged in.')); } else if ($_SERVER['REQUEST_METHOD'] == 'POST') { $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; } @@ -49,7 +49,7 @@ class FinishopenidloginAction extends Action $this->connectUser(); } else { common_debug(print_r($this->args, true), __FILE__); - $this->showForm(_('Something weird happened.'), + $this->showForm(_m('Something weird happened.'), $this->trimmed('newname')); } } else { @@ -63,13 +63,13 @@ class FinishopenidloginAction 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 OpenID 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 OpenID 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 _('OpenID Account Setup'); + return _m('OpenID Account Setup'); } function showForm($error=null, $username=null) @@ -94,14 +94,14 @@ class FinishopenidloginAction extends Action $this->hidden('token', common_session_token()); $this->elementStart('fieldset', array('id' => 'form_openid_createaccount')); $this->element('legend', null, - _('Create new account')); + _m('Create new account')); $this->element('p', null, - _('Create a new user with this nickname.')); + _m('Create a new user with this nickname.')); $this->elementStart('ul', 'form_data'); $this->elementStart('li'); - $this->input('newname', _('New nickname'), + $this->input('newname', _m('New nickname'), ($this->username) ? $this->username : '', - _('1-64 lowercase letters or numbers, no punctuation or spaces')); + _m('1-64 lowercase letters or numbers, no punctuation or spaces')); $this->elementEnd('li'); $this->elementStart('li'); $this->element('input', array('type' => 'checkbox', @@ -111,30 +111,30 @@ class FinishopenidloginAction extends Action 'value' => 'true')); $this->elementStart('label', array('for' => 'license', 'class' => 'checkbox')); - $this->text(_('My text and files are available under ')); + $this->text(_m('My text and files are available under ')); $this->element('a', array('href' => common_config('license', 'url')), common_config('license', 'title')); - $this->text(_(' except this private data: password, email address, IM address, phone number.')); + $this->text(_m(' except this private data: password, email address, IM address, phone number.')); $this->elementEnd('label'); $this->elementEnd('li'); $this->elementEnd('ul'); - $this->submit('create', _('Create')); + $this->submit('create', _m('Create')); $this->elementEnd('fieldset'); $this->elementStart('fieldset', array('id' => 'form_openid_createaccount')); $this->element('legend', null, - _('Connect existing account')); + _m('Connect existing account')); $this->element('p', null, - _('If you already have an account, login with your username and password to connect it to your OpenID.')); + _m('If you already have an account, login with your username and password to connect it to your OpenID.')); $this->elementStart('ul', 'form_data'); $this->elementStart('li'); - $this->input('nickname', _('Existing nickname')); + $this->input('nickname', _m('Existing nickname')); $this->elementEnd('li'); $this->elementStart('li'); - $this->password('password', _('Password')); + $this->password('password', _m('Password')); $this->elementEnd('li'); $this->elementEnd('ul'); - $this->submit('connect', _('Connect')); + $this->submit('connect', _m('Connect')); $this->elementEnd('fieldset'); $this->elementEnd('form'); } @@ -146,11 +146,11 @@ class FinishopenidloginAction extends Action $response = $consumer->complete(common_local_url('finishopenidlogin')); if ($response->status == Auth_OpenID_CANCEL) { - $this->message(_('OpenID authentication cancelled.')); + $this->message(_m('OpenID authentication cancelled.')); return; } else if ($response->status == Auth_OpenID_FAILURE) { // Authentication failed; display the error message. - $this->message(sprintf(_('OpenID authentication failed: %s'), $response->message)); + $this->message(sprintf(_m('OpenID authentication failed: %s'), $response->message)); } else if ($response->status == Auth_OpenID_SUCCESS) { // This means the authentication succeeded; extract the // identity URL and Simple Registration data (if it was @@ -212,7 +212,7 @@ class FinishopenidloginAction extends Action # FIXME: save invite code before redirect, and check here if (common_config('site', 'closed')) { - $this->clientError(_('Registration not allowed.')); + $this->clientError(_m('Registration not allowed.')); return; } @@ -221,14 +221,14 @@ class FinishopenidloginAction extends Action if (common_config('site', 'inviteonly')) { $code = $_SESSION['invitecode']; if (empty($code)) { - $this->clientError(_('Registration not allowed.')); + $this->clientError(_m('Registration not allowed.')); return; } $invite = Invitation::staticGet($code); if (empty($invite)) { - $this->clientError(_('Not a valid invitation code.')); + $this->clientError(_m('Not a valid invitation code.')); return; } } @@ -238,24 +238,24 @@ class FinishopenidloginAction extends Action if (!Validate::string($nickname, array('min_length' => 1, 'max_length' => 64, 'format' => NICKNAME_FMT))) { - $this->showForm(_('Nickname must have only lowercase letters and numbers and no spaces.')); + $this->showForm(_m('Nickname must have only lowercase letters and numbers and no spaces.')); return; } if (!User::allowed_nickname($nickname)) { - $this->showForm(_('Nickname not allowed.')); + $this->showForm(_m('Nickname not allowed.')); return; } if (User::staticGet('nickname', $nickname)) { - $this->showForm(_('Nickname already in use. Try another one.')); + $this->showForm(_m('Nickname already in use. Try another one.')); return; } list($display, $canonical, $sreg) = $this->getSavedValues(); if (!$display || !$canonical) { - $this->serverError(_('Stored OpenID not found.')); + $this->serverError(_m('Stored OpenID not found.')); return; } @@ -264,7 +264,7 @@ class FinishopenidloginAction extends Action $other = oid_get_user($canonical); if ($other) { - $this->serverError(_('Creating new account for OpenID that already has a user.')); + $this->serverError(_m('Creating new account for OpenID that already has a user.')); return; } @@ -324,7 +324,7 @@ class FinishopenidloginAction extends Action $password = $this->trimmed('password'); if (!common_check_user($nickname, $password)) { - $this->showForm(_('Invalid username or password.')); + $this->showForm(_m('Invalid username or password.')); return; } @@ -335,14 +335,14 @@ class FinishopenidloginAction extends Action list($display, $canonical, $sreg) = $this->getSavedValues(); if (!$display || !$canonical) { - $this->serverError(_('Stored OpenID not found.')); + $this->serverError(_m('Stored OpenID not found.')); return; } $result = oid_link_user($user->id, $canonical, $display); if (!$result) { - $this->serverError(_('Error connecting user to OpenID.')); + $this->serverError(_m('Error connecting user to OpenID.')); return; } diff --git a/plugins/OpenID/locale/OpenID.po b/plugins/OpenID/locale/OpenID.po new file mode 100644 index 0000000000..34738bc750 --- /dev/null +++ b/plugins/OpenID/locale/OpenID.po @@ -0,0 +1,344 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2009-12-07 20:38-0800\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: openidlogin.php:30 finishopenidlogin.php:34 +msgid "Already logged in." +msgstr "" + +#: openidlogin.php:37 openidsettings.php:194 finishopenidlogin.php:38 +msgid "There was a problem with your session token. Try again, please." +msgstr "" + +#: openidlogin.php:66 +#, php-format +msgid "" +"For security reasons, please re-login with your [OpenID](%%doc.openid%%) " +"before changing your settings." +msgstr "" + +#: openidlogin.php:70 +#, php-format +msgid "Login with an [OpenID](%%doc.openid%%) account." +msgstr "" + +#: openidlogin.php:95 finishaddopenid.php:170 +msgid "OpenID Login" +msgstr "" + +#: openidlogin.php:112 +msgid "OpenID login" +msgstr "" + +#: openidlogin.php:117 openidsettings.php:107 +msgid "OpenID URL" +msgstr "" + +#: openidlogin.php:119 +msgid "Your OpenID URL" +msgstr "" + +#: openidlogin.php:122 +msgid "Remember me" +msgstr "" + +#: openidlogin.php:123 +msgid "Automatically login in the future; not for shared computers!" +msgstr "" + +#: openidlogin.php:127 +msgid "Login" +msgstr "" + +#: openidserver.php:106 +#, php-format +msgid "You are not authorized to use the identity %s" +msgstr "" + +#: openidserver.php:126 +msgid "Just an OpenID provider. Nothing to see here, move along..." +msgstr "" + +#: OpenIDPlugin.php:123 OpenIDPlugin.php:135 +msgid "OpenID" +msgstr "" + +#: OpenIDPlugin.php:124 +msgid "Login or register with OpenID" +msgstr "" + +#: OpenIDPlugin.php:136 +msgid "Add or remove OpenIDs" +msgstr "" + +#: openid.php:141 +msgid "Cannot instantiate OpenID consumer object." +msgstr "" + +#: openid.php:151 +msgid "Not a valid OpenID." +msgstr "" + +#: openid.php:153 +#, php-format +msgid "OpenID failure: %s" +msgstr "" + +#: openid.php:180 +#, php-format +msgid "Could not redirect to server: %s" +msgstr "" + +#: openid.php:198 +#, php-format +msgid "Could not create OpenID form: %s" +msgstr "" + +#: openid.php:214 +msgid "" +"This form should automatically submit itself. If not, click the submit " +"button to go to your OpenID provider." +msgstr "" + +#: openid.php:246 +msgid "Error saving the profile." +msgstr "" + +#: openid.php:257 +msgid "Error saving the user." +msgstr "" + +#: openid.php:277 +msgid "OpenID Auto-Submit" +msgstr "" + +#: openidtrust.php:51 +msgid "OpenID Identity Verification" +msgstr "" + +#: openidtrust.php:69 +msgid "" +"This page should only be reached during OpenID processing, not directly." +msgstr "" + +#: openidtrust.php:118 +#, php-format +msgid "" +"%s has asked to verify your identity. Click Continue to verify your " +"identity and login without creating a new password." +msgstr "" + +#: openidtrust.php:136 +msgid "Continue" +msgstr "" + +#: openidtrust.php:137 +msgid "Cancel" +msgstr "" + +#: finishaddopenid.php:67 +msgid "Not logged in." +msgstr "" + +#: finishaddopenid.php:88 finishopenidlogin.php:149 +msgid "OpenID authentication cancelled." +msgstr "" + +#: finishaddopenid.php:92 finishopenidlogin.php:153 +#, php-format +msgid "OpenID authentication failed: %s" +msgstr "" + +#: finishaddopenid.php:112 +msgid "You already have this OpenID!" +msgstr "" + +#: finishaddopenid.php:114 +msgid "Someone else already has this OpenID." +msgstr "" + +#: finishaddopenid.php:126 +msgid "Error connecting user." +msgstr "" + +#: finishaddopenid.php:131 +msgid "Error updating profile" +msgstr "" + +#: openidsettings.php:59 +msgid "OpenID settings" +msgstr "" + +#: openidsettings.php:70 +#, php-format +msgid "" +"[OpenID](%%doc.openid%%) lets you log into many sites with the same user " +"account. Manage your associated OpenIDs from here." +msgstr "" + +#: openidsettings.php:99 +msgid "Add OpenID" +msgstr "" + +#: openidsettings.php:102 +msgid "" +"If you want to add an OpenID to your account, enter it in the box below and " +"click \"Add\"." +msgstr "" + +#: openidsettings.php:117 +msgid "Add" +msgstr "" + +#: openidsettings.php:129 +msgid "Remove OpenID" +msgstr "" + +#: openidsettings.php:134 +msgid "" +"Removing your only OpenID would make it impossible to log in! If you need to " +"remove it, add another OpenID first." +msgstr "" + +#: openidsettings.php:149 +msgid "" +"You can remove an OpenID from your account by clicking the button marked " +"\"Remove\"." +msgstr "" + +#: openidsettings.php:172 +msgid "Remove" +msgstr "" + +#: openidsettings.php:208 finishopenidlogin.php:52 +msgid "Something weird happened." +msgstr "" + +#: openidsettings.php:228 +msgid "No such OpenID." +msgstr "" + +#: openidsettings.php:233 +msgid "That OpenID does not belong to you." +msgstr "" + +#: openidsettings.php:237 +msgid "OpenID removed." +msgstr "" + +#: finishopenidlogin.php:43 +msgid "You can't register if you don't agree to the license." +msgstr "" + +#: finishopenidlogin.php:66 +#, php-format +msgid "" +"This is the first time you've logged into %s so we must connect your OpenID " +"to a local account. You can either create a new account, or connect with " +"your existing account, if you have one." +msgstr "" + +#: finishopenidlogin.php:72 +msgid "OpenID Account Setup" +msgstr "" + +#: finishopenidlogin.php:97 +msgid "Create new account" +msgstr "" + +#: finishopenidlogin.php:99 +msgid "Create a new user with this nickname." +msgstr "" + +#: finishopenidlogin.php:102 +msgid "New nickname" +msgstr "" + +#: finishopenidlogin.php:104 +msgid "1-64 lowercase letters or numbers, no punctuation or spaces" +msgstr "" + +#: finishopenidlogin.php:114 +msgid "My text and files are available under " +msgstr "" + +#: finishopenidlogin.php:117 +msgid "" +" except this private data: password, email address, IM address, phone number." +msgstr "" + +#: finishopenidlogin.php:121 +msgid "Create" +msgstr "" + +#: finishopenidlogin.php:126 +msgid "Connect existing account" +msgstr "" + +#: finishopenidlogin.php:128 +msgid "" +"If you already have an account, login with your username and password to " +"connect it to your OpenID." +msgstr "" + +#: finishopenidlogin.php:131 +msgid "Existing nickname" +msgstr "" + +#: finishopenidlogin.php:134 +msgid "Password" +msgstr "" + +#: finishopenidlogin.php:137 +msgid "Connect" +msgstr "" + +#: finishopenidlogin.php:215 finishopenidlogin.php:224 +msgid "Registration not allowed." +msgstr "" + +#: finishopenidlogin.php:231 +msgid "Not a valid invitation code." +msgstr "" + +#: finishopenidlogin.php:241 +msgid "Nickname must have only lowercase letters and numbers and no spaces." +msgstr "" + +#: finishopenidlogin.php:246 +msgid "Nickname not allowed." +msgstr "" + +#: finishopenidlogin.php:251 +msgid "Nickname already in use. Try another one." +msgstr "" + +#: finishopenidlogin.php:258 finishopenidlogin.php:338 +msgid "Stored OpenID not found." +msgstr "" + +#: finishopenidlogin.php:267 +msgid "Creating new account for OpenID that already has a user." +msgstr "" + +#: finishopenidlogin.php:327 +msgid "Invalid username or password." +msgstr "" + +#: finishopenidlogin.php:345 +msgid "Error connecting user to OpenID." +msgstr "" diff --git a/plugins/OpenID/openid.php b/plugins/OpenID/openid.php index dd628e7733..8f949c9c5d 100644 --- a/plugins/OpenID/openid.php +++ b/plugins/OpenID/openid.php @@ -138,7 +138,7 @@ function oid_authenticate($openid_url, $returnto, $immediate=false) $consumer = oid_consumer(); if (!$consumer) { - common_server_error(_('Cannot instantiate OpenID consumer object.')); + common_server_error(_m('Cannot instantiate OpenID consumer object.')); return false; } @@ -148,9 +148,9 @@ function oid_authenticate($openid_url, $returnto, $immediate=false) // Handle failure status return values. if (!$auth_request) { - return _('Not a valid OpenID.'); + return _m('Not a valid OpenID.'); } else if (Auth_OpenID::isFailure($auth_request)) { - return sprintf(_('OpenID failure: %s'), $auth_request->message); + return sprintf(_m('OpenID failure: %s'), $auth_request->message); } $sreg_request = Auth_OpenID_SRegRequest::build(// Required @@ -177,7 +177,7 @@ function oid_authenticate($openid_url, $returnto, $immediate=false) $immediate); if (!$redirect_url) { } else if (Auth_OpenID::isFailure($redirect_url)) { - return sprintf(_('Could not redirect to server: %s'), $redirect_url->message); + return sprintf(_m('Could not redirect to server: %s'), $redirect_url->message); } else { common_redirect($redirect_url, 303); } @@ -195,7 +195,7 @@ function oid_authenticate($openid_url, $returnto, $immediate=false) // Display an error if the form markup couldn't be generated; // otherwise, render the HTML. if (Auth_OpenID::isFailure($form_html)) { - common_server_error(sprintf(_('Could not create OpenID form: %s'), $form_html->message)); + common_server_error(sprintf(_m('Could not create OpenID form: %s'), $form_html->message)); } else { $action = new AutosubmitAction(); // see below $action->form_html = $form_html; @@ -211,7 +211,7 @@ function oid_authenticate($openid_url, $returnto, $immediate=false) function _oid_print_instructions() { common_element('div', 'instructions', - _('This form should automatically submit itself. '. + _m('This form should automatically submit itself. '. 'If not, click the submit button to go to your '. 'OpenID provider.')); } @@ -243,7 +243,7 @@ function oid_update_user(&$user, &$sreg) # XXX save timezone if it's passed if (!$profile->update($orig_profile)) { - common_server_error(_('Error saving the profile.')); + common_server_error(_m('Error saving the profile.')); return false; } @@ -254,7 +254,7 @@ function oid_update_user(&$user, &$sreg) } if (!$user->update($orig_user)) { - common_server_error(_('Error saving the user.')); + common_server_error(_m('Error saving the user.')); return false; } @@ -274,7 +274,7 @@ class AutosubmitAction extends Action function title() { - return _('OpenID Auto-Submit'); + return _m('OpenID Auto-Submit'); } function showContent() diff --git a/plugins/OpenID/openidlogin.php b/plugins/OpenID/openidlogin.php index 29e89234e9..9ba55911c0 100644 --- a/plugins/OpenID/openidlogin.php +++ b/plugins/OpenID/openidlogin.php @@ -27,14 +27,14 @@ class OpenidloginAction extends Action { parent::handle($args); if (common_is_real_login()) { - $this->clientError(_('Already logged in.')); + $this->clientError(_m('Already logged in.')); } else if ($_SERVER['REQUEST_METHOD'] == 'POST') { $openid_url = $this->trimmed('openid_url'); # CSRF protection $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { - $this->showForm(_('There was a problem with your session token. Try again, please.'), $openid_url); + $this->showForm(_m('There was a problem with your session token. Try again, please.'), $openid_url); return; } @@ -63,11 +63,11 @@ class OpenidloginAction extends Action common_get_returnto()) { // rememberme logins have to reauthenticate before // changing any profile settings (cookie-stealing protection) - return _('For security reasons, please re-login with your ' . + return _m('For security reasons, please re-login with your ' . '[OpenID](%%doc.openid%%) ' . 'before changing your settings.'); } else { - return _('Login with an [OpenID](%%doc.openid%%) account.'); + return _m('Login with an [OpenID](%%doc.openid%%) account.'); } } @@ -92,7 +92,7 @@ class OpenidloginAction extends Action function title() { - return _('OpenID Login'); + return _m('OpenID Login'); } function showForm($error=null, $openid_url) @@ -109,22 +109,22 @@ class OpenidloginAction extends Action 'class' => 'form_settings', 'action' => $formaction)); $this->elementStart('fieldset'); - $this->element('legend', null, _('OpenID login')); + $this->element('legend', null, _m('OpenID login')); $this->hidden('token', common_session_token()); $this->elementStart('ul', 'form_data'); $this->elementStart('li'); - $this->input('openid_url', _('OpenID URL'), + $this->input('openid_url', _m('OpenID URL'), $this->openid_url, - _('Your OpenID URL')); + _m('Your OpenID URL')); $this->elementEnd('li'); $this->elementStart('li', array('id' => 'settings_rememberme')); - $this->checkbox('rememberme', _('Remember me'), false, - _('Automatically login in the future; ' . + $this->checkbox('rememberme', _m('Remember me'), false, + _m('Automatically login in the future; ' . 'not for shared computers!')); $this->elementEnd('li'); $this->elementEnd('ul'); - $this->submit('submit', _('Login')); + $this->submit('submit', _m('Login')); $this->elementEnd('fieldset'); $this->elementEnd('form'); } diff --git a/plugins/OpenID/openidserver.php b/plugins/OpenID/openidserver.php index dab97c93ed..181cbdf45e 100644 --- a/plugins/OpenID/openidserver.php +++ b/plugins/OpenID/openidserver.php @@ -103,7 +103,7 @@ class OpenidserverAction extends Action $response = $this->generateDenyResponse($request); } else { //invalid - $this->clientError(sprintf(_('You are not authorized to use the identity %s'),$request->identity),$code=403); + $this->clientError(sprintf(_m('You are not authorized to use the identity %s'),$request->identity),$code=403); } } else { $response = $this->oserver->handleRequest($request); @@ -123,7 +123,7 @@ class OpenidserverAction extends Action } $this->raw($response->body); }else{ - $this->clientError(_('Just an OpenID provider. Nothing to see here, move along...'),$code=500); + $this->clientError(_m('Just an OpenID provider. Nothing to see here, move along...'),$code=500); } } diff --git a/plugins/OpenID/openidsettings.php b/plugins/OpenID/openidsettings.php index 3ad46f5f57..3fc3d61289 100644 --- a/plugins/OpenID/openidsettings.php +++ b/plugins/OpenID/openidsettings.php @@ -56,7 +56,7 @@ class OpenidsettingsAction extends AccountSettingsAction function title() { - return _('OpenID settings'); + return _m('OpenID settings'); } /** @@ -67,7 +67,7 @@ class OpenidsettingsAction extends AccountSettingsAction function getInstructions() { - return _('[OpenID](%%doc.openid%%) lets you log into many sites' . + return _m('[OpenID](%%doc.openid%%) lets you log into many sites' . ' with the same user account.'. ' Manage your associated OpenIDs from here.'); } @@ -96,15 +96,15 @@ class OpenidsettingsAction extends AccountSettingsAction 'action' => common_local_url('openidsettings'))); $this->elementStart('fieldset', array('id' => 'settings_openid_add')); - $this->element('legend', null, _('Add OpenID')); + $this->element('legend', null, _m('Add OpenID')); $this->hidden('token', common_session_token()); $this->element('p', 'form_guide', - _('If you want to add an OpenID to your account, ' . + _m('If you want to add an OpenID to your account, ' . 'enter it in the box below and click "Add".')); $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->element('label', array('for' => 'openid_url'), - _('OpenID URL')); + _m('OpenID URL')); $this->element('input', array('name' => 'openid_url', 'type' => 'text', 'id' => 'openid_url')); @@ -114,7 +114,7 @@ class OpenidsettingsAction extends AccountSettingsAction 'id' => 'settings_openid_add_action-submit', 'name' => 'add', 'class' => 'submit', - 'value' => _('Add'))); + 'value' => _m('Add'))); $this->elementEnd('fieldset'); $this->elementEnd('form'); @@ -126,12 +126,12 @@ class OpenidsettingsAction extends AccountSettingsAction if ($cnt > 0) { - $this->element('h2', null, _('Remove OpenID')); + $this->element('h2', null, _m('Remove OpenID')); if ($cnt == 1 && !$user->password) { $this->element('p', 'form_guide', - _('Removing your only OpenID '. + _m('Removing your only OpenID '. 'would make it impossible to log in! ' . 'If you need to remove it, '. 'add another OpenID first.')); @@ -146,7 +146,7 @@ class OpenidsettingsAction extends AccountSettingsAction } else { $this->element('p', 'form_guide', - _('You can remove an OpenID from your account '. + _m('You can remove an OpenID from your account '. 'by clicking the button marked "Remove".')); $idx = 0; @@ -169,7 +169,7 @@ class OpenidsettingsAction extends AccountSettingsAction 'id' => 'remove'.$idx, 'name' => 'remove', 'class' => 'submit remove', - 'value' => _('Remove'))); + 'value' => _m('Remove'))); $this->elementEnd('fieldset'); $this->elementEnd('form'); $idx++; @@ -191,7 +191,7 @@ class OpenidsettingsAction extends AccountSettingsAction // CSRF protection $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { - $this->showForm(_('There was a problem with your session token. '. + $this->showForm(_m('There was a problem with your session token. '. 'Try again, please.')); return; } @@ -205,7 +205,7 @@ class OpenidsettingsAction extends AccountSettingsAction } else if ($this->arg('remove')) { $this->removeOpenid(); } else { - $this->showForm(_('Something weird happened.')); + $this->showForm(_m('Something weird happened.')); } } @@ -225,16 +225,16 @@ class OpenidsettingsAction extends AccountSettingsAction $oid = User_openid::staticGet('canonical', $openid_url); if (!$oid) { - $this->showForm(_('No such OpenID.')); + $this->showForm(_m('No such OpenID.')); return; } $cur = common_current_user(); if (!$cur || $oid->user_id != $cur->id) { - $this->showForm(_('That OpenID does not belong to you.')); + $this->showForm(_m('That OpenID does not belong to you.')); return; } $oid->delete(); - $this->showForm(_('OpenID removed.'), true); + $this->showForm(_m('OpenID removed.'), true); return; } } diff --git a/plugins/OpenID/openidtrust.php b/plugins/OpenID/openidtrust.php index 29c7bdc23c..fa7ea36e26 100644 --- a/plugins/OpenID/openidtrust.php +++ b/plugins/OpenID/openidtrust.php @@ -48,7 +48,7 @@ class OpenidtrustAction extends Action function title() { - return _('OpenID Identity Verification'); + return _m('OpenID Identity Verification'); } function prepare($args) @@ -66,7 +66,7 @@ class OpenidtrustAction extends Action $this->allowUrl = $_SESSION['openid_allow_url']; $this->denyUrl = $_SESSION['openid_deny_url']; if(empty($this->trust_root) || empty($this->allowUrl) || empty($this->denyUrl)){ - $this->clientError(_('This page should only be reached during OpenID processing, not directly.')); + $this->clientError(_m('This page should only be reached during OpenID processing, not directly.')); return; } return true; @@ -115,7 +115,7 @@ class OpenidtrustAction extends Action function showPageNotice() { - $this->element('p',null,sprintf(_('%s has asked to verify your identity. Click Continue to verify your identity and login without creating a new password.'),$this->trust_root)); + $this->element('p',null,sprintf(_m('%s has asked to verify your identity. Click Continue to verify your identity and login without creating a new password.'),$this->trust_root)); } /** @@ -133,8 +133,8 @@ class OpenidtrustAction extends Action 'class' => 'form_settings', 'action' => common_local_url('openidtrust'))); $this->elementStart('fieldset'); - $this->submit('allow', _('Continue')); - $this->submit('deny', _('Cancel')); + $this->submit('allow', _m('Continue')); + $this->submit('deny', _m('Cancel')); $this->elementEnd('fieldset'); $this->elementEnd('form'); diff --git a/plugins/Sample/SamplePlugin.php b/plugins/Sample/SamplePlugin.php new file mode 100644 index 0000000000..6e361aafbe --- /dev/null +++ b/plugins/Sample/SamplePlugin.php @@ -0,0 +1,59 @@ +. + */ + +/** + * @package SamplePlugin + * @maintainer Your Name + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + // This check helps protect against security problems; + // your code file can't be executed directly from the web. + exit(1); +} + +class SamplePlugin extends Plugin +{ + function onInitializePlugin() + { + // Event handlers normally return true to indicate that all is well. + // + // Returning false will cancel further processing of any other + // plugins or core code hooking the same event. + return true; + } + + /** + * Hook for RouterInitialized event. + * + * @param Net_URL_Mapper $m path-to-action mapper + * @return boolean hook return + */ + + function onRouterInitialized($m) + { + $m->connect(':nickname/samples', + array('action' => 'showsamples'), + array('feed' => '[A-Za-z0-9_-]+')); + $m->connect('settings/sample', + array('action' => 'samplesettings')); + return true; + } +} + diff --git a/plugins/TwitterBridge/TwitterBridgePlugin.php b/plugins/TwitterBridge/TwitterBridgePlugin.php index adf9ceda34..de1181903e 100644 --- a/plugins/TwitterBridge/TwitterBridgePlugin.php +++ b/plugins/TwitterBridge/TwitterBridgePlugin.php @@ -86,8 +86,8 @@ class TwitterBridgePlugin extends Plugin $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; diff --git a/plugins/TwitterBridge/locale/TwitterBridge.po b/plugins/TwitterBridge/locale/TwitterBridge.po new file mode 100644 index 0000000000..14c30f1c9c --- /dev/null +++ b/plugins/TwitterBridge/locale/TwitterBridge.po @@ -0,0 +1,128 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2009-12-07 20:38-0800\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: twitterauthorization.php:81 +msgid "Not logged in." +msgstr "" + +#: twitterauthorization.php:131 twitterauthorization.php:150 +#: twitterauthorization.php:170 twitterauthorization.php:217 +msgid "Couldn't link your Twitter account." +msgstr "" + +#: TwitterBridgePlugin.php:89 +msgid "Twitter" +msgstr "" + +#: TwitterBridgePlugin.php:90 +msgid "Twitter integration options" +msgstr "" + +#: twittersettings.php:59 +msgid "Twitter settings" +msgstr "" + +#: twittersettings.php:70 +msgid "" +"Connect your Twitter account to share your updates with your Twitter friends " +"and vice-versa." +msgstr "" + +#: twittersettings.php:118 +msgid "Twitter account" +msgstr "" + +#: twittersettings.php:123 +msgid "Connected Twitter account" +msgstr "" + +#: twittersettings.php:125 +msgid "Remove" +msgstr "" + +#: twittersettings.php:131 +msgid "Preferences" +msgstr "" + +#: twittersettings.php:135 +msgid "Automatically send my notices to Twitter." +msgstr "" + +#: twittersettings.php:142 +msgid "Send local \"@\" replies to Twitter." +msgstr "" + +#: twittersettings.php:149 +msgid "Subscribe to my Twitter friends here." +msgstr "" + +#: twittersettings.php:158 +msgid "Import my Friends Timeline." +msgstr "" + +#: twittersettings.php:174 +msgid "Save" +msgstr "" + +#: twittersettings.php:176 +msgid "Add" +msgstr "" + +#: twittersettings.php:201 +msgid "There was a problem with your session token. Try again, please." +msgstr "" + +#: twittersettings.php:211 +msgid "Unexpected form submission." +msgstr "" + +#: twittersettings.php:230 +msgid "Couldn't remove Twitter user." +msgstr "" + +#: twittersettings.php:234 +msgid "Twitter account removed." +msgstr "" + +#: twittersettings.php:255 twittersettings.php:265 +msgid "Couldn't save Twitter preferences." +msgstr "" + +#: twittersettings.php:269 +msgid "Twitter preferences saved." +msgstr "" + +#: twitter.php:333 +msgid "Your Twitter bridge has been disabled." +msgstr "" + +#: twitter.php:337 +#, php-format +msgid "" +"Hi, %1$s. We're sorry to inform you that your link to Twitter has been " +"disabled. We no longer seem to have permission to update your Twitter " +"status. (Did you revoke %3$s's access?)\n" +"\n" +"You can re-enable your Twitter bridge by visiting your Twitter settings " +"page:\n" +"\n" +"\t%2$s\n" +"\n" +"Regards,\n" +"%3$s\n" +msgstr "" diff --git a/plugins/TwitterBridge/twitter.php b/plugins/TwitterBridge/twitter.php index fd51506388..b338a200de 100644 --- a/plugins/TwitterBridge/twitter.php +++ b/plugins/TwitterBridge/twitter.php @@ -330,11 +330,11 @@ function mail_twitter_bridge_removed($user) $profile = $user->getProfile(); - $subject = sprintf(_('Your Twitter bridge has been disabled.')); + $subject = sprintf(_m('Your Twitter bridge has been disabled.')); $site_name = common_config('site', 'name'); - $body = sprintf(_('Hi, %1$s. We\'re sorry to inform you that your ' . + $body = sprintf(_m('Hi, %1$s. We\'re sorry to inform you that your ' . 'link to Twitter has been disabled. We no longer seem to have ' . 'permission to update your Twitter status. (Did you revoke ' . '%3$s\'s access?)' . "\n\n" . diff --git a/plugins/TwitterBridge/twitterauthorization.php b/plugins/TwitterBridge/twitterauthorization.php index f1daefab12..4af2f03941 100644 --- a/plugins/TwitterBridge/twitterauthorization.php +++ b/plugins/TwitterBridge/twitterauthorization.php @@ -78,7 +78,7 @@ class TwitterauthorizationAction extends Action parent::handle($args); if (!common_logged_in()) { - $this->clientError(_('Not logged in.'), 403); + $this->clientError(_m('Not logged in.'), 403); } $user = common_current_user(); @@ -128,7 +128,7 @@ class TwitterauthorizationAction extends Action } catch (OAuthClientException $e) { $msg = sprintf('OAuth client cURL error - code: %1s, msg: %2s', $e->getCode(), $e->getMessage()); - $this->serverError(_('Couldn\'t link your Twitter account.')); + $this->serverError(_m('Couldn\'t link your Twitter account.')); } common_redirect($auth_link); @@ -147,7 +147,7 @@ class TwitterauthorizationAction extends Action // token we sent them if ($_SESSION['twitter_request_token'] != $this->oauth_token) { - $this->serverError(_('Couldn\'t link your Twitter account.')); + $this->serverError(_m('Couldn\'t link your Twitter account.')); } try { @@ -167,7 +167,7 @@ class TwitterauthorizationAction extends Action } catch (OAuthClientException $e) { $msg = sprintf('OAuth client cURL error - code: %1$s, msg: %2$s', $e->getCode(), $e->getMessage()); - $this->serverError(_('Couldn\'t link your Twitter account.')); + $this->serverError(_m('Couldn\'t link your Twitter account.')); } // Save the access token and Twitter user info @@ -214,7 +214,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.')); } save_twitter_user($twitter_user->id, $twitter_user->screen_name); diff --git a/plugins/TwitterBridge/twittersettings.php b/plugins/TwitterBridge/twittersettings.php index ca22c95535..bc9a636a15 100644 --- a/plugins/TwitterBridge/twittersettings.php +++ b/plugins/TwitterBridge/twittersettings.php @@ -56,7 +56,7 @@ class TwittersettingsAction extends ConnectSettingsAction function title() { - return _('Twitter settings'); + return _m('Twitter settings'); } /** @@ -67,8 +67,8 @@ class TwittersettingsAction extends ConnectSettingsAction function getInstructions() { - return _('Connect your Twitter account to share your updates ' . - 'with your Twitter friends and vice-versa.'); + return _m('Connect your Twitter account to share your updates ' . + 'with your Twitter friends and vice-versa.'); } /** @@ -115,38 +115,38 @@ class TwittersettingsAction extends ConnectSettingsAction $this->elementEnd('fieldset'); } else { - $this->element('legend', null, _('Twitter account')); + $this->element('legend', null, _m('Twitter account')); $this->elementStart('p', array('id' => 'form_confirmed')); $this->element('a', array('href' => $fuser->uri), $fuser->nickname); $this->elementEnd('p'); $this->element('p', 'form_note', - _('Connected Twitter account')); + _m('Connected Twitter account')); - $this->submit('remove', _('Remove')); + $this->submit('remove', _m('Remove')); $this->elementEnd('fieldset'); $this->elementStart('fieldset', array('id' => 'settings_twitter_preferences')); - $this->element('legend', null, _('Preferences')); + $this->element('legend', null, _m('Preferences')); $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->checkbox('noticesend', - _('Automatically send my notices to Twitter.'), + _m('Automatically send my notices to Twitter.'), ($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND) : true); $this->elementEnd('li'); $this->elementStart('li'); $this->checkbox('replysync', - _('Send local "@" replies to Twitter.'), + _m('Send local "@" replies to Twitter.'), ($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) : true); $this->elementEnd('li'); $this->elementStart('li'); $this->checkbox('friendsync', - _('Subscribe to my Twitter friends here.'), + _m('Subscribe to my Twitter friends here.'), ($flink) ? ($flink->friendsync & FOREIGN_FRIEND_RECV) : false); @@ -155,7 +155,7 @@ class TwittersettingsAction extends ConnectSettingsAction if (common_config('twitterimport','enabled')) { $this->elementStart('li'); $this->checkbox('noticerecv', - _('Import my Friends Timeline.'), + _m('Import my Friends Timeline.'), ($flink) ? ($flink->noticesync & FOREIGN_NOTICE_RECV) : false); @@ -171,9 +171,9 @@ class TwittersettingsAction extends ConnectSettingsAction $this->elementEnd('ul'); if ($flink) { - $this->submit('save', _('Save')); + $this->submit('save', _m('Save')); } else { - $this->submit('add', _('Add')); + $this->submit('add', _m('Add')); } $this->elementEnd('fieldset'); @@ -198,8 +198,8 @@ class TwittersettingsAction extends ConnectSettingsAction // CSRF protection $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; } @@ -208,7 +208,7 @@ class TwittersettingsAction extends ConnectSettingsAction } else if ($this->arg('remove')) { $this->removeTwitterAccount(); } else { - $this->showForm(_('Unexpected form submission.')); + $this->showForm(_m('Unexpected form submission.')); } } @@ -227,11 +227,11 @@ class TwittersettingsAction extends ConnectSettingsAction if (empty($result)) { common_log_db_error($flink, 'DELETE', __FILE__); - $this->serverError(_('Couldn\'t remove Twitter user.')); + $this->serverError(_m('Couldn\'t remove Twitter user.')); return; } - $this->showForm(_('Twitter account removed.'), true); + $this->showForm(_m('Twitter account removed.'), true); } /** @@ -252,7 +252,7 @@ class TwittersettingsAction extends ConnectSettingsAction if (empty($flink)) { common_log_db_error($flink, 'SELECT', __FILE__); - $this->showForm(_('Couldn\'t save Twitter preferences.')); + $this->showForm(_m('Couldn\'t save Twitter preferences.')); return; } @@ -262,11 +262,11 @@ class TwittersettingsAction extends ConnectSettingsAction if ($result === false) { common_log_db_error($flink, 'UPDATE', __FILE__); - $this->showForm(_('Couldn\'t save Twitter preferences.')); + $this->showForm(_m('Couldn\'t save Twitter preferences.')); return; } - $this->showForm(_('Twitter preferences saved.'), true); + $this->showForm(_m('Twitter preferences saved.'), true); } } diff --git a/scripts/update_po_templates.php b/scripts/update_po_templates.php new file mode 100755 index 0000000000..83bff6d806 --- /dev/null +++ b/scripts/update_po_templates.php @@ -0,0 +1,211 @@ +#!/usr/bin/env php +. + */ + +// Abort if called from a web server +if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) { + print "This script must be run from the command line\n"; + exit(); +} + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); + +function update_core($dir, $domain) +{ + $old = getcwd(); + chdir($dir); + passthru(<<isDir() && !$item->isDot()) { + $name = $item->getBasename(); + if (file_exists("$dir/plugins/$name/{$name}Plugin.php")) { + $plugins[] = $name; + } + } + } + return $plugins; +} + +function get_plugin_sources($dir) +{ + $files = array(); + + $dirs = new RecursiveDirectoryIterator($dir); + $iter = new RecursiveIteratorIterator($dirs); + foreach ($iter as $pathname => $item) { + if ($item->isFile() && preg_match('/\.php$/', $item->getBaseName())) { + $files[] = $pathname; + } + } + return $files; +} + +function plugin_using_gettext($dir) +{ + $files = get_plugin_sources($dir); + foreach ($files as $pathname) { + // Check if the file is using our _m gettext wrapper + $code = file_get_contents($pathname); + if (preg_match('/\b_m\(/', $code)) { + return true; + } + } + + return false; +} + +function update_plugin($basedir, $name) +{ + $dir = "$basedir/plugins/$name"; + if (plugin_using_gettext($dir)) { + do_update_plugin($dir, $name); + do_translatewiki_plugin($basedir, $name); + return true; + } else { + return false; + } +} + +$args = $_SERVER['argv']; +array_shift($args); + +$all = false; +$core = false; +$allplugins = false; +$plugins = array(); +if (count($args) == 0) { + $all = true; +} +foreach ($args as $arg) { + if ($arg == '--all') { + $all = true; + } elseif ($arg == "--core") { + $core = true; + } elseif ($arg == "--plugins") { + $allplugins = true; + } elseif (substr($arg, 0, 9) == "--plugin=") { + $plugins[] = substr($arg, 9); + } +} + + + +if ($all || $core) { + echo "core..."; + update_core(INSTALLDIR, 'statusnet'); + echo " ok\n"; +} +if ($all || $allplugins) { + $plugins = get_plugins(INSTALLDIR); +} +if ($plugins) { + foreach ($plugins as $plugin) { + echo "$plugin..."; + if (update_plugin(INSTALLDIR, $plugin)) { + echo " ok\n"; + } else { + echo " not localized\n"; + } + } +} + diff --git a/scripts/update_pot.sh b/scripts/update_pot.sh deleted file mode 100755 index de53fe7c90..0000000000 --- a/scripts/update_pot.sh +++ /dev/null @@ -1,13 +0,0 @@ -cd `dirname $0` -cd .. -xgettext \ - --from-code=UTF-8 \ - --default-domain=statusnet \ - --output=locale/statusnet.po \ - --language=PHP \ - --keyword="pgettext:1c,2" \ - --keyword="npgettext:1c,2,3" \ - actions/*.php \ - classes/*.php \ - lib/*.php \ - scripts/*.php From dfba47bdf4d3a8eda1778007e274c57de4c3451c Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 8 Dec 2009 15:32:50 -0500 Subject: [PATCH 03/45] include DB_DataObject 1.9.0 --- extlib/DB/DataObject.php | 258 ++++++++++++++++++++++------- extlib/DB/DataObject/Generator.php | 21 +-- 2 files changed, 207 insertions(+), 72 deletions(-) diff --git a/extlib/DB/DataObject.php b/extlib/DB/DataObject.php index 60ff1441b5..a69fbae86b 100644 --- a/extlib/DB/DataObject.php +++ b/extlib/DB/DataObject.php @@ -15,7 +15,7 @@ * @author Alan Knowles * @copyright 1997-2006 The PHP Group * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id: DataObject.php 284150 2009-07-15 23:27:59Z alan_k $ + * @version CVS: $Id: DataObject.php 291349 2009-11-27 09:15:18Z alan_k $ * @link http://pear.php.net/package/DB_DataObject */ @@ -235,7 +235,7 @@ class DB_DataObject extends DB_DataObject_Overload * @access private * @var string */ - var $_DB_DataObject_version = "1.8.12"; + var $_DB_DataObject_version = "1.9.0"; /** * The Database table (used by table extends) @@ -309,7 +309,8 @@ class DB_DataObject extends DB_DataObject_Overload /** * An autoloading, caching static get method using key, value (based on get) - * + * (depreciated - use ::get / and your own caching method) + * * Usage: * $object = DB_DataObject::staticGet("DbTable_mytable",12); * or @@ -942,9 +943,13 @@ class DB_DataObject extends DB_DataObject_Overload } $this->$key = $keyvalue; } - - - + + // if we haven't set disable_null_strings to "full" + $ignore_null = !isset($options['disable_null_strings']) + || !is_string($options['disable_null_strings']) + || strtolower($options['disable_null_strings']) !== 'full' ; + + foreach($items as $k => $v) { // if we are using autoincrement - skip the column... @@ -953,7 +958,10 @@ class DB_DataObject extends DB_DataObject_Overload } - if (!isset($this->$k)) { + + + // Ignore variables which aren't set to a value + if ( !isset($this->$k) && $ignore_null) { continue; } // dont insert data into mysql timestamps @@ -980,8 +988,7 @@ class DB_DataObject extends DB_DataObject_Overload } - - if (!isset($options['disable_null_strings']) && is_string($this->$k) && (strtolower($this->$k) === 'null') && !($v & DB_DATAOBJECT_NOTNULL)) { + if (!($v & DB_DATAOBJECT_NOTNULL) && DB_DataObject::_is_null($this,$k)) { $rightq .= " NULL "; continue; } @@ -1194,8 +1201,14 @@ class DB_DataObject extends DB_DataObject_Overload $options = $_DB_DATAOBJECT['CONFIG']; + $ignore_null = !isset($options['disable_null_strings']) + || !is_string($options['disable_null_strings']) + || strtolower($options['disable_null_strings']) !== 'full' ; + + foreach($items as $k => $v) { - if (!isset($this->$k)) { + + if (!isset($this->$k) && $ignore_null) { continue; } // ignore stuff thats @@ -1234,7 +1247,7 @@ class DB_DataObject extends DB_DataObject_Overload } // special values ... at least null is handled... - if (!isset($options['disable_null_strings']) && (strtolower($this->$k) === 'null') && !($v & DB_DATAOBJECT_NOTNULL)) { + if (!($v & DB_DATAOBJECT_NOTNULL) && DB_DataObject::_is_null($this,$k)) { $settings .= "$kSql = NULL "; continue; } @@ -1796,10 +1809,15 @@ class DB_DataObject extends DB_DataObject_Overload } - + $_DB_DATAOBJECT['INI'][$this->_database] = array(); foreach ($schemas as $ini) { if (file_exists($ini) && is_file($ini)) { - $_DB_DATAOBJECT['INI'][$this->_database] = parse_ini_file($ini, true); + + $_DB_DATAOBJECT['INI'][$this->_database] = array_merge( + $_DB_DATAOBJECT['INI'][$this->_database], + parse_ini_file($ini, true) + ); + if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) { if (!is_readable ($ini)) { $this->debug("ini file is not readable: $ini","databaseStructure",1); @@ -2478,7 +2496,8 @@ class DB_DataObject extends DB_DataObject_Overload $x = new DB_DataObject; $this->_query= $x->_query; } - + + foreach($keys as $k => $v) { // index keys is an indexed array /* these filter checks are a bit suspicious.. @@ -2519,7 +2538,7 @@ class DB_DataObject extends DB_DataObject_Overload continue; } - if (!isset($options['disable_null_strings']) && (strtolower($this->$k) === 'null') && !($v & DB_DATAOBJECT_NOTNULL)) { + if (!($v & DB_DATAOBJECT_NOTNULL) && DB_DataObject::_is_null($this,$k)) { $this->whereAdd(" $kSql IS NULL"); continue; } @@ -2624,15 +2643,31 @@ class DB_DataObject extends DB_DataObject_Overload } // does this need multi db support?? - $p = isset($_DB_DATAOBJECT['CONFIG']['class_prefix']) ? - $_DB_DATAOBJECT['CONFIG']['class_prefix'] : ''; - $class = $p . preg_replace('/[^A-Z0-9]/i','_',ucfirst($table)); - $ce = substr(phpversion(),0,1) > 4 ? class_exists($class,false) : class_exists($class); + $cp = isset($_DB_DATAOBJECT['CONFIG']['class_prefix']) ? + explode(PATH_SEPARATOR, $_DB_DATAOBJECT['CONFIG']['class_prefix']) : ''; - $class = $ce ? $class : DB_DataObject::_autoloadClass($class); + // multiprefix support. + $tbl = preg_replace('/[^A-Z0-9]/i','_',ucfirst($table)); + if (is_array($cp)) { + $class = array(); + foreach($cp as $cpr) { + $ce = substr(phpversion(),0,1) > 4 ? class_exists($cpr . $tbl,false) : class_exists($cpr . $tbl); + if ($ce) { + $class = $cpr . $tbl; + break; + } + $class[] = $cpr . $tbl; + } + } else { + $class = $tbl; + $ce = substr(phpversion(),0,1) > 4 ? class_exists($class,false) : class_exists($class); + } + + + $rclass = $ce ? $class : DB_DataObject::_autoloadClass($class, $table); // proxy = full|light - if (!$class && isset($_DB_DATAOBJECT['CONFIG']['proxy'])) { + if (!$rclass && isset($_DB_DATAOBJECT['CONFIG']['proxy'])) { DB_DataObject::debug("FAILED TO Autoload $database.$table - using proxy.","FACTORY",1); @@ -2653,12 +2688,14 @@ class DB_DataObject extends DB_DataObject_Overload return $x->$proxyMethod( $d->_database, $table); } - if (!$class) { + if (!$rclass) { return DB_DataObject::raiseError( - "factory could not find class $class from $table", + "factory could not find class " . + (is_array($class) ? implode(PATH_SEPARATOR, $class) : $class ). + "from $table", DB_DATAOBJECT_ERROR_INVALIDCONFIG); } - $ret = new $class; + $ret = new $rclass; if (!empty($database)) { DB_DataObject::debug("Setting database to $database","FACTORY",1); $ret->database($database); @@ -2668,11 +2705,12 @@ class DB_DataObject extends DB_DataObject_Overload /** * autoload Class * - * @param string $class Class + * @param string|array $class Class + * @param string $table Table trying to load. * @access private * @return string classname on Success */ - function _autoloadClass($class) + function _autoloadClass($class, $table=false) { global $_DB_DATAOBJECT; @@ -2682,32 +2720,62 @@ class DB_DataObject extends DB_DataObject_Overload $class_prefix = empty($_DB_DATAOBJECT['CONFIG']['class_prefix']) ? '' : $_DB_DATAOBJECT['CONFIG']['class_prefix']; - $table = substr($class,strlen($class_prefix)); + $table = $table ? $table : substr($class,strlen($class_prefix)); // only include the file if it exists - and barf badly if it has parse errors :) if (!empty($_DB_DATAOBJECT['CONFIG']['proxy']) || empty($_DB_DATAOBJECT['CONFIG']['class_location'])) { return false; } + // support for: + // class_location = mydir/ => maps to mydir/Tablename.php + // class_location = mydir/myfile_%s.php => maps to mydir/myfile_Tablename + // with directory sepr + // class_location = mydir/:mydir2/: => tries all of thes locations. + $cl = $_DB_DATAOBJECT['CONFIG']['class_location']; - if (strpos($_DB_DATAOBJECT['CONFIG']['class_location'],'%s') !== false) { - $file = sprintf($_DB_DATAOBJECT['CONFIG']['class_location'], preg_replace('/[^A-Z0-9]/i','_',ucfirst($table))); - } else { - $file = $_DB_DATAOBJECT['CONFIG']['class_location'].'/'.preg_replace('/[^A-Z0-9]/i','_',ucfirst($table)).".php"; + switch (true) { + case (strpos($cl ,'%s') !== false): + $file = sprintf($cl , preg_replace('/[^A-Z0-9]/i','_',ucfirst($table))); + break; + + case (strpos($cl , PATH_SEPARATOR) !== false): + $file = array(); + foreach(explode(PATH_SEPARATOR, $cl ) as $p) { + $file[] = $p .'/'.preg_replace('/[^A-Z0-9]/i','_',ucfirst($table)).".php"; + } + break; + default: + $file = $cl .'/'.preg_replace('/[^A-Z0-9]/i','_',ucfirst($table)).".php"; + break; } - if (!file_exists($file)) { + $cls = is_array($class) ? $class : array($class); + + if (is_array($file) || !file_exists($file)) { $found = false; - foreach(explode(PATH_SEPARATOR, ini_get('include_path')) as $p) { - if (file_exists("$p/$file")) { - $file = "$p/$file"; - $found = true; + + $file = is_array($file) ? $file : array($file); + $search = implode(PATH_SEPARATOR, $file); + foreach($file as $f) { + foreach(explode(PATH_SEPARATOR, '' . PATH_SEPARATOR . ini_get('include_path')) as $p) { + $ff = empty($p) ? $f : "$p/$f"; + + if (file_exists($ff)) { + $file = $ff; + $found = true; + break; + } + } + if ($found) { break; } } if (!$found) { DB_DataObject::raiseError( - "autoload:Could not find class {$class} using class_location value", + "autoload:Could not find class " . implode(',', $cls) . + " using class_location value :" . $search . + " using include_path value :" . ini_get('include_path'), DB_DATAOBJECT_ERROR_INVALIDCONFIG); return false; } @@ -2715,12 +2783,18 @@ class DB_DataObject extends DB_DataObject_Overload include_once $file; - - $ce = substr(phpversion(),0,1) > 4 ? class_exists($class,false) : class_exists($class); - + + $ce = false; + foreach($cls as $c) { + $ce = substr(phpversion(),0,1) > 4 ? class_exists($c,false) : class_exists($c); + if ($ce) { + $class = $c; + break; + } + } if (!$ce) { DB_DataObject::raiseError( - "autoload:Could not autoload {$class}", + "autoload:Could not autoload " . implode(',', $cls) , DB_DATAOBJECT_ERROR_INVALIDCONFIG); return false; } @@ -2786,7 +2860,7 @@ class DB_DataObject extends DB_DataObject_Overload } - + $_DB_DATAOBJECT['LINKS'][$this->_database] = array(); foreach ($schemas as $ini) { $links = @@ -2794,9 +2868,13 @@ class DB_DataObject extends DB_DataObject_Overload $_DB_DATAOBJECT['CONFIG']["links_{$this->_database}"] : str_replace('.ini','.links.ini',$ini); - if (empty($_DB_DATAOBJECT['LINKS'][$this->_database]) && file_exists($links) && is_file($links)) { + if (file_exists($links) && is_file($links)) { /* not sure why $links = ... here - TODO check if that works */ - $_DB_DATAOBJECT['LINKS'][$this->_database] = parse_ini_file($links, true); + $_DB_DATAOBJECT['LINKS'][$this->_database] = array_merge( + $_DB_DATAOBJECT['LINKS'][$this->_database], + parse_ini_file($links, true) + ); + if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) { $this->debug("Loaded links.ini file: $links","links",1); } @@ -2977,14 +3055,12 @@ class DB_DataObject extends DB_DataObject_Overload } if ($link) { if ($obj->get($link, $this->$row)) { - $obj->free(); return $obj; } return false; } if ($obj->get($this->$row)) { - $obj->free(); return $obj; } return false; @@ -3315,14 +3391,23 @@ class DB_DataObject extends DB_DataObject_Overload DB_DATAOBJECT_ERROR_INVALIDCONFIG); return false; } + + $ignore_null = !isset($options['disable_null_strings']) + || !is_string($options['disable_null_strings']) + || strtolower($options['disable_null_strings']) !== 'full' ; + foreach($items as $k => $v) { - if (!isset($obj->$k)) { + if (!isset($obj->$k) && $ignore_null) { continue; } $kSql = ($quoteIdentifiers ? $DB->quoteIdentifier($k) : $k); + if (DB_DataObject::_is_null($obj,$k)) { + $obj->whereAdd("{$joinAs}.{$kSql} IS NULL"); + continue; + } if ($v & DB_DATAOBJECT_STR) { $obj->whereAdd("{$joinAs}.{$kSql} = " . $this->_quote((string) ( @@ -3344,14 +3429,9 @@ class DB_DataObject extends DB_DataObject_Overload if (PEAR::isError($value)) { $this->raiseError($value->getMessage() ,DB_DATAOBJECT_ERROR_INVALIDARG); return false; - } - if (!isset($options['disable_null_strings']) && strtolower($value) === 'null') { - $obj->whereAdd("{$joinAs}.{$kSql} IS NULL"); - continue; - } else { - $obj->whereAdd("{$joinAs}.{$kSql} = $value"); - continue; - } + } + $obj->whereAdd("{$joinAs}.{$kSql} = $value"); + continue; } @@ -3514,7 +3594,7 @@ class DB_DataObject extends DB_DataObject_Overload continue; } - if (!isset($from[sprintf($format,$k)])) { + if (!isset($from[sprintf($format,$k)]) && !DB_DataObject::_is_null($from, sprintf($format,$k))) { continue; } @@ -3643,7 +3723,7 @@ class DB_DataObject extends DB_DataObject_Overload // if not null - and it's not set....... - if (!isset($this->$key) && ($val & DB_DATAOBJECT_NOTNULL)) { + if ($val & DB_DATAOBJECT_NOTNULL && DB_DataObject::_is_null($this, $key)) { // dont check empty sequence key values.. if (($key == $seq[0]) && ($seq[1] == true)) { continue; @@ -3653,7 +3733,7 @@ class DB_DataObject extends DB_DataObject_Overload } - if (!isset($options['disable_null_strings']) && is_string($this->$key) && (strtolower($this->$key) == 'null')) { + if (DB_DataObject::_is_null($this, $key)) { if ($val & DB_DATAOBJECT_NOTNULL) { $this->debug("'null' field used for '$key', but it is defined as NOT NULL", 'VALIDATION', 4); $ret[$key] = false; @@ -3868,13 +3948,14 @@ class DB_DataObject extends DB_DataObject_Overload //echo "FROM VALUE $col, {$cols[$col]}, $value\n"; switch (true) { // set to null and column is can be null... - case (!isset($options['disable_null_strings']) && (strtolower($value) == 'null') && (!($cols[$col] & DB_DATAOBJECT_NOTNULL))): + case ((!($cols[$col] & DB_DATAOBJECT_NOTNULL)) && DB_DataObject::_is_null($value, false)): case (is_object($value) && is_a($value,'DB_DataObject_Cast')): $this->$col = $value; return true; // fail on setting null on a not null field.. - case (!isset($options['disable_null_strings']) && (strtolower($value) == 'null') && ($cols[$col] & DB_DATAOBJECT_NOTNULL)): + case (($cols[$col] & DB_DATAOBJECT_NOTNULL) && DB_DataObject::_is_null($value,false)): + return false; case (($cols[$col] & DB_DATAOBJECT_DATE) && ($cols[$col] & DB_DATAOBJECT_TIME)): @@ -4189,9 +4270,65 @@ class DB_DataObject extends DB_DataObject_Overload if (isset($_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5])) { $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->num_rows = array(); } + + if (is_array($this->_link_loaded)) { + foreach ($this->_link_loaded as $do) { + $do->free(); + } + } + } + /** + * Evaluate whether or not a value is set to null, taking the 'disable_null_strings' option into account. + * If the value is a string set to "null" and the "disable_null_strings" option is not set to + * true, then the value is considered to be null. + * If the value is actually a PHP NULL value, and "disable_null_strings" has been set to + * the value "full", then it will also be considered null. - this can not differenticate between not set + * + * + * @param object|array $obj_or_ar + * @param string|false $prop prperty + * @access private + * @return bool object + */ + function _is_null($obj_or_ar , $prop) + { + global $_DB_DATAOBJECT; + + + $isset = $prop === false ? isset($obj_or_ar) : + (is_array($obj_or_ar) ? isset($obj_or_ar[$prop]) : isset($obj_or_ar->$prop)); + + $value = $isset ? + ($prop === false ? $obj_or_ar : + (is_array($obj_or_ar) ? $obj_or_ar[$prop] : $obj_or_ar->$prop)) + : null; + + + + $options = $_DB_DATAOBJECT['CONFIG']; + + $null_strings = !isset($options['disable_null_strings']) + || $options['disable_null_strings'] === false; + + $crazy_null = isset($options['disable_null_strings']) + && is_string($options['disable_null_strings']) + && strtolower($options['disable_null_strings'] === 'full'); + + if ( $null_strings && $isset && is_string($value) && (strtolower($value) === 'null') ) { + return true; + } + + if ( $crazy_null && !$isset ) { + return true; + } + + return false; + + + } /* ---- LEGACY BC METHODS - NOT DOCUMENTED - See Documentation on New Methods. ---*/ @@ -4214,3 +4351,4 @@ if (!defined('DB_DATAOBJECT_NO_OVERLOAD')) { } } + diff --git a/extlib/DB/DataObject/Generator.php b/extlib/DB/DataObject/Generator.php index ff6e42c7db..17d310f57c 100644 --- a/extlib/DB/DataObject/Generator.php +++ b/extlib/DB/DataObject/Generator.php @@ -15,7 +15,7 @@ * @author Alan Knowles * @copyright 1997-2006 The PHP Group * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id: Generator.php 284150 2009-07-15 23:27:59Z alan_k $ + * @version CVS: $Id: Generator.php 289384 2009-10-09 00:17:26Z alan_k $ * @link http://pear.php.net/package/DB_DataObject */ @@ -33,7 +33,7 @@ /** * * Config _$ptions - * [DB_DataObject_Generator] + * [DB_DataObject] * ; optional default = DB/DataObject.php * extends_location = * ; optional default = DB_DataObject @@ -775,11 +775,9 @@ class DB_DataObject_Generator extends DB_DataObject //echo "Generating Class files: \n"; $options = &PEAR::getStaticProperty('DB_DataObject','options'); - - if ($extends = @$options['extends']) { - $this->_extends = $extends; - $this->_extendsFile = $options['extends_location']; - } + $this->_extends = empty($options['extends']) ? $this->_extends : $options['extends']; + $this->_extendsFile = empty($options['extends_location']) ? $this->_extendsFile : $options['extends_location']; + foreach($this->tables as $this->table) { $this->table = trim($this->table); @@ -814,7 +812,7 @@ class DB_DataObject_Generator extends DB_DataObject } /** - * class being extended (can be overridden by [DB_DataObject_Generator] extends=xxxx + * class being extended (can be overridden by [DB_DataObject] extends=xxxx * * @var string * @access private @@ -1142,10 +1140,9 @@ class DB_DataObject_Generator extends DB_DataObject $options = &PEAR::getStaticProperty('DB_DataObject','options'); $class_prefix = empty($options['class_prefix']) ? '' : $options['class_prefix']; - if ($extends = @$options['extends']) { - $this->_extends = $extends; - $this->_extendsFile = $options['extends_location']; - } + $this->_extends = empty($options['extends']) ? $this->_extends : $options['extends']; + $this->_extendsFile = empty($options['extends_location']) ? $this->_extendsFile : $options['extends_location']; + $classname = $this->classname = $this->getClassNameFromTableName($this->table); $out = $this->_generateClassTable(); From 0f1d0ab4d7d50467dd7d4ab0646f04da2735b720 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 8 Dec 2009 15:43:11 -0500 Subject: [PATCH 04/45] add DB_DataObject for forward table --- classes/Forward.php | 45 +++++++++++++++++++++++++++++++++++++++++++ classes/statusnet.ini | 11 ++++++++++- 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100755 classes/Forward.php mode change 100644 => 100755 classes/statusnet.ini diff --git a/classes/Forward.php b/classes/Forward.php new file mode 100755 index 0000000000..61cec34e3d --- /dev/null +++ b/classes/Forward.php @@ -0,0 +1,45 @@ +. + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +/** + * Table Definition for location_namespace + */ + +require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; + +class Forward extends Memcached_DataObject +{ + ###START_AUTOCODE + /* the code below is auto generated do not remove the above tag */ + + public $__table = 'forward'; // table name + public $profile_id; // int(4) primary_key not_null + public $notice_id; // int(4) primary_key not_null + public $created; // datetime not_null default_0000-00-00%2000%3A00%3A00 + + /* Static get */ + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Forward',$k,$v); } + + /* the code above is auto generated do not remove the tag below */ + ###END_AUTOCODE +} diff --git a/classes/statusnet.ini b/classes/statusnet.ini old mode 100644 new mode 100755 index 253f458798..a5126795bd --- a/classes/statusnet.ini +++ b/classes/statusnet.ini @@ -1,3 +1,4 @@ + [avatar] profile_id = 129 original = 17 @@ -195,6 +196,15 @@ id = K service = K uri = U +[forward] +profile_id = 129 +notice_id = 129 +created = 142 + +[forward__keys] +profile_id = K +notice_id = K + [group_alias] alias = 130 group_id = 129 @@ -260,7 +270,6 @@ modified = 384 [login_token__keys] user_id = K -token = K [message] id = 129 From 6bc6af667ec51e41570e580de43eac1f9e155d30 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 8 Dec 2009 15:43:34 -0500 Subject: [PATCH 05/45] fix exe flag --- classes/Forward.php | 0 classes/statusnet.ini | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 classes/Forward.php mode change 100755 => 100644 classes/statusnet.ini diff --git a/classes/Forward.php b/classes/Forward.php old mode 100755 new mode 100644 diff --git a/classes/statusnet.ini b/classes/statusnet.ini old mode 100755 new mode 100644 From 72c82a2e293549c10b60ca9e295f2f430224e814 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 8 Dec 2009 16:30:33 -0500 Subject: [PATCH 06/45] Basic function to store forwards and redistribute --- classes/Forward.php | 64 ++++++++++++++++++++++++++++++++++++++++ classes/Notice.php | 34 +-------------------- classes/Notice_inbox.php | 42 +++++++++++++++++++++++++- 3 files changed, 106 insertions(+), 34 deletions(-) diff --git a/classes/Forward.php b/classes/Forward.php index 61cec34e3d..6d4848438c 100644 --- a/classes/Forward.php +++ b/classes/Forward.php @@ -42,4 +42,68 @@ class Forward extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + + static function saveNew($profile_id, $notice_id) + { + $forward = new Forward(); + + $forward->profile_id = $profile_id; + $forward->notice_id = $notice_id; + $forward->created = common_sql_now(); + + $forward->query('BEGIN'); + + if (!$forward->insert()) { + throw new ServerException(_("Couldn't insert forward.")); + } + + $ni = $forward->addToInboxes(); + + $forward->query('COMMIT'); + + $forward->blowCache($ni); + } + + function addToInboxes() + { + $inbox = new Notice_inbox(); + + $user = new User(); + + $user->query('SELECT id FROM user JOIN subscription ON user.id = subscription.subscriber '. + 'WHERE subscription.subscribed = '.$this->profile_id); + + $ni = array(); + + while ($user->fetch()) { + $inbox = Notice_inbox::pkeyGet(array('user_id' => $user->id, + 'notice_id' => $this->notice_id)); + + if (empty($inbox)) { + $ni[$user->id] = NOTICE_INBOX_SOURCE_FORWARD; + } else { + $inbox->free(); + } + } + + $user->free(); + + Notice_inbox::bulkInsert($this->notice_id, $this->created, $ni); + + return $ni; + } + + function blowCache($ni) + { + $cache = common_memcache(); + + if (!empty($cache)) { + foreach ($ni as $id => $source) { + $cache->delete(common_cache_key('notice_inbox:by_user:'.$id)); + $cache->delete(common_cache_key('notice_inbox:by_user_own:'.$id)); + $cache->delete(common_cache_key('notice_inbox:by_user:'.$id.';last')); + $cache->delete(common_cache_key('notice_inbox:by_user_own:'.$id.';last')); + } + } + } } diff --git a/classes/Notice.php b/classes/Notice.php index 6610721564..bcd7947bd1 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -948,39 +948,7 @@ class Notice extends Memcached_DataObject } } - $cnt = 0; - - $qryhdr = 'INSERT INTO notice_inbox (user_id, notice_id, source, created) VALUES '; - $qry = $qryhdr; - - foreach ($ni as $id => $source) { - if ($cnt > 0) { - $qry .= ', '; - } - $qry .= '('.$id.', '.$this->id.', '.$source.", '".$this->created. "') "; - $cnt++; - if (rand() % NOTICE_INBOX_SOFT_LIMIT == 0) { - // FIXME: Causes lag in replicated servers - // Notice_inbox::gc($id); - } - if ($cnt >= MAX_BOXCARS) { - $inbox = new Notice_inbox(); - $result = $inbox->query($qry); - if (PEAR::isError($result)) { - common_log_db_error($inbox, $qry); - } - $qry = $qryhdr; - $cnt = 0; - } - } - - if ($cnt > 0) { - $inbox = new Notice_inbox(); - $result = $inbox->query($qry); - if (PEAR::isError($result)) { - common_log_db_error($inbox, $qry); - } - } + Notice_inbox::bulkInsert($this->id, $this->created, $ni); return; } diff --git a/classes/Notice_inbox.php b/classes/Notice_inbox.php index d3e7853b1b..b39006542c 100644 --- a/classes/Notice_inbox.php +++ b/classes/Notice_inbox.php @@ -32,6 +32,7 @@ define('NOTICE_INBOX_SOFT_LIMIT', 1000); define('NOTICE_INBOX_SOURCE_SUB', 1); define('NOTICE_INBOX_SOURCE_GROUP', 2); define('NOTICE_INBOX_SOURCE_REPLY', 3); +define('NOTICE_INBOX_SOURCE_FORWARD', 4); define('NOTICE_INBOX_SOURCE_GATEWAY', -1); class Notice_inbox extends Memcached_DataObject @@ -83,7 +84,7 @@ class Notice_inbox extends Memcached_DataObject $inbox->whereAdd('created > \'' . date('Y-m-d H:i:s', $since) . '\''); } - $inbox->orderBy('notice_id DESC'); + $inbox->orderBy('created DESC'); if (!is_null($offset)) { $inbox->limit($offset, $limit); @@ -141,4 +142,43 @@ class Notice_inbox extends Memcached_DataObject 'WHERE user_id = ' . $user_id . ' ' . 'AND notice_id in ('.implode(',', $notices).')'); } + + static function bulkInsert($notice_id, $created, $ni) + { + $cnt = 0; + + $qryhdr = 'INSERT INTO notice_inbox (user_id, notice_id, source, created) VALUES '; + $qry = $qryhdr; + + foreach ($ni as $id => $source) { + if ($cnt > 0) { + $qry .= ', '; + } + $qry .= '('.$id.', '.$notice_id.', '.$source.", '".$created. "') "; + $cnt++; + if (rand() % NOTICE_INBOX_SOFT_LIMIT == 0) { + // FIXME: Causes lag in replicated servers + // Notice_inbox::gc($id); + } + if ($cnt >= MAX_BOXCARS) { + $inbox = new Notice_inbox(); + $result = $inbox->query($qry); + if (PEAR::isError($result)) { + common_log_db_error($inbox, $qry); + } + $qry = $qryhdr; + $cnt = 0; + } + } + + if ($cnt > 0) { + $inbox = new Notice_inbox(); + $result = $inbox->query($qry); + if (PEAR::isError($result)) { + common_log_db_error($inbox, $qry); + } + } + + return; + } } From c899e4a84ee45b65950980ccb87e52129871d58e Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 8 Dec 2009 17:02:48 -0500 Subject: [PATCH 07/45] show forwards in the inbox --- actions/all.php | 87 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 85 insertions(+), 2 deletions(-) diff --git a/actions/all.php b/actions/all.php index 5a9d97dd76..2c96298faf 100644 --- a/actions/all.php +++ b/actions/all.php @@ -144,7 +144,7 @@ class AllAction extends ProfileAction function showContent() { - $nl = new NoticeList($this->notice, $this); + $nl = new InboxNoticeList($this->notice, $this->user, $this); $cnt = $nl->show(); @@ -167,5 +167,88 @@ class AllAction extends ProfileAction $this->element('h1', null, sprintf(_('%s and friends'), $this->user->nickname)); } } - +} + +class InboxNoticeList extends NoticeList +{ + var $owner = null; + + function __construct($notice, $owner, $out=null) + { + parent::__construct($notice, $out); + $this->owner = $owner; + } + + function newListItem($notice) + { + return new InboxNoticeListItem($notice, $this->owner, $this->out); + } +} + +class InboxNoticeListItem extends NoticeListItem +{ + var $owner = null; + var $ib = null; + + function __construct($notice, $owner, $out=null) + { + parent::__construct($notice, $out); + $this->owner = $owner; + + $this->ib = Notice_inbox::pkeyGet(array('user_id' => $owner->id, + 'notice_id' => $notice->id)); + } + + function showAuthor() + { + parent::showAuthor(); + if ($this->ib->source == NOTICE_INBOX_SOURCE_FORWARD) { + $this->out->element('span', 'forward', _('Fwd')); + } + } + + function showEnd() + { + if ($this->ib->source == NOTICE_INBOX_SOURCE_FORWARD) { + + $forward = new Forward(); + + // FIXME: scary join! + + $forward->query('SELECT profile_id '. + 'FROM forward JOIN subscription ON forward.profile_id = subscription.subscribed '. + 'WHERE subscription.subscriber = ' . $this->owner->id . ' '. + 'AND forward.notice_id = ' . $this->notice->id . ' '. + 'ORDER BY forward.created '); + + $n = 0; + + $firstForwarder = null; + + while ($forward->fetch()) { + if (empty($firstForwarder)) { + $firstForwarder = Profile::staticGet('id', $forward->profile_id); + } + $n++; + } + + $forward->free(); + unset($forward); + + $this->out->elementStart('span', 'forwards'); + + $link = XMLStringer::estring('a', array('href' => $firstForwarder->profileurl), + $firstForwarder->nickname); + + if ($n == 1) { + $this->out->raw(sprintf(_('Forwarded by %s'), $link)); + } else { + // XXX: use that cool ngettext thing + $this->out->raw(sprintf(_('Forwarded by %s and %d other(s)'), $link, $n - 1)); + } + + $this->out->elementEnd('span'); + } + parent::showEnd(); + } } From 7dd0f2fa9c8e9332c5ff481c93b53169c2510ff7 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 8 Dec 2009 17:20:04 -0500 Subject: [PATCH 08/45] pkeyGet() method for Forward and return value from saveNew() --- classes/Forward.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/classes/Forward.php b/classes/Forward.php index 6d4848438c..52ec538715 100644 --- a/classes/Forward.php +++ b/classes/Forward.php @@ -43,6 +43,11 @@ class Forward extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + function &pkeyGet($kv) + { + return Memcached_DataObject::pkeyGet('Forward', $kv); + } + static function saveNew($profile_id, $notice_id) { $forward = new Forward(); @@ -62,6 +67,8 @@ class Forward extends Memcached_DataObject $forward->query('COMMIT'); $forward->blowCache($ni); + + return $forward; } function addToInboxes() From c49ece9fb40c68e6d6a47343208dc3da5726cf44 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 8 Dec 2009 17:20:17 -0500 Subject: [PATCH 09/45] method to check if a profile has forwarded a notice --- classes/Profile.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/classes/Profile.php b/classes/Profile.php index 4b2e090064..4c14f62a06 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -716,4 +716,12 @@ class Profile extends Memcached_DataObject } return $result; } + + function hasForwarded($notice_id) + { + $forward = Forward::pkeyGet(array('profile_id' => $this->id, + 'notice_id' => $notice_id)); + + return (!empty($forward)); + } } From 48a93810abe5fd5098ef4f91e2b9d5991e217748 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 8 Dec 2009 17:20:45 -0500 Subject: [PATCH 10/45] action to forward a notice --- actions/forward.php | 117 ++++++++++++++++++++++++++++++++++++++++++++ lib/router.php | 2 +- 2 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 actions/forward.php diff --git a/actions/forward.php b/actions/forward.php new file mode 100644 index 0000000000..87365c2d3c --- /dev/null +++ b/actions/forward.php @@ -0,0 +1,117 @@ + + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://status.net/ + * + * StatusNet - the distributed open-source microblogging tool + * Copyright (C) 2008, 2009, StatusNet, Inc. + * + * 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 . + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +/** + * Forward action + * + * @category Action + * @package StatusNet + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://status.net/ + */ + +class ForwardAction extends Action +{ + var $user = null; + var $notice = null; + + function prepare($args) + { + parent::prepare($args); + + $this->user = common_current_user(); + + if (empty($this->user)) { + $this->clientError(_("Only logged-in users can forward notices.")); + return false; + } + + $id = $this->trimmed('notice'); + + if (empty($id)) { + $this->clientError(_("No notice specified.")); + return false; + } + + $this->notice = Notice::staticGet('id', $id); + + if (empty($this->notice)) { + $this->clientError(_("No notice specified.")); + return false; + } + + $token = $this->trimmed('token'); + + if (empty($token) || $token != common_session_token()) { + $this->clientError(_("There was a problem with your session token. Try again, please.")); + return false; + } + + $profile = $this->user->getProfile(); + + if ($profile->hasForwarded($id)) { + $this->clientError(_("You already forwarded that notice.")); + return false; + } + + return true; + } + + /** + * Class handler. + * + * @param array $args query arguments + * + * @return void + */ + + function handle($args) + { + $forward = Forward::saveNew($this->user->id, $this->notice->id); + + if ($this->boolean('ajax')) { + $this->startHTML('text/xml;charset=utf-8'); + $this->elementStart('head'); + $this->element('title', null, _('Forwarded')); + $this->elementEnd('head'); + $this->elementStart('body'); + $this->element('p', array('id' => 'forward_response'), _('Forwarded!')); + $this->elementEnd('body'); + $this->elementEnd('html'); + } else { + // FIXME! + } + } +} diff --git a/lib/router.php b/lib/router.php index 37525319f7..398135a3e2 100644 --- a/lib/router.php +++ b/lib/router.php @@ -99,7 +99,7 @@ class Router 'groupblock', 'groupunblock', 'sandbox', 'unsandbox', 'silence', 'unsilence', - 'deleteuser'); + 'deleteuser', 'forward'); foreach ($main as $a) { $m->connect('main/'.$a, array('action' => $a)); From 41cbb90faeabc0a6002b41d40d392f45a59a7aba Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 8 Dec 2009 17:31:23 -0500 Subject: [PATCH 11/45] add (ugly) form to forward notices --- actions/forward.php | 2 +- js/util.js | 10 ++- lib/forwardform.php | 147 ++++++++++++++++++++++++++++++++++++++++++++ lib/noticelist.php | 21 +++++++ 4 files changed, 176 insertions(+), 4 deletions(-) create mode 100644 lib/forwardform.php diff --git a/actions/forward.php b/actions/forward.php index 87365c2d3c..867ed97d29 100644 --- a/actions/forward.php +++ b/actions/forward.php @@ -72,7 +72,7 @@ class ForwardAction extends Action return false; } - $token = $this->trimmed('token'); + $token = $this->trimmed('token-'.$id); if (empty($token) || $token != common_session_token()) { $this->clientError(_("There was a problem with your session token. Try again, please.")); diff --git a/js/util.js b/js/util.js index ed6a781f74..67df73507b 100644 --- a/js/util.js +++ b/js/util.js @@ -208,7 +208,7 @@ var SN = { // StatusNet $('#'+form_id+' .form_response').remove(); var result; if ($('#'+SN.C.S.Error, data).length > 0) { - result = document._importNode($('p', data)[0], true); + result = document._importNode($('p', data)[0], true); result = result.textContent || result.innerHTML; form.append('

'+result+'

'); } @@ -306,8 +306,12 @@ var SN = { // StatusNet $('.form_disfavor').each(function() { SN.U.FormXHR($(this)); }); }, + NoticeForward: function() { + $('.form_forward').each(function() { SN.U.FormXHR($(this)); }); + }, + NoticeAttachments: function() { - $('.notice a.attachment').each(function() { + $('.notice a.attachment').each(function() { SN.U.NoticeWithAttachment($(this).closest('.notice')); }); }, @@ -439,7 +443,7 @@ var SN = { // StatusNet Notices: function() { if ($('body.user_in').length > 0) { SN.U.NoticeFavor(); - + SN.U.NoticeForward(); SN.U.NoticeReply(); } diff --git a/lib/forwardform.php b/lib/forwardform.php new file mode 100644 index 0000000000..2052856ae6 --- /dev/null +++ b/lib/forwardform.php @@ -0,0 +1,147 @@ +. + * + * @category Form + * @package StatusNet + * @author Evan Prodromou + * @copyright 2009 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/form.php'; + +/** + * Form for forwarding a notice + * + * @category Form + * @package StatusNet + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +class ForwardForm extends Form +{ + /** + * Notice to forward + */ + + var $notice = null; + + /** + * Constructor + * + * @param HTMLOutputter $out output channel + * @param Notice $notice notice to forward + */ + + function __construct($out=null, $notice=null) + { + parent::__construct($out); + + $this->notice = $notice; + } + + /** + * ID of the form + * + * @return int ID of the form + */ + + function id() + { + return 'forward-' . $this->notice->id; + } + + /** + * Action of the form + * + * @return string URL of the action + */ + + function action() + { + return common_local_url('forward'); + } + + /** + * Include a session token for CSRF protection + * + * @return void + */ + + function sessionToken() + { + $this->out->hidden('token-' . $this->notice->id, + common_session_token()); + } + + /** + * Legend of the Form + * + * @return void + */ + function formLegend() + { + $this->out->element('legend', null, _('Forward this notice')); + } + + /** + * Data elements + * + * @return void + */ + + function formData() + { + $this->out->hidden('notice-n'.$this->notice->id, + $this->notice->id, + 'notice'); + } + + /** + * Action elements + * + * @return void + */ + + function formActions() + { + $this->out->submit('forward-submit-' . $this->notice->id, + _('Forward'), 'submit', null, _('Forward this notice')); + } + + /** + * Class of the form. + * + * @return string the form's class + */ + + function formClass() + { + return 'form_forward'; + } +} diff --git a/lib/noticelist.php b/lib/noticelist.php index 21cec528ff..b38860880d 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -212,6 +212,7 @@ class NoticeListItem extends Widget $this->out->elementStart('div', 'notice-options'); $this->showFaveForm(); $this->showReplyLink(); + $this->showForwardForm(); $this->showDeleteLink(); $this->out->elementEnd('div'); } @@ -530,6 +531,26 @@ class NoticeListItem extends Widget } } + /** + * show the form to forward a notice + * + * @return void + */ + + function showForwardForm() + { + $user = common_current_user(); + if ($user) { + $profile = $user->getProfile(); + if ($profile->hasForwarded($this->notice->id)) { + $this->out->text(_('Forwarded')); + } else { + $ff = new ForwardForm($this->out, $this->notice); + $ff->show(); + } + } + } + /** * if the user is the author, let them delete the notice * From 5344b3fb4bd48e0559e5ff37b961878ae3a31d3b Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 8 Dec 2009 17:32:09 -0500 Subject: [PATCH 12/45] add forward table to updates --- db/08to09.sql | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/db/08to09.sql b/db/08to09.sql index 64640f4ced..a945416ea4 100644 --- a/db/08to09.sql +++ b/db/08to09.sql @@ -82,3 +82,15 @@ create table login_token ( constraint primary key (user_id) ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; + +create table forward ( + + profile_id integer not null comment 'profile who forwarded the notice' references profile (id), + notice_id integer not null comment 'notice they forwarded' references notice (id), + + created datetime not null comment 'date this record was created', + + constraint primary key (profile_id, notice_id) + +) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; + From 9dff9e6cea6c46734de85081856064561a34a501 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 8 Dec 2009 17:42:07 -0500 Subject: [PATCH 13/45] make sure not to forward blocked users --- classes/Forward.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/classes/Forward.php b/classes/Forward.php index 52ec538715..e9b83a58bf 100644 --- a/classes/Forward.php +++ b/classes/Forward.php @@ -77,23 +77,33 @@ class Forward extends Memcached_DataObject $user = new User(); - $user->query('SELECT id FROM user JOIN subscription ON user.id = subscription.subscriber '. + $user->query('SELECT user.* FROM user JOIN subscription ON user.id = subscription.subscriber '. 'WHERE subscription.subscribed = '.$this->profile_id); $ni = array(); + $notice = Notice::staticGet('id', $this->notice_id); + + $author = Profile::staticGet('id', $notice->profile_id); + while ($user->fetch()) { $inbox = Notice_inbox::pkeyGet(array('user_id' => $user->id, 'notice_id' => $this->notice_id)); if (empty($inbox)) { - $ni[$user->id] = NOTICE_INBOX_SOURCE_FORWARD; + if (!$user->hasBlocked($author)) { + $ni[$user->id] = NOTICE_INBOX_SOURCE_FORWARD; + } } else { $inbox->free(); } } $user->free(); + $author->free(); + + unset($user); + unset($author); Notice_inbox::bulkInsert($this->notice_id, $this->created, $ni); From 985d6a0de424b682ebe7f3f90a504ba3e70f2f61 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 8 Dec 2009 17:48:24 -0500 Subject: [PATCH 14/45] make forward form slightly less obnoxious --- theme/base/css/display.css | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 44d1d0300f..f622f35caf 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -112,7 +112,6 @@ border-style:solid; line-height:0; } - .form_settings input.remove { margin-left:11px; } @@ -246,7 +245,6 @@ margin-left:11px; width:auto; } - address { float:left; margin-bottom:18px; @@ -709,7 +707,6 @@ border-radius:4px; margin-bottom:18px; } - .entity_send-a-message button { position:absolute; top:3px; @@ -1005,11 +1002,13 @@ float:left; } .notice-options .notice_delete, .notice-options .notice_reply, +.notice-options .form_forward, .notice-options .form_favor, .notice-options .form_disfavor { float:left; margin-left:20%; } +.notice-options .form_forward, .notice-options .form_favor, .notice-options .form_disfavor { margin-left:0; @@ -1035,10 +1034,12 @@ border-radius:0; -moz-border-radius:0; -webkit-border-radius:0; } +.notice-options .form_forward legend, .notice-options .form_favor legend, .notice-options .form_disfavor legend { display:none; } +.notice-options .form_forward fieldset, .notice-options .form_favor fieldset, .notice-options .form_disfavor fieldset { border:0; From 21757186e9a7ffd2e3330fd4ef61ffeb2dc0229b Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 8 Dec 2009 17:52:20 -0500 Subject: [PATCH 15/45] don't allow forwarding your own notice --- actions/forward.php | 5 +++++ lib/noticelist.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/actions/forward.php b/actions/forward.php index 867ed97d29..194833fe0c 100644 --- a/actions/forward.php +++ b/actions/forward.php @@ -72,6 +72,11 @@ class ForwardAction extends Action return false; } + if ($this->user->id == $this->notice->profile_id) { + $this->clientError(_("You can't forward your own notice.")); + return false; + } + $token = $this->trimmed('token-'.$id); if (empty($token) || $token != common_session_token()) { diff --git a/lib/noticelist.php b/lib/noticelist.php index b38860880d..d6ffc9ca9c 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -540,7 +540,7 @@ class NoticeListItem extends Widget function showForwardForm() { $user = common_current_user(); - if ($user) { + if ($user && $user->id != $this->notice->profile_id) { $profile = $user->getProfile(); if ($profile->hasForwarded($this->notice->id)) { $this->out->text(_('Forwarded')); From b139be6caf39628834ca34f5f7e58c1e08a3ebf3 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 9 Dec 2009 13:09:38 +1300 Subject: [PATCH 16/45] added missing table: location_namespace --- db/08to09_pg.sql | 10 ++++++++++ db/statusnet_pg.sql | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/db/08to09_pg.sql b/db/08to09_pg.sql index 0bd47dea56..ee590b52f9 100644 --- a/db/08to09_pg.sql +++ b/db/08to09_pg.sql @@ -39,6 +39,16 @@ create table profile_role ( ); +create table location_namespace ( + + id integer /*comment 'identity for this namespace'*/, + description text /* comment 'description of the namespace'*/ , + created integer not null /*comment 'date the record was created*/ , + /* modified timestamp comment 'date this record was modified',*/ + primary key (id) + +); + create table login_token ( user_id integer not null /* comment 'user owning this token'*/ references "user" (id), token char(32) not null /* comment 'token useable for logging in'*/, diff --git a/db/statusnet_pg.sql b/db/statusnet_pg.sql index 81b329d1e5..92546c814d 100644 --- a/db/statusnet_pg.sql +++ b/db/statusnet_pg.sql @@ -572,6 +572,16 @@ create table profile_role ( ); +create table location_namespace ( + + id integer /*comment 'identity for this namespace'*/, + description text /* comment 'description of the namespace'*/ , + created integer not null /*comment 'date the record was created*/ , + /* modified timestamp comment 'date this record was modified',*/ + primary key (id) + +); + create table login_token ( user_id integer not null /* comment 'user owning this token'*/ references "user" (id), token char(32) not null /* comment 'token useable for logging in'*/, From 3e9c2d779a3d3e014e8900060c3a2632d9e7f138 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 9 Dec 2009 13:12:29 +1300 Subject: [PATCH 17/45] add missing table "forward" --- db/08to09_pg.sql | 8 ++++++++ db/statusnet_pg.sql | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/db/08to09_pg.sql b/db/08to09_pg.sql index ee590b52f9..4f8281bc3e 100644 --- a/db/08to09_pg.sql +++ b/db/08to09_pg.sql @@ -79,3 +79,11 @@ ALTER TABLE profile ADD COLUMN lat decimal(10,7) /*comment 'latitude'*/ ; ALTER TABLE profile ADD COLUMN lon decimal(10,7) /*comment 'longitude'*/; ALTER TABLE profile ADD COLUMN location_id integer /* comment 'location id if possible'*/; ALTER TABLE profile ADD COLUMN location_ns integer /* comment 'namespace for location'*/; + +CREATE TABLE forward ( + profile_id integer not null /*comment 'profile who forwarded the notice'*/ references profile (id), + notice_id integer not null /*comment 'notice they forwarded'*/ references notice (id), + created timestamp not null /*comment 'date this record was created'*/ DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (profile_id, notice_id) +); + diff --git a/db/statusnet_pg.sql b/db/statusnet_pg.sql index 92546c814d..6bcc278859 100644 --- a/db/statusnet_pg.sql +++ b/db/statusnet_pg.sql @@ -582,6 +582,8 @@ create table location_namespace ( ); + + create table login_token ( user_id integer not null /* comment 'user owning this token'*/ references "user" (id), token char(32) not null /* comment 'token useable for logging in'*/, @@ -591,3 +593,9 @@ create table login_token ( primary key (user_id) ); +CREATE TABLE forward ( + profile_id integer not null /*comment 'profile who forwarded the notice'*/ references profile (id), + notice_id integer not null /*comment 'notice they forwarded'*/ references notice (id), + created timestamp not null /*comment 'date this record was created'*/ DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (profile_id, notice_id) +); From 789378838b9a3ad6bff906d70c8316527aed9e98 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 9 Dec 2009 13:26:59 +1300 Subject: [PATCH 18/45] that pesky table named user - now quoted --- classes/Forward.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/classes/Forward.php b/classes/Forward.php index e9b83a58bf..09b2d6a4ee 100644 --- a/classes/Forward.php +++ b/classes/Forward.php @@ -77,7 +77,8 @@ class Forward extends Memcached_DataObject $user = new User(); - $user->query('SELECT user.* FROM user JOIN subscription ON user.id = subscription.subscriber '. + $usertable = common_database_tablename('user'); + $user->query("SELECT $usertable.* FROM $usertable INNER JOIN subscription ON $usertable.id = subscription.subscriber ". 'WHERE subscription.subscribed = '.$this->profile_id); $ni = array(); From 2f59f0ddb5cc6030671af7e751e0ae85e4751497 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 8 Dec 2009 17:35:27 -0800 Subject: [PATCH 19/45] Compat fix for PHP 5.2.4 -- drop unneeded new param to debug_backtrace(), caused error spew on older PHP (introduced PHP 5.2.5) Fix for regression in 4b5e977a7b1c390555d880d3dc7f8b8c6744646c --- lib/language.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/language.php b/lib/language.php index ab46f1a656..916cee7ed4 100644 --- a/lib/language.php +++ b/lib/language.php @@ -153,7 +153,7 @@ if (!function_exists('npgettext')) { */ function _m($msg/*, ...*/) { - $domain = _mdomain(debug_backtrace(false)); + $domain = _mdomain(debug_backtrace()); $args = func_get_args(); switch(count($args)) { case 1: return dgettext($domain, $msg); From 45408142e9d7431dd4a664262d4806c655cc5c68 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 8 Dec 2009 21:02:54 -0500 Subject: [PATCH 20/45] reorder notices when not using memcached --- classes/Notice.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/classes/Notice.php b/classes/Notice.php index bcd7947bd1..c36c5a9c6b 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -788,10 +788,24 @@ class Notice extends Memcached_DataObject return $notice; } $notice->whereAdd('id in (' . implode(', ', $ids) . ')'); - $notice->orderBy('id DESC'); $notice->find(); - return $notice; + + $temp = array(); + + while ($notice->fetch()) { + $temp[$notice->id] = clone($notice); + } + + $wrapped = array(); + + foreach ($ids as $id) { + if (array_key_exists($id, $temp)) { + $wrapped[] = $temp[$id]; + } + } + + return new ArrayWrapper($wrapped); } } From 559415826a234c9d993535bc30f132af1e247160 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Wed, 9 Dec 2009 11:00:30 +0100 Subject: [PATCH 21/45] Added a todo list for Realtime plugin --- plugins/Realtime/README | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 plugins/Realtime/README diff --git a/plugins/Realtime/README b/plugins/Realtime/README new file mode 100644 index 0000000000..f5e4f91cf3 --- /dev/null +++ b/plugins/Realtime/README @@ -0,0 +1,9 @@ +== TODO == +* i18n +* Change in context URL to conversation (try not to construct the URL in JS) +* Update mark behaviour (on notice send) +* Pause, Send a notice ~ should not update counter +* Pause ~ retain up to 50-100 most recent notices +* Add geo data +* Make it work for Conversation page (perhaps a little tricky) +* IE is updating the counter in document title all the time (Not sure if this is still an issue) From 83830c26e746f9bccb149940ce67904d7e536851 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Wed, 9 Dec 2009 11:37:53 +0100 Subject: [PATCH 22/45] Added todo item to Realtime plugin --- plugins/Realtime/README | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/Realtime/README b/plugins/Realtime/README index f5e4f91cf3..524382696b 100644 --- a/plugins/Realtime/README +++ b/plugins/Realtime/README @@ -7,3 +7,5 @@ * Add geo data * Make it work for Conversation page (perhaps a little tricky) * IE is updating the counter in document title all the time (Not sure if this is still an issue) +* Reconsider the timestamp approach + From 4db184e5b4843ec15c7b4e48b3461f9d6fd87822 Mon Sep 17 00:00:00 2001 From: Eric Helgeson Date: Wed, 9 Dec 2009 22:31:07 -0500 Subject: [PATCH 23/45] New Events for avatar settings --- EVENTS.txt | 12 +++++ actions/avatarsettings.php | 108 +++++++++++++++++++------------------ 2 files changed, 69 insertions(+), 51 deletions(-) diff --git a/EVENTS.txt b/EVENTS.txt index e0516f8f45..96250f64c7 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -290,6 +290,18 @@ StartRegistrationTry: before validating and saving a new user EndRegistrationTry: after saving a new user (note: no profile or user object!) - $action: action object being shown +StartAvatarFormData: before displaying avatar form +- $action: action object being shown + +EndAvatarFormData: after displaying avatar form +- $action: action object being shown + +StartAvatarSaveForm: before saving the avatar +- $action: action object being shown + +EndAvatarSaveForm: after saving the avatar +- $action: action object being shown + StartNewQueueManager: before trying to start a new queue manager; good for plugins implementing new queue manager classes - $qm: empty queue manager to set diff --git a/actions/avatarsettings.php b/actions/avatarsettings.php index 879e44842f..cf45255520 100644 --- a/actions/avatarsettings.php +++ b/actions/avatarsettings.php @@ -118,53 +118,56 @@ class AvatarsettingsAction extends AccountSettingsAction $this->elementStart('fieldset'); $this->element('legend', null, _('Avatar settings')); $this->hidden('token', common_session_token()); + + if (Event::handle('StartAvatarFormData', array($this))) { + $this->elementStart('ul', 'form_data'); + if ($original) { + $this->elementStart('li', array('id' => 'avatar_original', + 'class' => 'avatar_view')); + $this->element('h2', null, _("Original")); + $this->elementStart('div', array('id'=>'avatar_original_view')); + $this->element('img', array('src' => $original->url, + 'width' => $original->width, + 'height' => $original->height, + 'alt' => $user->nickname)); + $this->elementEnd('div'); + $this->elementEnd('li'); + } - $this->elementStart('ul', 'form_data'); - if ($original) { - $this->elementStart('li', array('id' => 'avatar_original', - 'class' => 'avatar_view')); - $this->element('h2', null, _("Original")); - $this->elementStart('div', array('id'=>'avatar_original_view')); - $this->element('img', array('src' => $original->url, - 'width' => $original->width, - 'height' => $original->height, - 'alt' => $user->nickname)); - $this->elementEnd('div'); + $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE); + + if ($avatar) { + $this->elementStart('li', array('id' => 'avatar_preview', + 'class' => 'avatar_view')); + $this->element('h2', null, _("Preview")); + $this->elementStart('div', array('id'=>'avatar_preview_view')); + $this->element('img', array('src' => $original->url, + 'width' => AVATAR_PROFILE_SIZE, + 'height' => AVATAR_PROFILE_SIZE, + 'alt' => $user->nickname)); + $this->elementEnd('div'); + $this->submit('delete', _('Delete')); + $this->elementEnd('li'); + } + + $this->elementStart('li', array ('id' => 'settings_attach')); + $this->element('input', array('name' => 'avatarfile', + 'type' => 'file', + 'id' => 'avatarfile')); + $this->element('input', array('name' => 'MAX_FILE_SIZE', + 'type' => 'hidden', + 'id' => 'MAX_FILE_SIZE', + 'value' => ImageFile::maxFileSizeInt())); $this->elementEnd('li'); - } + $this->elementEnd('ul'); - $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE); - - if ($avatar) { - $this->elementStart('li', array('id' => 'avatar_preview', - 'class' => 'avatar_view')); - $this->element('h2', null, _("Preview")); - $this->elementStart('div', array('id'=>'avatar_preview_view')); - $this->element('img', array('src' => $original->url, - 'width' => AVATAR_PROFILE_SIZE, - 'height' => AVATAR_PROFILE_SIZE, - 'alt' => $user->nickname)); - $this->elementEnd('div'); - $this->submit('delete', _('Delete')); + $this->elementStart('ul', 'form_actions'); + $this->elementStart('li'); + $this->submit('upload', _('Upload')); $this->elementEnd('li'); + $this->elementEnd('ul'); } - - $this->elementStart('li', array ('id' => 'settings_attach')); - $this->element('input', array('name' => 'avatarfile', - 'type' => 'file', - 'id' => 'avatarfile')); - $this->element('input', array('name' => 'MAX_FILE_SIZE', - 'type' => 'hidden', - 'id' => 'MAX_FILE_SIZE', - 'value' => ImageFile::maxFileSizeInt())); - $this->elementEnd('li'); - $this->elementEnd('ul'); - - $this->elementStart('ul', 'form_actions'); - $this->elementStart('li'); - $this->submit('upload', _('Upload')); - $this->elementEnd('li'); - $this->elementEnd('ul'); + Event::handle('EndAvatarFormData', array($this)); $this->elementEnd('fieldset'); $this->elementEnd('form'); @@ -266,15 +269,18 @@ class AvatarsettingsAction extends AccountSettingsAction 'Try again, please.')); return; } - - if ($this->arg('upload')) { - $this->uploadAvatar(); - } else if ($this->arg('crop')) { - $this->cropAvatar(); - } else if ($this->arg('delete')) { - $this->deleteAvatar(); - } else { - $this->showForm(_('Unexpected form submission.')); + + if (Event::handle('StartAvatarSaveForm', array($this))) { + if ($this->arg('upload')) { + $this->uploadAvatar(); + } else if ($this->arg('crop')) { + $this->cropAvatar(); + } else if ($this->arg('delete')) { + $this->deleteAvatar(); + } else { + $this->showForm(_('Unexpected form submission.')); + } + Event::handle('EndAvatarSaveForm', array($this)); } } From 155659dd1fee44c011962432a3e2ef6d523f1a7d Mon Sep 17 00:00:00 2001 From: Eric Helgeson Date: Wed, 9 Dec 2009 22:32:57 -0500 Subject: [PATCH 24/45] Initial GravatarPlugin --- plugins/Gravatar/GravatarPlugin.php | 176 ++++++++++++++++++++++++++++ plugins/Gravatar/README | 13 ++ 2 files changed, 189 insertions(+) create mode 100644 plugins/Gravatar/GravatarPlugin.php create mode 100644 plugins/Gravatar/README diff --git a/plugins/Gravatar/GravatarPlugin.php b/plugins/Gravatar/GravatarPlugin.php new file mode 100644 index 0000000000..b18f627266 --- /dev/null +++ b/plugins/Gravatar/GravatarPlugin.php @@ -0,0 +1,176 @@ +. + */ + +/** + * @package GravatarPlugin + * @maintainer Eric Helgeson + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + // This check helps protect against security problems; + // your code file can't be executed directly from the web. + exit(1); +} + +class GravatarPlugin extends Plugin +{ + function onInitializePlugin() { + return true; + } + + function onStartAvatarFormData($action) { + $user = common_current_user(); + $hasGravatar = $this->hasGravatar($user->id); + + if($hasGravatar) { + return false; + } + } + + function onEndAvatarFormData(&$action) { + $user = common_current_user(); + $hasGravatar = $this->hasGravatar($user->id); + + if(!empty($user->email) && !$hasGravatar) { //and not gravatar already set + $action->elementStart('form', array('method' => 'post', + 'id' => 'form_settings_gravatar_add', + 'class' => 'form_settings', + 'action' => + common_local_url('avatarsettings'))); + $action->elementStart('fieldset', array('id' => 'settings_gravatar_add')); + $action->element('legend', null, _m('Set Gravatar')); + $action->hidden('token', common_session_token()); + $action->element('p', 'form_guide', + _m('If you want to use your Gravatar image, click "Add".')); + $action->element('input', array('type' => 'submit', + 'id' => 'settings_gravatar_add_action-submit', + 'name' => 'add', + 'class' => 'submit', + 'value' => _m('Add'))); + $action->elementEnd('fieldset'); + $action->elementEnd('form'); + } elseif($hasGravatar) { + $action->elementStart('form', array('method' => 'post', + 'id' => 'form_settings_gravatar_remove', + 'class' => 'form_settings', + 'action' => + common_local_url('avatarsettings'))); + $action->elementStart('fieldset', array('id' => 'settings_gravatar_remove')); + $action->element('legend', null, _m('Remove Gravatar')); + $action->hidden('token', common_session_token()); + $action->element('p', 'form_guide', + _m('If you want to remove your Gravatar image, click "Remove".')); + $action->element('input', array('type' => 'submit', + 'id' => 'settings_gravatar_remove_action-submit', + 'name' => 'remove', + 'class' => 'submit', + 'value' => _m('Remove'))); + $action->elementEnd('fieldset'); + $action->elementEnd('form'); + } else { + $action->element('p', 'form_guide', + _m('To use a Gravatar first enter in an email address.')); + } + } + + function onStartAvatarSaveForm($action) { + if ($action->arg('add')) { + $result = $this->gravatar_save(); + $action->showForm($result['message'], $result['success']); + return false; + } else if ($action->arg('remove')) { + $result = $this->gravatar_remove(); + $action->showForm($result['message'], $result['success']); + return false; + } else { + return true; + } + } + + function hasGravatar($id) { + $avatar = new Avatar(); + $avatar->profile_id = $id; + if ($avatar->find()) { + while ($avatar->fetch()) { + if($avatar->filename == null) { + return true; + } + } + } + return false; + } + + + function gravatar_save() + { + $cur = common_current_user(); + + if(empty($cur->email)) { + return array('message' => _m('You do not have a email set in your profile.'), + 'success' => false); + } + //Get rid of previous Avatar + $this->gravatar_remove(); + + foreach (array(AVATAR_PROFILE_SIZE, AVATAR_STREAM_SIZE, AVATAR_MINI_SIZE) as $size) { + $gravatar = new Avatar(); + $gravatar->profile_id = $cur->id; + $gravatar->width = $size; + $gravatar->height = $size; + $gravatar->original = false; //No file, so no original + $gravatar->mediatype = 'img';//XXX: Unsure what to put here + //$gravatar->filename = null;//No filename. Remote + $gravatar->url = $this->gravatar_url($cur->email, $size); + $gravatar->created = DB_DataObject_Cast::dateTime(); # current time + + if (!$gravatar->insert()) { + return array('message' => _m('Failed to save Gravatar to the DB.'), + 'success' => false); + } + } + return array('message' => _m('Gravatar added.'), + 'success' => true); + } + + function gravatar_remove() + { + $user = common_current_user(); + $profile = $user->getProfile(); + + $avatar = $profile->getOriginalAvatar(); + if($avatar) $avatar->delete(); + $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE); + if($avatar) $avatar->delete(); + $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE); + if($avatar) $avatar->delete(); + $avatar = $profile->getAvatar(AVATAR_MINI_SIZE); + if($avatar) $avatar->delete(); + + return array('message' => _m('Gravatar removed.'), + 'success' => true); + } + + function gravatar_url($email, $size) { + $url = "http://www.gravatar.com/avatar.php?gravatar_id=". + md5(strtolower($email)). + "&default=".urlencode(Avatar::defaultImage($size)). + "&size=".$size; + return $url; + } +} diff --git a/plugins/Gravatar/README b/plugins/Gravatar/README new file mode 100644 index 0000000000..9337e24a0a --- /dev/null +++ b/plugins/Gravatar/README @@ -0,0 +1,13 @@ +GravatarPlugin 0.1 + +About +This will allow users to use their Gravatar Avatar with your StatusNet install. + +Configuration +add this to your config.php: +addPlugin('Gravatar', array()); + +ToDo: +Site default all on for gravatar by default +Migration Script +Localize \ No newline at end of file From 1e166e1bc4a8b16ad2ef8e99db6a112f47803eda Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Thu, 10 Dec 2009 14:16:07 +0100 Subject: [PATCH 25/45] Updated FormNoticeEnhancements and Counter to use the max text value from HTML. It also allows each .form_notice to have its own counter. --- js/util.js | 38 ++++++++++++++++++++++---------------- lib/messageform.php | 2 -- lib/noticeform.php | 2 -- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/js/util.js b/js/util.js index 67df73507b..60865d3520 100644 --- a/js/util.js +++ b/js/util.js @@ -57,21 +57,28 @@ var SN = { // StatusNet U: { // Utils FormNoticeEnhancements: function(form) { form_id = form.attr('id'); - $('#'+form_id+' #'+SN.C.S.NoticeDataText).unbind('keyup'); - $('#'+form_id+' #'+SN.C.S.NoticeDataText).unbind('keydown'); - if (maxLength > 0) { - $('#'+form_id+' #'+SN.C.S.NoticeDataText).bind('keyup', function(e) { + + if (jQuery.data(form[0], 'ElementData') === undefined) { + MaxLength = $('#'+form_id+' #'+SN.C.S.NoticeTextCount).text(); + if (typeof(MaxLength) == 'undefined') { + MaxLength = SN.C.I.MaxLength; + } + jQuery.data(form[0], 'ElementData', {MaxLength:MaxLength}); + + SN.U.Counter(form); + + NDT = $('#'+form_id+' #'+SN.C.S.NoticeDataText); + + NDT.bind('keyup', function(e) { SN.U.Counter(form); }); - // run once in case there's something in there - SN.U.Counter(form); + + NDT.bind('keydown', function(e) { + SN.U.SubmitOnReturn(e, form); + }); } - $('#'+form_id+' #'+SN.C.S.NoticeDataText).bind('keydown', function(e) { - SN.U.SubmitOnReturn(e, form); - }); - - if($('body')[0].id != 'conversation') { + if ($('body')[0].id != 'conversation') { $('#'+form_id+' textarea').focus(); } }, @@ -91,15 +98,14 @@ var SN = { // StatusNet Counter: function(form) { SN.C.I.FormNoticeCurrent = form; form_id = form.attr('id'); - if (typeof(maxLength) == "undefined") { - maxLength = SN.C.I.MaxLength; - } - if (maxLength <= 0) { + var MaxLength = jQuery.data(form[0], 'ElementData').MaxLength; + + if (MaxLength <= 0) { return; } - var remaining = maxLength - $('#'+form_id+' #'+SN.C.S.NoticeDataText).val().length; + var remaining = MaxLength - $('#'+form_id+' #'+SN.C.S.NoticeDataText).val().length; var counter = $('#'+form_id+' #'+SN.C.S.NoticeTextCount); if (remaining.toString() != counter.text()) { diff --git a/lib/messageform.php b/lib/messageform.php index 4df193c6d1..0c568e1bd8 100644 --- a/lib/messageform.php +++ b/lib/messageform.php @@ -154,8 +154,6 @@ class MessageForm extends Form $contentLimit = Message::maxContent(); - $this->out->inlineScript('maxLength = ' . $contentLimit . ';'); - if ($contentLimit > 0) { $this->out->elementStart('dl', 'form_note'); $this->out->element('dt', null, _('Available characters')); diff --git a/lib/noticeform.php b/lib/noticeform.php index 0dd3f2d777..593a1e9322 100644 --- a/lib/noticeform.php +++ b/lib/noticeform.php @@ -178,8 +178,6 @@ class NoticeForm extends Form $contentLimit = Notice::maxContent(); - $this->out->inlineScript('maxLength = ' . $contentLimit . ';'); - if ($contentLimit > 0) { $this->out->elementStart('dl', 'form_note'); $this->out->element('dt', null, _('Available characters')); From b2a16407ca75a9bbe43fea74ff250bb70ba41140 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Thu, 10 Dec 2009 14:24:23 +0100 Subject: [PATCH 26/45] Updated entity_action form input styles --- theme/base/css/display.css | 3 ++- theme/default/css/display.css | 13 +++++++------ theme/identica/css/display.css | 13 +++++++------ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/theme/base/css/display.css b/theme/base/css/display.css index f622f35caf..e9dca8d02f 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -686,7 +686,8 @@ border-radius:4px; .entity_actions a, .entity_actions input, .entity_actions p { -border:0; +border-width:2px; +border-style:solid; padding-left:23px; } diff --git a/theme/default/css/display.css b/theme/default/css/display.css index d11bbe15e3..2d19b13a8c 100644 --- a/theme/default/css/display.css +++ b/theme/default/css/display.css @@ -87,11 +87,15 @@ input:focus, textarea:focus, select:focus, border-color:#9BB43E; } input.submit, -.entity_remote_subscribe, -.entity_actions .form_notice input.submit { +.entity_remote_subscribe { color:#FFFFFF; } -input.submit { +.entity_actions input.submit { +border-color:transparent; +text-shadow:none; +} +input.submit, +.form_notice input.submit { background:#AAAAAA url(../../base/images/illustrations/illu_pattern-01.png) 0 0 repeat-x; text-shadow:0 1px 0 #FFFFFF; color:#000000; @@ -109,9 +113,6 @@ box-shadow:3px 3px 3px rgba(194, 194, 194, 0.1); -webkit-box-shadow:3px 3px 3px rgba(194, 194, 194, 0.1); text-shadow:none; } -.entity_actions input.submit { -text-shadow:none; -} a, .form_settings input.form_action-primary, diff --git a/theme/identica/css/display.css b/theme/identica/css/display.css index d65ea2ef63..9b90d636aa 100644 --- a/theme/identica/css/display.css +++ b/theme/identica/css/display.css @@ -87,11 +87,15 @@ input:focus, textarea:focus, select:focus, border-color:#9BB43E; } input.submit, -.entity_remote_subscribe, -.entity_actions .form_notice input.submit { +.entity_remote_subscribe { color:#FFFFFF; } -input.submit { +.entity_actions input.submit { +border-color:transparent; +text-shadow:none; +} +input.submit, +.form_notice input.submit { background:#AAAAAA url(../../base/images/illustrations/illu_pattern-01.png) 0 0 repeat-x; text-shadow:0 1px 0 #FFFFFF; color:#000000; @@ -109,9 +113,6 @@ box-shadow:3px 3px 3px rgba(194, 194, 194, 0.1); -webkit-box-shadow:3px 3px 3px rgba(194, 194, 194, 0.1); text-shadow:none; } -.entity_actions input.submit { -text-shadow:none; -} a, .form_settings input.form_action-primary, From c855907f5943260a2b9740948a33f4170f3dda62 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Thu, 10 Dec 2009 14:29:27 +0100 Subject: [PATCH 27/45] Calling NewDirectMessage --- js/util.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/js/util.js b/js/util.js index 60865d3520..66d66c1547 100644 --- a/js/util.js +++ b/js/util.js @@ -463,6 +463,8 @@ var SN = { // StatusNet $('.form_group_join').each(function() { SN.U.FormXHR($(this)); }); $('.form_group_leave').each(function() { SN.U.FormXHR($(this)); }); $('.form_user_nudge').each(function() { SN.U.FormXHR($(this)); }); + + SN.U.NewDirectMessage(); } } } From 61023d42d33f51b6ad24de23adbb1cefe7d8a32d Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Thu, 10 Dec 2009 14:33:31 +0100 Subject: [PATCH 28/45] Updated input background colour for XHR direct message --- theme/default/css/display.css | 3 +-- theme/identica/css/display.css | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/theme/default/css/display.css b/theme/default/css/display.css index 2d19b13a8c..fc97101bb5 100644 --- a/theme/default/css/display.css +++ b/theme/default/css/display.css @@ -57,8 +57,7 @@ background:none; .form_notice.warning #notice_text-count, .form_settings .form_note, -.entity_remote_subscribe, -.entity_actions .form_notice input.submit { +.entity_remote_subscribe { background-color:#9BB43E; } input.submit, diff --git a/theme/identica/css/display.css b/theme/identica/css/display.css index 9b90d636aa..728ca97334 100644 --- a/theme/identica/css/display.css +++ b/theme/identica/css/display.css @@ -57,8 +57,7 @@ background:none; .form_notice.warning #notice_text-count, .form_settings .form_note, -.entity_remote_subscribe, -.entity_actions .form_notice input.submit { +.entity_remote_subscribe { background-color:#9BB43E; } input.submit, From c0aad854f7f17cf817f488e0f2ee57303ff75305 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Thu, 10 Dec 2009 14:52:05 +0100 Subject: [PATCH 29/45] If ElementData is set on the notice form, use the existing MaxLength --- js/util.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/js/util.js b/js/util.js index 66d66c1547..71514324b1 100644 --- a/js/util.js +++ b/js/util.js @@ -77,6 +77,9 @@ var SN = { // StatusNet SN.U.SubmitOnReturn(e, form); }); } + else { + $('#'+form_id+' #'+SN.C.S.NoticeTextCount).text(jQuery.data(form[0], 'ElementData').MaxLength); + } if ($('body')[0].id != 'conversation') { $('#'+form_id+' textarea').focus(); From b07e1143cc8f07bf0613835debe08be227970c73 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Thu, 10 Dec 2009 13:08:24 -0500 Subject: [PATCH 30/45] Override login_token's sequenceKey() so that it behaves correctly --- classes/Login_token.php | 13 +++++++++++++ lib/command.php | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/classes/Login_token.php b/classes/Login_token.php index c172b30abc..746cd7f229 100644 --- a/classes/Login_token.php +++ b/classes/Login_token.php @@ -39,4 +39,17 @@ class Login_token extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + + /* + DB_DataObject calculates the sequence key(s) by taking the first key returned by the keys() function. + In this case, the keys() function returns user_id as the first key. user_id is not a sequence, but + DB_DataObject's sequenceKey() will incorrectly think it is. Then, since the sequenceKey() is a numeric + type, but is not set to autoincrement in the database, DB_DataObject will create a _seq table and + manage the sequence itself. This is not the correct behavior for the user_id in this class. + So we override that incorrect behavior, and simply say there is no sequence key. + */ + function sequenceKey() + { + return array(false,false); + } } diff --git a/lib/command.php b/lib/command.php index e2a6655111..af8855a7f2 100644 --- a/lib/command.php +++ b/lib/command.php @@ -584,7 +584,7 @@ class LoginCommand extends Command function execute($channel) { $disabled = common_config('logincommand','disabled'); - if(isset($disabled)) { + if(isset($disabled) && $disabled) { $channel->error($this->user, _('Login command is disabled')); return; } From b36ec6da87056324ce0cdf98a4745cdc992c5d52 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Thu, 10 Dec 2009 13:22:46 -0500 Subject: [PATCH 31/45] Fixed incorrect disabling of login_token. --- actions/login.php | 3 ++- lib/command.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/actions/login.php b/actions/login.php index a6f86c0ca1..c775fa6924 100644 --- a/actions/login.php +++ b/actions/login.php @@ -77,12 +77,13 @@ class LoginAction extends Action parent::handle($args); $disabled = common_config('logincommand','disabled'); + $disabled = isset($disabled) && $disabled; if (common_is_real_login()) { $this->clientError(_('Already logged in.')); } else if ($_SERVER['REQUEST_METHOD'] == 'POST') { $this->checkLogin(); - } else if (!isset($disabled) && isset($args['user_id']) && isset($args['token'])){ + } else if (!$disabled && isset($args['user_id']) && isset($args['token'])){ $this->checkLogin($args['user_id'],$args['token']); } else { common_ensure_session(); diff --git a/lib/command.php b/lib/command.php index af8855a7f2..450db9da37 100644 --- a/lib/command.php +++ b/lib/command.php @@ -584,7 +584,8 @@ class LoginCommand extends Command function execute($channel) { $disabled = common_config('logincommand','disabled'); - if(isset($disabled) && $disabled) { + $disabled = isset($disabled) && $disabled; + if($disabled) { $channel->error($this->user, _('Login command is disabled')); return; } From 144faade3b3d366fc6f3a254ce6b1c36bd4f4cdb Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 10 Dec 2009 13:31:16 -0500 Subject: [PATCH 32/45] move forwarding stuff to Repeat plugin --- {classes => plugins/Repeat}/Forward.php | 0 {actions => plugins/Repeat}/forward.php | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {classes => plugins/Repeat}/Forward.php (100%) rename {actions => plugins/Repeat}/forward.php (100%) diff --git a/classes/Forward.php b/plugins/Repeat/Forward.php similarity index 100% rename from classes/Forward.php rename to plugins/Repeat/Forward.php diff --git a/actions/forward.php b/plugins/Repeat/forward.php similarity index 100% rename from actions/forward.php rename to plugins/Repeat/forward.php From 198e413a58f8aa3d07ce5da365f6c47ce98ab2c0 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 10 Dec 2009 13:34:11 -0500 Subject: [PATCH 33/45] move inbox notice list to repeat plugin --- actions/all.php | 86 +----------------------------- plugins/Repeat/inboxnoticelist.php | 85 +++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 85 deletions(-) create mode 100644 plugins/Repeat/inboxnoticelist.php diff --git a/actions/all.php b/actions/all.php index 2c96298faf..08fbacaef1 100644 --- a/actions/all.php +++ b/actions/all.php @@ -144,7 +144,7 @@ class AllAction extends ProfileAction function showContent() { - $nl = new InboxNoticeList($this->notice, $this->user, $this); + $nl = new NoticeList($this->notice, $this->user, $this); $cnt = $nl->show(); @@ -168,87 +168,3 @@ class AllAction extends ProfileAction } } } - -class InboxNoticeList extends NoticeList -{ - var $owner = null; - - function __construct($notice, $owner, $out=null) - { - parent::__construct($notice, $out); - $this->owner = $owner; - } - - function newListItem($notice) - { - return new InboxNoticeListItem($notice, $this->owner, $this->out); - } -} - -class InboxNoticeListItem extends NoticeListItem -{ - var $owner = null; - var $ib = null; - - function __construct($notice, $owner, $out=null) - { - parent::__construct($notice, $out); - $this->owner = $owner; - - $this->ib = Notice_inbox::pkeyGet(array('user_id' => $owner->id, - 'notice_id' => $notice->id)); - } - - function showAuthor() - { - parent::showAuthor(); - if ($this->ib->source == NOTICE_INBOX_SOURCE_FORWARD) { - $this->out->element('span', 'forward', _('Fwd')); - } - } - - function showEnd() - { - if ($this->ib->source == NOTICE_INBOX_SOURCE_FORWARD) { - - $forward = new Forward(); - - // FIXME: scary join! - - $forward->query('SELECT profile_id '. - 'FROM forward JOIN subscription ON forward.profile_id = subscription.subscribed '. - 'WHERE subscription.subscriber = ' . $this->owner->id . ' '. - 'AND forward.notice_id = ' . $this->notice->id . ' '. - 'ORDER BY forward.created '); - - $n = 0; - - $firstForwarder = null; - - while ($forward->fetch()) { - if (empty($firstForwarder)) { - $firstForwarder = Profile::staticGet('id', $forward->profile_id); - } - $n++; - } - - $forward->free(); - unset($forward); - - $this->out->elementStart('span', 'forwards'); - - $link = XMLStringer::estring('a', array('href' => $firstForwarder->profileurl), - $firstForwarder->nickname); - - if ($n == 1) { - $this->out->raw(sprintf(_('Forwarded by %s'), $link)); - } else { - // XXX: use that cool ngettext thing - $this->out->raw(sprintf(_('Forwarded by %s and %d other(s)'), $link, $n - 1)); - } - - $this->out->elementEnd('span'); - } - parent::showEnd(); - } -} diff --git a/plugins/Repeat/inboxnoticelist.php b/plugins/Repeat/inboxnoticelist.php new file mode 100644 index 0000000000..809fbe8af9 --- /dev/null +++ b/plugins/Repeat/inboxnoticelist.php @@ -0,0 +1,85 @@ +owner = $owner; + } + + function newListItem($notice) + { + return new InboxNoticeListItem($notice, $this->owner, $this->out); + } +} + +class InboxNoticeListItem extends NoticeListItem +{ + var $owner = null; + var $ib = null; + + function __construct($notice, $owner, $out=null) + { + parent::__construct($notice, $out); + $this->owner = $owner; + + $this->ib = Notice_inbox::pkeyGet(array('user_id' => $owner->id, + 'notice_id' => $notice->id)); + } + + function showAuthor() + { + parent::showAuthor(); + if ($this->ib->source == NOTICE_INBOX_SOURCE_FORWARD) { + $this->out->element('span', 'forward', _('Fwd')); + } + } + + function showEnd() + { + if ($this->ib->source == NOTICE_INBOX_SOURCE_FORWARD) { + + $forward = new Forward(); + + // FIXME: scary join! + + $forward->query('SELECT profile_id '. + 'FROM forward JOIN subscription ON forward.profile_id = subscription.subscribed '. + 'WHERE subscription.subscriber = ' . $this->owner->id . ' '. + 'AND forward.notice_id = ' . $this->notice->id . ' '. + 'ORDER BY forward.created '); + + $n = 0; + + $firstForwarder = null; + + while ($forward->fetch()) { + if (empty($firstForwarder)) { + $firstForwarder = Profile::staticGet('id', $forward->profile_id); + } + $n++; + } + + $forward->free(); + unset($forward); + + $this->out->elementStart('span', 'forwards'); + + $link = XMLStringer::estring('a', array('href' => $firstForwarder->profileurl), + $firstForwarder->nickname); + + if ($n == 1) { + $this->out->raw(sprintf(_('Forwarded by %s'), $link)); + } else { + // XXX: use that cool ngettext thing + $this->out->raw(sprintf(_('Forwarded by %s and %d other(s)'), $link, $n - 1)); + } + + $this->out->elementEnd('span'); + } + parent::showEnd(); + } +} From 37b0852fdb8b82741b327af57d898d4d89c2f177 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 10 Dec 2009 14:33:15 -0500 Subject: [PATCH 34/45] move forward form to plugin --- lib/noticelist.php | 21 --------------------- {lib => plugins/Repeat}/forwardform.php | 0 2 files changed, 21 deletions(-) rename {lib => plugins/Repeat}/forwardform.php (100%) diff --git a/lib/noticelist.php b/lib/noticelist.php index d6ffc9ca9c..21cec528ff 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -212,7 +212,6 @@ class NoticeListItem extends Widget $this->out->elementStart('div', 'notice-options'); $this->showFaveForm(); $this->showReplyLink(); - $this->showForwardForm(); $this->showDeleteLink(); $this->out->elementEnd('div'); } @@ -531,26 +530,6 @@ class NoticeListItem extends Widget } } - /** - * show the form to forward a notice - * - * @return void - */ - - function showForwardForm() - { - $user = common_current_user(); - if ($user && $user->id != $this->notice->profile_id) { - $profile = $user->getProfile(); - if ($profile->hasForwarded($this->notice->id)) { - $this->out->text(_('Forwarded')); - } else { - $ff = new ForwardForm($this->out, $this->notice); - $ff->show(); - } - } - } - /** * if the user is the author, let them delete the notice * diff --git a/lib/forwardform.php b/plugins/Repeat/forwardform.php similarity index 100% rename from lib/forwardform.php rename to plugins/Repeat/forwardform.php From dd098fee776fbb794080b8f95beab16b2f31556b Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 10 Dec 2009 14:34:47 -0500 Subject: [PATCH 35/45] remove forward table from db scripts --- classes/statusnet.ini | 10 ---------- db/08to09.sql | 12 ------------ db/statusnet.sql | 11 ----------- 3 files changed, 33 deletions(-) diff --git a/classes/statusnet.ini b/classes/statusnet.ini index a5126795bd..835faeb0b4 100644 --- a/classes/statusnet.ini +++ b/classes/statusnet.ini @@ -1,4 +1,3 @@ - [avatar] profile_id = 129 original = 17 @@ -196,15 +195,6 @@ id = K service = K uri = U -[forward] -profile_id = 129 -notice_id = 129 -created = 142 - -[forward__keys] -profile_id = K -notice_id = K - [group_alias] alias = 130 group_id = 129 diff --git a/db/08to09.sql b/db/08to09.sql index a945416ea4..64640f4ced 100644 --- a/db/08to09.sql +++ b/db/08to09.sql @@ -82,15 +82,3 @@ create table login_token ( constraint primary key (user_id) ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; - -create table forward ( - - profile_id integer not null comment 'profile who forwarded the notice' references profile (id), - notice_id integer not null comment 'notice they forwarded' references notice (id), - - created datetime not null comment 'date this record was created', - - constraint primary key (profile_id, notice_id) - -) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; - diff --git a/db/statusnet.sql b/db/statusnet.sql index b500b81f2d..18abcdfdb2 100644 --- a/db/statusnet.sql +++ b/db/statusnet.sql @@ -585,14 +585,3 @@ create table login_token ( constraint primary key (user_id) ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; -create table forward ( - - profile_id integer not null comment 'profile who forwarded the notice' references profile (id), - notice_id integer not null comment 'notice they forwarded' references notice (id), - - created datetime not null comment 'date this record was created', - - constraint primary key (profile_id, notice_id) - -) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; - From 79443d1ee2a50234e79c89f2bc41bb49935c66ca Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 10 Dec 2009 14:36:14 -0500 Subject: [PATCH 36/45] had wrong number of arguments to NoticeList in notice inbox --- actions/all.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/all.php b/actions/all.php index 08fbacaef1..452803d8ae 100644 --- a/actions/all.php +++ b/actions/all.php @@ -144,7 +144,7 @@ class AllAction extends ProfileAction function showContent() { - $nl = new NoticeList($this->notice, $this->user, $this); + $nl = new NoticeList($this->notice, $this); $cnt = $nl->show(); From a2fb1f5f9dda42b8bac689d3b5bfa86d7660416d Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 10 Dec 2009 14:37:58 -0500 Subject: [PATCH 37/45] remove form_forward from base css --- theme/base/css/display.css | 4 ---- 1 file changed, 4 deletions(-) diff --git a/theme/base/css/display.css b/theme/base/css/display.css index e9dca8d02f..d3b9d7cdca 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -1003,13 +1003,11 @@ float:left; } .notice-options .notice_delete, .notice-options .notice_reply, -.notice-options .form_forward, .notice-options .form_favor, .notice-options .form_disfavor { float:left; margin-left:20%; } -.notice-options .form_forward, .notice-options .form_favor, .notice-options .form_disfavor { margin-left:0; @@ -1035,12 +1033,10 @@ border-radius:0; -moz-border-radius:0; -webkit-border-radius:0; } -.notice-options .form_forward legend, .notice-options .form_favor legend, .notice-options .form_disfavor legend { display:none; } -.notice-options .form_forward fieldset, .notice-options .form_favor fieldset, .notice-options .form_disfavor fieldset { border:0; From 344c99df02fb34dcca02f36bee7cb66489742105 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 10 Dec 2009 14:40:00 -0500 Subject: [PATCH 38/45] remove forward table from PostgreSQL scripts --- db/08to09_pg.sql | 7 ----- db/statusnet_pg.sql | 62 ++++++++++++++++++--------------------------- 2 files changed, 25 insertions(+), 44 deletions(-) diff --git a/db/08to09_pg.sql b/db/08to09_pg.sql index 4f8281bc3e..1df8c249b5 100644 --- a/db/08to09_pg.sql +++ b/db/08to09_pg.sql @@ -80,10 +80,3 @@ ALTER TABLE profile ADD COLUMN lon decimal(10,7) /*comment 'longitude'*/; ALTER TABLE profile ADD COLUMN location_id integer /* comment 'location id if possible'*/; ALTER TABLE profile ADD COLUMN location_ns integer /* comment 'namespace for location'*/; -CREATE TABLE forward ( - profile_id integer not null /*comment 'profile who forwarded the notice'*/ references profile (id), - notice_id integer not null /*comment 'notice they forwarded'*/ references notice (id), - created timestamp not null /*comment 'date this record was created'*/ DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (profile_id, notice_id) -); - diff --git a/db/statusnet_pg.sql b/db/statusnet_pg.sql index 6bcc278859..c37fa81dee 100644 --- a/db/statusnet_pg.sql +++ b/db/statusnet_pg.sql @@ -64,7 +64,7 @@ create table "user" ( emailnotifyfav integer default 1 /* comment 'Notify by email of favorites' */, emailnotifynudge integer default 1 /* comment 'Notify by email of nudges' */, emailnotifymsg integer default 1 /* comment 'Notify by email of direct messages' */, - emailnotifyattn integer default 1 /* command 'Notify by email of @-replies' */, + emailnotifyattn integer default 1 /* command 'Notify by email of @-replies' */, emailmicroid integer default 1 /* comment 'whether to publish email microid' */, language varchar(50) /* comment 'preferred language' */, timezone varchar(50) /* comment 'timezone' */, @@ -82,7 +82,7 @@ create table "user" ( uri varchar(255) unique /* comment 'universally unique identifier, usually a tag URI' */, autosubscribe integer default 0 /* comment 'automatically subscribe to users who subscribe to us' */, urlshorteningservice varchar(50) default 'ur1.ca' /* comment 'service to use for auto-shortening URLs' */, - inboxed integer default 0 /* comment 'has an inbox been created for this user?' */, + inboxed integer default 0 /* comment 'has an inbox been created for this user?' */, design_id integer /* comment 'id of a design' */references design(id), viewdesigns integer default 1 /* comment 'whether to view user-provided designs'*/, created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */, @@ -298,7 +298,7 @@ create table foreign_user ( nickname varchar(255) /* comment 'nickname on foreign service' */, created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */, modified timestamp /* comment 'date this record was modified' */, - + primary key (id, service) ); @@ -308,7 +308,7 @@ create table foreign_link ( service int not null /* comment 'foreign key to service' */ references foreign_service (id), credentials varchar(255) /* comment 'authc credentials, typically a password' */, noticesync int not null default 1 /* comment 'notice synchronisation, bit 1 = sync outgoing, bit 2 = sync incoming, bit 3 = filter local replies' */, - friendsync int not null default 2 /* comment 'friend synchronisation, bit 1 = sync outgoing, bit 2 = sync incoming */, + friendsync int not null default 2 /* comment 'friend synchronisation, bit 1 = sync outgoing, bit 2 = sync incoming */, profilesync int not null default 1 /* comment 'profile synchronization, bit 1 = sync outgoing, bit 2 = sync incoming' */, last_noticesync timestamp default null /* comment 'last time notices were imported' */, last_friendsync timestamp default null /* comment 'last time friends were imported' */, @@ -324,7 +324,7 @@ create table foreign_subscription ( subscriber int not null /* comment 'subscriber on foreign service' */ , subscribed int not null /* comment 'subscribed user' */ , created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */, - + primary key (service, subscriber, subscribed) ); create index foreign_subscription_subscriber_idx on foreign_subscription using btree(subscriber); @@ -354,7 +354,7 @@ create table message ( created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */, modified timestamp /* comment 'date this record was modified' */, source varchar(32) /* comment 'source of comment, like "web", "im", or "clientname"' */ - + ); create index message_from_idx on message using btree(from_profile); create index message_to_idx on message using btree(to_profile); @@ -409,7 +409,6 @@ create table user_group ( mini_logo varchar(255) /* comment 'mini logo' */, design_id integer /*comment 'id of a design' */ references design(id), - created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */, modified timestamp /* comment 'date this record was modified' */ @@ -447,16 +446,15 @@ create table group_inbox ( ); create index group_inbox_created_idx on group_inbox using btree(created); - /*attachments and URLs stuff */ create sequence file_seq; create table file ( id bigint default nextval('file_seq') primary key /* comment 'unique identifier' */, - url varchar(255) unique, - mimetype varchar(50), - size integer, - title varchar(255), - date integer, + url varchar(255) unique, + mimetype varchar(50), + size integer, + title varchar(255), + date integer, protected integer, filename text /* comment 'if a local file, name of the file' */, modified timestamp default CURRENT_TIMESTAMP /* comment 'date this record was modified'*/ @@ -467,38 +465,38 @@ create table file_oembed ( file_id bigint default nextval('file_oembed_seq') primary key /* comment 'unique identifier' */, version varchar(20), type varchar(20), - mimetype varchar(50), + mimetype varchar(50), provider varchar(50), provider_url varchar(255), width integer, height integer, html text, title varchar(255), - author_name varchar(50), - author_url varchar(255), - url varchar(255) + author_name varchar(50), + author_url varchar(255), + url varchar(255) ); create sequence file_redirection_seq; create table file_redirection ( - url varchar(255) primary key, - file_id bigint, - redirections integer, + url varchar(255) primary key, + file_id bigint, + redirections integer, httpcode integer ); create sequence file_thumbnail_seq; create table file_thumbnail ( - file_id bigint primary key, - url varchar(255) unique, - width integer, - height integer + file_id bigint primary key, + url varchar(255) unique, + width integer, + height integer ); create sequence file_to_post_seq; create table file_to_post ( - file_id bigint, - post_id bigint, + file_id bigint, + post_id bigint, primary key (file_id, post_id) ); @@ -527,7 +525,7 @@ create table session ( id varchar(32) primary key /* comment 'session ID'*/, session_data text /* comment 'session data'*/, created timestamp not null DEFAULT CURRENT_TIMESTAMP /* comment 'date this record was created'*/, - modified integer DEFAULT extract(epoch from CURRENT_TIMESTAMP) /* comment 'date this record was modified'*/ + modified integer DEFAULT extract(epoch from CURRENT_TIMESTAMP) /* comment 'date this record was modified'*/ ); create index session_modified_idx on session (modified); @@ -543,7 +541,6 @@ create table deleted_notice ( CREATE index deleted_notice_profile_id_idx on deleted_notice (profile_id); - /* Textsearch stuff */ create index textsearch_idx on profile using gist(textsearch); @@ -551,7 +548,6 @@ create index noticecontent_idx on notice using gist(to_tsvector('english',conten create trigger textsearchupdate before insert or update on profile for each row execute procedure tsvector_update_trigger(textsearch, 'pg_catalog.english', nickname, fullname, location, bio, homepage); - create table config ( section varchar(32) /* comment 'configuration section'*/, @@ -582,8 +578,6 @@ create table location_namespace ( ); - - create table login_token ( user_id integer not null /* comment 'user owning this token'*/ references "user" (id), token char(32) not null /* comment 'token useable for logging in'*/, @@ -593,9 +587,3 @@ create table login_token ( primary key (user_id) ); -CREATE TABLE forward ( - profile_id integer not null /*comment 'profile who forwarded the notice'*/ references profile (id), - notice_id integer not null /*comment 'notice they forwarded'*/ references notice (id), - created timestamp not null /*comment 'date this record was created'*/ DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (profile_id, notice_id) -); From 14f7c784a6fa11625df128309c0f211ca36101c1 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Thu, 10 Dec 2009 14:40:26 -0500 Subject: [PATCH 39/45] Add table() and keys() overrides to User_username --- plugins/Authentication/User_username.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/plugins/Authentication/User_username.php b/plugins/Authentication/User_username.php index f30f60d839..853fd5cb86 100644 --- a/plugins/Authentication/User_username.php +++ b/plugins/Authentication/User_username.php @@ -43,4 +43,19 @@ class User_username extends Memcached_DataObject return false; } } + + function table() { + return array( + 'user_id' => DB_DATAOBJECT_INT, + 'username' => DB_DATAOBJECT_STR, + 'provider_name' => DB_DATAOBJECT_STR , + 'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + ); + } + + // now define the keys. + function keys() { + return array('provider_name', 'username'); + } + } From 433106dfc512605f93a1354034c23452fbb3956b Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 10 Dec 2009 14:40:48 -0500 Subject: [PATCH 40/45] remove 'has forwarded' method from Profile --- classes/Profile.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/classes/Profile.php b/classes/Profile.php index 4c14f62a06..4b2e090064 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -716,12 +716,4 @@ class Profile extends Memcached_DataObject } return $result; } - - function hasForwarded($notice_id) - { - $forward = Forward::pkeyGet(array('profile_id' => $this->id, - 'notice_id' => $notice_id)); - - return (!empty($forward)); - } } From 038fbddd02d2f144936357ed2ed40c09b1441c6b Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 10 Dec 2009 14:41:18 -0500 Subject: [PATCH 41/45] remove NoticeForward from util.js --- js/util.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/js/util.js b/js/util.js index 71514324b1..336cd8cfe5 100644 --- a/js/util.js +++ b/js/util.js @@ -315,10 +315,6 @@ var SN = { // StatusNet $('.form_disfavor').each(function() { SN.U.FormXHR($(this)); }); }, - NoticeForward: function() { - $('.form_forward').each(function() { SN.U.FormXHR($(this)); }); - }, - NoticeAttachments: function() { $('.notice a.attachment').each(function() { SN.U.NoticeWithAttachment($(this).closest('.notice')); @@ -452,7 +448,6 @@ var SN = { // StatusNet Notices: function() { if ($('body.user_in').length > 0) { SN.U.NoticeFavor(); - SN.U.NoticeForward(); SN.U.NoticeReply(); } From eceb5e8a0fbf798e42fb9c1d0598d9dc0f4b7550 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 10 Dec 2009 14:42:13 -0500 Subject: [PATCH 42/45] remove forward action from router --- lib/router.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/router.php b/lib/router.php index 398135a3e2..37525319f7 100644 --- a/lib/router.php +++ b/lib/router.php @@ -99,7 +99,7 @@ class Router 'groupblock', 'groupunblock', 'sandbox', 'unsandbox', 'silence', 'unsilence', - 'deleteuser', 'forward'); + 'deleteuser'); foreach ($main as $a) { $m->connect('main/'.$a, array('action' => $a)); From c10fa99b04ef544e1ea082a694ad714f9246df86 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 10 Dec 2009 15:16:44 -0500 Subject: [PATCH 43/45] remove the Repeat plugin (for now) --- plugins/Repeat/Forward.php | 127 ------------------------- plugins/Repeat/forward.php | 122 ------------------------ plugins/Repeat/forwardform.php | 147 ----------------------------- plugins/Repeat/inboxnoticelist.php | 85 ----------------- 4 files changed, 481 deletions(-) delete mode 100644 plugins/Repeat/Forward.php delete mode 100644 plugins/Repeat/forward.php delete mode 100644 plugins/Repeat/forwardform.php delete mode 100644 plugins/Repeat/inboxnoticelist.php diff --git a/plugins/Repeat/Forward.php b/plugins/Repeat/Forward.php deleted file mode 100644 index 09b2d6a4ee..0000000000 --- a/plugins/Repeat/Forward.php +++ /dev/null @@ -1,127 +0,0 @@ -. - */ - -if (!defined('STATUSNET')) { - exit(1); -} - -/** - * Table Definition for location_namespace - */ - -require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; - -class Forward extends Memcached_DataObject -{ - ###START_AUTOCODE - /* the code below is auto generated do not remove the above tag */ - - public $__table = 'forward'; // table name - public $profile_id; // int(4) primary_key not_null - public $notice_id; // int(4) primary_key not_null - public $created; // datetime not_null default_0000-00-00%2000%3A00%3A00 - - /* Static get */ - function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Forward',$k,$v); } - - /* the code above is auto generated do not remove the tag below */ - ###END_AUTOCODE - - function &pkeyGet($kv) - { - return Memcached_DataObject::pkeyGet('Forward', $kv); - } - - static function saveNew($profile_id, $notice_id) - { - $forward = new Forward(); - - $forward->profile_id = $profile_id; - $forward->notice_id = $notice_id; - $forward->created = common_sql_now(); - - $forward->query('BEGIN'); - - if (!$forward->insert()) { - throw new ServerException(_("Couldn't insert forward.")); - } - - $ni = $forward->addToInboxes(); - - $forward->query('COMMIT'); - - $forward->blowCache($ni); - - return $forward; - } - - function addToInboxes() - { - $inbox = new Notice_inbox(); - - $user = new User(); - - $usertable = common_database_tablename('user'); - $user->query("SELECT $usertable.* FROM $usertable INNER JOIN subscription ON $usertable.id = subscription.subscriber ". - 'WHERE subscription.subscribed = '.$this->profile_id); - - $ni = array(); - - $notice = Notice::staticGet('id', $this->notice_id); - - $author = Profile::staticGet('id', $notice->profile_id); - - while ($user->fetch()) { - $inbox = Notice_inbox::pkeyGet(array('user_id' => $user->id, - 'notice_id' => $this->notice_id)); - - if (empty($inbox)) { - if (!$user->hasBlocked($author)) { - $ni[$user->id] = NOTICE_INBOX_SOURCE_FORWARD; - } - } else { - $inbox->free(); - } - } - - $user->free(); - $author->free(); - - unset($user); - unset($author); - - Notice_inbox::bulkInsert($this->notice_id, $this->created, $ni); - - return $ni; - } - - function blowCache($ni) - { - $cache = common_memcache(); - - if (!empty($cache)) { - foreach ($ni as $id => $source) { - $cache->delete(common_cache_key('notice_inbox:by_user:'.$id)); - $cache->delete(common_cache_key('notice_inbox:by_user_own:'.$id)); - $cache->delete(common_cache_key('notice_inbox:by_user:'.$id.';last')); - $cache->delete(common_cache_key('notice_inbox:by_user_own:'.$id.';last')); - } - } - } -} diff --git a/plugins/Repeat/forward.php b/plugins/Repeat/forward.php deleted file mode 100644 index 194833fe0c..0000000000 --- a/plugins/Repeat/forward.php +++ /dev/null @@ -1,122 +0,0 @@ - - * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 - * @link http://status.net/ - * - * StatusNet - the distributed open-source microblogging tool - * Copyright (C) 2008, 2009, StatusNet, Inc. - * - * 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 . - */ - -if (!defined('STATUSNET')) { - exit(1); -} - -/** - * Forward action - * - * @category Action - * @package StatusNet - * @author Evan Prodromou - * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 - * @link http://status.net/ - */ - -class ForwardAction extends Action -{ - var $user = null; - var $notice = null; - - function prepare($args) - { - parent::prepare($args); - - $this->user = common_current_user(); - - if (empty($this->user)) { - $this->clientError(_("Only logged-in users can forward notices.")); - return false; - } - - $id = $this->trimmed('notice'); - - if (empty($id)) { - $this->clientError(_("No notice specified.")); - return false; - } - - $this->notice = Notice::staticGet('id', $id); - - if (empty($this->notice)) { - $this->clientError(_("No notice specified.")); - return false; - } - - if ($this->user->id == $this->notice->profile_id) { - $this->clientError(_("You can't forward your own notice.")); - return false; - } - - $token = $this->trimmed('token-'.$id); - - if (empty($token) || $token != common_session_token()) { - $this->clientError(_("There was a problem with your session token. Try again, please.")); - return false; - } - - $profile = $this->user->getProfile(); - - if ($profile->hasForwarded($id)) { - $this->clientError(_("You already forwarded that notice.")); - return false; - } - - return true; - } - - /** - * Class handler. - * - * @param array $args query arguments - * - * @return void - */ - - function handle($args) - { - $forward = Forward::saveNew($this->user->id, $this->notice->id); - - if ($this->boolean('ajax')) { - $this->startHTML('text/xml;charset=utf-8'); - $this->elementStart('head'); - $this->element('title', null, _('Forwarded')); - $this->elementEnd('head'); - $this->elementStart('body'); - $this->element('p', array('id' => 'forward_response'), _('Forwarded!')); - $this->elementEnd('body'); - $this->elementEnd('html'); - } else { - // FIXME! - } - } -} diff --git a/plugins/Repeat/forwardform.php b/plugins/Repeat/forwardform.php deleted file mode 100644 index 2052856ae6..0000000000 --- a/plugins/Repeat/forwardform.php +++ /dev/null @@ -1,147 +0,0 @@ -. - * - * @category Form - * @package StatusNet - * @author Evan Prodromou - * @copyright 2009 StatusNet, Inc. - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://status.net/ - */ - -if (!defined('STATUSNET') && !defined('LACONICA')) { - exit(1); -} - -require_once INSTALLDIR.'/lib/form.php'; - -/** - * Form for forwarding a notice - * - * @category Form - * @package StatusNet - * @author Evan Prodromou - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://status.net/ - */ - -class ForwardForm extends Form -{ - /** - * Notice to forward - */ - - var $notice = null; - - /** - * Constructor - * - * @param HTMLOutputter $out output channel - * @param Notice $notice notice to forward - */ - - function __construct($out=null, $notice=null) - { - parent::__construct($out); - - $this->notice = $notice; - } - - /** - * ID of the form - * - * @return int ID of the form - */ - - function id() - { - return 'forward-' . $this->notice->id; - } - - /** - * Action of the form - * - * @return string URL of the action - */ - - function action() - { - return common_local_url('forward'); - } - - /** - * Include a session token for CSRF protection - * - * @return void - */ - - function sessionToken() - { - $this->out->hidden('token-' . $this->notice->id, - common_session_token()); - } - - /** - * Legend of the Form - * - * @return void - */ - function formLegend() - { - $this->out->element('legend', null, _('Forward this notice')); - } - - /** - * Data elements - * - * @return void - */ - - function formData() - { - $this->out->hidden('notice-n'.$this->notice->id, - $this->notice->id, - 'notice'); - } - - /** - * Action elements - * - * @return void - */ - - function formActions() - { - $this->out->submit('forward-submit-' . $this->notice->id, - _('Forward'), 'submit', null, _('Forward this notice')); - } - - /** - * Class of the form. - * - * @return string the form's class - */ - - function formClass() - { - return 'form_forward'; - } -} diff --git a/plugins/Repeat/inboxnoticelist.php b/plugins/Repeat/inboxnoticelist.php deleted file mode 100644 index 809fbe8af9..0000000000 --- a/plugins/Repeat/inboxnoticelist.php +++ /dev/null @@ -1,85 +0,0 @@ -owner = $owner; - } - - function newListItem($notice) - { - return new InboxNoticeListItem($notice, $this->owner, $this->out); - } -} - -class InboxNoticeListItem extends NoticeListItem -{ - var $owner = null; - var $ib = null; - - function __construct($notice, $owner, $out=null) - { - parent::__construct($notice, $out); - $this->owner = $owner; - - $this->ib = Notice_inbox::pkeyGet(array('user_id' => $owner->id, - 'notice_id' => $notice->id)); - } - - function showAuthor() - { - parent::showAuthor(); - if ($this->ib->source == NOTICE_INBOX_SOURCE_FORWARD) { - $this->out->element('span', 'forward', _('Fwd')); - } - } - - function showEnd() - { - if ($this->ib->source == NOTICE_INBOX_SOURCE_FORWARD) { - - $forward = new Forward(); - - // FIXME: scary join! - - $forward->query('SELECT profile_id '. - 'FROM forward JOIN subscription ON forward.profile_id = subscription.subscribed '. - 'WHERE subscription.subscriber = ' . $this->owner->id . ' '. - 'AND forward.notice_id = ' . $this->notice->id . ' '. - 'ORDER BY forward.created '); - - $n = 0; - - $firstForwarder = null; - - while ($forward->fetch()) { - if (empty($firstForwarder)) { - $firstForwarder = Profile::staticGet('id', $forward->profile_id); - } - $n++; - } - - $forward->free(); - unset($forward); - - $this->out->elementStart('span', 'forwards'); - - $link = XMLStringer::estring('a', array('href' => $firstForwarder->profileurl), - $firstForwarder->nickname); - - if ($n == 1) { - $this->out->raw(sprintf(_('Forwarded by %s'), $link)); - } else { - // XXX: use that cool ngettext thing - $this->out->raw(sprintf(_('Forwarded by %s and %d other(s)'), $link, $n - 1)); - } - - $this->out->elementEnd('span'); - } - parent::showEnd(); - } -} From 08901c98c4129c1d7707acb470e18f1056f2502e Mon Sep 17 00:00:00 2001 From: Eric Helgeson Date: Thu, 10 Dec 2009 21:06:54 -0500 Subject: [PATCH 44/45] Changing avatar should broadcast the profile via OMB. --- plugins/Gravatar/GravatarPlugin.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plugins/Gravatar/GravatarPlugin.php b/plugins/Gravatar/GravatarPlugin.php index b18f627266..3c61a682ed 100644 --- a/plugins/Gravatar/GravatarPlugin.php +++ b/plugins/Gravatar/GravatarPlugin.php @@ -92,11 +92,23 @@ class GravatarPlugin extends Plugin function onStartAvatarSaveForm($action) { if ($action->arg('add')) { $result = $this->gravatar_save(); + + if($result['success']===true) { + common_broadcast_profile(common_current_user()->getProfile()); + } + $action->showForm($result['message'], $result['success']); + return false; } else if ($action->arg('remove')) { $result = $this->gravatar_remove(); + + if($result['success']===true) { + common_broadcast_profile(common_current_user()->getProfile()); + } + $action->showForm($result['message'], $result['success']); + return false; } else { return true; From 85473ecf94e92cd0e6503e4d27ea26452076aafd Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Fri, 11 Dec 2009 13:55:54 +0100 Subject: [PATCH 45/45] Removed styles from entity_remote_subscribe (doesn't need special treatment) in default and identica themes --- theme/base/css/display.css | 11 +---------- theme/default/css/display.css | 13 ++++--------- theme/identica/css/display.css | 13 ++++--------- 3 files changed, 9 insertions(+), 28 deletions(-) diff --git a/theme/base/css/display.css b/theme/base/css/display.css index d3b9d7cdca..e88e1f2226 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -670,8 +670,7 @@ display:block; text-align:left; width:100%; } -.entity_actions a, -.entity_remote_subscribe { +.entity_actions a { text-decoration:none; font-weight:bold; display:block; @@ -696,14 +695,6 @@ padding-left:23px; padding:2px 4px 1px 26px; } -.entity_remote_subscribe { -padding:4px; -border-width:2px; -border-style:solid; -border-radius:4px; --moz-border-radius:4px; --webkit-border-radius:4px; -} .entity_actions .accept { margin-bottom:18px; } diff --git a/theme/default/css/display.css b/theme/default/css/display.css index fc97101bb5..d4fcb23434 100644 --- a/theme/default/css/display.css +++ b/theme/default/css/display.css @@ -30,8 +30,7 @@ border-radius:4px; input, textarea, select, option { font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif; } -input, textarea, select, -.entity_remote_subscribe { +input, textarea, select { border-color:#AAAAAA; } @@ -56,14 +55,12 @@ background:none; } .form_notice.warning #notice_text-count, -.form_settings .form_note, -.entity_remote_subscribe { +.form_settings .form_note { background-color:#9BB43E; } input.submit, .form_notice.warning #notice_text-count, .form_settings .form_note, -.entity_remote_subscribe, .entity_actions a, .entity_actions input, .entity_moderation p, @@ -81,12 +78,10 @@ background-color:transparent; input:focus, textarea:focus, select:focus, .form_notice.warning #notice_data-text, .form_notice.warning #notice_text-count, -.form_settings .form_note, -.entity_remote_subscribe { +.form_settings .form_note { border-color:#9BB43E; } -input.submit, -.entity_remote_subscribe { +input.submit { color:#FFFFFF; } .entity_actions input.submit { diff --git a/theme/identica/css/display.css b/theme/identica/css/display.css index 728ca97334..0e8fa6d793 100644 --- a/theme/identica/css/display.css +++ b/theme/identica/css/display.css @@ -30,8 +30,7 @@ border-radius:4px; input, textarea, select, option { font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif; } -input, textarea, select, -.entity_remote_subscribe { +input, textarea, select { border-color:#AAAAAA; } @@ -56,14 +55,12 @@ background:none; } .form_notice.warning #notice_text-count, -.form_settings .form_note, -.entity_remote_subscribe { +.form_settings .form_note { background-color:#9BB43E; } input.submit, .form_notice.warning #notice_text-count, .form_settings .form_note, -.entity_remote_subscribe, .entity_actions a, .entity_actions input, .entity_moderation p, @@ -81,12 +78,10 @@ background-color:transparent; input:focus, textarea:focus, select:focus, .form_notice.warning #notice_data-text, .form_notice.warning #notice_text-count, -.form_settings .form_note, -.entity_remote_subscribe { +.form_settings .form_note { border-color:#9BB43E; } -input.submit, -.entity_remote_subscribe { +input.submit { color:#FFFFFF; } .entity_actions input.submit {