Merge branch '0.9.x' into inblob

This commit is contained in:
Evan Prodromou 2010-01-11 16:28:27 -08:00
commit ecb3abf84c
166 changed files with 24000 additions and 21588 deletions

View File

@ -81,7 +81,7 @@ class AllAction extends ProfileAction
function title() function title()
{ {
if ($this->page > 1) { if ($this->page > 1) {
return sprintf(_("%s and friends, page %d"), $this->user->nickname, $this->page); return sprintf(_("%1$s and friends, page %2$d"), $this->user->nickname, $this->page);
} else { } else {
return sprintf(_("%s and friends"), $this->user->nickname); return sprintf(_("%s and friends"), $this->user->nickname);
} }
@ -131,7 +131,7 @@ class AllAction extends ProfileAction
if ($this->user->id === $current_user->id) { if ($this->user->id === $current_user->id) {
$message .= _('Try subscribing to more people, [join a group](%%action.groups%%) or post something yourself.'); $message .= _('Try subscribing to more people, [join a group](%%action.groups%%) or post something yourself.');
} else { } else {
$message .= sprintf(_('You can try to [nudge %s](../%s) from his profile or [post something to his or her attention](%%%%action.newnotice%%%%?status_textarea=%s).'), $this->user->nickname, $this->user->nickname, '@' . $this->user->nickname); $message .= sprintf(_('You can try to [nudge %1$s](../%2$s) from his profile or [post something to his or her attention](%%%%action.newnotice%%%%?status_textarea=%3$s).'), $this->user->nickname, $this->user->nickname, '@' . $this->user->nickname);
} }
} else { } else {
$message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to his or her attention.'), $this->user->nickname); $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to his or her attention.'), $this->user->nickname);

View File

@ -153,7 +153,7 @@ class ApiDirectMessageAction extends ApiAuthAction
$this->showJsonDirectMessages(); $this->showJsonDirectMessages();
break; break;
default: default:
$this->clientError(_('API method not found!'), $code = 404); $this->clientError(_('API method not found.'), $code = 404);
break; break;
} }
} }

View File

@ -96,7 +96,7 @@ class ApiFavoriteCreateAction extends ApiAuthAction
if (!in_array($this->format, array('xml', 'json'))) { if (!in_array($this->format, array('xml', 'json'))) {
$this->clientError( $this->clientError(
_('API method not found!'), _('API method not found.'),
404, 404,
$this->format $this->format
); );
@ -116,7 +116,7 @@ class ApiFavoriteCreateAction extends ApiAuthAction
if ($this->user->hasFave($this->notice)) { if ($this->user->hasFave($this->notice)) {
$this->clientError( $this->clientError(
_('This status is already a favorite!'), _('This status is already a favorite.'),
403, 403,
$this->format $this->format
); );

View File

@ -97,7 +97,7 @@ class ApiFavoriteDestroyAction extends ApiAuthAction
if (!in_array($this->format, array('xml', 'json'))) { if (!in_array($this->format, array('xml', 'json'))) {
$this->clientError( $this->clientError(
_('API method not found!'), _('API method not found.'),
404, 404,
$this->format $this->format
); );
@ -119,7 +119,7 @@ class ApiFavoriteDestroyAction extends ApiAuthAction
if (!$fave->find(true)) { if (!$fave->find(true)) {
$this->clientError( $this->clientError(
_('That status is not a favorite!'), _('That status is not a favorite.'),
403, 403,
$this->favorite $this->favorite
); );

View File

@ -97,7 +97,7 @@ class ApiFriendshipsCreateAction extends ApiAuthAction
if (!in_array($this->format, array('xml', 'json'))) { if (!in_array($this->format, array('xml', 'json'))) {
$this->clientError( $this->clientError(
_('API method not found!'), _('API method not found.'),
404, 404,
$this->format $this->format
); );

View File

@ -97,7 +97,7 @@ class ApiFriendshipsDestroyAction extends ApiAuthAction
if (!in_array($this->format, array('xml', 'json'))) { if (!in_array($this->format, array('xml', 'json'))) {
$this->clientError( $this->clientError(
_('API method not found!'), _('API method not found.'),
404, 404,
$this->format $this->format
); );
@ -117,7 +117,7 @@ class ApiFriendshipsDestroyAction extends ApiAuthAction
if ($this->user->id == $this->other->id) { if ($this->user->id == $this->other->id) {
$this->clientError( $this->clientError(
_("You cannot unfollow yourself!"), _("You cannot unfollow yourself."),
403, 403,
$this->format $this->format
); );

View File

@ -126,7 +126,7 @@ class ApiFriendshipsShowAction extends ApiBareAuthAction
parent::handle($args); parent::handle($args);
if (!in_array($this->format, array('xml', 'json'))) { if (!in_array($this->format, array('xml', 'json'))) {
$this->clientError(_('API method not found!'), 404); $this->clientError(_('API method not found.'), 404);
return; return;
} }

View File

@ -133,7 +133,7 @@ class ApiGroupCreateAction extends ApiAuthAction
break; break;
default: default:
$this->clientError( $this->clientError(
_('API method not found!'), _('API method not found.'),
404, 404,
$this->format $this->format
); );

View File

@ -111,7 +111,7 @@ class ApiGroupIsMemberAction extends ApiBareAuthAction
break; break;
default: default:
$this->clientError( $this->clientError(
_('API method not found!'), _('API method not found.'),
400, 400,
$this->format $this->format
); );

View File

@ -135,7 +135,7 @@ class ApiGroupJoinAction extends ApiAuthAction
common_log_db_error($member, 'INSERT', __FILE__); common_log_db_error($member, 'INSERT', __FILE__);
$this->serverError( $this->serverError(
sprintf( sprintf(
_('Could not join user %s to group %s.'), _('Could not join user %1$s to group %2$s.'),
$this->user->nickname, $this->user->nickname,
$this->group->nickname $this->group->nickname
) )
@ -152,7 +152,7 @@ class ApiGroupJoinAction extends ApiAuthAction
break; break;
default: default:
$this->clientError( $this->clientError(
_('API method not found!'), _('API method not found.'),
404, 404,
$this->format $this->format
); );

View File

@ -121,7 +121,7 @@ class ApiGroupLeaveAction extends ApiAuthAction
common_log_db_error($member, 'DELETE', __FILE__); common_log_db_error($member, 'DELETE', __FILE__);
$this->serverError( $this->serverError(
sprintf( sprintf(
_('Could not remove user %s from group %s.'), _('Could not remove user %1$s from group %2$s.'),
$this->user->nickname, $this->user->nickname,
$this->group->nickname $this->group->nickname
) )
@ -138,7 +138,7 @@ class ApiGroupLeaveAction extends ApiAuthAction
break; break;
default: default:
$this->clientError( $this->clientError(
_('API method not found!'), _('API method not found.'),
404, 404,
$this->format $this->format
); );

View File

@ -100,7 +100,7 @@ class ApiGroupListAction extends ApiBareAuthAction
array('nickname' => $this->user->nickname) array('nickname' => $this->user->nickname)
); );
$subtitle = sprintf( $subtitle = sprintf(
_("Groups %s is a member of on %s."), _("Groups %1$s is a member of on %2$s."),
$this->user->nickname, $this->user->nickname,
$sitename $sitename
); );
@ -129,7 +129,7 @@ class ApiGroupListAction extends ApiBareAuthAction
break; break;
default: default:
$this->clientError( $this->clientError(
_('API method not found!'), _('API method not found.'),
404, 404,
$this->format $this->format
); );

View File

@ -117,7 +117,7 @@ class ApiGroupListAllAction extends ApiPrivateAuthAction
break; break;
default: default:
$this->clientError( $this->clientError(
_('API method not found!'), _('API method not found.'),
404, 404,
$this->format $this->format
); );

View File

@ -103,7 +103,7 @@ class ApiGroupMembershipAction extends ApiPrivateAuthAction
break; break;
default: default:
$this->clientError( $this->clientError(
_('API method not found!'), _('API method not found.'),
404, 404,
$this->format $this->format
); );

View File

@ -102,7 +102,7 @@ class ApiGroupShowAction extends ApiPrivateAuthAction
$this->showSingleJsonGroup($this->group); $this->showSingleJsonGroup($this->group);
break; break;
default: default:
$this->clientError(_('API method not found!'), 404, $this->format); $this->clientError(_('API method not found.'), 404, $this->format);
break; break;
} }

View File

@ -85,7 +85,7 @@ class ApiHelpTestAction extends ApiPrivateAuthAction
$this->endDocument('json'); $this->endDocument('json');
} else { } else {
$this->clientError( $this->clientError(
_('API method not found!'), _('API method not found.'),
404, 404,
$this->format $this->format
); );

View File

@ -99,7 +99,7 @@ class ApiStatusesDestroyAction extends ApiAuthAction
parent::handle($args); parent::handle($args);
if (!in_array($this->format, array('xml', 'json'))) { if (!in_array($this->format, array('xml', 'json'))) {
$this->clientError(_('API method not found!'), $code = 404); $this->clientError(_('API method not found.'), $code = 404);
return; return;
} }

View File

@ -109,7 +109,7 @@ class ApiStatusesRetweetsAction extends ApiAuthAction
$this->showJsonTimeline($strm); $this->showJsonTimeline($strm);
break; break;
default: default:
$this->clientError(_('API method not found!'), $code = 404); $this->clientError(_('API method not found.'), $code = 404);
break; break;
} }
} }

View File

@ -105,7 +105,7 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
parent::handle($args); parent::handle($args);
if (!in_array($this->format, array('xml', 'json'))) { if (!in_array($this->format, array('xml', 'json'))) {
$this->clientError(_('API method not found!'), $code = 404); $this->clientError(_('API method not found.'), $code = 404);
return; return;
} }

View File

@ -130,7 +130,7 @@ class ApiStatusnetConfigAction extends ApiAction
break; break;
default: default:
$this->clientError( $this->clientError(
_('API method not found!'), _('API method not found.'),
404, 404,
$this->format $this->format
); );

View File

@ -90,7 +90,7 @@ class ApiStatusnetVersionAction extends ApiPrivateAuthAction
break; break;
default: default:
$this->clientError( $this->clientError(
_('API method not found!'), _('API method not found.'),
404, 404,
$this->format $this->format
); );

View File

@ -108,7 +108,7 @@ class ApiSubscriptionsAction extends ApiBareAuthAction
parent::handle($args); parent::handle($args);
if (!in_array($this->format, array('xml', 'json'))) { if (!in_array($this->format, array('xml', 'json'))) {
$this->clientError(_('API method not found!'), $code = 404); $this->clientError(_('API method not found.'), $code = 404);
return; return;
} }

View File

@ -105,7 +105,7 @@ class ApiTimelineFavoritesAction extends ApiBareAuthAction
$sitename = common_config('site', 'name'); $sitename = common_config('site', 'name');
$title = sprintf( $title = sprintf(
_('%s / Favorites from %s'), _('%1$s / Favorites from %2$s'),
$sitename, $sitename,
$this->user->nickname $this->user->nickname
); );
@ -117,7 +117,7 @@ class ApiTimelineFavoritesAction extends ApiBareAuthAction
array('nickname' => $this->user->nickname) array('nickname' => $this->user->nickname)
); );
$subtitle = sprintf( $subtitle = sprintf(
_('%s updates favorited by %s / %s.'), _('%1$s updates favorited by %2$s / %2$s.'),
$sitename, $sitename,
$profile->getBestName(), $profile->getBestName(),
$this->user->nickname $this->user->nickname
@ -143,7 +143,7 @@ class ApiTimelineFavoritesAction extends ApiBareAuthAction
$this->showJsonTimeline($this->notices); $this->showJsonTimeline($this->notices);
break; break;
default: default:
$this->clientError(_('API method not found!'), $code = 404); $this->clientError(_('API method not found.'), $code = 404);
break; break;
} }
} }

View File

@ -153,7 +153,7 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
$this->showJsonTimeline($this->notices); $this->showJsonTimeline($this->notices);
break; break;
default: default:
$this->clientError(_('API method not found!'), $code = 404); $this->clientError(_('API method not found.'), $code = 404);
break; break;
} }
} }

View File

@ -147,7 +147,7 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction
break; break;
default: default:
$this->clientError( $this->clientError(
_('API method not found!'), _('API method not found.'),
404, 404,
$this->format $this->format
); );

View File

@ -153,7 +153,7 @@ class ApiTimelineHomeAction extends ApiBareAuthAction
$this->showJsonTimeline($this->notices); $this->showJsonTimeline($this->notices);
break; break;
default: default:
$this->clientError(_('API method not found!'), $code = 404); $this->clientError(_('API method not found.'), $code = 404);
break; break;
} }
} }

View File

@ -148,7 +148,7 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction
$this->showJsonTimeline($this->notices); $this->showJsonTimeline($this->notices);
break; break;
default: default:
$this->clientError(_('API method not found!'), $code = 404); $this->clientError(_('API method not found.'), $code = 404);
break; break;
} }
} }

View File

@ -128,7 +128,7 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction
$this->showJsonTimeline($this->notices); $this->showJsonTimeline($this->notices);
break; break;
default: default:
$this->clientError(_('API method not found!'), $code = 404); $this->clientError(_('API method not found.'), $code = 404);
break; break;
} }
} }

View File

@ -119,7 +119,7 @@ class ApiTimelineRetweetedByMeAction extends ApiAuthAction
break; break;
default: default:
$this->clientError(_('API method not found!'), $code = 404); $this->clientError(_('API method not found.'), $code = 404);
break; break;
} }
} }

View File

@ -118,7 +118,7 @@ class ApiTimelineRetweetedToMeAction extends ApiAuthAction
break; break;
default: default:
$this->clientError(_('API method not found!'), $code = 404); $this->clientError(_('API method not found.'), $code = 404);
break; break;
} }
} }

View File

@ -119,7 +119,7 @@ class ApiTimelineRetweetsOfMeAction extends ApiAuthAction
break; break;
default: default:
$this->clientError(_('API method not found!'), $code = 404); $this->clientError(_('API method not found.'), $code = 404);
break; break;
} }
} }

View File

@ -138,7 +138,7 @@ class ApiTimelineTagAction extends ApiPrivateAuthAction
$this->showJsonTimeline($this->notices); $this->showJsonTimeline($this->notices);
break; break;
default: default:
$this->clientError(_('API method not found!'), $code = 404); $this->clientError(_('API method not found.'), $code = 404);
break; break;
} }
} }

View File

@ -162,7 +162,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
$this->showJsonTimeline($this->notices); $this->showJsonTimeline($this->notices);
break; break;
default: default:
$this->clientError(_('API method not found!'), $code = 404); $this->clientError(_('API method not found.'), $code = 404);
break; break;
} }

View File

@ -98,7 +98,7 @@ class ApiUserShowAction extends ApiPrivateAuthAction
} }
if (!in_array($this->format, array('xml', 'json'))) { if (!in_array($this->format, array('xml', 'json'))) {
$this->clientError(_('API method not found!'), $code = 404); $this->clientError(_('API method not found.'), $code = 404);
return; return;
} }

View File

@ -70,14 +70,14 @@ class BlockedfromgroupAction extends GroupDesignAction
} }
if (!$nickname) { if (!$nickname) {
$this->clientError(_('No nickname'), 404); $this->clientError(_('No nickname.'), 404);
return false; return false;
} }
$this->group = User_group::staticGet('nickname', $nickname); $this->group = User_group::staticGet('nickname', $nickname);
if (!$this->group) { if (!$this->group) {
$this->clientError(_('No such group'), 404); $this->clientError(_('No such group.'), 404);
return false; return false;
} }
@ -90,7 +90,7 @@ class BlockedfromgroupAction extends GroupDesignAction
return sprintf(_('%s blocked profiles'), return sprintf(_('%s blocked profiles'),
$this->group->nickname); $this->group->nickname);
} else { } else {
return sprintf(_('%s blocked profiles, page %d'), return sprintf(_('%1$s blocked profiles, page %2$d'),
$this->group->nickname, $this->group->nickname,
$this->page); $this->page);
} }

View File

@ -155,7 +155,7 @@ class DeletenoticeAction extends Action
if (!$token || $token != common_session_token()) { if (!$token || $token != common_session_token()) {
$this->showForm(_('There was a problem with your session token. ' . $this->showForm(_('There was a problem with your session token. ' .
' Try again, please.')); 'Try again, please.'));
return; return;
} }

View File

@ -81,7 +81,7 @@ class EditgroupAction extends GroupDesignAction
} }
if (!$nickname) { if (!$nickname) {
$this->clientError(_('No nickname'), 404); $this->clientError(_('No nickname.'), 404);
return false; return false;
} }
@ -93,14 +93,14 @@ class EditgroupAction extends GroupDesignAction
} }
if (!$this->group) { if (!$this->group) {
$this->clientError(_('No such group'), 404); $this->clientError(_('No such group.'), 404);
return false; return false;
} }
$cur = common_current_user(); $cur = common_current_user();
if (!$cur->isAdmin($this->group)) { if (!$cur->isAdmin($this->group)) {
$this->clientError(_('You must be an admin to edit the group'), 403); $this->clientError(_('You must be an admin to edit the group.'), 403);
return false; return false;
} }
@ -165,7 +165,7 @@ class EditgroupAction extends GroupDesignAction
{ {
$cur = common_current_user(); $cur = common_current_user();
if (!$cur->isAdmin($this->group)) { if (!$cur->isAdmin($this->group)) {
$this->clientError(_('You must be an admin to edit the group'), 403); $this->clientError(_('You must be an admin to edit the group.'), 403);
return; return;
} }

View File

@ -57,7 +57,7 @@ class EmailsettingsAction extends AccountSettingsAction
function title() function title()
{ {
return _('Email Settings'); return _('Email settings');
} }
/** /**
@ -118,7 +118,7 @@ class EmailsettingsAction extends AccountSettingsAction
} else { } else {
$this->elementStart('ul', 'form_data'); $this->elementStart('ul', 'form_data');
$this->elementStart('li'); $this->elementStart('li');
$this->input('email', _('Email Address'), $this->input('email', _('Email address'),
($this->arg('email')) ? $this->arg('email') : null, ($this->arg('email')) ? $this->arg('email') : null,
_('Email address, like "UserName@example.org"')); _('Email address, like "UserName@example.org"'));
$this->elementEnd('li'); $this->elementEnd('li');
@ -328,7 +328,7 @@ class EmailsettingsAction extends AccountSettingsAction
return; return;
} }
if (!Validate::email($email, common_config('email', 'check_domain'))) { if (!Validate::email($email, common_config('email', 'check_domain'))) {
$this->showForm(_('Not a valid email address')); $this->showForm(_('Not a valid email address.'));
return; return;
} else if ($user->email == $email) { } else if ($user->email == $email) {
$this->showForm(_('That is already your email address.')); $this->showForm(_('That is already your email address.'));

View File

@ -159,7 +159,7 @@ class GroupblockAction extends Action
$this->hidden('token', common_session_token()); $this->hidden('token', common_session_token());
$this->element('legend', _('Block user')); $this->element('legend', _('Block user'));
$this->element('p', null, $this->element('p', null,
sprintf(_('Are you sure you want to block user "%s" from the group "%s"? '. sprintf(_('Are you sure you want to block user "%1$s" from the group "%2$s"? '.
'They will be removed from the group, unable to post, and '. 'They will be removed from the group, unable to post, and '.
'unable to subscribe to the group in the future.'), 'unable to subscribe to the group in the future.'),
$this->profile->getBestName(), $this->profile->getBestName(),

View File

@ -71,7 +71,7 @@ class GroupbyidAction extends Action
$id = $this->arg('id'); $id = $this->arg('id');
if (!$id) { if (!$id) {
$this->clientError(_('No ID')); $this->clientError(_('No ID.'));
return false; return false;
} }
@ -80,7 +80,7 @@ class GroupbyidAction extends Action
$this->group = User_group::staticGet('id', $id); $this->group = User_group::staticGet('id', $id);
if (!$this->group) { if (!$this->group) {
$this->clientError(_('No such group'), 404); $this->clientError(_('No such group.'), 404);
return false; return false;
} }

View File

@ -81,7 +81,7 @@ class GroupDesignSettingsAction extends DesignSettingsAction
} }
if (!$nickname) { if (!$nickname) {
$this->clientError(_('No nickname'), 404); $this->clientError(_('No nickname.'), 404);
return false; return false;
} }
@ -94,14 +94,14 @@ class GroupDesignSettingsAction extends DesignSettingsAction
} }
if (!$this->group) { if (!$this->group) {
$this->clientError(_('No such group'), 404); $this->clientError(_('No such group.'), 404);
return false; return false;
} }
$cur = common_current_user(); $cur = common_current_user();
if (!$cur->isAdmin($this->group)) { if (!$cur->isAdmin($this->group)) {
$this->clientError(_('You must be an admin to edit the group'), 403); $this->clientError(_('You must be an admin to edit the group.'), 403);
return false; return false;
} }
@ -284,7 +284,7 @@ class GroupDesignSettingsAction extends DesignSettingsAction
if (empty($id)) { if (empty($id)) {
common_log_db_error($id, 'INSERT', __FILE__); common_log_db_error($id, 'INSERT', __FILE__);
$this->showForm(_('Unable to save your design settings!')); $this->showForm(_('Unable to save your design settings.'));
return; return;
} }
@ -294,7 +294,7 @@ class GroupDesignSettingsAction extends DesignSettingsAction
if (empty($result)) { if (empty($result)) {
common_log_db_error($original, 'UPDATE', __FILE__); common_log_db_error($original, 'UPDATE', __FILE__);
$this->showForm(_('Unable to save your design settings!')); $this->showForm(_('Unable to save your design settings.'));
$this->group->query('ROLLBACK'); $this->group->query('ROLLBACK');
return; return;
} }

View File

@ -83,7 +83,7 @@ class GrouplogoAction extends GroupDesignAction
} }
if (!$nickname) { if (!$nickname) {
$this->clientError(_('No nickname'), 404); $this->clientError(_('No nickname.'), 404);
return false; return false;
} }
@ -96,14 +96,14 @@ class GrouplogoAction extends GroupDesignAction
} }
if (!$this->group) { if (!$this->group) {
$this->clientError(_('No such group'), 404); $this->clientError(_('No such group.'), 404);
return false; return false;
} }
$cur = common_current_user(); $cur = common_current_user();
if (!$cur->isAdmin($this->group)) { if (!$cur->isAdmin($this->group)) {
$this->clientError(_('You must be an admin to edit the group'), 403); $this->clientError(_('You must be an admin to edit the group.'), 403);
return false; return false;
} }
@ -175,7 +175,7 @@ class GrouplogoAction extends GroupDesignAction
if (!$profile) { if (!$profile) {
common_log_db_error($user, 'SELECT', __FILE__); common_log_db_error($user, 'SELECT', __FILE__);
$this->serverError(_('User without matching profile')); $this->serverError(_('User without matching profile.'));
return; return;
} }

View File

@ -73,14 +73,14 @@ class GroupmembersAction extends GroupDesignAction
} }
if (!$nickname) { if (!$nickname) {
$this->clientError(_('No nickname'), 404); $this->clientError(_('No nickname.'), 404);
return false; return false;
} }
$this->group = User_group::staticGet('nickname', $nickname); $this->group = User_group::staticGet('nickname', $nickname);
if (!$this->group) { if (!$this->group) {
$this->clientError(_('No such group'), 404); $this->clientError(_('No such group.'), 404);
return false; return false;
} }
@ -93,7 +93,7 @@ class GroupmembersAction extends GroupDesignAction
return sprintf(_('%s group members'), return sprintf(_('%s group members'),
$this->group->nickname); $this->group->nickname);
} else { } else {
return sprintf(_('%s group members, page %d'), return sprintf(_('%1$s group members, page %2$d'),
$this->group->nickname, $this->group->nickname,
$this->page); $this->page);
} }

View File

@ -56,7 +56,7 @@ class ImsettingsAction extends ConnectSettingsAction
function title() function title()
{ {
return _('IM Settings'); return _('IM settings');
} }
/** /**
@ -121,7 +121,7 @@ class ImsettingsAction extends ConnectSettingsAction
} else { } else {
$this->elementStart('ul', 'form_data'); $this->elementStart('ul', 'form_data');
$this->elementStart('li'); $this->elementStart('li');
$this->input('jabber', _('IM Address'), $this->input('jabber', _('IM address'),
($this->arg('jabber')) ? $this->arg('jabber') : null, ($this->arg('jabber')) ? $this->arg('jabber') : null,
sprintf(_('Jabber or GTalk address, '. sprintf(_('Jabber or GTalk address, '.
'like "UserName@example.org". '. 'like "UserName@example.org". '.

View File

@ -56,7 +56,7 @@ class InboxAction extends MailboxAction
function title() function title()
{ {
if ($this->page > 1) { if ($this->page > 1) {
return sprintf(_("Inbox for %s - page %d"), $this->user->nickname, return sprintf(_("Inbox for %1$s - page %2$d"), $this->user->nickname,
$this->page); $this->page);
} else { } else {
return sprintf(_("Inbox for %s"), $this->user->nickname); return sprintf(_("Inbox for %s"), $this->user->nickname);

View File

@ -128,7 +128,7 @@ class InviteAction extends CurrentUserDesignAction
$this->element('p', null, _('You are already subscribed to these users:')); $this->element('p', null, _('You are already subscribed to these users:'));
$this->elementStart('ul'); $this->elementStart('ul');
foreach ($this->already as $other) { foreach ($this->already as $other) {
$this->element('li', null, sprintf(_('%s (%s)'), $other->nickname, $other->email)); $this->element('li', null, sprintf(_('%1$s (%2$s)'), $other->nickname, $other->email));
} }
$this->elementEnd('ul'); $this->elementEnd('ul');
} }
@ -136,7 +136,7 @@ class InviteAction extends CurrentUserDesignAction
$this->element('p', null, _('These people are already users and you were automatically subscribed to them:')); $this->element('p', null, _('These people are already users and you were automatically subscribed to them:'));
$this->elementStart('ul'); $this->elementStart('ul');
foreach ($this->subbed as $other) { foreach ($this->subbed as $other) {
$this->element('li', null, sprintf(_('%s (%s)'), $other->nickname, $other->email)); $this->element('li', null, sprintf(_('%1$s (%2$s)'), $other->nickname, $other->email));
} }
$this->elementEnd('ul'); $this->elementEnd('ul');
} }

View File

@ -73,21 +73,21 @@ class JoingroupAction extends Action
} }
if (!$nickname) { if (!$nickname) {
$this->clientError(_('No nickname'), 404); $this->clientError(_('No nickname.'), 404);
return false; return false;
} }
$this->group = User_group::staticGet('nickname', $nickname); $this->group = User_group::staticGet('nickname', $nickname);
if (!$this->group) { if (!$this->group) {
$this->clientError(_('No such group'), 404); $this->clientError(_('No such group.'), 404);
return false; return false;
} }
$cur = common_current_user(); $cur = common_current_user();
if ($cur->isMember($this->group)) { if ($cur->isMember($this->group)) {
$this->clientError(_('You are already a member of that group'), 403); $this->clientError(_('You are already a member of that group.'), 403);
return false; return false;
} }
@ -125,14 +125,14 @@ class JoingroupAction extends Action
if (!$result) { if (!$result) {
common_log_db_error($member, 'INSERT', __FILE__); common_log_db_error($member, 'INSERT', __FILE__);
$this->serverError(sprintf(_('Could not join user %s to group %s'), $this->serverError(sprintf(_('Could not join user %1$s to group %2$s.'),
$cur->nickname, $this->group->nickname)); $cur->nickname, $this->group->nickname));
} }
if ($this->boolean('ajax')) { if ($this->boolean('ajax')) {
$this->startHTML('text/xml;charset=utf-8'); $this->startHTML('text/xml;charset=utf-8');
$this->elementStart('head'); $this->elementStart('head');
$this->element('title', null, sprintf(_('%s joined group %s'), $this->element('title', null, sprintf(_('%1$s joined group %2$s'),
$cur->nickname, $cur->nickname,
$this->group->nickname)); $this->group->nickname));
$this->elementEnd('head'); $this->elementEnd('head');

View File

@ -124,14 +124,14 @@ class LeavegroupAction extends Action
if (!$result) { if (!$result) {
common_log_db_error($member, 'DELETE', __FILE__); common_log_db_error($member, 'DELETE', __FILE__);
$this->serverError(sprintf(_('Could not remove user %s from group %s'), $this->serverError(sprintf(_('Could not remove user %1$s from group %2$s.'),
$cur->nickname, $this->group->nickname)); $cur->nickname, $this->group->nickname));
} }
if ($this->boolean('ajax')) { if ($this->boolean('ajax')) {
$this->startHTML('text/xml;charset=utf-8'); $this->startHTML('text/xml;charset=utf-8');
$this->elementStart('head'); $this->elementStart('head');
$this->element('title', null, sprintf(_('%s left group %s'), $this->element('title', null, sprintf(_('%1$s left group %2$s'),
$cur->nickname, $cur->nickname,
$this->group->nickname)); $this->group->nickname));
$this->elementEnd('head'); $this->elementEnd('head');

View File

@ -76,15 +76,10 @@ class LoginAction extends Action
{ {
parent::handle($args); parent::handle($args);
$disabled = common_config('logincommand','disabled');
$disabled = isset($disabled) && $disabled;
if (common_is_real_login()) { if (common_is_real_login()) {
$this->clientError(_('Already logged in.')); $this->clientError(_('Already logged in.'));
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') { } else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$this->checkLogin(); $this->checkLogin();
} else if (!$disabled && isset($args['user_id']) && isset($args['token'])){
$this->checkLogin($args['user_id'],$args['token']);
} else { } else {
common_ensure_session(); common_ensure_session();
$this->showForm(); $this->showForm();
@ -103,46 +98,30 @@ class LoginAction extends Action
function checkLogin($user_id=null, $token=null) function checkLogin($user_id=null, $token=null)
{ {
if(isset($token) && isset($user_id)){ // XXX: login throttle
//Token based login (from the LoginCommand)
$login_token = Login_token::staticGet('user_id',$user_id);
if($login_token && $login_token->token == $token){
if($login_token->modified > time()+2*60){
//token has expired
//delete the token as it is useless
$login_token->delete();
$this->showForm(_('Invalid or expired token.'));
return;
}else{
//delete the token so it cannot be reused
$login_token->delete();
//it's a valid token - let them log in
$user = User::staticGet('id', $user_id);
//$user = User::staticGet('nickname', "candrews");
}
}else{
$this->showForm(_('Invalid or expired token.'));
return;
}
}else{
// Regular form submission login
// XXX: login throttle // CSRF protection - token set in NoticeForm
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
$st = common_session_token();
if (empty($token)) {
common_log(LOG_WARNING, 'No token provided by client.');
} else if (empty($st)) {
common_log(LOG_WARNING, 'No session token stored.');
} else {
common_log(LOG_WARNING, 'Token = ' . $token . ' and session token = ' . $st);
}
// CSRF protection - token set in NoticeForm $this->clientError(_('There was a problem with your session token. '.
$token = $this->trimmed('token'); 'Try again, please.'));
if (!$token || $token != common_session_token()) { return;
$this->clientError(_('There was a problem with your session token. '.
'Try again, please.'));
return;
}
$nickname = $this->trimmed('nickname');
$password = $this->arg('password');
$user = common_check_user($nickname, $password);
} }
$nickname = $this->trimmed('nickname');
$password = $this->arg('password');
$user = common_check_user($nickname, $password);
if (!$user) { if (!$user) {
$this->showForm(_('Incorrect username or password.')); $this->showForm(_('Incorrect username or password.'));
return; return;
@ -165,6 +144,7 @@ class LoginAction extends Action
if ($url) { if ($url) {
// We don't have to return to it again // We don't have to return to it again
common_set_returnto(null); common_set_returnto(null);
$url = common_inject_session($url);
} else { } else {
$url = common_local_url('all', $url = common_local_url('all',
array('nickname' => array('nickname' =>
@ -240,9 +220,9 @@ class LoginAction extends Action
function showContent() function showContent()
{ {
$this->elementStart('form', array('method' => 'post', $this->elementStart('form', array('method' => 'post',
'id' => 'form_login', 'id' => 'form_login',
'class' => 'form_settings', 'class' => 'form_settings',
'action' => common_local_url('login'))); 'action' => common_local_url('login')));
$this->elementStart('fieldset'); $this->elementStart('fieldset');
$this->element('legend', null, _('Login to site')); $this->element('legend', null, _('Login to site'));
$this->elementStart('ul', 'form_data'); $this->elementStart('ul', 'form_data');
@ -255,7 +235,7 @@ class LoginAction extends Action
$this->elementStart('li'); $this->elementStart('li');
$this->checkbox('rememberme', _('Remember me'), false, $this->checkbox('rememberme', _('Remember me'), false,
_('Automatically login in the future; ' . _('Automatically login in the future; ' .
'not for shared computers!')); 'not for shared computers!'));
$this->elementEnd('li'); $this->elementEnd('li');
$this->elementEnd('ul'); $this->elementEnd('ul');
$this->submit('submit', _('Login')); $this->submit('submit', _('Login'));

View File

@ -92,7 +92,7 @@ class MakeadminAction extends Action
return false; return false;
} }
if ($this->profile->isAdmin($this->group)) { if ($this->profile->isAdmin($this->group)) {
$this->clientError(sprintf(_('%s is already an admin for group "%s".'), $this->clientError(sprintf(_('%1$s is already an admin for group "%2$s".'),
$this->profile->getBestName(), $this->profile->getBestName(),
$this->group->getBestName()), $this->group->getBestName()),
401); 401);
@ -129,7 +129,7 @@ class MakeadminAction extends Action
'profile_id' => $this->profile->id)); 'profile_id' => $this->profile->id));
if (empty($member)) { if (empty($member)) {
$this->serverError(_('Can\'t get membership record for %s in group %s'), $this->serverError(_('Can\'t get membership record for %1$s in group %2$s.'),
$this->profile->getBestName(), $this->profile->getBestName(),
$this->group->getBestName()); $this->group->getBestName());
} }
@ -142,7 +142,7 @@ class MakeadminAction extends Action
if (!$result) { if (!$result) {
common_log_db_error($member, 'UPDATE', __FILE__); common_log_db_error($member, 'UPDATE', __FILE__);
$this->serverError(_('Can\'t make %s an admin for group %s'), $this->serverError(_('Can\'t make %1$s an admin for group %2$s.'),
$this->profile->getBestName(), $this->profile->getBestName(),
$this->group->getBestName()); $this->group->getBestName());
} }

View File

@ -182,7 +182,7 @@ class NewmessageAction extends Action
$this->elementEnd('head'); $this->elementEnd('head');
$this->elementStart('body'); $this->elementStart('body');
$this->element('p', array('id' => 'command_result'), $this->element('p', array('id' => 'command_result'),
sprintf(_('Direct message to %s sent'), sprintf(_('Direct message to %s sent.'),
$this->other->nickname)); $this->other->nickname));
$this->elementEnd('body'); $this->elementEnd('body');
$this->elementEnd('html'); $this->elementEnd('html');

View File

@ -88,7 +88,7 @@ class NoticesearchAction extends SearchAction
return array(new Feed(Feed::RSS1, common_local_url('noticesearchrss', return array(new Feed(Feed::RSS1, common_local_url('noticesearchrss',
array('q' => $q)), array('q' => $q)),
sprintf(_('Search results for "%s" on %s'), sprintf(_('Search results for "%1$s" on %2$s'),
$q, common_config('site', 'name')))); $q, common_config('site', 'name'))));
} }

145
actions/otp.php Normal file
View File

@ -0,0 +1,145 @@
<?php
/**
* StatusNet, the distributed open-source microblogging tool
*
* Allow one-time password login
*
* PHP version 5
*
* LICENCE: This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @category Login
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @copyright 2010 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
* @link http://status.net/
*/
if (!defined('STATUSNET')) {
exit(1);
}
/**
* Allow one-time password login
*
* This action will automatically log in the user identified by the user_id
* parameter. A login_token record must be constructed beforehand, typically
* by code where the user is already authenticated.
*
* @category Login
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @copyright 2010 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
* @link http://status.net/
*/
class OtpAction extends Action
{
var $user;
var $token;
var $rememberme;
var $returnto;
var $lt;
function prepare($args)
{
parent::prepare($args);
if (common_is_real_login()) {
$this->clientError(_('Already logged in.'));
return false;
}
$id = $this->trimmed('user_id');
if (empty($id)) {
$this->clientError(_('No user ID specified.'));
return false;
}
$this->user = User::staticGet('id', $id);
if (empty($this->user)) {
$this->clientError(_('No such user.'));
return false;
}
$this->token = $this->trimmed('token');
if (empty($this->token)) {
$this->clientError(_('No login token specified.'));
return false;
}
$this->lt = Login_token::staticGet('user_id', $id);
if (empty($this->lt)) {
$this->clientError(_('No login token requested.'));
return false;
}
if ($this->lt->token != $this->token) {
$this->clientError(_('Invalid login token specified.'));
return false;
}
if ($this->lt->modified > time() + Login_token::TIMEOUT) {
//token has expired
//delete the token as it is useless
$this->lt->delete();
$this->lt = null;
$this->clientError(_('Login token expired.'));
return false;
}
$this->rememberme = $this->boolean('rememberme');
$this->returnto = $this->trimmed('returnto');
return true;
}
function handle($args)
{
parent::handle($args);
// success!
if (!common_set_user($this->user)) {
$this->serverError(_('Error setting user. You are probably not authorized.'));
return;
}
// We're now logged in; disable the lt
$this->lt->delete();
$this->lt = null;
if ($this->rememberme) {
common_rememberme($this->user);
}
if (!empty($this->returnto)) {
$url = $this->returnto;
// We don't have to return to it again
common_set_returnto(null);
} else {
$url = common_local_url('all',
array('nickname' =>
$this->user->nickname));
}
common_redirect($url, 303);
}
}

View File

@ -55,7 +55,7 @@ class OutboxAction extends MailboxAction
function title() function title()
{ {
if ($this->page > 1) { if ($this->page > 1) {
return sprintf(_("Outbox for %s - page %d"), return sprintf(_("Outbox for %1$s - page %2$d"),
$this->user->nickname, $page); $this->user->nickname, $page);
} else { } else {
return sprintf(_("Outbox for %s"), $this->user->nickname); return sprintf(_("Outbox for %s"), $this->user->nickname);

View File

@ -305,7 +305,7 @@ class PathsAdminPanelForm extends AdminForm
$this->unli(); $this->unli();
$this->li(); $this->li();
$this->input('sslserver', _('SSL Server'), $this->input('sslserver', _('SSL server'),
_('Server to direct SSL requests to'), 'site'); _('Server to direct SSL requests to'), 'site');
$this->unli(); $this->unli();
$this->out->elementEnd('ul'); $this->out->elementEnd('ul');

View File

@ -141,7 +141,7 @@ class PeopletagAction extends Action
*/ */
function title() function title()
{ {
return sprintf(_('Users self-tagged with %s - page %d'), return sprintf(_('Users self-tagged with %1$s - page %2$d'),
$this->tag, $this->page); $this->tag, $this->page);
} }

View File

@ -87,8 +87,8 @@ class PostnoticeAction extends Action
$license = $_POST['omb_notice_license']; $license = $_POST['omb_notice_license'];
$site_license = common_config('license', 'url'); $site_license = common_config('license', 'url');
if ($license && !common_compatible_license($license, $site_license)) { if ($license && !common_compatible_license($license, $site_license)) {
throw new Exception(sprintf(_('Notice license %s is not ' . throw new Exception(sprintf(_('Notice license %1$s is not ' .
'compatible with site license %s.'), 'compatible with site license %2$s.'),
$license, $site_license)); $license, $site_license));
} }
} }

View File

@ -259,6 +259,7 @@ class RegisterAction extends Action
// Re-init language env in case it changed (not yet, but soon) // Re-init language env in case it changed (not yet, but soon)
common_init_language(); common_init_language();
$this->showSuccess(); $this->showSuccess();
} else { } else {
$this->showForm(_('Invalid username or password.')); $this->showForm(_('Invalid username or password.'));
@ -534,9 +535,9 @@ class RegisterAction extends Action
array('nickname' => $nickname)); array('nickname' => $nickname));
$this->elementStart('div', 'success'); $this->elementStart('div', 'success');
$instr = sprintf(_('Congratulations, %s! And welcome to %%%%site.name%%%%. '. $instr = sprintf(_('Congratulations, %1$s! And welcome to %%%%site.name%%%%. '.
'From here, you may want to...'. "\n\n" . 'From here, you may want to...'. "\n\n" .
'* Go to [your profile](%s) '. '* Go to [your profile](%2$s) '.
'and post your first message.' . "\n" . 'and post your first message.' . "\n" .
'* Add a [Jabber/GTalk address]'. '* Add a [Jabber/GTalk address]'.
'(%%%%action.imsettings%%%%) '. '(%%%%action.imsettings%%%%) '.

View File

@ -124,7 +124,7 @@ class RepliesAction extends OwnerDesignAction
if ($this->page == 1) { if ($this->page == 1) {
return sprintf(_("Replies to %s"), $this->user->nickname); return sprintf(_("Replies to %s"), $this->user->nickname);
} else { } else {
return sprintf(_("Replies to %s, page %d"), return sprintf(_("Replies to %1$s, page %2$d"),
$this->user->nickname, $this->user->nickname,
$this->page); $this->page);
} }
@ -195,14 +195,14 @@ class RepliesAction extends OwnerDesignAction
function showEmptyListMessage() function showEmptyListMessage()
{ {
$message = sprintf(_('This is the timeline showing replies to %s but %s hasn\'t received a notice to his attention yet.'), $this->user->nickname, $this->user->nickname) . ' '; $message = sprintf(_('This is the timeline showing replies to %1$s but %2$s hasn\'t received a notice to his attention yet.'), $this->user->nickname, $this->user->nickname) . ' ';
if (common_logged_in()) { if (common_logged_in()) {
$current_user = common_current_user(); $current_user = common_current_user();
if ($this->user->id === $current_user->id) { if ($this->user->id === $current_user->id) {
$message .= _('You can engage other users in a conversation, subscribe to more people or [join groups](%%action.groups%%).'); $message .= _('You can engage other users in a conversation, subscribe to more people or [join groups](%%action.groups%%).');
} else { } else {
$message .= sprintf(_('You can try to [nudge %s](../%s) or [post something to his or her attention](%%%%action.newnotice%%%%?status_textarea=%s).'), $this->user->nickname, $this->user->nickname, '@' . $this->user->nickname); $message .= sprintf(_('You can try to [nudge %1$s](../%2$s) or [post something to his or her attention](%%%%action.newnotice%%%%?status_textarea=%3$s).'), $this->user->nickname, $this->user->nickname, '@' . $this->user->nickname);
} }
} }
else { else {

View File

@ -76,7 +76,7 @@ class ShowfavoritesAction extends OwnerDesignAction
if ($this->page == 1) { if ($this->page == 1) {
return sprintf(_("%s's favorite notices"), $this->user->nickname); return sprintf(_("%s's favorite notices"), $this->user->nickname);
} else { } else {
return sprintf(_("%s's favorite notices, page %d"), return sprintf(_("%1$s's favorite notices, page %2$d"),
$this->user->nickname, $this->user->nickname,
$this->page); $this->page);
} }

View File

@ -81,7 +81,7 @@ class ShowgroupAction extends GroupDesignAction
if ($this->page == 1) { if ($this->page == 1) {
return sprintf(_("%s group"), $base); return sprintf(_("%s group"), $base);
} else { } else {
return sprintf(_("%s group, page %d"), return sprintf(_("%1$s group, page %2$d"),
$base, $base,
$this->page); $this->page);
} }
@ -118,7 +118,7 @@ class ShowgroupAction extends GroupDesignAction
} }
if (!$nickname) { if (!$nickname) {
$this->clientError(_('No nickname'), 404); $this->clientError(_('No nickname.'), 404);
return false; return false;
} }
@ -134,7 +134,7 @@ class ShowgroupAction extends GroupDesignAction
common_redirect(common_local_url('groupbyid', $args), 301); common_redirect(common_local_url('groupbyid', $args), 301);
return false; return false;
} else { } else {
$this->clientError(_('No such group'), 404); $this->clientError(_('No such group.'), 404);
return false; return false;
} }
} }

View File

@ -76,7 +76,7 @@ class ShowstreamAction extends ProfileAction
if ($this->page == 1) { if ($this->page == 1) {
return $base; return $base;
} else { } else {
return sprintf(_("%s, page %d"), return sprintf(_("%1$s, page %2$d"),
$base, $base,
$this->page); $this->page);
} }
@ -119,7 +119,7 @@ class ShowstreamAction extends ProfileAction
common_local_url('userrss', common_local_url('userrss',
array('nickname' => $this->user->nickname, array('nickname' => $this->user->nickname,
'tag' => $this->tag)), 'tag' => $this->tag)),
sprintf(_('Notice feed for %s tagged %s (RSS 1.0)'), sprintf(_('Notice feed for %1$s tagged %2$s (RSS 1.0)'),
$this->user->nickname, $this->tag))); $this->user->nickname, $this->tag)));
} }
@ -188,14 +188,14 @@ class ShowstreamAction extends ProfileAction
function showEmptyListMessage() function showEmptyListMessage()
{ {
$message = sprintf(_('This is the timeline for %s but %s hasn\'t posted anything yet.'), $this->user->nickname, $this->user->nickname) . ' '; $message = sprintf(_('This is the timeline for %1$s but %2$s hasn\'t posted anything yet.'), $this->user->nickname, $this->user->nickname) . ' ';
if (common_logged_in()) { if (common_logged_in()) {
$current_user = common_current_user(); $current_user = common_current_user();
if ($this->user->id === $current_user->id) { if ($this->user->id === $current_user->id) {
$message .= _('Seen anything interesting recently? You haven\'t posted any notices yet, now would be a good time to start :)'); $message .= _('Seen anything interesting recently? You haven\'t posted any notices yet, now would be a good time to start :)');
} else { } else {
$message .= sprintf(_('You can try to nudge %s or [post something to his or her attention](%%%%action.newnotice%%%%?status_textarea=%s).'), $this->user->nickname, '@' . $this->user->nickname); $message .= sprintf(_('You can try to nudge %1$s or [post something to his or her attention](%%%%action.newnotice%%%%?status_textarea=%2$s).'), $this->user->nickname, '@' . $this->user->nickname);
} }
} }
else { else {

View File

@ -151,10 +151,10 @@ class SiteadminpanelAction extends AdminPanelAction
$values['site']['email'] = common_canonical_email($values['site']['email']); $values['site']['email'] = common_canonical_email($values['site']['email']);
if (empty($values['site']['email'])) { if (empty($values['site']['email'])) {
$this->clientError(_('You must have a valid contact email address')); $this->clientError(_('You must have a valid contact email address.'));
} }
if (!Validate::email($values['site']['email'], common_config('email', 'check_domain'))) { if (!Validate::email($values['site']['email'], common_config('email', 'check_domain'))) {
$this->clientError(_('Not a valid email address')); $this->clientError(_('Not a valid email address.'));
} }
// Validate timezone // Validate timezone
@ -169,7 +169,7 @@ class SiteadminpanelAction extends AdminPanelAction
if (!is_null($values['site']['language']) && if (!is_null($values['site']['language']) &&
!in_array($values['site']['language'], array_keys(get_nice_language_list()))) { !in_array($values['site']['language'], array_keys(get_nice_language_list()))) {
$this->clientError(sprintf(_('Unknown language "%s"'), $values['site']['language'])); $this->clientError(sprintf(_('Unknown language "%s".'), $values['site']['language']));
} }
// Validate report URL // Validate report URL

View File

@ -55,7 +55,7 @@ class SmssettingsAction extends ConnectSettingsAction
function title() function title()
{ {
return _('SMS Settings'); return _('SMS settings');
} }
/** /**
@ -135,7 +135,7 @@ class SmssettingsAction extends ConnectSettingsAction
} else { } else {
$this->elementStart('ul', 'form_data'); $this->elementStart('ul', 'form_data');
$this->elementStart('li'); $this->elementStart('li');
$this->input('sms', _('SMS Phone number'), $this->input('sms', _('SMS phone number'),
($this->arg('sms')) ? $this->arg('sms') : null, ($this->arg('sms')) ? $this->arg('sms') : null,
_('Phone number, no punctuation or spaces, '. _('Phone number, no punctuation or spaces, '.
'with area code')); 'with area code'));

View File

@ -49,7 +49,7 @@ class SubscribersAction extends GalleryAction
if ($this->page == 1) { if ($this->page == 1) {
return sprintf(_('%s subscribers'), $this->user->nickname); return sprintf(_('%s subscribers'), $this->user->nickname);
} else { } else {
return sprintf(_('%s subscribers, page %d'), return sprintf(_('%1$s subscribers, page %2$d'),
$this->user->nickname, $this->user->nickname,
$this->page); $this->page);
} }

View File

@ -51,7 +51,7 @@ class SubscriptionsAction extends GalleryAction
if ($this->page == 1) { if ($this->page == 1) {
return sprintf(_('%s subscriptions'), $this->user->nickname); return sprintf(_('%s subscriptions'), $this->user->nickname);
} else { } else {
return sprintf(_('%s subscriptions, page %d'), return sprintf(_('%1$s subscriptions, page %2$d'),
$this->user->nickname, $this->user->nickname,
$this->page); $this->page);
} }

View File

@ -65,7 +65,7 @@ class TagAction extends Action
if ($this->page == 1) { if ($this->page == 1) {
return sprintf(_("Notices tagged with %s"), $this->tag); return sprintf(_("Notices tagged with %s"), $this->tag);
} else { } else {
return sprintf(_("Notices tagged with %s, page %d"), return sprintf(_("Notices tagged with %1$s, page %2$d"),
$this->tag, $this->tag,
$this->page); $this->page);
} }

View File

@ -163,8 +163,8 @@ class TagotherAction extends Action
$token = $this->trimmed('token'); $token = $this->trimmed('token');
if (!$token || $token != common_session_token()) { if (!$token || $token != common_session_token()) {
$this->showForm(_('There was a problem with your session token.'. $this->showForm(_('There was a problem with your session token. '.
' Try again, please.')); 'Try again, please.'));
return; return;
} }

View File

@ -81,7 +81,7 @@ class UnsubscribeAction extends Action
$other = Profile::staticGet('id', $other_id); $other = Profile::staticGet('id', $other_id);
if (!$other) { if (!$other) {
$this->clientError(_('No profile with that id.')); $this->clientError(_('No profile with that ID.'));
return; return;
} }

View File

@ -59,8 +59,8 @@ class UpdateprofileAction extends Action
$license = $_POST['omb_listenee_license']; $license = $_POST['omb_listenee_license'];
$site_license = common_config('license', 'url'); $site_license = common_config('license', 'url');
if (!common_compatible_license($license, $site_license)) { if (!common_compatible_license($license, $site_license)) {
$this->clientError(sprintf(_('Listenee stream license %s is not '. $this->clientError(sprintf(_('Listenee stream license %1$s is not '.
'compatible with site license %s.'), 'compatible with site license %2$s.'),
$license, $site_license)); $license, $site_license));
return false; return false;
} }

View File

@ -293,7 +293,7 @@ class UserauthorizationAction extends Action
$user = User::staticGet('uri', $listener); $user = User::staticGet('uri', $listener);
if (!$user) { if (!$user) {
throw new Exception(sprintf(_('Listener URI %s not found here'), throw new Exception(sprintf(_('Listener URI %s not found here.'),
$listener)); $listener));
} }
@ -327,8 +327,8 @@ class UserauthorizationAction extends Action
$license = $_GET['omb_listenee_license']; $license = $_GET['omb_listenee_license'];
$site_license = common_config('license', 'url'); $site_license = common_config('license', 'url');
if (!common_compatible_license($license, $site_license)) { if (!common_compatible_license($license, $site_license)) {
throw new Exception(sprintf(_('Listenee stream license %s is not ' . throw new Exception(sprintf(_('Listenee stream license %1$s is not ' .
'compatible with site license %s.'), 'compatible with site license %2$s.'),
$license, $site_license)); $license, $site_license));
} }

View File

@ -207,7 +207,7 @@ class UserDesignSettingsAction extends DesignSettingsAction
if (empty($id)) { if (empty($id)) {
common_log_db_error($id, 'INSERT', __FILE__); common_log_db_error($id, 'INSERT', __FILE__);
$this->showForm(_('Unable to save your design settings!')); $this->showForm(_('Unable to save your design settings.'));
return; return;
} }
@ -217,7 +217,7 @@ class UserDesignSettingsAction extends DesignSettingsAction
if (empty($result)) { if (empty($result)) {
common_log_db_error($original, 'UPDATE', __FILE__); common_log_db_error($original, 'UPDATE', __FILE__);
$this->showForm(_('Unable to save your design settings!')); $this->showForm(_('Unable to save your design settings.'));
$user->query('ROLLBACK'); $user->query('ROLLBACK');
return; return;
} }
@ -260,7 +260,7 @@ class UserDesignSettingsAction extends DesignSettingsAction
if (empty($id)) { if (empty($id)) {
common_log_db_error($id, 'INSERT', __FILE__); common_log_db_error($id, 'INSERT', __FILE__);
$this->showForm(_('Unable to save your design settings!')); $this->showForm(_('Unable to save your design settings.'));
return; return;
} }
@ -270,7 +270,7 @@ class UserDesignSettingsAction extends DesignSettingsAction
if (empty($result)) { if (empty($result)) {
common_log_db_error($original, 'UPDATE', __FILE__); common_log_db_error($original, 'UPDATE', __FILE__);
$this->showForm(_('Unable to save your design settings!')); $this->showForm(_('Unable to save your design settings.'));
$user->query('ROLLBACK'); $user->query('ROLLBACK');
return; return;
} }

View File

@ -61,7 +61,7 @@ class UsergroupsAction extends OwnerDesignAction
if ($this->page == 1) { if ($this->page == 1) {
return sprintf(_("%s groups"), $this->user->nickname); return sprintf(_("%s groups"), $this->user->nickname);
} else { } else {
return sprintf(_("%s groups, page %d"), return sprintf(_("%1$s groups, page %2$d"),
$this->user->nickname, $this->user->nickname,
$this->page); $this->page);
} }

View File

@ -150,7 +150,7 @@ class VersionAction extends Action
{ {
$this->elementStart('p'); $this->elementStart('p');
$this->raw(sprintf(_('This site is powered by %s version %s, '. $this->raw(sprintf(_('This site is powered by %1$s version %2$s, '.
'Copyright 2008-2010 StatusNet, Inc. '. 'Copyright 2008-2010 StatusNet, Inc. '.
'and contributors.'), 'and contributors.'),
XMLStringer::estring('a', array('href' => 'http://status.net/'), XMLStringer::estring('a', array('href' => 'http://status.net/'),

View File

@ -80,7 +80,14 @@ class File extends Memcached_DataObject
if (isset($redir_data['type']) if (isset($redir_data['type'])
&& (('text/html' === substr($redir_data['type'], 0, 9) || 'application/xhtml+xml' === substr($redir_data['type'], 0, 21))) && (('text/html' === substr($redir_data['type'], 0, 9) || 'application/xhtml+xml' === substr($redir_data['type'], 0, 21)))
&& ($oembed_data = File_oembed::_getOembed($given_url))) { && ($oembed_data = File_oembed::_getOembed($given_url))) {
$fo = File_oembed::staticGet('file_id', $file_id);
if (empty($fo)) {
File_oembed::saveNew($oembed_data, $file_id); File_oembed::saveNew($oembed_data, $file_id);
} else {
common_log(LOG_WARNING, "Strangely, a File_oembed object exists for new file $file_id", __FILE__);
}
} }
return $x; return $x;
} }

View File

@ -115,7 +115,13 @@ class File_oembed extends Memcached_DataObject
} }
$file_oembed->insert(); $file_oembed->insert();
if (!empty($data->thumbnail_url)) { if (!empty($data->thumbnail_url)) {
File_thumbnail::saveNew($data, $file_id); $ft = File_thumbnail::staticGet('file_id', $file_id);
if (!empty($ft)) {
common_log(LOG_WARNING, "Strangely, a File_thumbnail object exists for new file $file_id",
__FILE__);
} else {
File_thumbnail::saveNew($data, $file_id);
}
} }
} }
} }

View File

@ -40,6 +40,8 @@ class Login_token extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */ /* the code above is auto generated do not remove the tag below */
###END_AUTOCODE ###END_AUTOCODE
const TIMEOUT = 120; // seconds after which to timeout the token
/* /*
DB_DataObject calculates the sequence key(s) by taking the first key returned by the keys() function. DB_DataObject calculates the sequence key(s) by taking the first key returned by the keys() function.
In this case, the keys() function returns user_id as the first key. user_id is not a sequence, but In this case, the keys() function returns user_id as the first key. user_id is not a sequence, but
@ -52,4 +54,29 @@ class Login_token extends Memcached_DataObject
{ {
return array(false,false); return array(false,false);
} }
function makeNew($user)
{
$login_token = Login_token::staticGet('user_id', $user->id);
if (!empty($login_token)) {
$login_token->delete();
}
$login_token = new Login_token();
$login_token->user_id = $user->id;
$login_token->token = common_good_rand(16);
$login_token->created = common_sql_now();
$result = $login_token->insert();
if (!$result) {
common_log_db_error($login_token, 'INSERT', __FILE__);
throw new Exception(sprintf(_('Could not create login token for %s'),
$user->nickname));
}
return $login_token;
}
} }

View File

@ -19,6 +19,8 @@
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
class Memcached_DataObject extends DB_DataObject class Memcached_DataObject extends DB_DataObject
{ {
/** /**
@ -66,6 +68,7 @@ class Memcached_DataObject extends DB_DataObject
// Clear this out so we don't accidentally break global // Clear this out so we don't accidentally break global
// state in *this* process. // state in *this* process.
$this->_DB_resultid = null; $this->_DB_resultid = null;
// We don't have any local DBO refs, so clear these out. // We don't have any local DBO refs, so clear these out.
$this->_link_loaded = false; $this->_link_loaded = false;
} }
@ -90,42 +93,30 @@ class Memcached_DataObject extends DB_DataObject
unset($i); unset($i);
} }
$i = Memcached_DataObject::getcached($cls, $k, $v); $i = Memcached_DataObject::getcached($cls, $k, $v);
if ($i === false) { // false == cache miss if ($i) {
$i = DB_DataObject::factory($cls);
if (empty($i)) {
$i = false;
return $i;
}
$result = $i->get($k, $v);
if ($result) {
// Hit!
$i->encache();
} else {
// save the fact that no such row exists
$c = self::memcache();
if (!empty($c)) {
$ck = self::cachekey($cls, $k, $v);
$c->set($ck, null);
}
$i = false;
}
}
return $i;
}
/**
* @fixme Should this return false on lookup fail to match staticGet?
*/
function pkeyGet($cls, $kv)
{
$i = Memcached_DataObject::multicache($cls, $kv);
if ($i !== false) { // false == cache miss
return $i; return $i;
} else { } else {
$i = DB_DataObject::factory($cls); $i = DB_DataObject::factory($cls);
if (empty($i)) { if (empty($i)) {
return false; return false;
} }
$result = $i->get($k, $v);
if ($result) {
$i->encache();
return $i;
} else {
return false;
}
}
}
function &pkeyGet($cls, $kv)
{
$i = Memcached_DataObject::multicache($cls, $kv);
if ($i) {
return $i;
} else {
$i = new $cls();
foreach ($kv as $k => $v) { foreach ($kv as $k => $v) {
$i->$k = $v; $i->$k = $v;
} }
@ -133,11 +124,6 @@ class Memcached_DataObject extends DB_DataObject
$i->encache(); $i->encache();
} else { } else {
$i = null; $i = null;
$c = self::memcache();
if (!empty($c)) {
$ck = self::multicacheKey($cls, $kv);
$c->set($ck, null);
}
} }
return $i; return $i;
} }
@ -146,9 +132,6 @@ class Memcached_DataObject extends DB_DataObject
function insert() function insert()
{ {
$result = parent::insert(); $result = parent::insert();
if ($result) {
$this->encache(); // in case of cached negative lookups
}
return $result; return $result;
} }
@ -188,23 +171,21 @@ class Memcached_DataObject extends DB_DataObject
if (!$c) { if (!$c) {
return false; return false;
} else { } else {
return $c->get(Memcached_DataObject::cacheKey($cls, $k, $v)); $obj = $c->get(Memcached_DataObject::cacheKey($cls, $k, $v));
if (0 == strcasecmp($cls, 'User')) {
// Special case for User
if (is_object($obj) && is_object($obj->id)) {
common_log(LOG_ERR, "User " . $obj->nickname . " was cached with User as ID; deleting");
$c->delete(Memcached_DataObject::cacheKey($cls, $k, $v));
return false;
}
}
return $obj;
} }
} }
function keyTypes() function keyTypes()
{ {
// ini-based classes return number-indexed arrays. handbuilt
// classes return column => keytype. Make this uniform.
$keys = $this->keys();
$keyskeys = array_keys($keys);
if (is_string($keyskeys[0])) {
return $keys;
}
global $_DB_DATAOBJECT; global $_DB_DATAOBJECT;
if (!isset($_DB_DATAOBJECT['INI'][$this->_database][$this->__table."__keys"])) { if (!isset($_DB_DATAOBJECT['INI'][$this->_database][$this->__table."__keys"])) {
$this->databaseStructure(); $this->databaseStructure();
@ -216,90 +197,73 @@ class Memcached_DataObject extends DB_DataObject
function encache() function encache()
{ {
$c = $this->memcache(); $c = $this->memcache();
if (!$c) { if (!$c) {
return false; return false;
} } else if ($this->tableName() == 'user' && is_object($this->id)) {
// Special case for User bug
$keys = $this->_allCacheKeys(); $e = new Exception();
common_log(LOG_ERR, __METHOD__ . ' caching user with User object as ID ' .
foreach ($keys as $key) { str_replace("\n", " ", $e->getTraceAsString()));
$c->set($key, $this); return false;
} else {
$pkey = array();
$pval = array();
$types = $this->keyTypes();
ksort($types);
foreach ($types as $key => $type) {
if ($type == 'K') {
$pkey[] = $key;
$pval[] = $this->$key;
} else {
$c->set($this->cacheKey($this->tableName(), $key, $this->$key), $this);
}
}
# XXX: should work for both compound and scalar pkeys
$pvals = implode(',', $pval);
$pkeys = implode(',', $pkey);
$c->set($this->cacheKey($this->tableName(), $pkeys, $pvals), $this);
} }
} }
function decache() function decache()
{ {
$c = $this->memcache(); $c = $this->memcache();
if (!$c) { if (!$c) {
return false; return false;
} } else {
$pkey = array();
$keys = $this->_allCacheKeys(); $pval = array();
$types = $this->keyTypes();
foreach ($keys as $key) { ksort($types);
$c->delete($key, $this); foreach ($types as $key => $type) {
} if ($type == 'K') {
} $pkey[] = $key;
$pval[] = $this->$key;
function _allCacheKeys() } else {
{ $c->delete($this->cacheKey($this->tableName(), $key, $this->$key));
$ckeys = array();
$types = $this->keyTypes();
ksort($types);
$pkey = array();
$pval = array();
foreach ($types as $key => $type) {
assert(!empty($key));
if ($type == 'U') {
if (empty($this->$key)) {
continue;
} }
$ckeys[] = $this->cacheKey($this->tableName(), $key, $this->$key);
} else if ($type == 'K' || $type == 'N') {
$pkey[] = $key;
$pval[] = $this->$key;
} else {
throw new Exception("Unknown key type $key => $type for " . $this->tableName());
} }
# should work for both compound and scalar pkeys
# XXX: comma works for now but may not be safe separator for future keys
$pvals = implode(',', $pval);
$pkeys = implode(',', $pkey);
$c->delete($this->cacheKey($this->tableName(), $pkeys, $pvals));
} }
assert(count($pkey) > 0);
// XXX: should work for both compound and scalar pkeys
$pvals = implode(',', $pval);
$pkeys = implode(',', $pkey);
$ckeys[] = $this->cacheKey($this->tableName(), $pkeys, $pvals);
return $ckeys;
} }
function multicache($cls, $kv) function multicache($cls, $kv)
{ {
ksort($kv); ksort($kv);
$c = self::memcache(); $c = Memcached_DataObject::memcache();
if (!$c) { if (!$c) {
return false; return false;
} else { } else {
return $c->get(self::multicacheKey($cls, $kv)); $pkeys = implode(',', array_keys($kv));
$pvals = implode(',', array_values($kv));
return $c->get(Memcached_DataObject::cacheKey($cls, $pkeys, $pvals));
} }
} }
static function multicacheKey($cls, $kv)
{
ksort($kv);
$pkeys = implode(',', array_keys($kv));
$pvals = implode(',', array_values($kv));
return self::cacheKey($cls, $pkeys, $pvals);
}
function getSearchEngine($table) function getSearchEngine($table)
{ {
require_once INSTALLDIR.'/lib/search_engines.php'; require_once INSTALLDIR.'/lib/search_engines.php';
@ -334,8 +298,7 @@ class Memcached_DataObject extends DB_DataObject
$key_part = common_keyize($cls).':'.md5($qry); $key_part = common_keyize($cls).':'.md5($qry);
$ckey = common_cache_key($key_part); $ckey = common_cache_key($key_part);
$stored = $c->get($ckey); $stored = $c->get($ckey);
if ($stored) {
if ($stored !== false) {
return new ArrayWrapper($stored); return new ArrayWrapper($stored);
} }

View File

@ -150,9 +150,19 @@ class Status_network extends DB_DataObject
} }
if (!empty($sn)) { if (!empty($sn)) {
if (!empty($sn->hostname) && 0 != strcasecmp($sn->hostname, $servername)) {
$sn->redirectToHostname(); // Redirect to the right URL
if (!empty($sn->hostname) &&
empty($_SERVER['HTTPS']) &&
0 != strcasecmp($sn->hostname, $servername)) {
$sn->redirectTo('http://'.$sn->hostname.$_SERVER['REQUEST_URI']);
} else if (!empty($_SERVER['HTTPS']) &&
0 != strcasecmp($sn->hostname, $servername) &&
0 != strcasecmp($sn->nickname.'.'.$wildcard, $servername)) {
$sn->redirectTo('https://'.$sn->nickname.'.'.$wildcard.$_SERVER['REQUEST_URI']);
} }
$dbhost = (empty($sn->dbhost)) ? 'localhost' : $sn->dbhost; $dbhost = (empty($sn->dbhost)) ? 'localhost' : $sn->dbhost;
$dbuser = (empty($sn->dbuser)) ? $sn->nickname : $sn->dbuser; $dbuser = (empty($sn->dbuser)) ? $sn->nickname : $sn->dbuser;
$dbpass = $sn->dbpass; $dbpass = $sn->dbpass;
@ -160,7 +170,11 @@ class Status_network extends DB_DataObject
$config['db']['database'] = "mysqli://$dbuser:$dbpass@$dbhost/$dbname"; $config['db']['database'] = "mysqli://$dbuser:$dbpass@$dbhost/$dbname";
$config['site']['name'] = $sn->sitename; $config['site']['name'] = $sn->sitename;
if (!empty($sn->hostname)) {
$config['site']['server'] = $sn->hostname;
}
if (!empty($sn->theme)) { if (!empty($sn->theme)) {
$config['site']['theme'] = $sn->theme; $config['site']['theme'] = $sn->theme;
@ -179,11 +193,8 @@ class Status_network extends DB_DataObject
// (C) 2006 by Heiko Richler http://www.richler.de/ // (C) 2006 by Heiko Richler http://www.richler.de/
// LGPL // LGPL
function redirectToHostname() function redirectTo($destination)
{ {
$destination = 'http://'.$this->hostname;
$destination .= $_SERVER['REQUEST_URI'];
$old = 'http'. $old = 'http'.
(($_SERVER['HTTPS'] == 'on') ? 'S' : ''). (($_SERVER['HTTPS'] == 'on') ? 'S' : '').
'://'. '://'.

View File

@ -136,7 +136,7 @@ create table notice (
lon decimal(10,7) /* comment 'longitude'*/ , lon decimal(10,7) /* comment 'longitude'*/ ,
location_id integer /* comment 'location id if possible'*/ , location_id integer /* comment 'location id if possible'*/ ,
location_ns integer /* comment 'namespace for location'*/ , location_ns integer /* comment 'namespace for location'*/ ,
repeat_of integer /* comment 'notice this is a repeat of' */ references notice (id) , repeat_of integer /* comment 'notice this is a repeat of' */ references notice (id)
/* FULLTEXT(content) */ /* FULLTEXT(content) */
); );

View File

@ -289,6 +289,7 @@ var SN = { // StatusNet
} }
} }
$('#'+form_id).resetForm(); $('#'+form_id).resetForm();
$('#'+form_id+' #'+SN.C.S.NoticeInReplyTo).val('');
$('#'+form_id+' #'+SN.C.S.NoticeDataAttachSelected).remove(); $('#'+form_id+' #'+SN.C.S.NoticeDataAttachSelected).remove();
SN.U.FormNoticeEnhancements($('#'+form_id)); SN.U.FormNoticeEnhancements($('#'+form_id));
} }

View File

@ -141,7 +141,7 @@ class Action extends HTMLOutputter // lawsuit
function showTitle() function showTitle()
{ {
$this->element('title', null, $this->element('title', null,
sprintf(_("%s - %s"), sprintf(_("%1\$s - %2\$s"),
$this->title(), $this->title(),
common_config('site', 'name'))); common_config('site', 'name')));
} }

View File

@ -140,12 +140,14 @@ class ApiAction extends Action
// Note: some profiles don't have an associated user // Note: some profiles don't have an associated user
$defaultDesign = Design::siteDesign();
if (!empty($user)) { if (!empty($user)) {
$design = $user->getDesign(); $design = $user->getDesign();
} }
if (empty($design)) { if (empty($design)) {
$design = Design::siteDesign(); $design = $defaultDesign;
} }
$color = Design::toWebColor(empty($design->backgroundcolor) ? $defaultDesign->backgroundcolor : $design->backgroundcolor); $color = Design::toWebColor(empty($design->backgroundcolor) ? $defaultDesign->backgroundcolor : $design->backgroundcolor);
@ -787,7 +789,7 @@ class ApiAction extends Action
$from = $message->getFrom(); $from = $message->getFrom();
$entry['title'] = sprintf('Message from %s to %s', $entry['title'] = sprintf('Message from %1$s to %2$s',
$from->nickname, $message->getTo()->nickname); $from->nickname, $message->getTo()->nickname);
$entry['content'] = common_xml_safe_str($message->rendered); $entry['content'] = common_xml_safe_str($message->rendered);

View File

@ -650,25 +650,17 @@ class LoginCommand extends Command
$channel->error($this->user, _('Login command is disabled')); $channel->error($this->user, _('Login command is disabled'));
return; return;
} }
$login_token = Login_token::staticGet('user_id',$this->user->id);
if($login_token){ try {
$login_token->delete(); $login_token = Login_token::makeNew($this->user);
} } catch (Exception $e) {
$login_token = new Login_token(); $channel->error($this->user, $e->getMessage());
$login_token->user_id = $this->user->id;
$login_token->token = common_good_rand(16);
$login_token->created = common_sql_now();
$result = $login_token->insert();
if (!$result) {
common_log_db_error($login_token, 'INSERT', __FILE__);
$channel->error($this->user, sprintf(_('Could not create login token for %s'),
$this->user->nickname));
return;
} }
$channel->output($this->user, $channel->output($this->user,
sprintf(_('This link is useable only once, and is good for only 2 minutes: %s'), sprintf(_('This link is useable only once, and is good for only 2 minutes: %s'),
common_local_url('login', common_local_url('otp',
array('user_id'=>$login_token->user_id, 'token'=>$login_token->token)))); array('user_id' => $login_token->user_id, 'token' => $login_token->token))));
} }
} }

View File

@ -197,7 +197,7 @@ function _have_config()
// XXX: Find a way to use htmlwriter for this instead of handcoded markup // XXX: Find a way to use htmlwriter for this instead of handcoded markup
if (!_have_config()) { if (!_have_config()) {
echo '<p>'. _('No configuration file found. ') .'</p>'; echo '<p>'. _('No configuration file found. ') .'</p>';
echo '<p>'. _('I looked for configuration files in the following places: ') .'<br/> '. implode($_config_files, '<br/>'); echo '<p>'. _('I looked for configuration files in the following places: ') .'<br /> '. implode($_config_files, '<br />');
echo '<p>'. _('You may wish to run the installer to fix this.') .'</p>'; echo '<p>'. _('You may wish to run the installer to fix this.') .'</p>';
echo '<a href="install.php">'. _('Go to the installer.') .'</a>'; echo '<a href="install.php">'. _('Go to the installer.') .'</a>';
exit; exit;

View File

@ -251,11 +251,11 @@ function mail_subscribe_notify_profile($listenee, $other)
common_config('site', 'name'), common_config('site', 'name'),
$other->profileurl, $other->profileurl,
($other->location) ? ($other->location) ?
sprintf(_("Location: %s\n"), $other->location) : '', sprintf(_("Location: %s"), $other->location) . "\n" : '',
($other->homepage) ? ($other->homepage) ?
sprintf(_("Homepage: %s\n"), $other->homepage) : '', sprintf(_("Homepage: %s"), $other->homepage) . "\n" : '',
($other->bio) ? ($other->bio) ?
sprintf(_("Bio: %s\n\n"), $other->bio) : '', sprintf(_("Bio: %s"), $other->bio) . "\n\n" : '',
common_config('site', 'name'), common_config('site', 'name'),
common_local_url('emailsettings')); common_local_url('emailsettings'));
@ -652,4 +652,3 @@ function mail_notify_attn($user, $notice)
common_init_locale(); common_init_locale();
mail_to_user($user, $subject, $body); mail_to_user($user, $subject, $body);
} }

View File

@ -139,7 +139,7 @@ class MailHandler
$headers['From'] = $to; $headers['From'] = $to;
$headers['To'] = $from; $headers['To'] = $from;
$headers['Subject'] = "Command complete"; $headers['Subject'] = _('Command complete');
return mail_send(array($from), $headers, $response); return mail_send(array($from), $headers, $response);
} }
@ -225,7 +225,7 @@ class MailHandler
function unsupported_type($type) function unsupported_type($type)
{ {
$this->error(null, "Unsupported message type: " . $type); $this->error(null, sprintf(_('Unsupported message type: %s'), $type));
} }
function cleanup_msg($msg) function cleanup_msg($msg)

View File

@ -176,7 +176,7 @@ class MediaFile
// Should never actually get here // Should never actually get here
@unlink($_FILES[$param]['tmp_name']); @unlink($_FILES[$param]['tmp_name']);
throw new ClientException(_('File exceeds user\'s quota!')); throw new ClientException(_('File exceeds user\'s quota.'));
return; return;
} }
@ -198,7 +198,7 @@ class MediaFile
} }
} else { } else {
throw new ClientException(_('Could not determine file\'s mime-type!')); throw new ClientException(_('Could not determine file\'s MIME type.'));
return; return;
} }
@ -213,7 +213,7 @@ class MediaFile
// Should never actually get here // Should never actually get here
throw new ClientException(_('File exceeds user\'s quota!')); throw new ClientException(_('File exceeds user\'s quota.'));
return; return;
} }
@ -234,7 +234,7 @@ class MediaFile
$stream['uri'] . ' ' . $filepath)); $stream['uri'] . ' ' . $filepath));
} }
} else { } else {
throw new ClientException(_('Could not determine file\'s mime-type!')); throw new ClientException(_('Could not determine file\'s MIME type.'));
return; return;
} }
@ -272,7 +272,7 @@ class MediaFile
$hint = ''; $hint = '';
} }
throw new ClientException(sprintf( throw new ClientException(sprintf(
_('%s is not a supported filetype on this server.'), $filetype) . $hint); _('%s is not a supported file type on this server.'), $filetype) . $hint);
} }
static function respectsQuota($user, $filesize) static function respectsQuota($user, $filesize)
@ -286,4 +286,4 @@ class MediaFile
} }
} }
} }

View File

@ -211,7 +211,7 @@ class NoticeForm extends Form
'title' => common_local_url('geocode'))); 'title' => common_local_url('geocode')));
$this->out->checkbox('notice_data-geo', _('Share my location'), true); $this->out->checkbox('notice_data-geo', _('Share my location'), true);
$this->out->elementEnd('div'); $this->out->elementEnd('div');
$this->out->inlineScript(' var NoticeDataGeoShareDisable_text = "'._('Do not share my location.').'";'. $this->out->inlineScript(' var NoticeDataGeoShareDisable_text = "'._('Do not share my location').'";'.
' var NoticeDataGeoInfoMinimize_text = "'._('Hide this info').'";'); ' var NoticeDataGeoInfoMinimize_text = "'._('Hide this info').'";');
} }

View File

@ -88,7 +88,10 @@ class Router
$m->connect('doc/:title', array('action' => 'doc')); $m->connect('doc/:title', array('action' => 'doc'));
$m->connect('main/login?user_id=:user_id&token=:token', array('action'=>'login'), array('user_id'=> '[0-9]+', 'token'=>'.+')); $m->connect('main/otp/:user_id/:token',
array('action' => 'otp'),
array('user_id' => '[0-9]+',
'token' => '.+'));
// main stuff is repetitive // main stuff is repetitive
@ -442,19 +445,19 @@ class Router
// Social graph // Social graph
$m->connect('api/friends/ids/:id.:format', $m->connect('api/friends/ids/:id.:format',
array('action' => 'apiFriends', array('action' => 'apiuserfriends',
'ids_only' => true)); 'ids_only' => true));
$m->connect('api/followers/ids/:id.:format', $m->connect('api/followers/ids/:id.:format',
array('action' => 'apiFollowers', array('action' => 'apiuserfollowers',
'ids_only' => true)); 'ids_only' => true));
$m->connect('api/friends/ids.:format', $m->connect('api/friends/ids.:format',
array('action' => 'apiFriends', array('action' => 'apiuserfriends',
'ids_only' => true)); 'ids_only' => true));
$m->connect('api/followers/ids.:format', $m->connect('api/followers/ids.:format',
array('action' => 'apiFollowers', array('action' => 'apiuserfollowers',
'ids_only' => true)); 'ids_only' => true));
// account // account

View File

@ -173,8 +173,12 @@ class Snapshot
// XXX: Use OICU2 and OAuth to make authorized requests // XXX: Use OICU2 and OAuth to make authorized requests
$reporturl = common_config('snapshot', 'reporturl'); $reporturl = common_config('snapshot', 'reporturl');
$request = HTTPClient::start(); try {
$request->post($reporturl, null, $this->stats); $request = HTTPClient::start();
$request->post($reporturl, null, $this->stats);
} catch (Exception $e) {
common_log(LOG_WARNING, "Error in snapshot: " . $e->getMessage());
}
} }
/** /**

View File

@ -123,7 +123,7 @@ class SubscriptionListItem extends ProfileListItem
} }
$this->out->elementEnd('ul'); $this->out->elementEnd('ul');
} else { } else {
$this->out->text(_('(none)')); $this->out->text(_('(None)'));
} }
$this->out->elementEnd('dd'); $this->out->elementEnd('dd');
$this->out->elementEnd('dl'); $this->out->elementEnd('dl');

View File

@ -119,6 +119,11 @@ function common_language()
function common_munge_password($password, $id) function common_munge_password($password, $id)
{ {
if (is_object($id) || is_object($password)) {
$e = new Exception();
common_log(LOG_ERR, __METHOD__ . ' object in param to common_munge_password ' .
str_replace("\n", " ", $e->getTraceAsString()));
}
return md5($password . $id); return md5($password . $id);
} }
@ -166,15 +171,27 @@ function common_ensure_session()
if (common_config('sessions', 'handle')) { if (common_config('sessions', 'handle')) {
Session::setSaveHandler(); Session::setSaveHandler();
} }
if (array_key_exists(session_name(), $_GET)) {
$id = $_GET[session_name()];
common_log(LOG_INFO, 'Setting session from GET parameter: '.$id);
} else if (array_key_exists(session_name(), $_COOKIE)) {
$id = $_COOKIE[session_name()];
common_log(LOG_INFO, 'Setting session from COOKIE: '.$id);
}
if (isset($id)) {
session_id($id);
setcookie(session_name(), $id);
}
@session_start(); @session_start();
if (!isset($_SESSION['started'])) { if (!isset($_SESSION['started'])) {
$_SESSION['started'] = time(); $_SESSION['started'] = time();
if (!empty($c)) { if (!empty($id)) {
common_log(LOG_WARNING, 'Session cookie "' . $_COOKIE[session_name()] . '" ' . common_log(LOG_WARNING, 'Session cookie "' . $_COOKIE[session_name()] . '" ' .
' is set but started value is null'); ' is set but started value is null');
} }
} }
} }
common_debug("Session ID = " . session_id());
} }
// Three kinds of arguments: // Three kinds of arguments:
@ -809,20 +826,50 @@ function common_path($relative, $ssl=false)
} else if (common_config('site', 'server')) { } else if (common_config('site', 'server')) {
$serverpart = common_config('site', 'server'); $serverpart = common_config('site', 'server');
} else { } else {
common_log(LOG_ERR, 'Site Sever not configured, unable to determine site name.'); common_log(LOG_ERR, 'Site server not configured, unable to determine site name.');
} }
} else { } else {
$proto = 'http'; $proto = 'http';
if (common_config('site', 'server')) { if (common_config('site', 'server')) {
$serverpart = common_config('site', 'server'); $serverpart = common_config('site', 'server');
} else { } else {
common_log(LOG_ERR, 'Site Sever not configured, unable to determine site name.'); common_log(LOG_ERR, 'Site server not configured, unable to determine site name.');
} }
} }
$relative = common_inject_session($relative, $serverpart);
return $proto.'://'.$serverpart.'/'.$pathpart.$relative; return $proto.'://'.$serverpart.'/'.$pathpart.$relative;
} }
function common_inject_session($url, $serverpart = null)
{
if (common_have_session()) {
if (empty($serverpart)) {
$serverpart = parse_url($url, PHP_URL_HOST);
}
$currentServer = $_SERVER['HTTP_HOST'];
// Are we pointing to another server (like an SSL server?)
if (!empty($currentServer) &&
0 != strcasecmp($currentServer, $serverpart)) {
// Pass the session ID as a GET parameter
$sesspart = session_name() . '=' . session_id();
$i = strpos($url, '?');
if ($i === false) { // no GET params, just append
$url .= '?' . $sesspart;
} else {
$url = substr($url, 0, $i + 1).$sesspart.'&'.substr($url, $i + 1);
}
}
}
return $url;
}
function common_date_string($dt) function common_date_string($dt)
{ {
// XXX: do some sexy date formatting // XXX: do some sexy date formatting
@ -1010,7 +1057,12 @@ function common_profile_url($nickname)
function common_root_url($ssl=false) function common_root_url($ssl=false)
{ {
return common_path('', $ssl); $url = common_path('', $ssl);
$i = strpos($url, '?');
if ($i !== false) {
$url = substr($url, 0, $i);
}
return $url;
} }
// returns $bytes bytes of random data as a hexadecimal string // returns $bytes bytes of random data as a hexadecimal string

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More