We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit bfdb8385 authored by Zach Copley's avatar Zach Copley

Merge branch '0.9.x' of gitorious.org:statusnet/mainline into 0.9.x

Conflicts:
	actions/apioauthauthorize.php
	lib/apioauthstore.php
parents e56385a7 31f52ec3
......@@ -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
---------
......
......@@ -89,7 +89,7 @@ class AllAction extends ProfileAction
// TRANS: Page title. %1$s is user nickname, %2$d is page number
return sprintf(_('%1$s and friends, page %2$d'), $this->user->nickname, $this->page);
} else {
// TRANS: Page title. %1$s is user nickname
// TRANS: Page title. %s is user nickname
return sprintf(_("%s and friends"), $this->user->nickname);
}
}
......@@ -103,7 +103,7 @@ class AllAction extends ProfileAction
'nickname' =>
$this->user->nickname)
),
// TRANS: %1$s is user nickname
// TRANS: %s is user nickname
sprintf(_('Feed for friends of %s (RSS 1.0)'), $this->user->nickname)),
new Feed(Feed::RSS2,
common_local_url(
......@@ -112,7 +112,7 @@ class AllAction extends ProfileAction
'id' => $this->user->nickname
)
),
// TRANS: %1$s is user nickname
// TRANS: %s is user nickname
sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->user->nickname)),
new Feed(Feed::ATOM,
common_local_url(
......@@ -121,7 +121,7 @@ class AllAction extends ProfileAction
'id' => $this->user->nickname
)
),
// TRANS: %1$s is user nickname
// TRANS: %s is user nickname
sprintf(_('Feed for friends of %s (Atom)'), $this->user->nickname))
);
}
......@@ -134,18 +134,23 @@ class AllAction extends ProfileAction
function showEmptyListMessage()
{
// TRANS: %1$s is user nickname
// TRANS: %s is user nickname
$message = sprintf(_('This is the timeline for %s and friends but no one has posted anything yet.'), $this->user->nickname) . ' ';
if (common_logged_in()) {
$current_user = common_current_user();
if ($this->user->id === $current_user->id) {
// TRANS: Encouragement displayed on logged in user's empty timeline.
// TRANS: This message contains Markdown links. Keep "](" together.
$message .= _('Try subscribing to more people, [join a group](%%action.groups%%) or post something yourself.');
} else {
// TRANS: %1$s is user nickname, %2$s is user nickname, %2$s is user nickname prefixed with "@"
// TRANS: This message contains Markdown links. Keep "](" together.
$message .= sprintf(_('You can try to [nudge %1$s](../%2$s) from their profile or [post something to them](%%%%action.newnotice%%%%?status_textarea=%3$s).'), $this->user->nickname, $this->user->nickname, '@' . $this->user->nickname);
}
} else {
// TRANS: Encoutagement displayed on empty timeline user pages for anonymous users.
// TRANS: %s is a user nickname. This message contains Markdown links. Keep "](" together.
$message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to them.'), $this->user->nickname);
}
......@@ -181,7 +186,7 @@ class AllAction extends ProfileAction
// TRANS: H1 text
$this->element('h1', null, _("You and friends"));
} else {
// TRANS: H1 text. %1$s is user nickname
// TRANS: H1 text. %s is a user nickname
$this->element('h1', null, sprintf(_('%s and friends'), $this->user->nickname));
}
}
......
......@@ -45,7 +45,6 @@ require_once INSTALLDIR . '/lib/apiauth.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 ApiAccountUpdateDeliveryDeviceAction extends ApiAuthAction
{
/**
......@@ -56,7 +55,6 @@ class ApiAccountUpdateDeliveryDeviceAction extends ApiAuthAction
* @return boolean success flag
*
*/
function prepare($args)
{
parent::prepare($args);
......@@ -76,7 +74,6 @@ class ApiAccountUpdateDeliveryDeviceAction extends ApiAuthAction
*
* @return void
*/
function handle($args)
{
parent::handle($args);
......@@ -92,6 +89,7 @@ class ApiAccountUpdateDeliveryDeviceAction extends ApiAuthAction
if (!in_array($this->format, array('xml', 'json'))) {
$this->clientError(
// TRANS: Client error displayed handling a non-existing API method.
_('API method not found.'),
404,
$this->format
......@@ -102,16 +100,14 @@ class ApiAccountUpdateDeliveryDeviceAction extends ApiAuthAction
// Note: Twitter no longer supports IM
if (!in_array(strtolower($this->device), array('sms', 'im', 'none'))) {
$this->clientError(
_(
'You must specify a parameter named ' .
'\'device\' with a value of one of: sms, im, none.'
)
);
// TRANS: Client error displayed when no valid device parameter is provided for a user's delivery device setting.
$this->clientError(_( 'You must specify a parameter named ' .
'\'device\' with a value of one of: sms, im, none.' ));
return;
}
if (empty($this->user)) {
// TRANS: Client error displayed when no existing user is provided for a user's delivery device setting.
$this->clientError(_('No such user.'), 404, $this->format);
return;
}
......@@ -131,6 +127,7 @@ class ApiAccountUpdateDeliveryDeviceAction extends ApiAuthAction
if ($result === false) {
common_log_db_error($this->user, 'UPDATE', __FILE__);
// TRANS: Server error displayed when a user's delivery device cannot be updated.
$this->serverError(_('Could not update user.'));
return;
}
......@@ -155,5 +152,4 @@ class ApiAccountUpdateDeliveryDeviceAction extends ApiAuthAction
$this->endDocument('json');
}
}
}
......@@ -43,10 +43,8 @@ require_once INSTALLDIR . '/lib/apiauth.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 ApiAccountUpdateProfileAction extends ApiAuthAction
{
/**
* Take arguments for running
*
......@@ -55,7 +53,6 @@ class ApiAccountUpdateProfileAction extends ApiAuthAction
* @return boolean success flag
*
*/
function prepare($args)
{
parent::prepare($args);
......@@ -79,7 +76,6 @@ class ApiAccountUpdateProfileAction extends ApiAuthAction
*
* @return void
*/
function handle($args)
{
parent::handle($args);
......@@ -103,6 +99,7 @@ class ApiAccountUpdateProfileAction extends ApiAuthAction
}
if (empty($this->user)) {
// TRANS: Client error displayed if a user could not be found.
$this->clientError(_('No such user.'), 404, $this->format);
return;
}
......@@ -110,6 +107,7 @@ class ApiAccountUpdateProfileAction extends ApiAuthAction
$profile = $this->user->getProfile();
if (empty($profile)) {
// TRANS: Client error displayed if a user profile could not be found.
$this->clientError(_('User has no profile.'));
return;
}
......@@ -145,6 +143,7 @@ class ApiAccountUpdateProfileAction extends ApiAuthAction
if (!$result) {
common_log_db_error($profile, 'UPDATE', __FILE__);
// TRANS: Server error displayed if a user profile could not be saved.
$this->serverError(_('Could not save profile.'));
return;
}
......@@ -163,5 +162,4 @@ class ApiAccountUpdateProfileAction extends ApiAuthAction
$this->endDocument('json');
}
}
}
......@@ -42,10 +42,8 @@ require_once INSTALLDIR . '/lib/apiauth.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 ApiAccountUpdateProfileBackgroundImageAction extends ApiAuthAction
{
var $tile = false;
/**
......@@ -56,7 +54,6 @@ class ApiAccountUpdateProfileBackgroundImageAction extends ApiAuthAction
* @return boolean success flag
*
*/
function prepare($args)
{
parent::prepare($args);
......@@ -76,7 +73,6 @@ class ApiAccountUpdateProfileBackgroundImageAction extends ApiAuthAction
*
* @return void
*/
function handle($args)
{
parent::handle($args);
......@@ -92,6 +88,7 @@ class ApiAccountUpdateProfileBackgroundImageAction extends ApiAuthAction
if (!in_array($this->format, array('xml', 'json'))) {
$this->clientError(
// TRANS: Client error displayed when trying to handle an unknown API method.
_('API method not found.'),
404,
$this->format
......@@ -106,8 +103,11 @@ class ApiAccountUpdateProfileBackgroundImageAction 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;
......@@ -125,7 +125,6 @@ class ApiAccountUpdateProfileBackgroundImageAction extends ApiAuthAction
// is part of the img filename.
if (empty($design)) {
$this->user->query('BEGIN');
// save new design
......@@ -134,6 +133,7 @@ class ApiAccountUpdateProfileBackgroundImageAction extends ApiAuthAction
if (empty($id)) {
common_log_db_error($id, 'INSERT', __FILE__);
// TRANS: Client error displayed when saving design settings fails because of an empty id.
$this->clientError(_('Unable to save your design settings.'));
return;
}
......@@ -144,6 +144,7 @@ class ApiAccountUpdateProfileBackgroundImageAction extends ApiAuthAction
if (empty($result)) {
common_log_db_error($original, 'UPDATE', __FILE__);
// TRANS: Client error displayed when saving design settings fails because of an empty result.
$this->clientError(_('Unable to save your design settings.'));
$this->user->query('ROLLBACK');
return;
......@@ -185,6 +186,7 @@ class ApiAccountUpdateProfileBackgroundImageAction extends ApiAuthAction
if ($result === false) {
common_log_db_error($design, 'UPDATE', __FILE__);
// TRANS: Error displayed when updating design settings fails.
$this->showForm(_('Could not update your design.'));
return;
}
......@@ -192,6 +194,7 @@ class ApiAccountUpdateProfileBackgroundImageAction extends ApiAuthAction
$profile = $this->user->getProfile();
if (empty($profile)) {
// TRANS: Client error displayed when a user has no profile.
$this->clientError(_('User has no profile.'));
return;
}
......@@ -208,5 +211,4 @@ class ApiAccountUpdateProfileBackgroundImageAction extends ApiAuthAction
$this->endDocument('json');
}
}
}
......@@ -46,7 +46,6 @@ require_once INSTALLDIR . '/lib/apiauth.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 ApiBlockCreateAction extends ApiAuthAction
{
var $other = null;
......@@ -59,7 +58,6 @@ class ApiBlockCreateAction extends ApiAuthAction
* @return boolean success flag
*
*/
function prepare($args)
{
parent::prepare($args);
......@@ -79,7 +77,6 @@ class ApiBlockCreateAction extends ApiAuthAction
*
* @return void
*/
function handle($args)
{
parent::handle($args);
......@@ -103,6 +100,7 @@ class ApiBlockCreateAction extends ApiAuthAction
if ($this->user->id == $this->other->id) {
$this->clientError(
// TRANS: Client error displayed when users try to block themselves.
_("You cannot block yourself!"),
403,
$this->format
......@@ -124,10 +122,8 @@ class ApiBlockCreateAction extends ApiAuthAction
$this->showProfile($this->other, $this->format);
$this->endDocument($this->format);
} else {
// TRANS: Server error displayed when blocking a user has failed.
$this->serverError(_('Block user failed.'), 500, $this->format);
}
}
}
......@@ -45,7 +45,6 @@ require_once INSTALLDIR . '/lib/apiauth.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 ApiBlockDestroyAction extends ApiAuthAction
{
var $other = null;
......@@ -58,7 +57,6 @@ class ApiBlockDestroyAction extends ApiAuthAction
* @return boolean success flag
*
*/
function prepare($args)
{
parent::prepare($args);
......@@ -78,7 +76,6 @@ class ApiBlockDestroyAction extends ApiAuthAction
*
* @return void
*/
function handle($args)
{
parent::handle($args);
......@@ -112,10 +109,8 @@ class ApiBlockDestroyAction extends ApiAuthAction
$this->showProfile($this->other, $this->format);
$this->endDocument($this->format);
} else {
// TRANS: Server error displayed when unblocking a user has failed.
$this->serverError(_('Unblock user failed.'));
}
}
}
......@@ -121,9 +121,9 @@ class ApiDirectMessageNewAction extends ApiAuthAction
} else {
$content_shortened = common_shorten_links($this->content);
if (Message::contentTooLong($content_shortened)) {
// TRANS: Client error displayed when message content is too long.
// TRANS: %d is the maximum number of characters for a message.
$this->clientError(
// TRANS: Client error displayed when message content is too long.
// TRANS: %d is the maximum number of characters for a message.
sprintf(_m('That\'s too long. Maximum message size is %d character.', 'That\'s too long. Maximum message size is %d characters.', Message::maxContent()),
Message::maxContent()
),
......
......@@ -48,7 +48,6 @@ require_once INSTALLDIR . '/lib/apiauth.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 ApiFavoriteCreateAction extends ApiAuthAction
{
var $notice = null;
......@@ -61,7 +60,6 @@ class ApiFavoriteCreateAction extends ApiAuthAction
* @return boolean success flag
*
*/
function prepare($args)
{
parent::prepare($args);
......@@ -81,7 +79,6 @@ class ApiFavoriteCreateAction extends ApiAuthAction
*
* @return void
*/
function handle($args)
{
parent::handle($args);
......@@ -107,6 +104,7 @@ class ApiFavoriteCreateAction extends ApiAuthAction
if (empty($this->notice)) {
$this->clientError(
// TRANS: Client error displayed when requesting a status with a non-existing ID.
_('No status found with that ID.'),
404,
$this->format
......@@ -118,6 +116,7 @@ class ApiFavoriteCreateAction extends ApiAuthAction
if ($this->user->hasFave($this->notice)) {
$this->clientError(
// TRANS: Client error displayed when trying to mark a notice favourite that already is a favourite.
_('This status is already a favorite.'),
403,
$this->format
......@@ -129,6 +128,7 @@ class ApiFavoriteCreateAction extends ApiAuthAction
if (empty($fave)) {
$this->clientError(
// TRANS: Client error displayed when marking a notice as favourite fails.
_('Could not create favorite.'),
403,
$this->format
......@@ -166,5 +166,4 @@ class ApiFavoriteCreateAction extends ApiAuthAction
// XXX: notify by SMS
}
}
}
......@@ -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');
......@@ -101,6 +99,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 {
......
......@@ -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.'));
}
......@@ -154,10 +157,15 @@ class ApiOauthAuthorizeAction extends Action
// XXX Force credentials check?
// XXX OpenID
// @fixme this should probably use a unified login form handler
$user = null;
if (Event::handle('StartOAuthLoginCheck', array($this, &$user))) {
$user = common_check_user($this->nickname, $this->password);
}
Event::handle('EndOAuthLoginCheck', array($this, &$user));
$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;
}
......@@ -207,7 +215,6 @@ class ApiOauthAuthorizeAction extends Action
}
if (!empty($this->callback)) {
$targetUrl = $this->getCallback(
$this->callback,
array(
......@@ -218,9 +225,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(
......@@ -257,6 +262,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.'));
}
}
......@@ -307,6 +313,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');
}
......@@ -324,6 +331,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());
......@@ -340,6 +348,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 <strong>%1$s</strong> by ' .
'<strong>%2$s</strong> would like the ability ' .
'to <strong>%3$s</strong> your %4$s account data. ' .
......@@ -355,34 +366,43 @@ class ApiOauthAuthorizeAction extends Action
$this->elementEnd('li');
$this->elementEnd('ul');
// quickie hack
$button = false;
if (!common_logged_in()) {
$this->elementStart('fieldset');
$this->element('legend', null, _('Account'));
$this->elementStart('ul', 'form_data');
$this->elementStart('li');
$this->input('nickname', _('Nickname'));
$this->elementEnd('li');
$this->elementStart('li');
$this->password('password', _('Password'));
$this->elementEnd('li');
$this->elementEnd('ul');
$this->elementEnd('fieldset');
if (Event::handle('StartOAuthLoginForm', array($this, &$button))) {
$this->elementStart('fieldset');
// 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');
}
Event::handle('EndOAuthLoginForm', array($this, &$button));
}
$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',