* translator documentation updated/added.
* superfluous whitespace removed.
* @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;
// Spec doesn't say they MUST be.
try {
-
$req = OAuthRequest::from_request();
$this->reqToken = $req->get_parameter('oauth_token');
);
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 {
* @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;
// 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 {
$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."));
}
}
// 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.'));
}
$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;
}
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.'));
}
}
if (!empty($this->callback)) {
-
$targetUrl = $this->getCallback(
$this->callback,
array(
// 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(
}
} else {
+ // TRANS: Client error given on when invalid data was passed through a form in the OAuth API.
$this->clientError(_('Unexpected form submission.'));
}
}
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');
}
'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());
$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 <strong>%1$s</strong> by ' .
'<strong>%2$s</strong> would like the ability ' .
'to <strong>%3$s</strong> your %4$s account data. ' .
$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');
*
* @return void
*/
-
function getInstructions()
{
+ // TRANS: Form instructions.
return _('Authorize access to your account information.');
}
*
* @return void
*/
-
function showLocalNav()
{
// NOP
*
* @return nothing
*/
-
function showSiteNotice()
{
// NOP
*
* @return nothing
*/
-
function showNoticeForm()
{
// NOP
*
* @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
)
*
* @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
);
*
* @return string $url a URL to use for redirecting to
*/
-
function getCallback($url, $params)
{
foreach ($params as $k => $v) {
*
* @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);
* @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;
* @return boolean success flag
*
*/
-
function prepare($args)
{
parent::prepare($args);
*
* @return void
*/
-
function handle($args)
{
parent::handle($args);
&& 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;
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
$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,
$cmd = $inter->handle_command($this->auth_user, $status_shortened);
if ($cmd) {
-
if ($this->supported($cmd)) {
$cmd->execute(new Channel());
}
// 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);
$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
);
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,
if (isset($upload)) {
$upload->attachToNotice($this->notice);
}
-
}
$this->showNotice();
*
* @return void
*/
-
function showNotice()
{
if (!empty($this->notice)) {
*
* @return boolean true or false
*/
-
function supported($cmd)
{
static $cmdlist = array('MessageCommand', 'SubCommand', 'UnsubCommand',
return false;
}
-
}
*
* @see SettingsAction
*/
-
class OauthconnectionssettingsAction extends ConnectSettingsAction
{
-
var $page = null;
var $oauth_token = null;
function title()
{
+ // TRANS: Title for OAuth connection settings.
return _('Connected applications');
}
function getInstructions()
{
+ // TRANS: Instructions for OAuth connection settings.
return _('The following connections exist for your account.');
}
*
* @return void
*/
-
function handlePost()
{
// CSRF protection
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;
}
* @param int $appId the ID of the application
*
*/
-
function revokeAccess($token)
{
$cur = common_current_user();
$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;
}
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;
}
);
$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)
);
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');
$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')
);
$this->elementEnd('section');
}
-
}
// 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 {
);
$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;
}
}
*
* @param string $logMsg additional log message
*/
-
function logAuthFailure($logMsg)
{
list($proxy, $ip) = common_client_ip();
$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;
$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;
*
* @return OAuthToken $token a new unauthorized OAuth request token
*/
-
function new_request_token($consumer, $callback)
{
$t = new Token();
return new OAuthToken($t->tok, $t->secret);
}
}
-
-
}
{
return;
}
-
}
-
/**
* Widget to show a list of connected OAuth clients
*
$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(
$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');
-
}
}