From 1459110124c012364800484cd3677f754917de63 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Wed, 20 Oct 2010 11:16:21 +0200 Subject: Fix nasty bug in parameter for e-mail notification for favourite. --- lib/mail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/mail.php b/lib/mail.php index 3703e5c35..30d743848 100644 --- a/lib/mail.php +++ b/lib/mail.php @@ -600,7 +600,7 @@ function mail_notify_fave($other, $user, $notice) // TRANS: Subject for favorite notification e-mail. // TRANS: %1$s is the adding user's long name, %2$s is the adding user's nickname. - $subject = sprintf(_('%1s$ (@%2$s) added your notice as a favorite'), $bestname, $user->nickname); + $subject = sprintf(_('%1$s (@%2$s) added your notice as a favorite'), $bestname, $user->nickname); // TRANS: Body for favorite notification e-mail. // TRANS: %1$s is the adding user's long name, $2$s is the date the notice was created, -- cgit v1.2.3-54-g00ecf From dc62cf1c0b6f77ebd4e4bf885aa3de7846b3232a Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Wed, 20 Oct 2010 19:34:27 +0200 Subject: * i18n/L10n fixes. * translator documentation updated/added. * superfluous whitespace removed. --- actions/apioauthaccesstoken.php | 3 +-- actions/apioauthauthorize.php | 46 +++++++++++++++++++++++------------- actions/apistatusesupdate.php | 35 +++++++++++++-------------- actions/oauthconnectionssettings.php | 21 ++++++++++------ lib/apiauth.php | 5 ++-- lib/apioauthstore.php | 9 ++++--- lib/applicationlist.php | 9 ++++--- 7 files changed, 70 insertions(+), 58 deletions(-) (limited to 'lib') diff --git a/actions/apioauthaccesstoken.php b/actions/apioauthaccesstoken.php index 21e0049ce..59abcf812 100644 --- a/actions/apioauthaccesstoken.php +++ b/actions/apioauthaccesstoken.php @@ -44,7 +44,6 @@ require_once INSTALLDIR . '/lib/apioauth.php'; * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ - class ApiOauthAccessTokenAction extends ApiOauthAction { protected $reqToken = null; @@ -73,7 +72,6 @@ class ApiOauthAccessTokenAction extends ApiOauthAction // Spec doesn't say they MUST be. try { - $req = OAuthRequest::from_request(); $this->reqToken = $req->get_parameter('oauth_token'); @@ -100,6 +98,7 @@ class ApiOauthAccessTokenAction extends ApiOauthAction ); common_log(LOG_WARNING, $msg); + // TRANS: Client error given from the OAuth API when the request token or verifier is invalid. $this->clientError(_("Invalid request token or verifier.", 400, 'text')); } else { diff --git a/actions/apioauthauthorize.php b/actions/apioauthauthorize.php index 01cbca18f..0e61cdf2c 100644 --- a/actions/apioauthauthorize.php +++ b/actions/apioauthauthorize.php @@ -43,7 +43,6 @@ require_once INSTALLDIR . '/lib/info.php'; * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ - class ApiOauthAuthorizeAction extends Action { var $oauthTokenParam; @@ -106,6 +105,7 @@ class ApiOauthAuthorizeAction extends Action // Make sure a oauth_token parameter was provided if (empty($this->oauthTokenParam)) { + // TRANS: Client error given when no oauth_token was passed to the OAuth API. $this->clientError(_('No oauth_token parameter provided.')); } else { @@ -113,11 +113,13 @@ class ApiOauthAuthorizeAction extends Action $this->reqToken = $this->store->getTokenByKey($this->oauthTokenParam); if (empty($this->reqToken)) { + // TRANS: Client error given when an invalid request token was passed to the OAuth API. $this->clientError(_('Invalid request token.')); } else { // Check to make sure we haven't already authorized the token if ($this->reqToken->state != 0) { + // TRANS: Client error given when an invalid request token was passed to the OAuth API. $this->clientError(_("Invalid request token.")); } } @@ -125,6 +127,7 @@ class ApiOauthAuthorizeAction extends Action // make sure there's an app associated with this token if (empty($this->app)) { + // TRANS: Client error given when an invalid request token was passed to the OAuth API. $this->clientError(_('Invalid request token.')); } @@ -158,6 +161,7 @@ class ApiOauthAuthorizeAction extends Action $user = common_check_user($this->nickname, $this->password); if (empty($user)) { + // TRANS: Form validation error given when an invalid username and/or password was passed to the OAuth API. $this->showForm(_("Invalid nickname / password!")); return; } @@ -198,6 +202,7 @@ class ApiOauthAuthorizeAction extends Action if (!$result) { common_log_db_error($appUser, 'INSERT', __FILE__); + // TRANS: Server error given when a database error occurs inserting an OAuth application user. $this->serverError(_('Database error inserting OAuth application user.')); } @@ -211,7 +216,6 @@ class ApiOauthAuthorizeAction extends Action } if (!empty($this->callback)) { - $targetUrl = $this->getCallback( $this->callback, array( @@ -222,9 +226,7 @@ class ApiOauthAuthorizeAction extends Action // Redirect the user to the provided OAuth callback common_redirect($targetUrl, 303); - } elseif ($this->app->type == 2) { - // Strangely, a web application seems to want to do the OOB // workflow. Because no callback was specified anywhere. common_log( @@ -261,6 +263,7 @@ class ApiOauthAuthorizeAction extends Action } } else { + // TRANS: Client error given on when invalid data was passed through a form in the OAuth API. $this->clientError(_('Unexpected form submission.')); } } @@ -287,6 +290,7 @@ class ApiOauthAuthorizeAction extends Action function title() { + // TRANS: Title for a page where a user can confirm/deny account access by an external application. return _('An application would like to connect to your account'); } @@ -304,6 +308,7 @@ class ApiOauthAuthorizeAction extends Action 'action' => common_local_url('ApiOauthAuthorize'))); $this->elementStart('fieldset'); $this->element('legend', array('id' => 'apioauthauthorize_allowdeny'), + // TRANS: Fieldset legend. _('Allow or deny access')); $this->hidden('token', common_session_token()); @@ -320,6 +325,9 @@ class ApiOauthAuthorizeAction extends Action $access = ($this->app->access_type & Oauth_application::$writeAccess) ? 'access and update' : 'access'; + // TRANS: User notification of external application requesting account access. + // TRANS: %1$s is the application name requesting access, %2$s is the organisation behind the application, + // TRANS: %3$s is the access type requested, %4$s is the StatusNet sitename. $msg = _('The application %1$s by ' . '%2$s would like the ability ' . 'to %3$s your %4$s account data. ' . @@ -336,33 +344,37 @@ class ApiOauthAuthorizeAction extends Action $this->elementEnd('ul'); if (!common_logged_in()) { - $this->elementStart('fieldset'); - $this->element('legend', null, _('Account')); + // TRANS: Fieldset legend. + $this->element('legend', null, _m('LEGEND','Account')); $this->elementStart('ul', 'form_data'); $this->elementStart('li'); + // TRANS: Field label on OAuth API authorisation form. $this->input('nickname', _('Nickname')); $this->elementEnd('li'); $this->elementStart('li'); + // TRANS: Field label on OAuth API authorisation form. $this->password('password', _('Password')); $this->elementEnd('li'); $this->elementEnd('ul'); $this->elementEnd('fieldset'); - } $this->element('input', array('id' => 'cancel_submit', 'class' => 'submit submit form_action-primary', 'name' => 'cancel', 'type' => 'submit', - 'value' => _('Cancel'))); + // TRANS: Button text that when clicked will cancel the process of allowing access to an account + // TRANS: by an external application. + 'value' => _m('BUTTON','Cancel'))); $this->element('input', array('id' => 'allow_submit', 'class' => 'submit submit form_action-secondary', 'name' => 'allow', 'type' => 'submit', - 'value' => _('Allow'))); + // TRANS: Button text that when clicked will allow access to an account by an external application. + 'value' => _m('BUTTON','Allow'))); $this->elementEnd('fieldset'); $this->elementEnd('form'); @@ -376,9 +388,9 @@ class ApiOauthAuthorizeAction extends Action * * @return void */ - function getInstructions() { + // TRANS: Form instructions. return _('Authorize access to your account information.'); } @@ -389,7 +401,6 @@ class ApiOauthAuthorizeAction extends Action * * @return void */ - function showLocalNav() { // NOP @@ -400,7 +411,6 @@ class ApiOauthAuthorizeAction extends Action * * @return nothing */ - function showSiteNotice() { // NOP @@ -413,7 +423,6 @@ class ApiOauthAuthorizeAction extends Action * * @return nothing */ - function showNoticeForm() { // NOP @@ -425,12 +434,14 @@ class ApiOauthAuthorizeAction extends Action * * @return nothing */ - function showCanceled() { $info = new InfoAction( + // TRANS: Header for user notification after revoking OAuth access to an application. _('Authorization canceled.'), sprintf( + // TRANS: User notification after revoking OAuth access to an application. + // TRANS: %s is an OAuth token. _('The request token %s has been revoked.'), $this->oauthTokenParm ) @@ -445,15 +456,18 @@ class ApiOauthAuthorizeAction extends Action * * @return nothing */ - function showAuthorized() { $title = sprintf( + // TRANS: Header of user notification after authorising an application access to a profile. + // TRANS: %s is the authorised application name. _("You have successfully authorized %s."), $this->app->name ); $msg = sprintf( + // TRANS: Uer notification after authorising an application access to a profile. + // TRANS: %s is the authorised application name. _('Please return to %s and enter the following security code to complete the process.'), $this->app->name ); @@ -488,7 +502,6 @@ class ApiOauthAuthorizeAction extends Action * * @return string $url a URL to use for redirecting to */ - function getCallback($url, $params) { foreach ($params as $k => $v) { @@ -512,7 +525,6 @@ class ApiOauthAuthorizeAction extends Action * * @return string $url the new URL with added parameter */ - function appendQueryVar($url, $k, $v) { $url = preg_replace('/(.*)(\?|&)' . $k . '=[^&]+?(&)(.*)/i', '$1$2$4', $url . '&'); $url = substr($url, 0, -1); diff --git a/actions/apistatusesupdate.php b/actions/apistatusesupdate.php index 91dcdd10f..822ebacbd 100644 --- a/actions/apistatusesupdate.php +++ b/actions/apistatusesupdate.php @@ -147,7 +147,6 @@ require_once INSTALLDIR . '/lib/mediafile.php'; * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ - class ApiStatusesUpdateAction extends ApiAuthAction { var $status = null; @@ -163,7 +162,6 @@ class ApiStatusesUpdateAction extends ApiAuthAction * @return boolean success flag * */ - function prepare($args) { parent::prepare($args); @@ -187,7 +185,6 @@ class ApiStatusesUpdateAction extends ApiAuthAction * * @return void */ - function handle($args) { parent::handle($args); @@ -209,8 +206,11 @@ class ApiStatusesUpdateAction extends ApiAuthAction && empty($_POST) && ($_SERVER['CONTENT_LENGTH'] > 0) ) { - $msg = _('The server was unable to handle that much POST ' . - 'data (%s bytes) due to its current configuration.'); + // TRANS: Client error displayed when the number of bytes in a POST request exceeds a limit. + // TRANS: %s is the number of bytes of the CONTENT_LENGTH. + $msg = _m('The server was unable to handle that much POST data (%s byte) due to its current configuration.', + 'The server was unable to handle that much POST data (%s bytes) due to its current configuration.', + intval($_SERVER['CONTENT_LENGTH'])); $this->clientError(sprintf($msg, $_SERVER['CONTENT_LENGTH'])); return; @@ -218,6 +218,7 @@ class ApiStatusesUpdateAction extends ApiAuthAction if (empty($this->status)) { $this->clientError( + // TRANS: Client error displayed when the parameter "status" is missing. _('Client must provide a \'status\' parameter with a value.'), 400, $this->format @@ -239,7 +240,11 @@ class ApiStatusesUpdateAction extends ApiAuthAction $this->clientError( sprintf( - _('That\'s too long. Max notice size is %d chars.'), + // TRANS: Client error displayed when the parameter "status" is missing. + // TRANS: %d is the maximum number of character for a notice. + _m('That\'s too long. Maximum notice size is %d character.', + 'That\'s too long. Maximum notice size is %d characters.', + Notice::maxContent()), Notice::maxContent() ), 406, @@ -255,7 +260,6 @@ class ApiStatusesUpdateAction extends ApiAuthAction $cmd = $inter->handle_command($this->auth_user, $status_shortened); if ($cmd) { - if ($this->supported($cmd)) { $cmd->execute(new Channel()); } @@ -265,13 +269,10 @@ class ApiStatusesUpdateAction extends ApiAuthAction // or not! $this->notice = $this->auth_user->getCurrentNotice(); - } else { - $reply_to = null; if (!empty($this->in_reply_to_status_id)) { - // Check whether notice actually exists $reply = Notice::staticGet($this->in_reply_to_status_id); @@ -280,7 +281,8 @@ class ApiStatusesUpdateAction extends ApiAuthAction $reply_to = $this->in_reply_to_status_id; } else { $this->clientError( - _('Not found.'), + // TRANS: Client error displayed when replying to a non-existing notice. + _('Parent notice not found.'), $code = 404, $this->format ); @@ -302,10 +304,9 @@ class ApiStatusesUpdateAction extends ApiAuthAction if (Notice::contentTooLong($status_shortened)) { $upload->delete(); - $msg = _( - 'Max notice size is %d chars, ' . - 'including attachment URL.' - ); + $msg = _m('Maximum notice size is %d character, including attachment URL.', + 'Maximum notice size is %d characters, including attachment URL.', + Notice::maxContent()); $this->clientError( sprintf($msg, Notice::maxContent()), 400, @@ -344,7 +345,6 @@ class ApiStatusesUpdateAction extends ApiAuthAction if (isset($upload)) { $upload->attachToNotice($this->notice); } - } $this->showNotice(); @@ -355,7 +355,6 @@ class ApiStatusesUpdateAction extends ApiAuthAction * * @return void */ - function showNotice() { if (!empty($this->notice)) { @@ -374,7 +373,6 @@ class ApiStatusesUpdateAction extends ApiAuthAction * * @return boolean true or false */ - function supported($cmd) { static $cmdlist = array('MessageCommand', 'SubCommand', 'UnsubCommand', @@ -386,5 +384,4 @@ class ApiStatusesUpdateAction extends ApiAuthAction return false; } - } diff --git a/actions/oauthconnectionssettings.php b/actions/oauthconnectionssettings.php index 0590b729c..9a7cda924 100644 --- a/actions/oauthconnectionssettings.php +++ b/actions/oauthconnectionssettings.php @@ -46,10 +46,8 @@ require_once INSTALLDIR . '/lib/apioauthstore.php'; * * @see SettingsAction */ - class OauthconnectionssettingsAction extends ConnectSettingsAction { - var $page = null; var $oauth_token = null; @@ -69,6 +67,7 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction function title() { + // TRANS: Title for OAuth connection settings. return _('Connected applications'); } @@ -80,6 +79,7 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction function getInstructions() { + // TRANS: Instructions for OAuth connection settings. return _('The following connections exist for your account.'); } @@ -129,7 +129,6 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction * * @return void */ - function handlePost() { // CSRF protection @@ -144,6 +143,7 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction if ($this->arg('revoke')) { $this->revokeAccess($this->oauth_token); } else { + // TRANS: Client error when submitting a form with unexpected information. $this->clientError(_('Unexpected form submission.'), 401); return false; } @@ -157,7 +157,6 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction * @param int $appId the ID of the application * */ - function revokeAccess($token) { $cur = common_current_user(); @@ -165,6 +164,7 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction $appUser = Oauth_application_user::getByUserAndToken($cur, $token); if (empty($appUser)) { + // TRANS: Client error when trying to revoke access for an application while not being a user of it. $this->clientError(_('You are not a user of that application.'), 401); return false; } @@ -178,7 +178,9 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction if (!$result) { common_log_db_error($orig, 'DELETE', __FILE__); - $this->clientError(sprintf(_('Unable to revoke access for app: %s.'), $app->id)); + // TRANS: Client error when revoking access has failed for some reason. + // TRANS: %s is the application ID revoking access failed for. + $this->clientError(sprintf(_('Unable to revoke access for application: %s.'), $app->id)); return false; } @@ -195,7 +197,9 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction ); $msg = sprintf( - _('You have successfully revoked access for %s and the access token starting with %s'), + // TRANS: Success message after revoking access for an application. + // TRANS: %1$s is the application name, %2$s is the first part of the user token. + _('You have successfully revoked access for %1$s and the access token starting with %2$s.'), $app->name, substr($appUser->token, 0, 7) ); @@ -205,6 +209,7 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction function showEmptyListMessage() { + // TRANS: Empty list message when no applications have been authorised yet. $message = _('You have not authorized any applications to use your account.'); $this->elementStart('div', 'guide'); @@ -222,6 +227,9 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction $this->elementStart('p'); $devMsg = sprintf( + // TRANS: Note for developers in the OAuth connection settings form. + // TRANS: This message contains a Markdown link. Do not separate "](". + // TRANS: %s is the URL to the OAuth settings. _('Are you a developer? [Register an OAuth client application](%s) to use with this instance of StatusNet.'), common_local_url('oauthappssettings') ); @@ -233,5 +241,4 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction $this->elementEnd('section'); } - } diff --git a/lib/apiauth.php b/lib/apiauth.php index 0ebd7aa10..1dacf1409 100644 --- a/lib/apiauth.php +++ b/lib/apiauth.php @@ -263,7 +263,7 @@ class ApiAuthAction extends ApiAction // show error if the user clicks 'cancel' // TRANS: Client error thrown when authentication fails becaus a user clicked "Cancel". - $this->clientError(_("Could not authenticate you."), 401, $this->format); + $this->clientError(_('Could not authenticate you.'), 401, $this->format); exit; } else { @@ -290,7 +290,7 @@ class ApiAuthAction extends ApiAction ); $this->logAuthFailure($msg); // TRANS: Client error thrown when authentication fails. - $this->clientError(_("Could not authenticate you."), 401, $this->format); + $this->clientError(_('Could not authenticate you.'), 401, $this->format); exit; } } @@ -342,7 +342,6 @@ class ApiAuthAction extends ApiAction * * @param string $logMsg additional log message */ - function logAuthFailure($logMsg) { list($proxy, $ip) = common_client_ip(); diff --git a/lib/apioauthstore.php b/lib/apioauthstore.php index e30eea129..76df6c1ed 100644 --- a/lib/apioauthstore.php +++ b/lib/apioauthstore.php @@ -37,7 +37,8 @@ class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore $con->consumer_secret = $consumerKey; $result = $con->insert(); if (!$result) { - $this->serverError(_("Could not create anonymous consumer.")); + // TRANS: Server error displayed when trying to create an anynymous OAuth consumer. + $this->serverError(_('Could not create anonymous consumer.')); } $app = new OAuth_application(); $app->consumer_key = $con->consumer_key; @@ -49,7 +50,8 @@ class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore $app->access_type = 3; // read + write $id = $app->insert(); if (!$id) { - $this->serverError(_("Could not create anonymous OAuth application.")); + // TRANS: Server error displayed when trying to create an anynymous OAuth application. + $this->serverError(_('Could not create anonymous OAuth application.')); } } else { return null; @@ -230,7 +232,6 @@ class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore * * @return OAuthToken $token a new unauthorized OAuth request token */ - function new_request_token($consumer, $callback) { $t = new Token(); @@ -255,6 +256,4 @@ class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore return new OAuthToken($t->tok, $t->secret); } } - - } diff --git a/lib/applicationlist.php b/lib/applicationlist.php index 6801fb6cf..ff9ac5a20 100644 --- a/lib/applicationlist.php +++ b/lib/applicationlist.php @@ -142,10 +142,8 @@ class ApplicationList extends Widget { return; } - } - /** * Widget to show a list of connected OAuth clients * @@ -279,7 +277,9 @@ class ConnectedAppsList extends Widget $this->out->element( 'p', array( 'class' => 'access_token'), - _('Access token starting with: ') . substr($this->connection->token, 0, 7) + // TRANS: Access token in the application list. + // TRANS: %s are the first 7 characters of the access token. + sprintf(_('Access token starting with: %s'), substr($this->connection->token, 0, 7)) ); $this->out->elementStart( @@ -295,11 +295,10 @@ class ConnectedAppsList extends Widget $this->out->hidden('oauth_token', $this->connection->token); $this->out->hidden('token', common_session_token()); // TRANS: Button label - $this->out->submit('revoke', _('Revoke')); + $this->out->submit('revoke', _m('BUTTON','Revoke')); $this->out->elementEnd('fieldset'); $this->out->elementEnd('form'); $this->out->elementEnd('li'); - } } -- cgit v1.2.3-54-g00ecf From e980da3d20b5f18bd10e4c25e97366de84255867 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Wed, 20 Oct 2010 20:01:12 +0200 Subject: Add FIXME --- lib/applicationlist.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/applicationlist.php b/lib/applicationlist.php index ff9ac5a20..3f50f110b 100644 --- a/lib/applicationlist.php +++ b/lib/applicationlist.php @@ -243,7 +243,7 @@ class ConnectedAppsList extends Widget $this->out->elementEnd('span'); if ($app->name != 'anonymous') { - + // @todo FIXME: i18n trouble. $this->out->raw(_(' by ')); $this->out->element( -- cgit v1.2.3-54-g00ecf From 8004e2809d98bdd535a3c59bd7d15c3fa2dd7ba9 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 20 Oct 2010 14:34:25 -0700 Subject: Fix for ticket #2845: singleuser nickname configuration was being overridden by site owner in router setup. I've consolidated the checks for which user to use for single-user mode into User::singleUser(), which now uses the configured nickname by preference, falling back to the site owner if it's unset. This is now called consistently from the places that needed to use the primary user's nickname in routing setup. Setting $config['singleuser']['nickname'] should now work again as expected. --- README | 3 ++- classes/User.php | 29 +++++++++++++++++++++++++++++ lib/action.php | 3 ++- lib/router.php | 12 ++---------- lib/util.php | 3 ++- 5 files changed, 37 insertions(+), 13 deletions(-) (limited to 'lib') diff --git a/README b/README index 26a9fe4ec..43a9bb5e9 100644 --- a/README +++ b/README @@ -1486,7 +1486,8 @@ If an installation has only one user, this can simplify a lot of the interface. It also makes the user's profile the root URL. enabled: Whether to run in "single user mode". Default false. -nickname: nickname of the single user. +nickname: nickname of the single user. If no nickname is specified, + the site owner account will be used (if present). robotstxt --------- diff --git a/classes/User.php b/classes/User.php index e784fd9e9..c68be223d 100644 --- a/classes/User.php +++ b/classes/User.php @@ -875,4 +875,33 @@ class User extends Memcached_DataObject return $owner; } + + /** + * Pull the primary site account to use in single-user mode. + * If a valid user nickname is listed in 'singleuser':'nickname' + * in the config, this will be used; otherwise the site owner + * account is taken by default. + * + * @return User + * @throws ServerException if no valid single user account is present + * @throws ServerException if called when not in single-user mode + */ + static function singleUser() + { + if (common_config('singleuser', 'enabled')) { + $nickname = common_config('singleuser', 'nickname'); + if ($nickname) { + $user = User::staticGet('nickname', $nickname); + } else { + $user = User::siteOwner(); + } + if ($user) { + return $user; + } else { + throw new ServerException(_("No single user defined for single-user mode.")); + } + } else { + throw new ServerException(_('Single-user mode code called when not enabled.')); + } + } } diff --git a/lib/action.php b/lib/action.php index 55ee83bde..e273b5d04 100644 --- a/lib/action.php +++ b/lib/action.php @@ -419,8 +419,9 @@ class Action extends HTMLOutputter // lawsuit 'class' => 'vcard')); if (Event::handle('StartAddressData', array($this))) { if (common_config('singleuser', 'enabled')) { + $user = User::singleUser(); $url = common_local_url('showstream', - array('nickname' => common_config('singleuser', 'nickname'))); + array('nickname' => $user->nickname)); } else { $url = common_local_url('public'); } diff --git a/lib/router.php b/lib/router.php index b1cc8d529..8c682cefa 100644 --- a/lib/router.php +++ b/lib/router.php @@ -701,16 +701,8 @@ class Router if (common_config('singleuser', 'enabled')) { - $user = User::siteOwner(); - - if (!empty($user)) { - $nickname = $user->nickname; - } else { - $nickname = common_config('singleuser', 'nickname'); - if (empty($nickname)) { - throw new ServerException(_("No single user defined for single-user mode.")); - } - } + $user = User::singleUser(); + $nickname = $user->nickname; foreach (array('subscriptions', 'subscribers', 'all', 'foaf', 'xrds', diff --git a/lib/util.php b/lib/util.php index 5a94182bd..86380af28 100644 --- a/lib/util.php +++ b/lib/util.php @@ -974,8 +974,9 @@ function common_tag_link($tag) $canonical = common_canonical_tag($tag); if (common_config('singleuser', 'enabled')) { // regular TagAction isn't set up in 1user mode + $user = User::singleUser(); $url = common_local_url('showstream', - array('nickname' => common_config('singleuser', 'nickname'), + array('nickname' => $user->nickname, 'tag' => $canonical)); } else { $url = common_local_url('tag', array('tag' => $canonical)); -- cgit v1.2.3-54-g00ecf From 28ec9d64632a7a43be9144a474432a3c5b8d6b97 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Thu, 21 Oct 2010 01:12:56 +0200 Subject: * translator documentation added. * moved some translator comments that were not directly above the line with the message to the correct location. * i18n for UI text. * superfluous whitespace removed. --- classes/User.php | 4 +++- lib/action.php | 6 +++--- lib/router.php | 8 ++------ 3 files changed, 8 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/classes/User.php b/classes/User.php index c68be223d..f381ec607 100644 --- a/classes/User.php +++ b/classes/User.php @@ -898,9 +898,11 @@ class User extends Memcached_DataObject if ($user) { return $user; } else { - throw new ServerException(_("No single user defined for single-user mode.")); + // TRANS: Server exception. + throw new ServerException(_('No single user defined for single-user mode.')); } } else { + // TRANS: Server exception. throw new ServerException(_('Single-user mode code called when not enabled.')); } } diff --git a/lib/action.php b/lib/action.php index e273b5d04..3d7d1d808 100644 --- a/lib/action.php +++ b/lib/action.php @@ -527,20 +527,20 @@ class Action extends HTMLOutputter // lawsuit } // TRANS: Tooltip for main menu option "Login" $tooltip = _m('TOOLTIP', 'Login to the site'); - // TRANS: Main menu option when not logged in to log in $this->menuItem(common_local_url('login'), + // TRANS: Main menu option when not logged in to log in _m('MENU', 'Login'), $tooltip, false, 'nav_login'); } // TRANS: Tooltip for main menu option "Help" $tooltip = _m('TOOLTIP', 'Help me!'); - // TRANS: Main menu option for help on the StatusNet site $this->menuItem(common_local_url('doc', array('title' => 'help')), + // TRANS: Main menu option for help on the StatusNet site _m('MENU', 'Help'), $tooltip, false, 'nav_help'); if ($user || !common_config('site', 'private')) { // TRANS: Tooltip for main menu option "Search" $tooltip = _m('TOOLTIP', 'Search for people or text'); - // TRANS: Main menu option when logged in or when the StatusNet instance is not private $this->menuItem(common_local_url('peoplesearch'), + // TRANS: Main menu option when logged in or when the StatusNet instance is not private _m('MENU', 'Search'), $tooltip, false, 'nav_search'); } Event::handle('EndPrimaryNav', array($this)); diff --git a/lib/router.php b/lib/router.php index 8c682cefa..417206e6b 100644 --- a/lib/router.php +++ b/lib/router.php @@ -34,7 +34,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { require_once 'Net/URL/Mapper.php'; class StatusNet_URL_Mapper extends Net_URL_Mapper { - private static $_singleton = null; private function __construct() @@ -71,7 +70,6 @@ class StatusNet_URL_Mapper extends Net_URL_Mapper { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ - class Router { var $m = null; @@ -692,7 +690,6 @@ class Router $m->connect('admin/snapshot', array('action' => 'snapshotadminpanel')); $m->connect('admin/license', array('action' => 'licenseadminpanel')); - $m->connect('getfile/:filename', array('action' => 'getfile'), array('filename' => '[A-Za-z0-9._-]+')); @@ -757,9 +754,7 @@ class Router $m->connect('', array('action' => 'showstream', 'nickname' => $nickname)); - } else { - $m->connect('', array('action' => 'public')); $m->connect('rss', array('action' => 'publicrss')); $m->connect('featuredrss', array('action' => 'featuredrss')); @@ -840,7 +835,8 @@ class Router } catch (Net_URL_Mapper_InvalidException $e) { common_log(LOG_ERR, "Problem getting route for $path - " . $e->getMessage()); - $cac = new ClientErrorAction("Page not found.", 404); + // TRANS: Client error on action trying to visit a non-existing page. + $cac = new ClientErrorAction(_('Page not found.'), 404); $cac->showPage(); } -- cgit v1.2.3-54-g00ecf