forked from GNUsocial/gnu-social
* i18n/L10n fixes.
* translator documentation updated/added. * superfluous whitespace removed.
This commit is contained in:
parent
17f5cc4f29
commit
dc62cf1c0b
@ -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
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class ApiOauthAccessTokenAction extends ApiOauthAction
|
class ApiOauthAccessTokenAction extends ApiOauthAction
|
||||||
{
|
{
|
||||||
protected $reqToken = null;
|
protected $reqToken = null;
|
||||||
@ -73,7 +72,6 @@ class ApiOauthAccessTokenAction extends ApiOauthAction
|
|||||||
// Spec doesn't say they MUST be.
|
// Spec doesn't say they MUST be.
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$req = OAuthRequest::from_request();
|
$req = OAuthRequest::from_request();
|
||||||
|
|
||||||
$this->reqToken = $req->get_parameter('oauth_token');
|
$this->reqToken = $req->get_parameter('oauth_token');
|
||||||
@ -100,6 +98,7 @@ class ApiOauthAccessTokenAction extends ApiOauthAction
|
|||||||
);
|
);
|
||||||
|
|
||||||
common_log(LOG_WARNING, $msg);
|
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'));
|
$this->clientError(_("Invalid request token or verifier.", 400, 'text'));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -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
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class ApiOauthAuthorizeAction extends Action
|
class ApiOauthAuthorizeAction extends Action
|
||||||
{
|
{
|
||||||
var $oauthTokenParam;
|
var $oauthTokenParam;
|
||||||
@ -106,6 +105,7 @@ class ApiOauthAuthorizeAction extends Action
|
|||||||
|
|
||||||
// Make sure a oauth_token parameter was provided
|
// Make sure a oauth_token parameter was provided
|
||||||
if (empty($this->oauthTokenParam)) {
|
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.'));
|
$this->clientError(_('No oauth_token parameter provided.'));
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@ -113,11 +113,13 @@ class ApiOauthAuthorizeAction extends Action
|
|||||||
$this->reqToken = $this->store->getTokenByKey($this->oauthTokenParam);
|
$this->reqToken = $this->store->getTokenByKey($this->oauthTokenParam);
|
||||||
|
|
||||||
if (empty($this->reqToken)) {
|
if (empty($this->reqToken)) {
|
||||||
|
// TRANS: Client error given when an invalid request token was passed to the OAuth API.
|
||||||
$this->clientError(_('Invalid request token.'));
|
$this->clientError(_('Invalid request token.'));
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Check to make sure we haven't already authorized the token
|
// Check to make sure we haven't already authorized the token
|
||||||
if ($this->reqToken->state != 0) {
|
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."));
|
$this->clientError(_("Invalid request token."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,6 +127,7 @@ class ApiOauthAuthorizeAction extends Action
|
|||||||
|
|
||||||
// make sure there's an app associated with this token
|
// make sure there's an app associated with this token
|
||||||
if (empty($this->app)) {
|
if (empty($this->app)) {
|
||||||
|
// TRANS: Client error given when an invalid request token was passed to the OAuth API.
|
||||||
$this->clientError(_('Invalid request token.'));
|
$this->clientError(_('Invalid request token.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,6 +161,7 @@ class ApiOauthAuthorizeAction extends Action
|
|||||||
|
|
||||||
$user = common_check_user($this->nickname, $this->password);
|
$user = common_check_user($this->nickname, $this->password);
|
||||||
if (empty($user)) {
|
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!"));
|
$this->showForm(_("Invalid nickname / password!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -198,6 +202,7 @@ class ApiOauthAuthorizeAction extends Action
|
|||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
common_log_db_error($appUser, 'INSERT', __FILE__);
|
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.'));
|
$this->serverError(_('Database error inserting OAuth application user.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,7 +216,6 @@ class ApiOauthAuthorizeAction extends Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($this->callback)) {
|
if (!empty($this->callback)) {
|
||||||
|
|
||||||
$targetUrl = $this->getCallback(
|
$targetUrl = $this->getCallback(
|
||||||
$this->callback,
|
$this->callback,
|
||||||
array(
|
array(
|
||||||
@ -222,9 +226,7 @@ class ApiOauthAuthorizeAction extends Action
|
|||||||
|
|
||||||
// Redirect the user to the provided OAuth callback
|
// Redirect the user to the provided OAuth callback
|
||||||
common_redirect($targetUrl, 303);
|
common_redirect($targetUrl, 303);
|
||||||
|
|
||||||
} elseif ($this->app->type == 2) {
|
} elseif ($this->app->type == 2) {
|
||||||
|
|
||||||
// Strangely, a web application seems to want to do the OOB
|
// Strangely, a web application seems to want to do the OOB
|
||||||
// workflow. Because no callback was specified anywhere.
|
// workflow. Because no callback was specified anywhere.
|
||||||
common_log(
|
common_log(
|
||||||
@ -261,6 +263,7 @@ class ApiOauthAuthorizeAction extends Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
// TRANS: Client error given on when invalid data was passed through a form in the OAuth API.
|
||||||
$this->clientError(_('Unexpected form submission.'));
|
$this->clientError(_('Unexpected form submission.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -287,6 +290,7 @@ class ApiOauthAuthorizeAction extends Action
|
|||||||
|
|
||||||
function title()
|
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');
|
return _('An application would like to connect to your account');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,6 +308,7 @@ class ApiOauthAuthorizeAction extends Action
|
|||||||
'action' => common_local_url('ApiOauthAuthorize')));
|
'action' => common_local_url('ApiOauthAuthorize')));
|
||||||
$this->elementStart('fieldset');
|
$this->elementStart('fieldset');
|
||||||
$this->element('legend', array('id' => 'apioauthauthorize_allowdeny'),
|
$this->element('legend', array('id' => 'apioauthauthorize_allowdeny'),
|
||||||
|
// TRANS: Fieldset legend.
|
||||||
_('Allow or deny access'));
|
_('Allow or deny access'));
|
||||||
|
|
||||||
$this->hidden('token', common_session_token());
|
$this->hidden('token', common_session_token());
|
||||||
@ -320,6 +325,9 @@ class ApiOauthAuthorizeAction extends Action
|
|||||||
$access = ($this->app->access_type & Oauth_application::$writeAccess) ?
|
$access = ($this->app->access_type & Oauth_application::$writeAccess) ?
|
||||||
'access and update' : 'access';
|
'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 ' .
|
$msg = _('The application <strong>%1$s</strong> by ' .
|
||||||
'<strong>%2$s</strong> would like the ability ' .
|
'<strong>%2$s</strong> would like the ability ' .
|
||||||
'to <strong>%3$s</strong> your %4$s account data. ' .
|
'to <strong>%3$s</strong> your %4$s account data. ' .
|
||||||
@ -336,33 +344,37 @@ class ApiOauthAuthorizeAction extends Action
|
|||||||
$this->elementEnd('ul');
|
$this->elementEnd('ul');
|
||||||
|
|
||||||
if (!common_logged_in()) {
|
if (!common_logged_in()) {
|
||||||
|
|
||||||
$this->elementStart('fieldset');
|
$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('ul', 'form_data');
|
||||||
$this->elementStart('li');
|
$this->elementStart('li');
|
||||||
|
// TRANS: Field label on OAuth API authorisation form.
|
||||||
$this->input('nickname', _('Nickname'));
|
$this->input('nickname', _('Nickname'));
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
$this->elementStart('li');
|
$this->elementStart('li');
|
||||||
|
// TRANS: Field label on OAuth API authorisation form.
|
||||||
$this->password('password', _('Password'));
|
$this->password('password', _('Password'));
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
$this->elementEnd('ul');
|
$this->elementEnd('ul');
|
||||||
|
|
||||||
$this->elementEnd('fieldset');
|
$this->elementEnd('fieldset');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->element('input', array('id' => 'cancel_submit',
|
$this->element('input', array('id' => 'cancel_submit',
|
||||||
'class' => 'submit submit form_action-primary',
|
'class' => 'submit submit form_action-primary',
|
||||||
'name' => 'cancel',
|
'name' => 'cancel',
|
||||||
'type' => 'submit',
|
'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',
|
$this->element('input', array('id' => 'allow_submit',
|
||||||
'class' => 'submit submit form_action-secondary',
|
'class' => 'submit submit form_action-secondary',
|
||||||
'name' => 'allow',
|
'name' => 'allow',
|
||||||
'type' => 'submit',
|
'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('fieldset');
|
||||||
$this->elementEnd('form');
|
$this->elementEnd('form');
|
||||||
@ -376,9 +388,9 @@ class ApiOauthAuthorizeAction extends Action
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getInstructions()
|
function getInstructions()
|
||||||
{
|
{
|
||||||
|
// TRANS: Form instructions.
|
||||||
return _('Authorize access to your account information.');
|
return _('Authorize access to your account information.');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -389,7 +401,6 @@ class ApiOauthAuthorizeAction extends Action
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function showLocalNav()
|
function showLocalNav()
|
||||||
{
|
{
|
||||||
// NOP
|
// NOP
|
||||||
@ -400,7 +411,6 @@ class ApiOauthAuthorizeAction extends Action
|
|||||||
*
|
*
|
||||||
* @return nothing
|
* @return nothing
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function showSiteNotice()
|
function showSiteNotice()
|
||||||
{
|
{
|
||||||
// NOP
|
// NOP
|
||||||
@ -413,7 +423,6 @@ class ApiOauthAuthorizeAction extends Action
|
|||||||
*
|
*
|
||||||
* @return nothing
|
* @return nothing
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function showNoticeForm()
|
function showNoticeForm()
|
||||||
{
|
{
|
||||||
// NOP
|
// NOP
|
||||||
@ -425,12 +434,14 @@ class ApiOauthAuthorizeAction extends Action
|
|||||||
*
|
*
|
||||||
* @return nothing
|
* @return nothing
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function showCanceled()
|
function showCanceled()
|
||||||
{
|
{
|
||||||
$info = new InfoAction(
|
$info = new InfoAction(
|
||||||
|
// TRANS: Header for user notification after revoking OAuth access to an application.
|
||||||
_('Authorization canceled.'),
|
_('Authorization canceled.'),
|
||||||
sprintf(
|
sprintf(
|
||||||
|
// TRANS: User notification after revoking OAuth access to an application.
|
||||||
|
// TRANS: %s is an OAuth token.
|
||||||
_('The request token %s has been revoked.'),
|
_('The request token %s has been revoked.'),
|
||||||
$this->oauthTokenParm
|
$this->oauthTokenParm
|
||||||
)
|
)
|
||||||
@ -445,15 +456,18 @@ class ApiOauthAuthorizeAction extends Action
|
|||||||
*
|
*
|
||||||
* @return nothing
|
* @return nothing
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function showAuthorized()
|
function showAuthorized()
|
||||||
{
|
{
|
||||||
$title = sprintf(
|
$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."),
|
_("You have successfully authorized %s."),
|
||||||
$this->app->name
|
$this->app->name
|
||||||
);
|
);
|
||||||
|
|
||||||
$msg = sprintf(
|
$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.'),
|
_('Please return to %s and enter the following security code to complete the process.'),
|
||||||
$this->app->name
|
$this->app->name
|
||||||
);
|
);
|
||||||
@ -488,7 +502,6 @@ class ApiOauthAuthorizeAction extends Action
|
|||||||
*
|
*
|
||||||
* @return string $url a URL to use for redirecting to
|
* @return string $url a URL to use for redirecting to
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getCallback($url, $params)
|
function getCallback($url, $params)
|
||||||
{
|
{
|
||||||
foreach ($params as $k => $v) {
|
foreach ($params as $k => $v) {
|
||||||
@ -512,7 +525,6 @@ class ApiOauthAuthorizeAction extends Action
|
|||||||
*
|
*
|
||||||
* @return string $url the new URL with added parameter
|
* @return string $url the new URL with added parameter
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function appendQueryVar($url, $k, $v) {
|
function appendQueryVar($url, $k, $v) {
|
||||||
$url = preg_replace('/(.*)(\?|&)' . $k . '=[^&]+?(&)(.*)/i', '$1$2$4', $url . '&');
|
$url = preg_replace('/(.*)(\?|&)' . $k . '=[^&]+?(&)(.*)/i', '$1$2$4', $url . '&');
|
||||||
$url = substr($url, 0, -1);
|
$url = substr($url, 0, -1);
|
||||||
|
@ -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
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class ApiStatusesUpdateAction extends ApiAuthAction
|
class ApiStatusesUpdateAction extends ApiAuthAction
|
||||||
{
|
{
|
||||||
var $status = null;
|
var $status = null;
|
||||||
@ -163,7 +162,6 @@ class ApiStatusesUpdateAction extends ApiAuthAction
|
|||||||
* @return boolean success flag
|
* @return boolean success flag
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function prepare($args)
|
function prepare($args)
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
@ -187,7 +185,6 @@ class ApiStatusesUpdateAction extends ApiAuthAction
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function handle($args)
|
function handle($args)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
@ -209,8 +206,11 @@ class ApiStatusesUpdateAction extends ApiAuthAction
|
|||||||
&& empty($_POST)
|
&& empty($_POST)
|
||||||
&& ($_SERVER['CONTENT_LENGTH'] > 0)
|
&& ($_SERVER['CONTENT_LENGTH'] > 0)
|
||||||
) {
|
) {
|
||||||
$msg = _('The server was unable to handle that much POST ' .
|
// TRANS: Client error displayed when the number of bytes in a POST request exceeds a limit.
|
||||||
'data (%s bytes) due to its current configuration.');
|
// 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']));
|
$this->clientError(sprintf($msg, $_SERVER['CONTENT_LENGTH']));
|
||||||
return;
|
return;
|
||||||
@ -218,6 +218,7 @@ class ApiStatusesUpdateAction extends ApiAuthAction
|
|||||||
|
|
||||||
if (empty($this->status)) {
|
if (empty($this->status)) {
|
||||||
$this->clientError(
|
$this->clientError(
|
||||||
|
// TRANS: Client error displayed when the parameter "status" is missing.
|
||||||
_('Client must provide a \'status\' parameter with a value.'),
|
_('Client must provide a \'status\' parameter with a value.'),
|
||||||
400,
|
400,
|
||||||
$this->format
|
$this->format
|
||||||
@ -239,7 +240,11 @@ class ApiStatusesUpdateAction extends ApiAuthAction
|
|||||||
|
|
||||||
$this->clientError(
|
$this->clientError(
|
||||||
sprintf(
|
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()
|
Notice::maxContent()
|
||||||
),
|
),
|
||||||
406,
|
406,
|
||||||
@ -255,7 +260,6 @@ class ApiStatusesUpdateAction extends ApiAuthAction
|
|||||||
$cmd = $inter->handle_command($this->auth_user, $status_shortened);
|
$cmd = $inter->handle_command($this->auth_user, $status_shortened);
|
||||||
|
|
||||||
if ($cmd) {
|
if ($cmd) {
|
||||||
|
|
||||||
if ($this->supported($cmd)) {
|
if ($this->supported($cmd)) {
|
||||||
$cmd->execute(new Channel());
|
$cmd->execute(new Channel());
|
||||||
}
|
}
|
||||||
@ -265,13 +269,10 @@ class ApiStatusesUpdateAction extends ApiAuthAction
|
|||||||
// or not!
|
// or not!
|
||||||
|
|
||||||
$this->notice = $this->auth_user->getCurrentNotice();
|
$this->notice = $this->auth_user->getCurrentNotice();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$reply_to = null;
|
$reply_to = null;
|
||||||
|
|
||||||
if (!empty($this->in_reply_to_status_id)) {
|
if (!empty($this->in_reply_to_status_id)) {
|
||||||
|
|
||||||
// Check whether notice actually exists
|
// Check whether notice actually exists
|
||||||
|
|
||||||
$reply = Notice::staticGet($this->in_reply_to_status_id);
|
$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;
|
$reply_to = $this->in_reply_to_status_id;
|
||||||
} else {
|
} else {
|
||||||
$this->clientError(
|
$this->clientError(
|
||||||
_('Not found.'),
|
// TRANS: Client error displayed when replying to a non-existing notice.
|
||||||
|
_('Parent notice not found.'),
|
||||||
$code = 404,
|
$code = 404,
|
||||||
$this->format
|
$this->format
|
||||||
);
|
);
|
||||||
@ -302,10 +304,9 @@ class ApiStatusesUpdateAction extends ApiAuthAction
|
|||||||
|
|
||||||
if (Notice::contentTooLong($status_shortened)) {
|
if (Notice::contentTooLong($status_shortened)) {
|
||||||
$upload->delete();
|
$upload->delete();
|
||||||
$msg = _(
|
$msg = _m('Maximum notice size is %d character, including attachment URL.',
|
||||||
'Max notice size is %d chars, ' .
|
'Maximum notice size is %d characters, including attachment URL.',
|
||||||
'including attachment URL.'
|
Notice::maxContent());
|
||||||
);
|
|
||||||
$this->clientError(
|
$this->clientError(
|
||||||
sprintf($msg, Notice::maxContent()),
|
sprintf($msg, Notice::maxContent()),
|
||||||
400,
|
400,
|
||||||
@ -344,7 +345,6 @@ class ApiStatusesUpdateAction extends ApiAuthAction
|
|||||||
if (isset($upload)) {
|
if (isset($upload)) {
|
||||||
$upload->attachToNotice($this->notice);
|
$upload->attachToNotice($this->notice);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->showNotice();
|
$this->showNotice();
|
||||||
@ -355,7 +355,6 @@ class ApiStatusesUpdateAction extends ApiAuthAction
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function showNotice()
|
function showNotice()
|
||||||
{
|
{
|
||||||
if (!empty($this->notice)) {
|
if (!empty($this->notice)) {
|
||||||
@ -374,7 +373,6 @@ class ApiStatusesUpdateAction extends ApiAuthAction
|
|||||||
*
|
*
|
||||||
* @return boolean true or false
|
* @return boolean true or false
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function supported($cmd)
|
function supported($cmd)
|
||||||
{
|
{
|
||||||
static $cmdlist = array('MessageCommand', 'SubCommand', 'UnsubCommand',
|
static $cmdlist = array('MessageCommand', 'SubCommand', 'UnsubCommand',
|
||||||
@ -386,5 +384,4 @@ class ApiStatusesUpdateAction extends ApiAuthAction
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -46,10 +46,8 @@ require_once INSTALLDIR . '/lib/apioauthstore.php';
|
|||||||
*
|
*
|
||||||
* @see SettingsAction
|
* @see SettingsAction
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class OauthconnectionssettingsAction extends ConnectSettingsAction
|
class OauthconnectionssettingsAction extends ConnectSettingsAction
|
||||||
{
|
{
|
||||||
|
|
||||||
var $page = null;
|
var $page = null;
|
||||||
var $oauth_token = null;
|
var $oauth_token = null;
|
||||||
|
|
||||||
@ -69,6 +67,7 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction
|
|||||||
|
|
||||||
function title()
|
function title()
|
||||||
{
|
{
|
||||||
|
// TRANS: Title for OAuth connection settings.
|
||||||
return _('Connected applications');
|
return _('Connected applications');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,6 +79,7 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction
|
|||||||
|
|
||||||
function getInstructions()
|
function getInstructions()
|
||||||
{
|
{
|
||||||
|
// TRANS: Instructions for OAuth connection settings.
|
||||||
return _('The following connections exist for your account.');
|
return _('The following connections exist for your account.');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,7 +129,6 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function handlePost()
|
function handlePost()
|
||||||
{
|
{
|
||||||
// CSRF protection
|
// CSRF protection
|
||||||
@ -144,6 +143,7 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction
|
|||||||
if ($this->arg('revoke')) {
|
if ($this->arg('revoke')) {
|
||||||
$this->revokeAccess($this->oauth_token);
|
$this->revokeAccess($this->oauth_token);
|
||||||
} else {
|
} else {
|
||||||
|
// TRANS: Client error when submitting a form with unexpected information.
|
||||||
$this->clientError(_('Unexpected form submission.'), 401);
|
$this->clientError(_('Unexpected form submission.'), 401);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -157,7 +157,6 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction
|
|||||||
* @param int $appId the ID of the application
|
* @param int $appId the ID of the application
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function revokeAccess($token)
|
function revokeAccess($token)
|
||||||
{
|
{
|
||||||
$cur = common_current_user();
|
$cur = common_current_user();
|
||||||
@ -165,6 +164,7 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction
|
|||||||
$appUser = Oauth_application_user::getByUserAndToken($cur, $token);
|
$appUser = Oauth_application_user::getByUserAndToken($cur, $token);
|
||||||
|
|
||||||
if (empty($appUser)) {
|
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);
|
$this->clientError(_('You are not a user of that application.'), 401);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -178,7 +178,9 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction
|
|||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
common_log_db_error($orig, 'DELETE', __FILE__);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,7 +197,9 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction
|
|||||||
);
|
);
|
||||||
|
|
||||||
$msg = sprintf(
|
$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,
|
$app->name,
|
||||||
substr($appUser->token, 0, 7)
|
substr($appUser->token, 0, 7)
|
||||||
);
|
);
|
||||||
@ -205,6 +209,7 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction
|
|||||||
|
|
||||||
function showEmptyListMessage()
|
function showEmptyListMessage()
|
||||||
{
|
{
|
||||||
|
// TRANS: Empty list message when no applications have been authorised yet.
|
||||||
$message = _('You have not authorized any applications to use your account.');
|
$message = _('You have not authorized any applications to use your account.');
|
||||||
|
|
||||||
$this->elementStart('div', 'guide');
|
$this->elementStart('div', 'guide');
|
||||||
@ -222,6 +227,9 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction
|
|||||||
$this->elementStart('p');
|
$this->elementStart('p');
|
||||||
|
|
||||||
$devMsg = sprintf(
|
$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.'),
|
_('Are you a developer? [Register an OAuth client application](%s) to use with this instance of StatusNet.'),
|
||||||
common_local_url('oauthappssettings')
|
common_local_url('oauthappssettings')
|
||||||
);
|
);
|
||||||
@ -233,5 +241,4 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction
|
|||||||
|
|
||||||
$this->elementEnd('section');
|
$this->elementEnd('section');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -263,7 +263,7 @@ class ApiAuthAction extends ApiAction
|
|||||||
|
|
||||||
// show error if the user clicks 'cancel'
|
// show error if the user clicks 'cancel'
|
||||||
// TRANS: Client error thrown when authentication fails becaus a user clicked "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;
|
exit;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -290,7 +290,7 @@ class ApiAuthAction extends ApiAction
|
|||||||
);
|
);
|
||||||
$this->logAuthFailure($msg);
|
$this->logAuthFailure($msg);
|
||||||
// TRANS: Client error thrown when authentication fails.
|
// 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;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -342,7 +342,6 @@ class ApiAuthAction extends ApiAction
|
|||||||
*
|
*
|
||||||
* @param string $logMsg additional log message
|
* @param string $logMsg additional log message
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function logAuthFailure($logMsg)
|
function logAuthFailure($logMsg)
|
||||||
{
|
{
|
||||||
list($proxy, $ip) = common_client_ip();
|
list($proxy, $ip) = common_client_ip();
|
||||||
|
@ -37,7 +37,8 @@ class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore
|
|||||||
$con->consumer_secret = $consumerKey;
|
$con->consumer_secret = $consumerKey;
|
||||||
$result = $con->insert();
|
$result = $con->insert();
|
||||||
if (!$result) {
|
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 = new OAuth_application();
|
||||||
$app->consumer_key = $con->consumer_key;
|
$app->consumer_key = $con->consumer_key;
|
||||||
@ -49,7 +50,8 @@ class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore
|
|||||||
$app->access_type = 3; // read + write
|
$app->access_type = 3; // read + write
|
||||||
$id = $app->insert();
|
$id = $app->insert();
|
||||||
if (!$id) {
|
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 {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
@ -230,7 +232,6 @@ class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore
|
|||||||
*
|
*
|
||||||
* @return OAuthToken $token a new unauthorized OAuth request token
|
* @return OAuthToken $token a new unauthorized OAuth request token
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function new_request_token($consumer, $callback)
|
function new_request_token($consumer, $callback)
|
||||||
{
|
{
|
||||||
$t = new Token();
|
$t = new Token();
|
||||||
@ -255,6 +256,4 @@ class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore
|
|||||||
return new OAuthToken($t->tok, $t->secret);
|
return new OAuthToken($t->tok, $t->secret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -142,10 +142,8 @@ class ApplicationList extends Widget
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Widget to show a list of connected OAuth clients
|
* Widget to show a list of connected OAuth clients
|
||||||
*
|
*
|
||||||
@ -279,7 +277,9 @@ class ConnectedAppsList extends Widget
|
|||||||
$this->out->element(
|
$this->out->element(
|
||||||
'p', array(
|
'p', array(
|
||||||
'class' => 'access_token'),
|
'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->elementStart(
|
||||||
@ -295,11 +295,10 @@ class ConnectedAppsList extends Widget
|
|||||||
$this->out->hidden('oauth_token', $this->connection->token);
|
$this->out->hidden('oauth_token', $this->connection->token);
|
||||||
$this->out->hidden('token', common_session_token());
|
$this->out->hidden('token', common_session_token());
|
||||||
// TRANS: Button label
|
// TRANS: Button label
|
||||||
$this->out->submit('revoke', _('Revoke'));
|
$this->out->submit('revoke', _m('BUTTON','Revoke'));
|
||||||
$this->out->elementEnd('fieldset');
|
$this->out->elementEnd('fieldset');
|
||||||
$this->out->elementEnd('form');
|
$this->out->elementEnd('form');
|
||||||
|
|
||||||
$this->out->elementEnd('li');
|
$this->out->elementEnd('li');
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user