Merge branch '0.9.x' into 1.0.x

Conflicts:
	actions/confirmaddress.php
	actions/imsettings.php
This commit is contained in:
Craig Andrews 2010-04-18 19:21:15 -04:00
commit 39392e03a7
147 changed files with 47498 additions and 23334 deletions

View File

@ -61,7 +61,7 @@ class AllAction extends ProfileAction
if ($this->page > 1 && $this->notice->N == 0) {
// TRANS: Server error when page not found (404)
$this->serverError(_('No such page'), $code = 404);
$this->serverError(_('No such page.'), $code = 404);
}
return true;

View File

@ -112,10 +112,12 @@ class AllrssAction extends Rss10Action
$c = array('url' => common_local_url('allrss',
array('nickname' =>
$user->nickname)),
// TRANS: Message is used as link title. %s is a user nickname.
'title' => sprintf(_('%s and friends'), $user->nickname),
'link' => common_local_url('all',
array('nickname' =>
$user->nickname)),
// TRANS: Message is used as link description. %1$s is a username, %2$s is a site name.
'description' => sprintf(_('Updates from %1$s and friends on %2$s!'),
$user->nickname, common_config('site', 'name')));
return $c;

View File

@ -103,7 +103,7 @@ class ApiAccountUpdateDeliveryDeviceAction extends ApiAuthAction
$this->clientError(
_(
'You must specify a parameter named ' .
'\'device\' with a value of one of: sms, im, none'
'\'device\' with a value of one of: sms, im, none.'
)
);
return;

View File

@ -263,7 +263,7 @@ class ApiGroupCreateAction extends ApiAuthAction
if (!$valid) {
$this->clientError(
sprintf(_('Invalid alias: "%s"'), $alias),
sprintf(_('Invalid alias: "%s".'), $alias),
403,
$this->format
);

View File

@ -92,7 +92,7 @@ class ApiGroupIsMemberAction extends ApiBareAuthAction
}
if (empty($this->group)) {
$this->clientError(_('Group not found!'), 404, $this->format);
$this->clientError(_('Group not found.'), 404, $this->format);
return false;
}

View File

@ -101,7 +101,7 @@ class ApiGroupJoinAction extends ApiAuthAction
}
if (empty($this->group)) {
$this->clientError(_('Group not found!'), 404, $this->format);
$this->clientError(_('Group not found.'), 404, $this->format);
return false;
}

View File

@ -101,7 +101,7 @@ class ApiGroupLeaveAction extends ApiAuthAction
}
if (empty($this->group)) {
$this->clientError(_('Group not found!'), 404, $this->format);
$this->clientError(_('Group not found.'), 404, $this->format);
return false;
}

View File

@ -87,6 +87,7 @@ class ApiGroupListAllAction extends ApiPrivateAuthAction
parent::handle($args);
$sitename = common_config('site', 'name');
// TRANS: Message is used as a title. %s is a site name.
$title = sprintf(_("%s groups"), $sitename);
$taguribase = TagURI::base();
$id = "tag:$taguribase:Groups";

View File

@ -88,7 +88,7 @@ class ApiGroupMembershipAction extends ApiPrivateAuthAction
parent::handle($args);
if (empty($this->group)) {
$this->clientError(_('Group not found!'), 404, $this->format);
$this->clientError(_('Group not found.'), 404, $this->format);
return false;
}

View File

@ -79,7 +79,7 @@ class ApiGroupShowAction extends ApiPrivateAuthAction
common_redirect(common_local_url('ApiGroupShow', $args), 301);
} else {
$this->clientError(
_('Group not found!'),
_('Group not found.'),
404,
$this->format
);

View File

@ -199,7 +199,7 @@ class ApiStatusesUpdateAction extends ApiAuthAction
$reply_to = $this->in_reply_to_status_id;
} else {
$this->clientError(
_('Not found'),
_('Not found.'),
$code = 404,
$this->format
);

View File

@ -116,6 +116,7 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
$id = "tag:$taguribase:FriendsTimeline:" . $this->user->id;
$subtitle = sprintf(
// TRANS: Message is used as a subtitle. %1$s is a user nickname, %2$s is a site name.
_('Updates from %1$s and friends on %2$s!'),
$this->user->nickname,
$sitename

View File

@ -88,7 +88,7 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction
parent::handle($args);
if (empty($this->group)) {
$this->clientError(_('Group not found!'), 404, $this->format);
$this->clientError(_('Group not found.'), 404, $this->format);
return false;
}

View File

@ -117,6 +117,7 @@ class ApiTimelineHomeAction extends ApiBareAuthAction
$id = "tag:$taguribase:HomeTimeline:" . $this->user->id;
$subtitle = sprintf(
// TRANS: Message is used as a subtitle. %1$s is a user nickname, %2$s is a site name.
_('Updates from %1$s and friends on %2$s!'),
$this->user->nickname, $sitename
);

View File

@ -69,7 +69,7 @@ class ApiTimelineRetweetedByMeAction extends ApiAuthAction
{
parent::prepare($args);
$this->serverError('Unimplemented', 503);
$this->serverError('Unimplemented.', 503);
return false;
}

View File

@ -103,7 +103,7 @@ class AvatarsettingsAction extends AccountSettingsAction
if (!$profile) {
common_log_db_error($user, 'SELECT', __FILE__);
$this->serverError(_('User without matching profile'));
$this->serverError(_('User without matching profile.'));
return;
}
@ -182,7 +182,7 @@ class AvatarsettingsAction extends AccountSettingsAction
if (!$profile) {
common_log_db_error($user, 'SELECT', __FILE__);
$this->serverError(_('User without matching profile'));
$this->serverError(_('User without matching profile.'));
return;
}

View File

@ -66,7 +66,7 @@ class BlockAction extends ProfileFormAction
assert(!empty($cur)); // checked by parent
if ($cur->hasBlocked($this->profile)) {
$this->clientError(_("You already blocked that user."));
$this->clientError(_('You already blocked that user.'));
return false;
}
@ -140,8 +140,20 @@ class BlockAction extends ProfileFormAction
$this->hidden($k, $v);
}
}
$this->submit('form_action-no', _('No'), 'submit form_action-primary', 'no', _("Do not block this user"));
$this->submit('form_action-yes', _('Yes'), 'submit form_action-secondary', 'yes', _('Block this user'));
$this->submit('form_action-no',
// TRANS: Button label on the user block form.
_m('BUTTON','No'),
'submit form_action-primary',
'no',
// TRANS: Submit button title for 'No' when blocking a user.
_('Do not block this user'));
$this->submit('form_action-yes',
// TRANS: Button label on the user block form.
_m('BUTTON','Yes'),
'submit form_action-secondary',
'yes',
// TRANS: Submit button title for 'Yes' when blocking a user.
_('Block this user'));
$this->elementEnd('fieldset');
$this->elementEnd('form');
}

View File

@ -47,7 +47,8 @@ class BookmarkletAction extends NewnoticeAction
{
function showTitle()
{
$this->element('title', null, _('Post to ').common_config('site', 'name'));
// TRANS: Title for mini-posting window loaded from bookmarklet.
$this->element('title', null, sprintf(_('Post to %s'), common_config('site', 'name')));
}
function showHeader()

View File

@ -89,6 +89,7 @@ class ConfirmaddressAction extends Action
$transports = array();
Event::handle('GetImTransports', array(&$transports));
if (!in_array($type, array('email', 'sms')) && !in_array($type, array_keys($transports))) {
// TRANS: Server error for an unknown address type, which can be 'email', 'sms', or the name of an IM network (such as 'xmpp' or 'aim')
$this->serverError(sprintf(_('Unrecognized address type %s'), $type));
return;
}

View File

@ -150,13 +150,17 @@ class DeleteapplicationAction extends Action
'This will clear all data about the application from the '.
'database, including all existing user connections.'));
$this->submit('form_action-no',
_('No'),
// TRANS: Button label on the delete application form.
_m('BUTTON','No'),
'submit form_action-primary',
'no',
_("Do not delete this application"));
// TRANS: Submit button title for 'No' when deleting an application.
_('Do not delete this application'));
$this->submit('form_action-yes',
_('Yes'),
// TRANS: Button label on the delete application form.
_m('BUTTON','Yes'),
'submit form_action-secondary',
// TRANS: Submit button title for 'Yes' when deleting an application.
'yes', _('Delete this application'));
$this->elementEnd('fieldset');
$this->elementEnd('form');

View File

@ -142,8 +142,20 @@ class DeletenoticeAction extends Action
$this->hidden('token', common_session_token());
$this->hidden('notice', $this->trimmed('notice'));
$this->element('p', null, _('Are you sure you want to delete this notice?'));
$this->submit('form_action-no', _('No'), 'submit form_action-primary', 'no', _("Do not delete this notice"));
$this->submit('form_action-yes', _('Yes'), 'submit form_action-secondary', 'yes', _('Delete this notice'));
$this->submit('form_action-no',
// TRANS: Button label on the delete notice form.
_m('BUTTON','No'),
'submit form_action-primary',
'no',
// TRANS: Submit button title for 'No' when deleting a notice.
_("Do not delete this notice"));
$this->submit('form_action-yes',
// TRANS: Button label on the delete notice form.
_m('BUTTON','Yes'),
'submit form_action-secondary',
'yes',
// TRANS: Submit button title for 'Yes' when deleting a notice.
_('Delete this notice'));
$this->elementEnd('fieldset');
$this->elementEnd('form');
}

View File

@ -64,14 +64,14 @@ class DeleteuserAction extends ProfileFormAction
assert(!empty($cur)); // checked by parent
if (!$cur->hasRight(Right::DELETEUSER)) {
$this->clientError(_("You cannot delete users."));
$this->clientError(_('You cannot delete users.'));
return false;
}
$this->user = User::staticGet('id', $this->profile->id);
if (empty($this->user)) {
$this->clientError(_("You can only delete local users."));
$this->clientError(_('You can only delete local users.'));
return false;
}
@ -147,8 +147,20 @@ class DeleteuserAction extends ProfileFormAction
}
Event::handle('EndDeleteUserForm', array($this, $this->user));
}
$this->submit('form_action-no', _('No'), 'submit form_action-primary', 'no', _("Do not block this user"));
$this->submit('form_action-yes', _('Yes'), 'submit form_action-secondary', 'yes', _('Delete this user'));
$this->submit('form_action-no',
// TRANS: Button label on the delete user form.
_m('BUTTON','No'),
'submit form_action-primary',
'no',
// TRANS: Submit button title for 'No' when deleting a user.
_('Do not block this user'));
$this->submit('form_action-yes',
// TRANS: Button label on the delete user form.
_m('BUTTON','Yes'),
'submit form_action-secondary',
'yes',
// TRANS: Submit button title for 'Yes' when deleting a user.
_('Delete this user'));
$this->elementEnd('fieldset');
$this->elementEnd('form');
}

View File

@ -59,6 +59,7 @@ class DesignadminpanelAction extends AdminPanelAction
function title()
{
// TRANS: Message used as title for design settings for the site.
return _('Design');
}
@ -272,11 +273,11 @@ class DesignadminpanelAction extends AdminPanelAction
{
if (!empty($values['logo']) &&
!Validate::uri($values['logo'], array('allowed_schemes' => array('http', 'https')))) {
$this->clientError(_("Invalid logo URL."));
$this->clientError(_('Invalid logo URL.'));
}
if (!in_array($values['theme'], Theme::listAvailable())) {
$this->clientError(sprintf(_("Theme not available: %s"), $values['theme']));
$this->clientError(sprintf(_("Theme not available: %s."), $values['theme']));
}
}
@ -454,6 +455,7 @@ class DesignAdminPanelForm extends AdminForm
$this->out->element('label', array('for' => 'design_background-image_on',
'class' => 'radio'),
// TRANS: Used as radio button label to add a background image.
_('On'));
$attrs = array('name' => 'design_background-image_onoff',
@ -470,6 +472,7 @@ class DesignAdminPanelForm extends AdminForm
$this->out->element('label', array('for' => 'design_background-image_off',
'class' => 'radio'),
// TRANS: Used as radio button label to not add a background image.
_('Off'));
$this->out->element('p', 'form_guide', _('Turn background image on or off.'));
$this->unli();

View File

@ -71,7 +71,7 @@ class DisfavorAction extends Action
$notice = Notice::staticGet($id);
$token = $this->trimmed('token-'.$notice->id);
if (!$token || $token != common_session_token()) {
$this->clientError(_("There was a problem with your session token. Try again, please."));
$this->clientError(_('There was a problem with your session token. Try again, please.'));
return;
}
$fave = new Fave();

View File

@ -57,6 +57,7 @@ class EmailsettingsAction extends AccountSettingsAction
function title()
{
// TRANS: Title for e-mail settings.
return _('Email settings');
}
@ -68,6 +69,10 @@ class EmailsettingsAction extends AccountSettingsAction
function getInstructions()
{
// XXX: For consistency of parameters in messages, this should be a
// regular parameters, replaced with sprintf().
// TRANS: E-mail settings page instructions.
// TRANS: %%site.name%% is the name of the site.
return _('Manage how you get email from %%site.name%%.');
}
@ -97,102 +102,126 @@ class EmailsettingsAction extends AccountSettingsAction
common_local_url('emailsettings')));
$this->elementStart('fieldset');
$this->elementStart('fieldset', array('id' => 'settings_email_address'));
$this->element('legend', null, _('Address'));
// TRANS: Form legend for e-mail settings form.
$this->element('legend', null, _('Email address'));
$this->hidden('token', common_session_token());
if ($user->email) {
$this->element('p', array('id' => 'form_confirmed'), $user->email);
// TRANS: Form note in e-mail settings form.
$this->element('p', array('class' => 'form_note'), _('Current confirmed email address.'));
$this->hidden('email', $user->email);
$this->submit('remove', _('Remove'));
// TRANS: Button label to remove a confirmed e-mail address.
$this->submit('remove', _m('BUTTON','Remove'));
} else {
$confirm = $this->getConfirmation();
if ($confirm) {
$this->element('p', array('id' => 'form_unconfirmed'), $confirm->address);
// TRANS: Form note in e-mail settings form.
$this->element('p', array('class' => 'form_note'),
_('Awaiting confirmation on this address. '.
'Check your inbox (and spam box!) for a message '.
'with further instructions.'));
$this->hidden('email', $confirm->address);
$this->submit('cancel', _('Cancel'));
// TRANS: Button label to cancel an e-mail address confirmation procedure.
$this->submit('cancel', _m('BUTTON','Cancel'));
} else {
$this->elementStart('ul', 'form_data');
$this->elementStart('li');
// TRANS: Field label for e-mail address input in e-mail settings form.
$this->input('email', _('Email address'),
($this->arg('email')) ? $this->arg('email') : null,
// TRANS: Instructions for e-mail address input form.
_('Email address, like "UserName@example.org"'));
$this->elementEnd('li');
$this->elementEnd('ul');
$this->submit('add', _('Add'));
// TRANS: Button label for adding an e-mail address in e-mail settings form.
$this->submit('add', _m('BUTTON','Add'));
}
}
$this->elementEnd('fieldset');
if (common_config('emailpost', 'enabled') && $user->email) {
$this->elementStart('fieldset', array('id' => 'settings_email_incoming'));
// TRANS: Form legend for incoming e-mail settings form.
$this->element('legend', null, _('Incoming email'));
if ($user->incomingemail) {
$this->elementStart('p');
$this->element('span', 'address', $user->incomingemail);
// XXX: Looks a little awkward in the UI.
// Something like "xxxx@identi.ca Send email ..". Needs improvement.
$this->element('span', 'input_instructions',
// TRANS: Form instructions for incoming e-mail form in e-mail settings.
_('Send email to this address to post new notices.'));
$this->elementEnd('p');
$this->submit('removeincoming', _('Remove'));
// TRANS: Button label for removing a set sender e-mail address to post notices from.
$this->submit('removeincoming', _m('BUTTON','Remove'));
}
$this->elementStart('p');
$this->element('span', 'input_instructions',
// TRANS: Instructions for incoming e-mail address input form.
_('Make a new email address for posting to; '.
'cancels the old one.'));
$this->elementEnd('p');
$this->submit('newincoming', _('New'));
// TRANS: Button label for adding an e-mail address to send notices from.
$this->submit('newincoming', _m('BUTTON','New'));
$this->elementEnd('fieldset');
}
$this->elementStart('fieldset', array('id' => 'settings_email_preferences'));
$this->element('legend', null, _('Preferences'));
// TRANS: Form legend for e-mail preferences form.
$this->element('legend', null, _('Email preferences'));
$this->elementStart('ul', 'form_data');
$this->elementStart('li');
$this->checkbox('emailnotifysub',
// TRANS: Checkbox label in e-mail preferences form.
_('Send me notices of new subscriptions through email.'),
$user->emailnotifysub);
$this->elementEnd('li');
$this->elementStart('li');
$this->checkbox('emailnotifyfav',
// TRANS: Checkbox label in e-mail preferences form.
_('Send me email when someone '.
'adds my notice as a favorite.'),
$user->emailnotifyfav);
$this->elementEnd('li');
$this->elementStart('li');
$this->checkbox('emailnotifymsg',
// TRANS: Checkbox label in e-mail preferences form.
_('Send me email when someone sends me a private message.'),
$user->emailnotifymsg);
$this->elementEnd('li');
$this->elementStart('li');
$this->checkbox('emailnotifyattn',
// TRANS: Checkbox label in e-mail preferences form.
_('Send me email when someone sends me an "@-reply".'),
$user->emailnotifyattn);
$this->elementEnd('li');
$this->elementStart('li');
$this->checkbox('emailnotifynudge',
// TRANS: Checkbox label in e-mail preferences form.
_('Allow friends to nudge me and send me an email.'),
$user->emailnotifynudge);
$this->elementEnd('li');
if (common_config('emailpost', 'enabled')) {
$this->elementStart('li');
$this->checkbox('emailpost',
// TRANS: Checkbox label in e-mail preferences form.
_('I want to post notices by email.'),
$user->emailpost);
$this->elementEnd('li');
}
$this->elementStart('li');
$this->checkbox('emailmicroid',
// TRANS: Checkbox label in e-mail preferences form.
_('Publish a MicroID for my email address.'),
$user->emailmicroid);
$this->elementEnd('li');
$this->elementEnd('ul');
$this->submit('save', _('Save'));
// TRANS: Button label to save e-mail preferences.
$this->submit('save', _m('BUTTON','Save'));
$this->elementEnd('fieldset');
$this->elementEnd('fieldset');
$this->elementEnd('form');
@ -253,6 +282,7 @@ class EmailsettingsAction extends AccountSettingsAction
} else if ($this->arg('newincoming')) {
$this->newIncoming();
} else {
// TRANS: Message given submitting a form with an unknown action in e-mail settings.
$this->showForm(_('Unexpected form submission.'));
}
}
@ -293,13 +323,15 @@ class EmailsettingsAction extends AccountSettingsAction
if ($result === false) {
common_log_db_error($user, 'UPDATE', __FILE__);
// TRANS: Server error thrown on database error updating e-mail preferences.
$this->serverError(_('Couldn\'t update user.'));
return;
}
$user->query('COMMIT');
$this->showForm(_('Preferences saved.'), true);
// TRANS: Confirmation message for successful e-mail preferences save.
$this->showForm(_('Email preferences saved.'), true);
}
/**
@ -317,6 +349,7 @@ class EmailsettingsAction extends AccountSettingsAction
// Some validation
if (!$email) {
// TRANS: Message given saving e-mail address without having provided one.
$this->showForm(_('No email address.'));
return;
}
@ -324,16 +357,20 @@ class EmailsettingsAction extends AccountSettingsAction
$email = common_canonical_email($email);
if (!$email) {
// TRANS: Message given saving e-mail address that cannot be normalised.
$this->showForm(_('Cannot normalize that email address'));
return;
}
if (!Validate::email($email, common_config('email', 'check_domain'))) {
// TRANS: Message given saving e-mail address that not valid.
$this->showForm(_('Not a valid email address.'));
return;
} else if ($user->email == $email) {
// TRANS: Message given saving e-mail address that is already set.
$this->showForm(_('That is already your email address.'));
return;
} else if ($this->emailExists($email)) {
// TRANS: Message given saving e-mail address that is already set for another user.
$this->showForm(_('That email address already belongs '.
'to another user.'));
return;
@ -350,12 +387,14 @@ class EmailsettingsAction extends AccountSettingsAction
if ($result === false) {
common_log_db_error($confirm, 'INSERT', __FILE__);
// TRANS: Server error thrown on database error adding e-mail confirmation code.
$this->serverError(_('Couldn\'t insert confirmation code.'));
return;
}
mail_confirm_address($user, $confirm->code, $user->nickname, $email);
// TRANS: Message given saving valid e-mail address that is to be confirmed.
$msg = _('A confirmation code was sent to the email address you added. '.
'Check your inbox (and spam box!) for the code and instructions '.
'on how to use it.');
@ -376,11 +415,13 @@ class EmailsettingsAction extends AccountSettingsAction
$confirm = $this->getConfirmation();
if (!$confirm) {
// TRANS: Message given canceling e-mail address confirmation that is not pending.
$this->showForm(_('No pending confirmation to cancel.'));
return;
}
if ($confirm->address != $email) {
$this->showForm(_('That is the wrong IM address.'));
// TRANS: Message given canceling e-mail address confirmation for the wrong e-mail address.
$this->showForm(_('That is the wrong email address.'));
return;
}
@ -388,11 +429,13 @@ class EmailsettingsAction extends AccountSettingsAction
if (!$result) {
common_log_db_error($confirm, 'DELETE', __FILE__);
// TRANS: Server error thrown on database error canceling e-mail address confirmation.
$this->serverError(_('Couldn\'t delete email confirmation.'));
return;
}
$this->showForm(_('Confirmation cancelled.'), true);
// TRANS: Message given after successfully canceling e-mail address confirmation.
$this->showForm(_('Email confirmation cancelled.'), true);
}
/**
@ -410,6 +453,8 @@ class EmailsettingsAction extends AccountSettingsAction
// Maybe an old tab open...?
if ($user->email != $email) {
// TRANS: Message given trying to remove an e-mail address that is not
// TRANS: registered for the active user.
$this->showForm(_('That is not your email address.'));
return;
}
@ -424,12 +469,14 @@ class EmailsettingsAction extends AccountSettingsAction
if (!$result) {
common_log_db_error($user, 'UPDATE', __FILE__);
// TRANS: Server error thrown on database error removing a registered e-mail address.
$this->serverError(_('Couldn\'t update user.'));
return;
}
$user->query('COMMIT');
$this->showForm(_('The address was removed.'), true);
// TRANS: Message given after successfully removing a registered e-mail address.
$this->showForm(_('The email address was removed.'), true);
}
/**
@ -453,9 +500,11 @@ class EmailsettingsAction extends AccountSettingsAction
if (!$user->updateKeys($orig)) {
common_log_db_error($user, 'UPDATE', __FILE__);
// TRANS: Server error thrown on database error removing incoming e-mail address.
$this->serverError(_("Couldn't update user record."));
}
// TRANS: Message given after successfully removing an incoming e-mail address.
$this->showForm(_('Incoming email address removed.'), true);
}
@ -475,9 +524,11 @@ class EmailsettingsAction extends AccountSettingsAction
if (!$user->updateKeys($orig)) {
common_log_db_error($user, 'UPDATE', __FILE__);
// TRANS: Server error thrown on database error adding incoming e-mail address.
$this->serverError(_("Couldn't update user record."));
}
// TRANS: Message given after successfully adding an incoming e-mail address.
$this->showForm(_('New incoming email address added.'), true);
}

View File

@ -72,7 +72,7 @@ class FavorAction extends Action
$notice = Notice::staticGet($id);
$token = $this->trimmed('token-'.$notice->id);
if (!$token || $token != common_session_token()) {
$this->clientError(_("There was a problem with your session token. Try again, please."));
$this->clientError(_('There was a problem with your session token. Try again, please.'));
return;
}
if ($user->hasFave($notice)) {

View File

@ -135,7 +135,7 @@ class FinishremotesubscribeAction extends Action
$service->getServiceURI(OMB_ENDPOINT_UPDATEPROFILE);
if (!$remote->update($orig_remote)) {
$this->serverError(_('Error updating remote profile'));
$this->serverError(_('Error updating remote profile.'));
return;
}

View File

@ -56,7 +56,7 @@ class FoafGroupAction extends Action
return false;
}
$local = Local_group::staticGet('nickname', $nickname);
$local = Local_group::staticGet('nickname', $this->nickname);
if (!$local) {
$this->clientError(_('No such group.'), 404);
@ -126,7 +126,8 @@ class FoafGroupAction extends Action
while ($members->fetch()) {
$member_uri = common_local_url('userbyid', array('id'=>$members->id));
$member_details[$member_uri] = array(
'nickname' => $members->nickname
'nickname' => $members->nickname,
'is_admin' => false,
);
$this->element('member', array('rdf:resource' => $member_uri));
}

View File

@ -59,11 +59,11 @@ class GrantRoleAction extends ProfileFormAction
$this->role = $this->arg('role');
if (!Profile_role::isValid($this->role)) {
$this->clientError(_("Invalid role."));
$this->clientError(_('Invalid role.'));
return false;
}
if (!Profile_role::isSettable($this->role)) {
$this->clientError(_("This role is reserved and cannot be set."));
$this->clientError(_('This role is reserved and cannot be set.'));
return false;
}
@ -72,14 +72,14 @@ class GrantRoleAction extends ProfileFormAction
assert(!empty($cur)); // checked by parent
if (!$cur->hasRight(Right::GRANTROLE)) {
$this->clientError(_("You cannot grant user roles on this site."));
$this->clientError(_('You cannot grant user roles on this site.'));
return false;
}
assert(!empty($this->profile)); // checked by parent
if ($this->profile->hasRole($this->role)) {
$this->clientError(_("User already has this role."));
$this->clientError(_('User already has this role.'));
return false;
}

View File

@ -41,7 +41,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
* @link http://status.net/
*/
class GroupblockAction extends Action
class GroupblockAction extends RedirectingAction
{
var $profile = null;
var $group = null;
@ -117,9 +117,7 @@ class GroupblockAction extends Action
parent::handle($args);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if ($this->arg('no')) {
common_redirect(common_local_url('groupmembers',
array('nickname' => $this->group->nickname)),
303);
$this->returnToArgs();
} elseif ($this->arg('yes')) {
$this->blockProfile();
} elseif ($this->arg('blockto')) {
@ -175,8 +173,20 @@ class GroupblockAction extends Action
$this->hidden($k, $v);
}
}
$this->submit('form_action-no', _('No'), 'submit form_action-primary', 'no', _("Do not block this user from this group"));
$this->submit('form_action-yes', _('Yes'), 'submit form_action-secondary', 'yes', _('Block this user from this group'));
$this->submit('form_action-no',
// TRANS: Button label on the form to block a user from a group.
_m('BUTTON','No'),
'submit form_action-primary',
'no',
// TRANS: Submit button title for 'No' when blocking a user from a group.
_('Do not block this user from this group'));
$this->submit('form_action-yes',
// TRANS: Button label on the form to block a user from a group.
_m('BUTTON','Yes'),
'submit form_action-secondary',
'yes',
// TRANS: Submit button title for 'Yes' when blocking a user from a group.
_('Block this user from this group'));
$this->elementEnd('fieldset');
$this->elementEnd('form');
}
@ -197,22 +207,19 @@ class GroupblockAction extends Action
return false;
}
// Now, gotta figure where we go back to
foreach ($this->args as $k => $v) {
if ($k == 'returnto-action') {
$action = $v;
} elseif (substr($k, 0, 9) == 'returnto-') {
$args[substr($k, 9)] = $v;
}
$this->returnToArgs();
}
if ($action) {
common_redirect(common_local_url($action, $args), 303);
} else {
common_redirect(common_local_url('groupmembers',
array('nickname' => $this->group->nickname)),
303);
}
/**
* If we reached this form without returnto arguments, default to
* the top of the group's member list.
*
* @return string URL
*/
function defaultReturnTo()
{
return common_local_url('groupmembers',
array('nickname' => $this->group->nickname));
}
function showScripts()

View File

@ -205,8 +205,7 @@ class GroupMemberListItem extends ProfileListItem
!$this->profile->isAdmin($this->group)) {
$this->out->elementStart('li', 'entity_make_admin');
$maf = new MakeAdminForm($this->out, $this->profile, $this->group,
array('action' => 'groupmembers',
'nickname' => $this->group->nickname));
$this->returnToArgs());
$maf->show();
$this->out->elementEnd('li');
}
@ -220,8 +219,7 @@ class GroupMemberListItem extends ProfileListItem
if (!empty($user) && $user->id != $this->profile->id && $user->isAdmin($this->group)) {
$this->out->elementStart('li', 'entity_block');
$bf = new GroupBlockForm($this->out, $this->profile, $this->group,
array('action' => 'groupmembers',
'nickname' => $this->group->nickname));
$this->returnToArgs());
$bf->show();
$this->out->elementEnd('li');
}
@ -240,9 +238,30 @@ class GroupMemberListItem extends ProfileListItem
function homepageAttributes()
{
$aAttrs = parent::linkAttributes();
if (common_config('nofollow', 'members')) {
$aAttrs['rel'] = 'nofollow';
}
return $aAttrs;
}
/**
* Fetch necessary return-to arguments for the profile forms
* to return to this list when they're done.
*
* @return array
*/
protected function returnToArgs()
{
$args = array('action' => 'groupmembers',
'nickname' => $this->group->nickname);
$page = $this->out->arg('page');
if ($page) {
$args['param-page'] = $page;
}
return $args;
}
}

View File

@ -135,8 +135,10 @@ class groupRssAction extends Rss10Action
$c = array('url' => common_local_url('grouprss',
array('nickname' =>
$group->nickname)),
// TRANS: Message is used as link title. %s is a user nickname.
'title' => sprintf(_('%s timeline'), $group->nickname),
'link' => common_local_url('showgroup', array('nickname' => $group->nickname)),
// TRANS: Message is used as link description. %1$s is a username, %2$s is a site name.
'description' => sprintf(_('Updates from members of %1$s on %2$s!'),
$group->nickname, common_config('site', 'name')));
return $c;

View File

@ -53,6 +53,7 @@ class ImsettingsAction extends ConnectSettingsAction
function title()
{
// TRANS: Title for instance messaging settings.
return _('IM settings');
}
@ -64,6 +65,9 @@ class ImsettingsAction extends ConnectSettingsAction
function getInstructions()
{
// TRANS: Instant messaging settings page instructions.
// TRANS: [instant messages] is link text, "(%%doc.im%%)" is the link.
// TRANS: the order and formatting of link text and link should remain unchanged.
return _('You can send and receive notices through '.
'instant messaging [instant messages](%%doc.im%%). '.
'Configure your addresses and settings below.');
@ -85,6 +89,7 @@ class ImsettingsAction extends ConnectSettingsAction
Event::handle('GetImTransports', array(&$transports));
if (! $transports) {
$this->element('div', array('class' => 'error'),
// TRANS: Message given in the IM settings if IM is not enabled on the site.
_('IM is not available.'));
return;
}
@ -101,6 +106,7 @@ class ImsettingsAction extends ConnectSettingsAction
'action' =>
common_local_url('imsettings')));
$this->elementStart('fieldset', array('id' => 'settings_im_address'));
// TRANS: Form legend for IM settings form.
$this->element('legend', null, $transport_info['display']);
$this->hidden('token', common_session_token());
$this->hidden('transport', $transport);
@ -108,21 +114,30 @@ class ImsettingsAction extends ConnectSettingsAction
if ($user_im_prefs = User_im_prefs::pkeyGet( array('transport' => $transport, 'user_id' => $user->id) )) {
$user_im_prefs_by_transport[$transport] = $user_im_prefs;
$this->element('p', 'form_confirmed', $user_im_prefs->screenname);
// TRANS: Form note in IM settings form.
$this->element('p', 'form_note',
sprintf(_('Current confirmed %s address.'),$transport_info['display']));
$this->hidden('screenname', $user_im_prefs->screenname);
$this->submit('remove', _('Remove'));
// TRANS: Button label to remove a confirmed IM address.
$this->submit('remove', _m('BUTTON','Remove'));
} else {
$confirm = $this->getConfirmation($transport);
if ($confirm) {
$this->element('p', 'form_unconfirmed', $confirm->address);
// TRANS: Form note in IM settings form.
$this->element('p', 'form_note',
// TRANS: Form note in IM settings form.
// TRANS: %s is the IM address set for the site.
sprintf(_('Awaiting confirmation on this address. '.
'Check your %s account for a '.
'message with further instructions.'),
$transport_info['display']));
'message with further instructions. '.
'(Did you add %s to your buddy list?)'),
$transport_info['display'],
$transport_info['daemon_screenname'],
jabber_daemon_address()));
$this->hidden('screenname', $confirm->address);
$this->submit('cancel', _('Cancel'));
// TRANS: Button label to cancel an IM address confirmation procedure.
$this->submit('cancel', _m('BUTTON','Cancel'));
} else {
$this->elementStart('ul', 'form_data');
$this->elementStart('li');
@ -132,7 +147,8 @@ class ImsettingsAction extends ConnectSettingsAction
$transport_info['display']));
$this->elementEnd('li');
$this->elementEnd('ul');
$this->submit('add', _('Add'));
// TRANS: Button label for adding an IM address in IM settings form.
$this->submit('add', _m('BUTTON','Add'));
}
}
$this->elementEnd('fieldset');
@ -151,17 +167,22 @@ class ImsettingsAction extends ConnectSettingsAction
$this->hidden('token', common_session_token());
$this->elementStart('table');
$this->elementStart('tr');
$this->element('th', null, _('Preferences'));
// TRANS: Header for IM preferences form.
$this->element('th', null, _('IM Preferences'));
foreach($user_im_prefs_by_transport as $transport=>$user_im_prefs)
{
$this->element('th', null, $transports[$transport]['display']);
}
$this->elementEnd('tr');
$preferences = array(
// TRANS: Checkbox label in IM preferences form.
array('name'=>'notify', 'description'=>_('Send me notices')),
// TRANS: Checkbox label in IM preferences form.
array('name'=>'updatefrompresence', 'description'=>_('Post a notice when my status changes.')),
// TRANS: Checkbox label in IM preferences form.
array('name'=>'replies', 'description'=>_('Send me replies '.
'from people I\'m not subscribed to.')),
// TRANS: Checkbox label in IM preferences form.
array('name'=>'microid', 'description'=>_('Publish a MicroID'))
);
foreach($preferences as $preference)
@ -179,7 +200,8 @@ class ImsettingsAction extends ConnectSettingsAction
$this->elementEnd('tr');
}
$this->elementEnd('table');
$this->submit('save', _('Save'));
// TRANS: Button label to save IM preferences.
$this->submit('save', _m('BUTTON','Save'));
$this->elementEnd('fieldset');
$this->elementEnd('form');
}
@ -237,6 +259,7 @@ class ImsettingsAction extends ConnectSettingsAction
} else if ($this->arg('remove')) {
$this->removeAddress();
} else {
// TRANS: Message given submitting a form with an unknown action in IM settings.
$this->showForm(_('Unexpected form submission.'));
}
}
@ -271,12 +294,14 @@ class ImsettingsAction extends ConnectSettingsAction
if ($result === false) {
common_log_db_error($user, 'UPDATE', __FILE__);
// TRANS: Server error thrown on database error updating IM preferences.
$this->serverError(_('Couldn\'t update IM preferences.'));
return;
}
}while($user_im_prefs->fetch());
$user_im_prefs->query('COMMIT');
}
// TRANS: Confirmation message for successful IM preferences save.
$this->showForm(_('Preferences saved.'), true);
}
@ -299,6 +324,7 @@ class ImsettingsAction extends ConnectSettingsAction
// Some validation
if (!$screenname) {
// TRANS: Message given saving IM address without having provided one.
$this->showForm(_('No screenname.'));
return;
}
@ -311,15 +337,18 @@ class ImsettingsAction extends ConnectSettingsAction
Event::handle('NormalizeImScreenname', array($transport, &$screenname));
if (!$screenname) {
// TRANS: Message given saving IM address that cannot be normalised.
$this->showForm(_('Cannot normalize that screenname'));
return;
}
$valid = false;
Event::handle('ValidateImScreenname', array($transport, $screenname, &$valid));
if (!$valid) {
// TRANS: Message given saving IM address that not valid.
$this->showForm(_('Not a valid screenname'));
return;
} else if ($this->screennameExists($transport, $screenname)) {
// TRANS: Message given saving IM address that is already set for another user.
$this->showForm(_('Screenname already belongs to another user.'));
return;
}
@ -337,12 +366,14 @@ class ImsettingsAction extends ConnectSettingsAction
if ($result === false) {
common_log_db_error($confirm, 'INSERT', __FILE__);
// TRANS: Server error thrown on database error adding IM confirmation code.
$this->serverError(_('Couldn\'t insert confirmation code.'));
return;
}
Event::handle('SendImConfirmationCode', array($transport, $screenname, $confirm->code, $user));
// TRANS: Message given saving valid IM address that is to be confirmed.
$msg = _('A confirmation code was sent '.
'to the IM address you added.');
@ -365,10 +396,12 @@ class ImsettingsAction extends ConnectSettingsAction
$confirm = $this->getConfirmation($transport);
if (!$confirm) {
// TRANS: Message given canceling IM address confirmation that is not pending.
$this->showForm(_('No pending confirmation to cancel.'));
return;
}
if ($confirm->address != $screenname) {
// TRANS: Message given canceling IM address confirmation for the wrong IM address.
$this->showForm(_('That is the wrong IM address.'));
return;
}
@ -377,11 +410,13 @@ class ImsettingsAction extends ConnectSettingsAction
if (!$result) {
common_log_db_error($confirm, 'DELETE', __FILE__);
// TRANS: Server error thrown on database error canceling IM address confirmation.
$this->serverError(_('Couldn\'t delete confirmation.'));
return;
}
$this->showForm(_('Confirmation cancelled.'), true);
// TRANS: Message given after successfully canceling IM address confirmation.
$this->showForm(_('IM confirmation cancelled.'), true);
}
/**
@ -404,6 +439,8 @@ class ImsettingsAction extends ConnectSettingsAction
$user_im_prefs = new User_im_prefs();
$user_im_prefs->user_id = $user->id;
if(! ($user_im_prefs->find() && $user_im_prefs->fetch())) {
// TRANS: Message given trying to remove an IM address that is not
// TRANS: registered for the active user.
$this->showForm(_('That is not your screenname.'));
return;
}
@ -412,13 +449,16 @@ class ImsettingsAction extends ConnectSettingsAction
if (!$result) {
common_log_db_error($user, 'UPDATE', __FILE__);
// TRANS: Server error thrown on database error removing a registered IM address.
$this->serverError(_('Couldn\'t update user im prefs.'));
$this->serverError(_('Couldn\'t update user.'));
return;
}
// XXX: unsubscribe to the old address
$this->showForm(_('The address was removed.'), true);
// TRANS: Message given after successfully removing a registered IM address.
$this->showForm(_('The IM address was removed.'), true);
}
/**

View File

@ -38,7 +38,7 @@ class InviteAction extends CurrentUserDesignAction
if (!common_config('invite', 'enabled')) {
$this->clientError(_('Invites have been disabled.'));
} else if (!common_logged_in()) {
$this->clientError(sprintf(_('You must be logged in to invite other users to use %s'),
$this->clientError(sprintf(_('You must be logged in to invite other users to use %s.'),
common_config('site', 'name')));
return;
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
@ -224,8 +224,10 @@ class InviteAction extends CurrentUserDesignAction
$headers['From'] = mail_notify_from();
$headers['To'] = trim($email);
// TRANS: Subject for invitation email. Note that 'them' is correct as a gender-neutral singular 3rd-person pronoun in English.
$headers['Subject'] = sprintf(_('%1$s has invited you to join them on %2$s'), $bestname, $sitename);
// TRANS: Body text for invitation email. Note that 'them' is correct as a gender-neutral singular 3rd-person pronoun in English.
$body = sprintf(_("%1\$s has invited you to join them on %2\$s (%3\$s).\n\n".
"%2\$s is a micro-blogging service that lets you keep up-to-date with people you know and people who interest you.\n\n".
"You can also share news about yourself, your thoughts, or your life online with people who know about you. ".

View File

@ -41,7 +41,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
* @link http://status.net/
*/
class MakeadminAction extends Action
class MakeadminAction extends RedirectingAction
{
var $profile = null;
var $group = null;
@ -148,20 +148,19 @@ class MakeadminAction extends Action
$this->group->getBestName());
}
foreach ($this->args as $k => $v) {
if ($k == 'returnto-action') {
$action = $v;
} else if (substr($k, 0, 9) == 'returnto-') {
$args[substr($k, 9)] = $v;
}
$this->returnToArgs();
}
if ($action) {
common_redirect(common_local_url($action, $args), 303);
} else {
common_redirect(common_local_url('groupmembers',
array('nickname' => $this->group->nickname)),
303);
}
/**
* If we reached this form without returnto arguments, default to
* the top of the group's member list.
*
* @return string URL
*/
function defaultReturnTo()
{
return common_local_url('groupmembers',
array('nickname' => $this->group->nickname));
}
}

View File

@ -66,7 +66,7 @@ class MicrosummaryAction extends Action
$notice = $user->getCurrentNotice();
if (!$notice) {
$this->clientError(_('No current status'), 404);
$this->clientError(_('No current status.'), 404);
}
header('Content-Type: text/plain');

View File

@ -183,7 +183,7 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction
if (!$result) {
common_log_db_error($orig, 'DELETE', __FILE__);
$this->clientError(_('Unable to revoke access for app: ' . $app->id));
$this->clientError(sprintf(_('Unable to revoke access for app: %s.'), $app->id));
return false;
}
@ -195,7 +195,7 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction
function showEmptyListMessage()
{
$message = sprintf(_('You have not authorized any applications to use your account.'));
$message = _('You have not authorized any applications to use your account.');
$this->elementStart('div', 'guide');
$this->raw(common_markup_to_html($message));

View File

@ -60,7 +60,7 @@ class OembedAction extends Action
$proxy_args = $r->map($path);
if (!$proxy_args) {
$this->serverError(_("$path not found"), 404);
$this->serverError(_("$path not found."), 404);
}
$oembed=array();
$oembed['version']='1.0';
@ -72,11 +72,11 @@ class OembedAction extends Action
$id = $proxy_args['notice'];
$notice = Notice::staticGet($id);
if(empty($notice)){
$this->serverError(_("notice $id not found"), 404);
$this->serverError(_("Notice $id not found."), 404);
}
$profile = $notice->getProfile();
if (empty($profile)) {
$this->serverError(_('Notice has no profile'), 500);
$this->serverError(_('Notice has no profile.'), 500);
}
if (!empty($profile->fullname)) {
$authorname = $profile->fullname . ' (' . $profile->nickname . ')';
@ -95,7 +95,7 @@ class OembedAction extends Action
$id = $proxy_args['attachment'];
$attachment = File::staticGet($id);
if(empty($attachment)){
$this->serverError(_("attachment $id not found"), 404);
$this->serverError(_("Attachment $id not found."), 404);
}
if(empty($attachment->filename) && $file_oembed = File_oembed::staticGet('file_id', $attachment->id)){
// Proxy the existing oembed information
@ -123,7 +123,7 @@ class OembedAction extends Action
if($attachment->title) $oembed['title']=$attachment->title;
break;
default:
$this->serverError(_("$path not supported for oembed requests"), 501);
$this->serverError(_("$path not supported for oembed requests."), 501);
}
switch($args['format']){
case 'xml':
@ -154,10 +154,12 @@ class OembedAction extends Action
$this->end_document('json');
break;
default:
$this->serverError(_('content type ' . $apidata['content-type'] . ' not supported'), 501);
// TRANS: Error message displaying attachments. %s is a raw MIME type (eg 'image/png')
$this->serverError(sprintf(_('Content type %s not supported.'), $apidata['content-type']), 501);
}
}else{
$this->serverError(_('Only ' . common_root_url() . ' urls over plain http please'), 404);
// TRANS: Error message displaying attachments. %s is the site's base URL.
$this->serverError(sprintf(_('Only %s URLs over plain HTTP please.'), common_root_url()), 404);
}
}

View File

@ -154,19 +154,19 @@ class PathsadminpanelAction extends AdminPanelAction
// Validate theme dir
if (!empty($values['theme']['dir']) && !is_readable($values['theme']['dir'])) {
$this->clientError(sprintf(_("Theme directory not readable: %s"), $values['theme']['dir']));
$this->clientError(sprintf(_("Theme directory not readable: %s."), $values['theme']['dir']));
}
// Validate avatar dir
if (empty($values['avatar']['dir']) || !is_writable($values['avatar']['dir'])) {
$this->clientError(sprintf(_("Avatar directory not writable: %s"), $values['avatar']['dir']));
$this->clientError(sprintf(_("Avatar directory not writable: %s."), $values['avatar']['dir']));
}
// Validate background dir
if (empty($values['background']['dir']) || !is_writable($values['background']['dir'])) {
$this->clientError(sprintf(_("Background directory not writable: %s"), $values['background']['dir']));
$this->clientError(sprintf(_("Background directory not writable: %s."), $values['background']['dir']));
}
// Validate locales dir
@ -174,13 +174,13 @@ class PathsadminpanelAction extends AdminPanelAction
// XXX: What else do we need to validate for lacales path here? --Z
if (!empty($values['site']['locale_path']) && !is_readable($values['site']['locale_path'])) {
$this->clientError(sprintf(_("Locales directory not readable: %s"), $values['site']['locale_path']));
$this->clientError(sprintf(_("Locales directory not readable: %s."), $values['site']['locale_path']));
}
// Validate SSL setup
if (mb_strlen($values['site']['sslserver']) > 255) {
$this->clientError(_("Invalid SSL server. The maximum length is 255 characters."));
$this->clientError(_('Invalid SSL server. The maximum length is 255 characters.'));
}
}

View File

@ -65,7 +65,7 @@ class PeopletagAction extends Action
$this->tag = $this->trimmed('tag');
if (!common_valid_profile_tag($this->tag)) {
$this->clientError(sprintf(_('Not a valid people tag: %s'),
$this->clientError(sprintf(_('Not a valid people tag: %s.'),
$this->tag));
return;
}
@ -168,9 +168,13 @@ class PeopleTagListItem extends ProfileListItem
function homepageAttributes()
{
$aAttrs = parent::linkAttributes();
if (common_config('nofollow', 'peopletag')) {
$aAttrs['rel'] = 'nofollow';
}
return $aAttrs;
}
}

View File

@ -92,7 +92,7 @@ class PostnoticeAction extends Action
{
$content = common_shorten_links($_POST['omb_notice_content']);
if (Notice::contentTooLong($content)) {
$this->clientError(_('Invalid notice content'), 400);
$this->clientError(_('Invalid notice content.'), 400);
return false;
}
$license = $_POST['omb_notice_license'];

View File

@ -80,7 +80,7 @@ class PublicAction extends Action
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
if ($this->page > MAX_PUBLIC_PAGE) {
$this->clientError(sprintf(_("Beyond the page limit (%s)"), MAX_PUBLIC_PAGE));
$this->clientError(sprintf(_("Beyond the page limit (%s)."), MAX_PUBLIC_PAGE));
}
common_set_returnto($this->selfUrl());
@ -95,7 +95,7 @@ class PublicAction extends Action
if($this->page > 1 && $this->notice->N == 0){
// TRANS: Server error when page not found (404)
$this->serverError(_('No such page'),$code=404);
$this->serverError(_('No such page.'),$code=404);
}
return true;

View File

@ -491,11 +491,15 @@ class RegisterAction extends Action
$this->elementStart('li');
$this->element('input', $attrs);
$this->elementStart('label', array('class' => 'checkbox', 'for' => 'license'));
$this->text(_('My text and files are available under '));
$this->element('a', array('href' => common_config('license', 'url')),
common_config('license', 'title'), _("Creative Commons Attribution 3.0"));
$this->text(_(' except this private data: password, '.
'email address, IM address, and phone number.'));
$message = _('My text and files are available under %s ' .
'except this private data: password, ' .
'email address, IM address, and phone number.');
$link = '<a href="' .
htmlspecialchars(common_config('license', 'url')) .
'">' .
htmlspecialchars(common_config('license', 'title')) .
'</a>';
$this->raw(sprintf(htmlspecialchars($message), $link));
$this->elementEnd('label');
$this->elementEnd('li');
}

View File

@ -188,7 +188,7 @@ class RemotesubscribeAction extends Action
$profile = $user->getProfile();
if (!$profile) {
common_log_db_error($user, 'SELECT', __FILE__);
$this->serverError(_('User without matching profile'));
$this->serverError(_('User without matching profile.'));
return;
}

View File

@ -54,21 +54,21 @@ class RepeatAction extends Action
$this->user = common_current_user();
if (empty($this->user)) {
$this->clientError(_("Only logged-in users can repeat notices."));
$this->clientError(_('Only logged-in users can repeat notices.'));
return false;
}
$id = $this->trimmed('notice');
if (empty($id)) {
$this->clientError(_("No notice specified."));
$this->clientError(_('No notice specified.'));
return false;
}
$this->notice = Notice::staticGet('id', $id);
if (empty($this->notice)) {
$this->clientError(_("No notice specified."));
$this->clientError(_('No notice specified.'));
return false;
}
@ -80,14 +80,14 @@ class RepeatAction extends Action
$token = $this->trimmed('token-'.$id);
if (empty($token) || $token != common_session_token()) {
$this->clientError(_("There was a problem with your session token. Try again, please."));
$this->clientError(_('There was a problem with your session token. Try again, please.'));
return false;
}
$profile = $this->user->getProfile();
if ($profile->hasRepeated($id)) {
$this->clientError(_("You already repeated that notice."));
$this->clientError(_('You already repeated that notice.'));
return false;
}

View File

@ -90,7 +90,7 @@ class RepliesAction extends OwnerDesignAction
if($this->page > 1 && $this->notice->N == 0){
// TRANS: Server error when page not found (404)
$this->serverError(_('No such page'),$code=404);
$this->serverError(_('No such page.'),$code=404);
}
return true;

View File

@ -59,11 +59,11 @@ class RevokeRoleAction extends ProfileFormAction
$this->role = $this->arg('role');
if (!Profile_role::isValid($this->role)) {
$this->clientError(_("Invalid role."));
$this->clientError(_('Invalid role.'));
return false;
}
if (!Profile_role::isSettable($this->role)) {
$this->clientError(_("This role is reserved and cannot be set."));
$this->clientError(_('This role is reserved and cannot be set.'));
return false;
}
@ -72,7 +72,7 @@ class RevokeRoleAction extends ProfileFormAction
assert(!empty($cur)); // checked by parent
if (!$cur->hasRight(Right::REVOKEROLE)) {
$this->clientError(_("You cannot revoke user roles on this site."));
$this->clientError(_('You cannot revoke user roles on this site.'));
return false;
}

View File

@ -62,14 +62,14 @@ class SandboxAction extends ProfileFormAction
assert(!empty($cur)); // checked by parent
if (!$cur->hasRight(Right::SANDBOXUSER)) {
$this->clientError(_("You cannot sandbox users on this site."));
$this->clientError(_('You cannot sandbox users on this site.'));
return false;
}
assert(!empty($this->profile)); // checked by parent
if ($this->profile->isSandboxed()) {
$this->clientError(_("User is already sandboxed."));
$this->clientError(_('User is already sandboxed.'));
return false;
}

View File

@ -135,7 +135,7 @@ class ShowfavoritesAction extends OwnerDesignAction
if($this->page > 1 && $this->notice->N == 0){
// TRANS: Server error when page not found (404)
$this->serverError(_('No such page'),$code=404);
$this->serverError(_('No such page.'),$code=404);
}
return true;

View File

@ -97,7 +97,7 @@ class ShownoticeAction extends OwnerDesignAction
$this->profile = $this->notice->getProfile();
if (empty($this->profile)) {
$this->serverError(_('Notice has no profile'), 500);
$this->serverError(_('Notice has no profile.'), 500);
return false;
}

View File

@ -62,14 +62,14 @@ class SilenceAction extends ProfileFormAction
assert(!empty($cur)); // checked by parent
if (!$cur->hasRight(Right::SILENCEUSER)) {
$this->clientError(_("You cannot silence users on this site."));
$this->clientError(_('You cannot silence users on this site.'));
return false;
}
assert(!empty($this->profile)); // checked by parent
if ($this->profile->isSilenced()) {
$this->clientError(_("User is already silenced."));
$this->clientError(_('User is already silenced.'));
return false;
}

View File

@ -130,7 +130,7 @@ class SiteadminpanelAction extends AdminPanelAction
// Validate site name
if (empty($values['site']['name'])) {
$this->clientError(_("Site name must have non-zero length."));
$this->clientError(_('Site name must have non-zero length.'));
}
// Validate email
@ -168,7 +168,7 @@ class SiteadminpanelAction extends AdminPanelAction
// Validate dupe limit
if (!Validate::number($values['site']['dupelimit'], array('min' => 1))) {
$this->clientError(_("Dupe limit must 1 or more seconds."));
$this->clientError(_("Dupe limit must be one or more seconds."));
}
}

View File

@ -110,7 +110,7 @@ class SitenoticeadminpanelAction extends AdminPanelAction
if (mb_strlen($siteNotice) > 255) {
$this->clientError(
_('Max length for the site-wide notice is 255 chars')
_('Max length for the site-wide notice is 255 chars.')
);
}

View File

@ -55,6 +55,7 @@ class SmssettingsAction extends ConnectSettingsAction
function title()
{
// TRANS: Title for SMS settings.
return _('SMS settings');
}
@ -66,6 +67,10 @@ class SmssettingsAction extends ConnectSettingsAction
function getInstructions()
{
// XXX: For consistency of parameters in messages, this should be a
// regular parameters, replaced with sprintf().
// TRANS: SMS settings page instructions.
// TRANS: %%site.name%% is the name of the site.
return _('You can receive SMS messages through email from %%site.name%%.');
}
@ -88,6 +93,7 @@ class SmssettingsAction extends ConnectSettingsAction
{
if (!common_config('sms', 'enabled')) {
$this->element('div', array('class' => 'error'),
// TRANS: Message given in the SMS settings if SMS is not enabled on the site.
_('SMS is not available.'));
return;
}
@ -101,7 +107,8 @@ class SmssettingsAction extends ConnectSettingsAction
common_local_url('smssettings')));
$this->elementStart('fieldset', array('id' => 'settings_sms_address'));
$this->element('legend', null, _('Address'));
// TRANS: Form legend for SMS settings form.
$this->element('legend', null, _('SMS address'));
$this->hidden('token', common_session_token());
if ($user->sms) {
@ -109,10 +116,12 @@ class SmssettingsAction extends ConnectSettingsAction
$this->element('p', 'form_confirmed',
$user->sms . ' (' . $carrier->name . ')');
$this->element('p', 'form_guide',
// TRANS: Form guide in SMS settings form.
_('Current confirmed SMS-enabled phone number.'));
$this->hidden('sms', $user->sms);
$this->hidden('carrier', $user->carrier);
$this->submit('remove', _('Remove'));
// TRANS: Button label to remove a confirmed SMS address.
$this->submit('remove', _m('BUTTON','Remove'));
} else {
$confirm = $this->getConfirmation();
if ($confirm) {
@ -120,57 +129,75 @@ class SmssettingsAction extends ConnectSettingsAction
$this->element('p', 'form_unconfirmed',
$confirm->address . ' (' . $carrier->name . ')');
$this->element('p', 'form_guide',
// TRANS: Form guide in IM settings form.
_('Awaiting confirmation on this phone number.'));
$this->hidden('sms', $confirm->address);
$this->hidden('carrier', $confirm->address_extra);
$this->submit('cancel', _('Cancel'));
// TRANS: Button label to cancel a SMS address confirmation procedure.
$this->submit('cancel', _m('BUTTON','Cancel'));
$this->elementStart('ul', 'form_data');
$this->elementStart('li');
// TRANS: Field label for SMS address input in SMS settings form.
$this->input('code', _('Confirmation code'), null,
// TRANS: Form field instructions in SMS settings form.
_('Enter the code you received on your phone.'));
$this->elementEnd('li');
$this->elementEnd('ul');
$this->submit('confirm', _('Confirm'));
// TRANS: Button label to confirm SMS confirmation code in SMS settings.
$this->submit('confirm', _m('BUTTON','Confirm'));
} else {
$this->elementStart('ul', 'form_data');
$this->elementStart('li');
// TRANS: Field label for SMS phone number input in SMS settings form.
$this->input('sms', _('SMS phone number'),
($this->arg('sms')) ? $this->arg('sms') : null,
// TRANS: SMS phone number input field instructions in SMS settings form.
_('Phone number, no punctuation or spaces, '.
'with area code'));
$this->elementEnd('li');
$this->elementEnd('ul');
$this->carrierSelect();
$this->submit('add', _('Add'));
// TRANS: Button label for adding a SMS phone number in SMS settings form.
$this->submit('add', _m('BUTTON','Add'));
}
}
$this->elementEnd('fieldset');
if ($user->sms) {
$this->elementStart('fieldset', array('id' => 'settings_sms_incoming_email'));
// XXX: Confused! This is about SMS. Should this message be updated?
// TRANS: Form legend for incoming SMS settings form.
$this->element('legend', null, _('Incoming email'));
if ($user->incomingemail) {
$this->element('p', 'form_unconfirmed', $user->incomingemail);
$this->element('p', 'form_note',
// XXX: Confused! This is about SMS. Should this message be updated?
// TRANS: Form instructions for incoming SMS e-mail address form in SMS settings.
_('Send email to this address to post new notices.'));
$this->submit('removeincoming', _('Remove'));
// TRANS: Button label for removing a set sender SMS e-mail address to post notices from.
$this->submit('removeincoming', _m('BUTTON','Remove'));
}
$this->element('p', 'form_guide',
// XXX: Confused! This is about SMS. Should this message be updated?
// TRANS: Instructions for incoming SMS e-mail address input form.
_('Make a new email address for posting to; '.
'cancels the old one.'));
$this->submit('newincoming', _('New'));
// TRANS: Button label for adding an SMS e-mail address to send notices from.
$this->submit('newincoming', _m('BUTTON','New'));
$this->elementEnd('fieldset');
}
$this->elementStart('fieldset', array('id' => 'settings_sms_preferences'));
$this->element('legend', null, _('Preferences'));
// TRANS: Form legend for SMS preferences form.
$this->element('legend', null, _('SMS preferences'));
$this->elementStart('ul', 'form_data');
$this->elementStart('li');
$this->checkbox('smsnotify',
// TRANS: Checkbox label in SMS preferences form.
_('Send me notices through SMS; '.
'I understand I may incur '.
'exorbitant charges from my carrier.'),
@ -178,7 +205,8 @@ class SmssettingsAction extends ConnectSettingsAction
$this->elementEnd('li');
$this->elementEnd('ul');
$this->submit('save', _('Save'));
// TRANS: Button label to save SMS preferences.
$this->submit('save', _m('BUTTON','Save'));
$this->elementEnd('fieldset');
$this->elementEnd('form');
@ -245,6 +273,7 @@ class SmssettingsAction extends ConnectSettingsAction
} else if ($this->arg('confirm')) {
$this->confirmCode();
} else {
// TRANS: Message given submitting a form with an unknown action in SMS settings.
$this->showForm(_('Unexpected form submission.'));
}
}
@ -275,13 +304,15 @@ class SmssettingsAction extends ConnectSettingsAction
if ($result === false) {
common_log_db_error($user, 'UPDATE', __FILE__);
// TRANS: Server error thrown on database error updating SMS preferences.
$this->serverError(_('Couldn\'t update user.'));
return;
}
$user->query('COMMIT');
$this->showForm(_('Preferences saved.'), true);
// TRANS: Confirmation message for successful SMS preferences save.
$this->showForm(_('SMS preferences saved.'), true);
}
/**
@ -303,11 +334,13 @@ class SmssettingsAction extends ConnectSettingsAction
// Some validation
if (!$sms) {
// TRANS: Message given saving SMS phone number without having provided one.
$this->showForm(_('No phone number.'));
return;
}
if (!$carrier_id) {
// TRANS: Message given saving SMS phone number without having selected a carrier.
$this->showForm(_('No carrier selected.'));
return;
}
@ -315,9 +348,11 @@ class SmssettingsAction extends ConnectSettingsAction
$sms = common_canonical_sms($sms);
if ($user->sms == $sms) {
// TRANS: Message given saving SMS phone number that is already set.
$this->showForm(_('That is already your phone number.'));
return;
} else if ($this->smsExists($sms)) {
// TRANS: Message given saving SMS phone number that is already set for another user.
$this->showForm(_('That phone number already belongs to another user.'));
return;
}
@ -334,6 +369,7 @@ class SmssettingsAction extends ConnectSettingsAction
if ($result === false) {
common_log_db_error($confirm, 'INSERT', __FILE__);
// TRANS: Server error thrown on database error adding SMS confirmation code.
$this->serverError(_('Couldn\'t insert confirmation code.'));
return;
}
@ -344,6 +380,7 @@ class SmssettingsAction extends ConnectSettingsAction
$user->nickname,
$carrier->toEmailAddress($sms));
// TRANS: Message given saving valid SMS phone number that is to be confirmed.
$msg = _('A confirmation code was sent to the phone number you added. '.
'Check your phone for the code and instructions '.
'on how to use it.');
@ -367,10 +404,12 @@ class SmssettingsAction extends ConnectSettingsAction
$confirm = $this->getConfirmation();
if (!$confirm) {
// TRANS: Message given canceling SMS phone number confirmation that is not pending.
$this->showForm(_('No pending confirmation to cancel.'));
return;
}
if ($confirm->address != $sms) {
// TRANS: Message given canceling SMS phone number confirmation for the wrong phone number.
$this->showForm(_('That is the wrong confirmation number.'));
return;
}
@ -379,11 +418,13 @@ class SmssettingsAction extends ConnectSettingsAction
if (!$result) {
common_log_db_error($confirm, 'DELETE', __FILE__);
// TRANS: Server error thrown on database error canceling SMS phone number confirmation.
$this->serverError(_('Couldn\'t delete email confirmation.'));
return;
}
$this->showForm(_('Confirmation cancelled.'), true);
// TRANS: Message given after successfully canceling SMS phone number confirmation.
$this->showForm(_('SMS confirmation cancelled.'), true);
}
/**
@ -402,6 +443,8 @@ class SmssettingsAction extends ConnectSettingsAction
// Maybe an old tab open...?
if ($user->sms != $sms) {
// TRANS: Message given trying to remove an SMS phone number that is not
// TRANS: registered for the active user.
$this->showForm(_('That is not your phone number.'));
return;
}
@ -417,12 +460,14 @@ class SmssettingsAction extends ConnectSettingsAction
$result = $user->updateKeys($original);
if (!$result) {
common_log_db_error($user, 'UPDATE', __FILE__);
// TRANS: Server error thrown on database error removing a registered SMS phone number.
$this->serverError(_('Couldn\'t update user.'));
return;
}
$user->query('COMMIT');
$this->showForm(_('The address was removed.'), true);
// TRANS: Message given after successfully removing a registered SMS phone number.
$this->showForm(_('The SMS phone number was removed.'), true);
}
/**
@ -462,10 +507,12 @@ class SmssettingsAction extends ConnectSettingsAction
$this->elementStart('ul', 'form_data');
$this->elementStart('li');
// TRANS: Label for mobile carrier dropdown menu in SMS settings.
$this->element('label', array('for' => 'carrier'), _('Mobile carrier'));
$this->elementStart('select', array('name' => 'carrier',
'id' => 'carrier'));
$this->element('option', array('value' => 0),
// TRANS: Default option for mobile carrier dropdown menu in SMS settings.
_('Select a carrier'));
while ($carrier->fetch()) {
$this->element('option', array('value' => $carrier->id),
@ -473,6 +520,8 @@ class SmssettingsAction extends ConnectSettingsAction
}
$this->elementEnd('select');
$this->element('p', 'form_guide',
// TRANS: Form instructions for mobile carrier dropdown menu in SMS settings.
// TRANS: %s is an administrative contact's e-mail address.
sprintf(_('Mobile carrier for your phone. '.
'If you know a carrier that accepts ' .
'SMS over email but isn\'t listed here, ' .
@ -495,6 +544,7 @@ class SmssettingsAction extends ConnectSettingsAction
$code = $this->trimmed('code');
if (!$code) {
// TRANS: Message given saving SMS phone number confirmation code without having provided one.
$this->showForm(_('No code entered'));
return;
}

View File

@ -124,13 +124,13 @@ class SnapshotadminpanelAction extends AdminPanelAction
// Validate snapshot run value
if (!in_array($values['snapshot']['run'], array('web', 'cron', 'never'))) {
$this->clientError(_("Invalid snapshot run value."));
$this->clientError(_('Invalid snapshot run value.'));
}
// Validate snapshot frequency value
if (!Validate::number($values['snapshot']['frequency'])) {
$this->clientError(_("Snapshot frequency must be a number."));
$this->clientError(_('Snapshot frequency must be a number.'));
}
// Validate report URL
@ -141,7 +141,7 @@ class SnapshotadminpanelAction extends AdminPanelAction
array('allowed_schemes' => array('http', 'https')
)
)) {
$this->clientError(_("Invalid snapshot report URL."));
$this->clientError(_('Invalid snapshot report URL.'));
}
}
}
@ -197,7 +197,7 @@ class SnapshotAdminPanelForm extends AdminForm
$this->out->elementStart('ul', 'form_data');
$this->li();
$snapshot = array(
'web' => _('Randomly during Web hit'),
'web' => _('Randomly during web hit'),
'cron' => _('In a scheduled job'),
'never' => _('Never')
);

View File

@ -157,9 +157,13 @@ class SubscribersListItem extends SubscriptionListItem
$user = common_current_user();
if (!empty($user) && $this->owner->id == $user->id) {
$bf = new BlockForm($this->out, $this->profile,
array('action' => 'subscribers',
'nickname' => $this->owner->nickname));
$returnto = array('action' => 'subscribers',
'nickname' => $this->owner->nickname);
$page = $this->out->arg('page');
if ($page) {
$returnto['param-page'] = $page;
}
$bf = new BlockForm($this->out, $this->profile, $returnto);
$bf->show();
}
}
@ -177,8 +181,12 @@ class SubscribersListItem extends SubscriptionListItem
function homepageAttributes()
{
$aAttrs = parent::linkAttributes();
if (common_config('nofollow', 'subscribers')) {
$aAttrs['rel'] = 'nofollow';
}
return $aAttrs;
}
}

View File

@ -49,7 +49,7 @@ class TagAction extends Action
if($this->page > 1 && $this->notice->N == 0){
// TRANS: Server error when page not found (404)
$this->serverError(_('No such page'),$code=404);
$this->serverError(_('No such page.'),$code=404);
}
return true;

View File

@ -62,14 +62,14 @@ class UnsandboxAction extends ProfileFormAction
assert(!empty($cur)); // checked by parent
if (!$cur->hasRight(Right::SANDBOXUSER)) {
$this->clientError(_("You cannot sandbox users on this site."));
$this->clientError(_('You cannot sandbox users on this site.'));
return false;
}
assert(!empty($this->profile)); // checked by parent
if (!$this->profile->isSandboxed()) {
$this->clientError(_("User is not sandboxed."));
$this->clientError(_('User is not sandboxed.'));
return false;
}

View File

@ -62,14 +62,14 @@ class UnsilenceAction extends ProfileFormAction
assert(!empty($cur)); // checked by parent
if (!$cur->hasRight(Right::SILENCEUSER)) {
$this->clientError(_("You cannot silence users on this site."));
$this->clientError(_('You cannot silence users on this site.'));
return false;
}
assert(!empty($this->profile)); // checked by parent
if (!$this->profile->isSilenced()) {
$this->clientError(_("User is not silenced."));
$this->clientError(_('User is not silenced.'));
return false;
}

View File

@ -74,7 +74,7 @@ class UnsubscribeAction extends Action
$other_id = $this->arg('unsubscribeto');
if (!$other_id) {
$this->clientError(_('No profile id in request.'));
$this->clientError(_('No profile ID in request.'));
return;
}

View File

@ -69,7 +69,7 @@ class UserauthorizationAction extends Action
$profile = $user->getProfile();
if (!$profile) {
common_log_db_error($user, 'SELECT', __FILE__);
$this->serverError(_('User without matching profile'));
$this->serverError(_('User without matching profile.'));
return;
}

View File

@ -59,8 +59,10 @@ class UsergroupsAction extends OwnerDesignAction
function title()
{
if ($this->page == 1) {
// TRANS: Message is used as a page title. %s is a nick name.
return sprintf(_('%s groups'), $this->user->nickname);
} else {
// TRANS: Message is used as a page title. %1$s is a nick name, %2$d is a page number.
return sprintf(_('%1$s groups, page %2$d'),
$this->user->nickname,
$this->page);

View File

@ -72,7 +72,7 @@ class UserrssAction extends Rss10Action
{
$notice = $this->user->getNotices(
0,
($limit == 0) ? NOTICES_PER_PAGE : $limit
($this->limit == 0) ? NOTICES_PER_PAGE : $this->limit
);
$notices = array();
@ -90,8 +90,10 @@ class UserrssAction extends Rss10Action
$c = array('url' => common_local_url('userrss',
array('nickname' =>
$user->nickname)),
// TRANS: Message is used as link title. %s is a user nickname.
'title' => sprintf(_('%s timeline'), $user->nickname),
'link' => $profile->profileurl,
// TRANS: Message is used as link description. %1$s is a username, %2$s is a site name.
'description' => sprintf(_('Updates from %1$s on %2$s!'),
$user->nickname, common_config('site', 'name')));
return $c;
@ -103,7 +105,7 @@ class UserrssAction extends Rss10Action
$profile = $user->getProfile();
if (!$profile) {
common_log_db_error($user, 'SELECT', __FILE__);
$this->serverError(_('User without matching profile'));
$this->serverError(_('User without matching profile.'));
return null;
}
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);

View File

@ -148,11 +148,11 @@ class Notice extends Memcached_DataObject
//turn each into their canonical tag
//this is needed to remove dupes before saving e.g. #hash.tag = #hashtag
for($i=0; $i<count($hashtags); $i++) {
/* elide characters we don't want in the tag */
$hashtags[$i] = common_canonical_tag($hashtags[$i]);
}
foreach(array_unique($hashtags) as $hashtag) {
/* elide characters we don't want in the tag */
$this->saveTag($hashtag);
self::blow('profile:notice_ids_tagged:%d:%s', $this->profile_id, $hashtag);
}
@ -172,7 +172,8 @@ class Notice extends Memcached_DataObject
$id = $tag->insert();
if (!$id) {
throw new ServerException(sprintf(_('DB error inserting hashtag: %s'),
// TRANS: Server exception. %s are the error details.
throw new ServerException(sprintf(_('Database error inserting hashtag: %s'),
$last_error->message));
return;
}
@ -373,18 +374,20 @@ class Notice extends Memcached_DataObject
$notice->saveReplies();
}
if (isset($groups)) {
$notice->saveKnownGroups($groups);
} else {
$notice->saveGroups();
}
if (isset($tags)) {
$notice->saveKnownTags($tags);
} else {
$notice->saveTags();
}
// Note: groups may save tags, so must be run after tags are saved
// to avoid errors on duplicates.
if (isset($groups)) {
$notice->saveKnownGroups($groups);
} else {
$notice->saveGroups();
}
if (isset($urls)) {
$notice->saveKnownUrls($urls);
} else {
@ -699,6 +702,27 @@ class Notice extends Memcached_DataObject
return $ids;
}
/**
* Is this notice part of an active conversation?
*
* @return boolean true if other messages exist in the same
* conversation, false if this is the only one
*/
function hasConversation()
{
if (!empty($this->conversation)) {
$conversation = Notice::conversationStream(
$this->conversation,
1,
1
);
if ($conversation->N > 0) {
return true;
}
}
return false;
}
/**
* @param $groups array of Group *objects*
* @param $recipients array of profile *ids*
@ -964,11 +988,19 @@ class Notice extends Memcached_DataObject
*/
function saveKnownReplies($uris)
{
if (empty($uris)) {
return;
}
$sender = Profile::staticGet($this->profile_id);
foreach ($uris as $uri) {
$user = User::staticGet('uri', $uri);
if (!empty($user)) {
if ($user->hasBlocked($sender)) {
continue;
}
$reply = new Reply();
@ -1478,6 +1510,8 @@ class Notice extends Memcached_DataObject
{
$author = Profile::staticGet('id', $this->profile_id);
// TRANS: Message used to repeat a notice. RT is the abbreviation of 'retweet'.
// TRANS: %1$s is the repeated user's name, %2$s is the repeated notice.
$content = sprintf(_('RT @%1$s %2$s'),
$author->nickname,
$this->content);

View File

@ -543,7 +543,10 @@ class User extends Memcached_DataObject
return false;
}
Subscription::cancel($other, $this->getProfile());
$self = $this->getProfile();
if (Subscription::exists($other, $self)) {
Subscription::cancel($other, $self);
}
$block->query('COMMIT');

View File

@ -1,8 +1,7 @@
<?php
/**
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2009, StatusNet, Inc.
* Copyright (C) 2009-2010, StatusNet, Inc.
*
* 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
@ -39,414 +38,7 @@
define('INSTALLDIR', dirname(__FILE__));
$external_libraries=array(
array(
'name'=>'gettext',
'url'=>'http://us.php.net/manual/en/book.gettext.php',
'check_function'=>'gettext'
),
array(
'name'=>'PEAR',
'url'=>'http://pear.php.net/',
'deb'=>'php-pear',
'include'=>'PEAR.php',
'check_class'=>'PEAR'
),
array(
'name'=>'DB',
'pear'=>'DB',
'url'=>'http://pear.php.net/package/DB',
'deb'=>'php-db',
'include'=>'DB/common.php',
'check_class'=>'DB_common'
),
array(
'name'=>'DB_DataObject',
'pear'=>'DB_DataObject',
'url'=>'http://pear.php.net/package/DB_DataObject',
'include'=>'DB/DataObject.php',
'check_class'=>'DB_DataObject'
),
array(
'name'=>'Console_Getopt',
'pear'=>'Console_Getopt',
'url'=>'http://pear.php.net/package/Console_Getopt',
'include'=>'Console/Getopt.php',
'check_class'=>'Console_Getopt'
),
array(
'name'=>'Facebook API',
'url'=>'http://developers.facebook.com/',
'include'=>'facebook/facebook.php',
'check_class'=>'Facebook'
),
array(
'name'=>'htmLawed',
'url'=>'http://www.bioinformatics.org/phplabware/internal_utilities/htmLawed',
'include'=>'htmLawed/htmLawed.php',
'check_function'=>'htmLawed'
),
array(
'name'=>'HTTP_Request',
'pear'=>'HTTP_Request',
'url'=>'http://pear.php.net/package/HTTP_Request',
'deb'=>'php-http-request',
'include'=>'HTTP/Request.php',
'check_class'=>'HTTP_Request'
),
array(
'name'=>'HTTP_Request2',
'pear'=>'HTTP_Request2',
'url'=>'http://pear.php.net/package/HTTP_Request2',
'include'=>'HTTP/Request2.php',
'check_class'=>'HTTP_Request2'
),
array(
'name'=>'Mail',
'pear'=>'Mail',
'url'=>'http://pear.php.net/package/Mail',
'deb'=>'php-mail',
'include'=>'Mail.php',
'check_class'=>'Mail'
),
array(
'name'=>'Mail_mimeDecode',
'pear'=>'Mail_mimeDecode',
'url'=>'http://pear.php.net/package/Mail_mimeDecode',
'deb'=>'php-mail-mimedecode',
'include'=>'Mail/mimeDecode.php',
'check_class'=>'Mail_mimeDecode'
),
array(
'name'=>'Mime_Type',
'pear'=>'Mime_Type',
'url'=>'http://pear.php.net/package/Mime_Type',
'include'=>'MIME/Type.php',
'check_class'=>'Mime_Type'
),
array(
'name'=>'Net_URL_Mapper',
'pear'=>'Net_URL_Mapper',
'url'=>'http://pear.php.net/package/Net_URL_Mapper',
'include'=>'Net/URL/Mapper.php',
'check_class'=>'Net_URL_Mapper'
),
array(
'name'=>'Net_LDAP2',
'pear'=>'Net_LDAP2',
'url'=>'http://pear.php.net/package/Net_LDAP2',
'deb'=>'php-net-ldap2',
'include'=>'Net/LDAP2.php',
'check_class'=>'Net_LDAP2'
),
array(
'name'=>'Net_Socket',
'pear'=>'Net_Socket',
'url'=>'http://pear.php.net/package/Net_Socket',
'deb'=>'php-net-socket',
'include'=>'Net/Socket.php',
'check_class'=>'Net_Socket'
),
array(
'name'=>'Net_SMTP',
'pear'=>'Net_SMTP',
'url'=>'http://pear.php.net/package/Net_SMTP',
'deb'=>'php-net-smtp',
'include'=>'Net/SMTP.php',
'check_class'=>'Net_SMTP'
),
array(
'name'=>'Net_URL',
'pear'=>'Net_URL',
'url'=>'http://pear.php.net/package/Net_URL',
'deb'=>'php-net-url',
'include'=>'Net/URL.php',
'check_class'=>'Net_URL'
),
array(
'name'=>'Net_URL2',
'pear'=>'Net_URL2',
'url'=>'http://pear.php.net/package/Net_URL2',
'include'=>'Net/URL2.php',
'check_class'=>'Net_URL2'
),
array(
'name'=>'Services_oEmbed',
'pear'=>'Services_oEmbed',
'url'=>'http://pear.php.net/package/Services_oEmbed',
'include'=>'Services/oEmbed.php',
'check_class'=>'Services_oEmbed'
),
array(
'name'=>'Stomp',
'url'=>'http://stomp.codehaus.org/PHP',
'include'=>'Stomp.php',
'check_class'=>'Stomp'
),
array(
'name'=>'System_Command',
'pear'=>'System_Command',
'url'=>'http://pear.php.net/package/System_Command',
'include'=>'System/Command.php',
'check_class'=>'System_Command'
),
array(
'name'=>'XMPPHP',
'url'=>'http://code.google.com/p/xmpphp',
'include'=>'XMPPHP/XMPP.php',
'check_class'=>'XMPPHP_XMPP'
),
array(
'name'=>'PHP Markdown',
'url'=>'http://www.michelf.com/projects/php-markdown/',
'include'=>'markdown.php',
'check_class'=>'Markdown_Parser'
),
array(
'name'=>'OAuth',
'url'=>'http://code.google.com/p/oauth-php',
'include'=>'OAuth.php',
'check_class'=>'OAuthRequest'
),
array(
'name'=>'Validate',
'pear'=>'Validate',
'url'=>'http://pear.php.net/package/Validate',
'include'=>'Validate.php',
'check_class'=>'Validate'
)
);
$dbModules = array(
'mysql' => array(
'name' => 'MySQL',
'check_module' => 'mysql', // mysqli?
'installer' => 'mysql_db_installer',
),
'pgsql' => array(
'name' => 'PostgreSQL',
'check_module' => 'pgsql',
'installer' => 'pgsql_db_installer',
),
);
/**
* the actual installation.
* If call libraries are present, then install
*
* @return void
*/
function main()
{
if (!checkPrereqs()) {
return;
}
if (!empty($_GET['checklibs'])) {
showLibs();
} else {
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
handlePost();
} else {
showForm();
}
}
}
/**
* checks if an external libary is present
*
* @param string $external_library Name of library
*
* @return boolean indicates if library present
*/
function haveExternalLibrary($external_library)
{
if (isset($external_library['include']) && !haveIncludeFile($external_library['include'])) {
return false;
}
if (isset($external_library['check_function']) && ! function_exists($external_library['check_function'])) {
return false;
}
if (isset($external_library['check_class']) && ! class_exists($external_library['check_class'])) {
return false;
}
return true;
}
// Attempt to include a PHP file and report if it worked, while
// suppressing the annoying warning messages on failure.
function haveIncludeFile($filename) {
$old = error_reporting(error_reporting() & ~E_WARNING);
$ok = include_once($filename);
error_reporting($old);
return $ok;
}
/**
* Check if all is ready for installation
*
* @return void
*/
function checkPrereqs()
{
$pass = true;
if (file_exists(INSTALLDIR.'/config.php')) {
printf('<p class="error">Config file &quot;config.php&quot; already exists.</p>');
$pass = false;
}
if (version_compare(PHP_VERSION, '5.2.3', '<')) {
printf('<p class="error">Require PHP version 5.2.3 or greater.</p>');
$pass = false;
}
// Look for known library bugs
$str = "abcdefghijklmnopqrstuvwxyz";
$replaced = preg_replace('/[\p{Cc}\p{Cs}]/u', '*', $str);
if ($str != $replaced) {
printf('<p class="error">PHP is linked to a version of the PCRE library ' .
'that does not support Unicode properties. ' .
'If you are running Red Hat Enterprise Linux / ' .
'CentOS 5.4 or earlier, see <a href="' .
'http://status.net/wiki/Red_Hat_Enterprise_Linux#PCRE_library' .
'">our documentation page</a> on fixing this.</p>');
$pass = false;
}
$reqs = array('gd', 'curl',
'xmlwriter', 'mbstring', 'xml', 'dom', 'simplexml');
foreach ($reqs as $req) {
if (!checkExtension($req)) {
printf('<p class="error">Cannot load required extension: <code>%s</code></p>', $req);
$pass = false;
}
}
// Make sure we have at least one database module available
global $dbModules;
$missingExtensions = array();
foreach ($dbModules as $type => $info) {
if (!checkExtension($info['check_module'])) {
$missingExtensions[] = $info['check_module'];
}
}
if (count($missingExtensions) == count($dbModules)) {
$req = implode(', ', $missingExtensions);
printf('<p class="error">Cannot find mysql or pgsql extension. You need one or the other.');
$pass = false;
}
if (!is_writable(INSTALLDIR)) {
printf('<p class="error">Cannot write config file to: <code>%s</code></p>', INSTALLDIR);
printf('<p>On your server, try this command: <code>chmod a+w %s</code>', INSTALLDIR);
$pass = false;
}
// Check the subdirs used for file uploads
$fileSubdirs = array('avatar', 'background', 'file');
foreach ($fileSubdirs as $fileSubdir) {
$fileFullPath = INSTALLDIR."/$fileSubdir/";
if (!is_writable($fileFullPath)) {
printf('<p class="error">Cannot write to %s directory: <code>%s</code></p>', $fileSubdir, $fileFullPath);
printf('<p>On your server, try this command: <code>chmod a+w %s</code></p>', $fileFullPath);
$pass = false;
}
}
return $pass;
}
/**
* Checks if a php extension is both installed and loaded
*
* @param string $name of extension to check
*
* @return boolean whether extension is installed and loaded
*/
function checkExtension($name)
{
if (extension_loaded($name)) {
return true;
} elseif (function_exists('dl') && ini_get('enable_dl') && !ini_get('safe_mode')) {
// dl will throw a fatal error if it's disabled or we're in safe mode.
// More fun, it may not even exist under some SAPIs in 5.3.0 or later...
$soname = $name . '.' . PHP_SHLIB_SUFFIX;
if (PHP_SHLIB_SUFFIX == 'dll') {
$soname = "php_" . $soname;
}
return @dl($soname);
} else {
return false;
}
}
/**
* Show list of libraries
*
* @return void
*/
function showLibs()
{
global $external_libraries;
$present_libraries=array();
$absent_libraries=array();
foreach ($external_libraries as $external_library) {
if (haveExternalLibrary($external_library)) {
$present_libraries[]=$external_library;
} else {
$absent_libraries[]=$external_library;
}
}
echo<<<E_O_T
<div class="instructions">
<p>StatusNet comes bundled with a number of libraries required for the application to work. However, it is best that you use PEAR or you distribution to manage
libraries instead, as they tend to provide security updates faster, and may offer improved performance.</p>
<p>On Debian based distributions, such as Ubuntu, use a package manager (such as &quot;aptitude&quot;, &quot;apt-get&quot;, and &quot;synaptic&quot;) to install the package listed.</p>
<p>On RPM based distributions, such as Red Hat, Fedora, CentOS, Scientific Linux, Yellow Dog Linux and Oracle Enterprise Linux, use a package manager (such as &quot;yum&quot;, &quot;apt-rpm&quot;, and &quot;up2date&quot;) to install the package listed.</p>
<p>On servers without a package manager (such as Windows), or if the library is not packaged for your distribution, you can use PHP's PEAR to install the library. Simply run &quot;pear install &lt;name&gt;&quot;.</p>
</div>
<h2>Absent Libraries</h2>
<ul id="absent_libraries">
E_O_T;
foreach ($absent_libraries as $library) {
echo '<li>';
if (isset($library['url'])) {
echo '<a href="'.$library['url'].'">'.htmlentities($library['name']).'</a>';
} else {
echo htmlentities($library['name']);
}
echo '<ul>';
if (isset($library['deb'])) {
echo '<li class="deb package">deb: <a href="apt:' . urlencode($library['deb']) . '">' . htmlentities($library['deb']) . '</a></li>';
}
if (isset($library['rpm'])) {
echo '<li class="rpm package">rpm: ' . htmlentities($library['rpm']) . '</li>';
}
if (isset($library['pear'])) {
echo '<li class="pear package">pear: ' . htmlentities($library['pear']) . '</li>';
}
echo '</ul>';
}
echo<<<E_O_T
</ul>
<h2>Installed Libraries</h2>
<ul id="present_libraries">
E_O_T;
foreach ($present_libraries as $library) {
echo '<li>';
if (isset($library['url'])) {
echo '<a href="'.$library['url'].'">'.htmlentities($library['name']).'</a>';
} else {
echo htmlentities($library['name']);
}
echo '</li>';
}
echo<<<E_O_T
</ul>
E_O_T;
}
require INSTALLDIR . '/lib/installer.php';
/**
* Helper class for building form
@ -462,6 +54,53 @@ class Posted {
}
}
/**
* Web-based installer: provides a form and such.
*/
class WebInstaller extends Installer
{
/**
* the actual installation.
* If call libraries are present, then install
*
* @return void
*/
function main()
{
if (!$this->checkPrereqs()) {
$this->showForm();
return;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$this->handlePost();
} else {
$this->showForm();
}
}
/**
* Web implementation of warning output
*/
function warning($message, $submessage='')
{
print "<p class=\"error\">$message</p>\n";
if ($submessage != '') {
print "<p>$submessage</p>\n";
}
}
/**
* Web implementation of status output
*/
function updateStatus($status, $error=false)
{
echo '<li' . ($error ? ' class="error"': '' ) . ">$status</li>";
}
/**
* Show the web form!
*/
function showForm()
{
global $dbModules;
@ -472,8 +111,8 @@ function showForm()
} else {
$dbtype = null;
}
foreach ($dbModules as $type => $info) {
if (checkExtension($info['check_module'])) {
foreach (self::$dbModules as $type => $info) {
if ($this->checkExtension($info['check_module'])) {
if ($dbtype == null || $dbtype == $type) {
$checked = 'checked="checked" ';
$dbtype = $type; // if we didn't have one checked, hit the first
@ -485,9 +124,6 @@ function showForm()
}
echo<<<E_O_T
</ul>
</dd>
</dl>
<form method="post" action="install.php" class="form_settings" id="form_install">
<fieldset>
<fieldset id="settings_site">
@ -574,345 +210,74 @@ function showForm()
E_O_T;
}
function updateStatus($status, $error=false)
{
echo '<li' . ($error ? ' class="error"': '' ) . ">$status</li>";
}
/**
* Handle a POST submission... if we have valid input, start the install!
* Otherwise shows the form along with any error messages.
*/
function handlePost()
{
$host = $_POST['host'];
$dbtype = $_POST['dbtype'];
$database = $_POST['database'];
$username = $_POST['dbusername'];
$password = $_POST['dbpassword'];
$sitename = $_POST['sitename'];
$fancy = !empty($_POST['fancy']);
$adminNick = strtolower($_POST['admin_nickname']);
$adminPass = $_POST['admin_password'];
$adminPass2 = $_POST['admin_password2'];
$adminEmail = $_POST['admin_email'];
$adminUpdates = $_POST['admin_updates'];
$server = $_SERVER['HTTP_HOST'];
$path = substr(dirname($_SERVER['PHP_SELF']), 1);
echo <<<STR
<dl class="system_notice">
<dt>Page notice</dt>
<dd>
<ul>
STR;
$fail = false;
if (empty($host)) {
updateStatus("No hostname specified.", true);
$fail = true;
$this->validated = $this->prepare();
if ($this->validated) {
$this->doInstall();
}
if (empty($database)) {
updateStatus("No database specified.", true);
$fail = true;
echo <<<STR
</ul>
</dd>
</dl>
STR;
if (!$this->validated) {
$this->showForm();
}
if (empty($username)) {
updateStatus("No username specified.", true);
$fail = true;
}
if (empty($sitename)) {
updateStatus("No sitename specified.", true);
$fail = true;
}
if (empty($adminNick)) {
updateStatus("No initial StatusNet user nickname specified.", true);
$fail = true;
}
if ($adminNick && !preg_match('/^[0-9a-z]{1,64}$/', $adminNick)) {
updateStatus('The user nickname "' . htmlspecialchars($adminNick) .
'" is invalid; should be plain letters and numbers no longer than 64 characters.', true);
$fail = true;
}
// @fixme hardcoded list; should use User::allowed_nickname()
// if/when it's safe to have loaded the infrastructure here
$blacklist = array('main', 'admin', 'twitter', 'settings', 'rsd.xml', 'favorited', 'featured', 'favoritedrss', 'featuredrss', 'rss', 'getfile', 'api', 'groups', 'group', 'peopletag', 'tag', 'user', 'message', 'conversation', 'bookmarklet', 'notice', 'attachment', 'search', 'index.php', 'doc', 'opensearch', 'robots.txt', 'xd_receiver.html', 'facebook');
if (in_array($adminNick, $blacklist)) {
updateStatus('The user nickname "' . htmlspecialchars($adminNick) .
'" is reserved.', true);
$fail = true;
}
if (empty($adminPass)) {
updateStatus("No initial StatusNet user password specified.", true);
$fail = true;
}
if ($adminPass != $adminPass2) {
updateStatus("Administrator passwords do not match. Did you mistype?", true);
$fail = true;
}
if ($fail) {
showForm();
return;
}
global $dbModules;
$db = call_user_func($dbModules[$dbtype]['installer'], $host, $database, $username, $password);
if (!$db) {
// database connection failed, do not move on to create config file.
return false;
}
updateStatus("Writing config file...");
$res = writeConf($sitename, $server, $path, $fancy, $db);
if (!$res) {
updateStatus("Can't write config file.", true);
showForm();
return;
}
// Okay, cross fingers and try to register an initial user
if (registerInitialUser($adminNick, $adminPass, $adminEmail, $adminUpdates)) {
updateStatus(
"An initial user with the administrator role has been created."
);
} else {
updateStatus(
"Could not create initial StatusNet user (administrator).",
true
);
showForm();
return;
}
/*
TODO https needs to be considered
*/
$link = "http://".$server.'/'.$path;
updateStatus("StatusNet has been installed at $link");
updateStatus(
"<strong>DONE!</strong> You can visit your <a href='$link'>new StatusNet site</a> (login as '$adminNick'). If this is your first StatusNet install, you may want to poke around our <a href='http://status.net/wiki/Getting_started'>Getting Started guide</a>."
);
}
function Pgsql_Db_installer($host, $database, $username, $password)
{
$connstring = "dbname=$database host=$host user=$username";
//No password would mean trust authentication used.
if (!empty($password)) {
$connstring .= " password=$password";
}
updateStatus("Starting installation...");
updateStatus("Checking database...");
$conn = pg_connect($connstring);
if ($conn ===false) {
updateStatus("Failed to connect to database: $connstring");
showForm();
return false;
}
//ensure database encoding is UTF8
$record = pg_fetch_object(pg_query($conn, 'SHOW server_encoding'));
if ($record->server_encoding != 'UTF8') {
updateStatus("StatusNet requires UTF8 character encoding. Your database is ". htmlentities($record->server_encoding));
showForm();
return false;
}
updateStatus("Running database script...");
//wrap in transaction;
pg_query($conn, 'BEGIN');
$res = runDbScript(INSTALLDIR.'/db/statusnet_pg.sql', $conn, 'pgsql');
if ($res === false) {
updateStatus("Can't run database script.", true);
showForm();
return false;
}
foreach (array('sms_carrier' => 'SMS carrier',
'notice_source' => 'notice source',
'foreign_services' => 'foreign service')
as $scr => $name) {
updateStatus(sprintf("Adding %s data to database...", $name));
$res = runDbScript(INSTALLDIR.'/db/'.$scr.'.sql', $conn, 'pgsql');
if ($res === false) {
updateStatus(sprintf("Can't run %d script.", $name), true);
showForm();
return false;
}
}
pg_query($conn, 'COMMIT');
if (empty($password)) {
$sqlUrl = "pgsql://$username@$host/$database";
} else {
$sqlUrl = "pgsql://$username:$password@$host/$database";
}
$db = array('type' => 'pgsql', 'database' => $sqlUrl);
return $db;
}
function Mysql_Db_installer($host, $database, $username, $password)
{
updateStatus("Starting installation...");
updateStatus("Checking database...");
$conn = mysql_connect($host, $username, $password);
if (!$conn) {
updateStatus("Can't connect to server '$host' as '$username'.", true);
showForm();
return false;
}
updateStatus("Changing to database...");
$res = mysql_select_db($database, $conn);
if (!$res) {
updateStatus("Can't change to database.", true);
showForm();
return false;
}
updateStatus("Running database script...");
$res = runDbScript(INSTALLDIR.'/db/statusnet.sql', $conn);
if ($res === false) {
updateStatus("Can't run database script.", true);
showForm();
return false;
}
foreach (array('sms_carrier' => 'SMS carrier',
'notice_source' => 'notice source',
'foreign_services' => 'foreign service')
as $scr => $name) {
updateStatus(sprintf("Adding %s data to database...", $name));
$res = runDbScript(INSTALLDIR.'/db/'.$scr.'.sql', $conn);
if ($res === false) {
updateStatus(sprintf("Can't run %d script.", $name), true);
showForm();
return false;
}
}
$sqlUrl = "mysqli://$username:$password@$host/$database";
$db = array('type' => 'mysql', 'database' => $sqlUrl);
return $db;
}
function writeConf($sitename, $server, $path, $fancy, $db)
{
// assemble configuration file in a string
$cfg = "<?php\n".
"if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }\n\n".
// site name
"\$config['site']['name'] = '$sitename';\n\n".
// site location
"\$config['site']['server'] = '$server';\n".
"\$config['site']['path'] = '$path'; \n\n".
// checks if fancy URLs are enabled
($fancy ? "\$config['site']['fancy'] = true;\n\n":'').
// database
"\$config['db']['database'] = '{$db['database']}';\n\n".
($db['type'] == 'pgsql' ? "\$config['db']['quote_identifiers'] = true;\n\n":'').
"\$config['db']['type'] = '{$db['type']}';\n\n";
// write configuration file out to install directory
$res = file_put_contents(INSTALLDIR.'/config.php', $cfg);
return $res;
}
/**
* Install schema into the database
* Read and validate input data.
* May output side effects.
*
* @param string $filename location of database schema file
* @param dbconn $conn connection to database
* @param string $type type of database, currently mysql or pgsql
*
* @return boolean - indicating success or failure
* @return boolean success
*/
function runDbScript($filename, $conn, $type = 'mysqli')
function prepare()
{
$sql = trim(file_get_contents($filename));
$stmts = explode(';', $sql);
foreach ($stmts as $stmt) {
$stmt = trim($stmt);
if (!mb_strlen($stmt)) {
continue;
}
// FIXME: use PEAR::DB or PDO instead of our own switch
switch ($type) {
case 'mysqli':
$res = mysql_query($stmt, $conn);
if ($res === false) {
$error = mysql_error();
}
break;
case 'pgsql':
$res = pg_query($conn, $stmt);
if ($res === false) {
$error = pg_last_error();
}
break;
default:
updateStatus("runDbScript() error: unknown database type ". $type ." provided.");
}
if ($res === false) {
updateStatus("ERROR ($error) for SQL '$stmt'");
return $res;
}
}
return true;
$this->host = $_POST['host'];
$this->dbtype = $_POST['dbtype'];
$this->database = $_POST['database'];
$this->username = $_POST['dbusername'];
$this->password = $_POST['dbpassword'];
$this->sitename = $_POST['sitename'];
$this->fancy = !empty($_POST['fancy']);
$this->adminNick = strtolower($_POST['admin_nickname']);
$this->adminPass = $_POST['admin_password'];
$adminPass2 = $_POST['admin_password2'];
$this->adminEmail = $_POST['admin_email'];
$this->adminUpdates = $_POST['admin_updates'];
$this->server = $_SERVER['HTTP_HOST'];
$this->path = substr(dirname($_SERVER['PHP_SELF']), 1);
$fail = false;
if (!$this->validateDb()) {
$fail = true;
}
function registerInitialUser($nickname, $password, $email, $adminUpdates)
{
define('STATUSNET', true);
define('LACONICA', true); // compatibility
require_once INSTALLDIR . '/lib/common.php';
$data = array('nickname' => $nickname,
'password' => $password,
'fullname' => $nickname);
if ($email) {
$data['email'] = $email;
}
$user = User::register($data);
if (empty($user)) {
return false;
if (!$this->validateAdmin()) {
$fail = true;
}
// give initial user carte blanche
$user->grantRole('owner');
$user->grantRole('moderator');
$user->grantRole('administrator');
// Attempt to do a remote subscribe to update@status.net
// Will fail if instance is on a private network.
if (class_exists('Ostatus_profile') && $adminUpdates) {
try {
$oprofile = Ostatus_profile::ensureProfileURL('http://update.status.net/');
Subscription::start($user->getProfile(), $oprofile->localProfile());
updateStatus("Set up subscription to <a href='http://update.status.net/'>update@status.net</a>.");
} catch (Exception $e) {
updateStatus("Could not set up subscription to <a href='http://update.status.net/'>update@status.net</a>.");
}
if ($this->adminPass != $adminPass2) {
$this->updateStatus("Administrator passwords do not match. Did you mistype?", true);
$fail = true;
}
return !$fail;
}
return true;
}
?>
@ -945,7 +310,10 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<div id="content">
<div id="content_inner">
<h1>Install StatusNet</h1>
<?php main(); ?>
<?php
$installer = new WebInstaller();
$installer->main();
?>
</div>
</div>
</div>

View File

@ -105,27 +105,45 @@ class AccountSettingsNav extends Widget
$user = common_current_user();
if(Event::handle('StartAccountSettingsProfileMenuItem', array($this, &$menu))){
$this->showMenuItem('profilesettings',_('Profile'),_('Change your profile settings'));
// TRANS: Link title attribute in user account settings menu.
$title = _('Change your profile settings');
// TRANS: Link description in user account settings menu.
$this->showMenuItem('profilesettings',_('Profile'),$title);
Event::handle('EndAccountSettingsProfileMenuItem', array($this, &$menu));
}
if(Event::handle('StartAccountSettingsAvatarMenuItem', array($this, &$menu))){
$this->showMenuItem('avatarsettings',_('Avatar'),_('Upload an avatar'));
// TRANS: Link title attribute in user account settings menu.
$title = _('Upload an avatar');
// TRANS: Link description in user account settings menu.
$this->showMenuItem('avatarsettings',_('Avatar'),$title);
Event::handle('EndAccountSettingsAvatarMenuItem', array($this, &$menu));
}
if(Event::handle('StartAccountSettingsPasswordMenuItem', array($this, &$menu))){
$this->showMenuItem('passwordsettings',_('Password'),_('Change your password'));
// TRANS: Link title attribute in user account settings menu.
$title = _('Change your password');
// TRANS: Link description in user account settings menu.
$this->showMenuItem('passwordsettings',_('Password'),$title);
Event::handle('EndAccountSettingsPasswordMenuItem', array($this, &$menu));
}
if(Event::handle('StartAccountSettingsEmailMenuItem', array($this, &$menu))){
$this->showMenuItem('emailsettings',_('Email'),_('Change email handling'));
// TRANS: Link title attribute in user account settings menu.
$title = _('Change email handling');
// TRANS: Link description in user account settings menu.
$this->showMenuItem('emailsettings',_('Email'),$title);
Event::handle('EndAccountSettingsEmailMenuItem', array($this, &$menu));
}
if(Event::handle('StartAccountSettingsDesignMenuItem', array($this, &$menu))){
$this->showMenuItem('userdesignsettings',_('Design'),_('Design your profile'));
// TRANS: Link title attribute in user account settings menu.
$title = _('Design your profile');
// TRANS: Link description in user account settings menu.
$this->showMenuItem('userdesignsettings',_('Design'),$title);
Event::handle('EndAccountSettingsDesignMenuItem', array($this, &$menu));
}
if(Event::handle('StartAccountSettingsOtherMenuItem', array($this, &$menu))){
$this->showMenuItem('othersettings',_('Other'),_('Other options'));
// TRANS: Link title attribute in user account settings menu.
$title = _('Other options');
// TRANS: Link description in user account settings menu.
$this->showMenuItem('othersettings',_('Other'),$title);
Event::handle('EndAccountSettingsOtherMenuItem', array($this, &$menu));
}

View File

@ -141,6 +141,7 @@ class Action extends HTMLOutputter // lawsuit
function showTitle()
{
$this->element('title', null,
// TRANS: Page title. %1$s is the title, %2$s is the site name.
sprintf(_("%1\$s - %2\$s"),
$this->title(),
common_config('site', 'name')));
@ -156,6 +157,7 @@ class Action extends HTMLOutputter // lawsuit
function title()
{
// TRANS: Page title for a page without a title set.
return _("Untitled page");
}
@ -420,6 +422,7 @@ class Action extends HTMLOutputter // lawsuit
{
$user = common_current_user();
$this->elementStart('dl', array('id' => 'site_nav_global_primary'));
// TRANS: DT element for primary navigation menu. String is hidden in default CSS.
$this->element('dt', null, _('Primary site navigation'));
$this->elementStart('dd');
$this->elementStart('ul', array('class' => 'nav'));
@ -427,31 +430,31 @@ class Action extends HTMLOutputter // lawsuit
if ($user) {
// TRANS: Tooltip for main menu option "Personal"
$tooltip = _m('TOOLTIP', 'Personal profile and friends timeline');
// TRANS: Main menu option when logged in for access to personal profile and friends timeline
$this->menuItem(common_local_url('all', array('nickname' => $user->nickname)),
// TRANS: Main menu option when logged in for access to personal profile and friends timeline
_m('MENU', 'Personal'), $tooltip, false, 'nav_home');
// TRANS: Tooltip for main menu option "Account"
$tooltip = _m('TOOLTIP', 'Change your email, avatar, password, profile');
// TRANS: Main menu option when logged in for access to user settings
$this->menuItem(common_local_url('profilesettings'),
// TRANS: Main menu option when logged in for access to user settings
_('Account'), $tooltip, false, 'nav_account');
// TRANS: Tooltip for main menu option "Services"
$tooltip = _m('TOOLTIP', 'Connect to services');
// TRANS: Main menu option when logged in and connection are possible for access to options to connect to other services
$this->menuItem(common_local_url('oauthconnectionssettings'),
// TRANS: Main menu option when logged in and connection are possible for access to options to connect to other services
_('Connect'), $tooltip, false, 'nav_connect');
if ($user->hasRight(Right::CONFIGURESITE)) {
// TRANS: Tooltip for menu option "Admin"
$tooltip = _m('TOOLTIP', 'Change site configuration');
// TRANS: Main menu option when logged in and site admin for access to site configuration
$this->menuItem(common_local_url('siteadminpanel'),
// TRANS: Main menu option when logged in and site admin for access to site configuration
_m('MENU', 'Admin'), $tooltip, false, 'nav_admin');
}
if (common_config('invite', 'enabled')) {
// TRANS: Tooltip for main menu option "Invite"
$tooltip = _m('TOOLTIP', 'Invite friends and colleagues to join you on %s');
// TRANS: Main menu option when logged in and invitations are allowed for inviting new users
$this->menuItem(common_local_url('invite'),
// TRANS: Main menu option when logged in and invitations are allowed for inviting new users
_m('MENU', 'Invite'),
sprintf($tooltip,
common_config('site', 'name')),
@ -459,16 +462,16 @@ class Action extends HTMLOutputter // lawsuit
}
// TRANS: Tooltip for main menu option "Logout"
$tooltip = _m('TOOLTIP', 'Logout from the site');
// TRANS: Main menu option when logged in to log out the current user
$this->menuItem(common_local_url('logout'),
// TRANS: Main menu option when logged in to log out the current user
_m('MENU', 'Logout'), $tooltip, false, 'nav_logout');
}
else {
if (!common_config('site', 'closed')) {
// TRANS: Tooltip for main menu option "Register"
$tooltip = _m('TOOLTIP', 'Create an account');
// TRANS: Main menu option when not logged in to register a new account
$this->menuItem(common_local_url('register'),
// TRANS: Main menu option when not logged in to register a new account
_m('MENU', 'Register'), $tooltip, false, 'nav_register');
}
// TRANS: Tooltip for main menu option "Login"
@ -575,6 +578,7 @@ class Action extends HTMLOutputter // lawsuit
function showLocalNavBlock()
{
$this->elementStart('dl', array('id' => 'site_nav_local_views'));
// TRANS: DT element for local views block. String is hidden in default CSS.
$this->element('dt', null, _('Local views'));
$this->elementStart('dd');
$this->showLocalNav();
@ -641,6 +645,7 @@ class Action extends HTMLOutputter // lawsuit
$this->elementStart('dl', array('id' => 'page_notice',
'class' => 'system_notice'));
// TRANS: DT element for page notice. String is hidden in default CSS.
$this->element('dt', null, _('Page notice'));
$this->elementStart('dd');
if (Event::handle('StartShowPageNotice', array($this))) {
@ -743,28 +748,37 @@ class Action extends HTMLOutputter // lawsuit
function showSecondaryNav()
{
$this->elementStart('dl', array('id' => 'site_nav_global_secondary'));
// TRANS: DT element for secondary navigation menu. String is hidden in default CSS.
$this->element('dt', null, _('Secondary site navigation'));
$this->elementStart('dd', null);
$this->elementStart('ul', array('class' => 'nav'));
if (Event::handle('StartSecondaryNav', array($this))) {
$this->menuItem(common_local_url('doc', array('title' => 'help')),
// TRANS: Secondary navigation menu option leading to help on StatusNet.
_('Help'));
$this->menuItem(common_local_url('doc', array('title' => 'about')),
// TRANS: Secondary navigation menu option leading to text about StatusNet site.
_('About'));
$this->menuItem(common_local_url('doc', array('title' => 'faq')),
// TRANS: Secondary navigation menu option leading to Frequently Asked Questions.
_('FAQ'));
$bb = common_config('site', 'broughtby');
if (!empty($bb)) {
$this->menuItem(common_local_url('doc', array('title' => 'tos')),
// TRANS: Secondary navigation menu option leading to Terms of Service.
_('TOS'));
}
$this->menuItem(common_local_url('doc', array('title' => 'privacy')),
// TRANS: Secondary navigation menu option leading to privacy policy.
_('Privacy'));
$this->menuItem(common_local_url('doc', array('title' => 'source')),
// TRANS: Secondary navigation menu option.
_('Source'));
$this->menuItem(common_local_url('version'),
// TRANS: Secondary navigation menu option leading to version information on the StatusNet site.
_('Version'));
$this->menuItem(common_local_url('doc', array('title' => 'contact')),
// TRANS: Secondary navigation menu option leading to contact information on the StatusNet site.
_('Contact'));
$this->menuItem(common_local_url('doc', array('title' => 'badge')),
_('Badge'));
@ -795,16 +809,18 @@ class Action extends HTMLOutputter // lawsuit
*/
function showStatusNetLicense()
{
// TRANS: DT element for StatusNet software license.
$this->element('dt', array('id' => 'site_statusnet_license'), _('StatusNet software license'));
$this->elementStart('dd', null);
// @fixme drop the final spaces in the messages when at good spot
// to let translations get updated.
if (common_config('site', 'broughtby')) {
// TRANS: First sentence of the StatusNet site license. Used if 'broughtby' is set.
$instr = _('**%%site.name%%** is a microblogging service brought to you by [%%site.broughtby%%](%%site.broughtbyurl%%).');
} else {
// TRANS: First sentence of the StatusNet site license. Used if 'broughtby' is not set.
$instr = _('**%%site.name%%** is a microblogging service.');
}
$instr .= ' ';
// TRANS: Second sentence of the StatusNet site license. Mentions the StatusNet source code license.
$instr .= sprintf(_('It runs the [StatusNet](http://status.net/) microblogging software, version %s, available under the [GNU Affero General Public License](http://www.fsf.org/licensing/licenses/agpl-3.0.html).'), STATUSNET_VERSION);
$output = common_markup_to_html($instr);
$this->raw($output);
@ -820,19 +836,25 @@ class Action extends HTMLOutputter // lawsuit
function showContentLicense()
{
if (Event::handle('StartShowContentLicense', array($this))) {
// TRANS: DT element for StatusNet site content license.
$this->element('dt', array('id' => 'site_content_license'), _('Site content license'));
$this->elementStart('dd', array('id' => 'site_content_license_cc'));
switch (common_config('license', 'type')) {
case 'private':
// TRANS: Content license displayed when license is set to 'private'.
// TRANS: %1$s is the site name.
$this->element('p', null, sprintf(_('Content and data of %1$s are private and confidential.'),
common_config('site', 'name')));
// fall through
case 'allrightsreserved':
if (common_config('license', 'owner')) {
// TRANS: Content license displayed when license is set to 'allrightsreserved'.
// TRANS: %1$s is the copyright owner.
$this->element('p', null, sprintf(_('Content and data copyright by %1$s. All rights reserved.'),
common_config('license', 'owner')));
} else {
// TRANS: Content license displayed when license is set to 'allrightsreserved' and no owner is set.
$this->element('p', null, _('Content and data copyright by contributors. All rights reserved.'));
}
break;
@ -845,14 +867,16 @@ class Action extends HTMLOutputter // lawsuit
'width' => '80',
'height' => '15'));
$this->text(' ');
//TODO: This is dirty: i18n
$this->text(_('All '.common_config('site', 'name').' content and data are available under the '));
$this->element('a', array('class' => 'license',
'rel' => 'external license',
'href' => common_config('license', 'url')),
common_config('license', 'title'));
$this->text(' ');
$this->text(_('license.'));
// TRANS: license message in footer. %1$s is the site name, %2$s is a link to the license URL, with a licence name set in configuration.
$notice = _('All %1$s content and data are available under the %2$s license.');
$link = "<a class=\"license\" rel=\"external license\" href=\"" .
htmlspecialchars(common_config('license', 'url')) .
"\">" .
htmlspecialchars(common_config('license', 'title')) .
"</a>";
$this->raw(sprintf(htmlspecialchars($notice),
htmlspecialchars(common_config('site', 'name')),
$link));
$this->elementEnd('p');
break;
}
@ -1146,11 +1170,15 @@ class Action extends HTMLOutputter // lawsuit
*
* @return nothing
*/
// XXX: The messages in this pagination method only tailor to navigating
// notices. In other lists, "Previous"/"Next" type navigation is
// desirable, but not available.
function pagination($have_before, $have_after, $page, $action, $args=null)
{
// Does a little before-after block for next/prev page
if ($have_before || $have_after) {
$this->elementStart('dl', 'pagination');
// TRANS: DT element for pagination (previous/next, etc.).
$this->element('dt', null, _('Pagination'));
$this->elementStart('dd', null);
$this->elementStart('ul', array('class' => 'nav'));
@ -1160,6 +1188,8 @@ class Action extends HTMLOutputter // lawsuit
$this->elementStart('li', array('class' => 'nav_prev'));
$this->element('a', array('href' => common_local_url($action, $args, $pargs),
'rel' => 'prev'),
// TRANS: Pagination message to go to a page displaying information more in the
// TRANS: present than the currently displayed information.
_('After'));
$this->elementEnd('li');
}
@ -1168,6 +1198,8 @@ class Action extends HTMLOutputter // lawsuit
$this->elementStart('li', array('class' => 'nav_next'));
$this->element('a', array('href' => common_local_url($action, $args, $pargs),
'rel' => 'next'),
// TRANS: Pagination message to go to a page displaying information more in the
// TRANS: past than the currently displayed information.
_('Before'));
$this->elementEnd('li');
}
@ -1211,6 +1243,8 @@ class Action extends HTMLOutputter // lawsuit
* @return void
*/
// XXX: Finding this type of check with the same message about 50 times.
// Possible to refactor?
function checkSessionToken()
{
// CSRF protection

View File

@ -117,7 +117,8 @@ class Activity
// Insist on a feed's root DOMElement; don't allow a DOMDocument
if ($feed instanceof DOMDocument) {
throw new ClientException(
_("Expecting a root feed element but got a whole XML document.")
// TRANS: Client exception thrown when a feed instance is a DOMDocument.
_('Expecting a root feed element but got a whole XML document.')
);
}

View File

@ -69,7 +69,7 @@ class AdminPanelAction extends Action
// User must be logged in.
if (!common_logged_in()) {
// TRANS: Client error message
// TRANS: Client error message thrown when trying to access the admin panel while not logged in.
$this->clientError(_('Not logged in.'));
return false;
}
@ -94,7 +94,7 @@ class AdminPanelAction extends Action
// User must have the right to change admin settings
if (!$user->hasRight(Right::CONFIGURESITE)) {
// TRANS: Client error message
// TRANS: Client error message thrown when a user tries to change admin settings but has no access rights.
$this->clientError(_('You cannot make changes to this site.'));
return false;
}
@ -106,7 +106,7 @@ class AdminPanelAction extends Action
$name = mb_substr($name, 0, -10);
if (!self::canAdmin($name)) {
// TRANS: Client error message
// TRANS: Client error message throw when a certain panel's settings cannot be changed.
$this->clientError(_('Changes to that panel are not allowed.'), 403);
return false;
}
@ -225,7 +225,7 @@ class AdminPanelAction extends Action
function showForm()
{
// TRANS: Client error message
// TRANS: Client error message.
$this->clientError(_('showForm() not implemented.'));
return;
}
@ -279,7 +279,8 @@ class AdminPanelAction extends Action
$result = $config->delete();
if (!$result) {
common_log_db_error($config, 'DELETE', __FILE__);
// TRANS: Client error message
// TRANS: Client error message thrown if design settings could not be deleted in
// TRANS: the admin panel Design.
$this->clientError(_("Unable to delete design setting."));
return null;
}

View File

@ -102,6 +102,7 @@ class ApiAction extends Action
function handle($args)
{
header('Access-Control-Allow-Origin: *');
parent::handle($args);
}
@ -1065,6 +1066,7 @@ class ApiAction extends Action
$this->initTwitterAtom();
break;
default:
// TRANS: Client error on an API request with an unsupported data format.
$this->clientError(_('Not a supported data format.'));
break;
}
@ -1093,6 +1095,7 @@ class ApiAction extends Action
$this->endTwitterRss();
break;
default:
// TRANS: Client error on an API request with an unsupported data format.
$this->clientError(_('Not a supported data format.'));
break;
}
@ -1209,6 +1212,7 @@ class ApiAction extends Action
$this->showJsonObjects($profile_array);
break;
default:
// TRANS: Client error on an API request with an unsupported data format.
$this->clientError(_('Not a supported data format.'));
return;
}

View File

@ -91,6 +91,7 @@ class ApiAuthAction extends ApiAction
if ($this->isReadOnly($args) == false) {
if ($this->access != self::READ_WRITE) {
// TRANS: Client error 401.
$msg = _('API resource requires read-write access, ' .
'but you only have read access.');
$this->clientError($msg, 401, $this->format);
@ -273,8 +274,8 @@ class ApiAuthAction extends ApiAction
list($proxy, $ip) = common_client_ip();
$msg = sprintf(_('Failed API auth attempt, nickname = %1$s, ' .
'proxy = %2$s, ip = %3$s'),
$msg = sprintf( 'Failed API auth attempt, nickname = %1$s, ' .
'proxy = %2$s, ip = %3$s',
$this->auth_user_nickname,
$proxy,
$ip);

View File

@ -133,6 +133,7 @@ class ApplicationEditForm extends Form
function formLegend()
{
// TRANS: Form legend.
$this->out->element('legend', null, _('Edit application'));
}
@ -177,10 +178,12 @@ class ApplicationEditForm extends Form
}
$this->out->element('label', array('for' => 'app_icon'),
// TRANS: Form input field label for application icon.
_('Icon'));
$this->out->element('input', array('name' => 'app_icon',
'type' => 'file',
'id' => 'app_icon'));
// TRANS: Form guide.
$this->out->element('p', 'form_guide', _('Icon for this application'));
$this->out->element('input', array('name' => 'MAX_FILE_SIZE',
'type' => 'hidden',
@ -192,6 +195,7 @@ class ApplicationEditForm extends Form
$this->out->hidden('application_id', $id);
// TRANS: Form input field label for application name.
$this->out->input('name', _('Name'),
($this->out->arg('name')) ? $this->out->arg('name') : $name);
@ -201,11 +205,14 @@ class ApplicationEditForm extends Form
$maxDesc = Oauth_application::maxDesc();
if ($maxDesc > 0) {
// TRANS: Form input field instructions.
$descInstr = sprintf(_('Describe your application in %d characters'),
$maxDesc);
} else {
// TRANS: Form input field instructions.
$descInstr = _('Describe your application');
}
// TRANS: Form input field label.
$this->out->textarea('description', _('Description'),
($this->out->arg('description')) ? $this->out->arg('description') : $description,
$descInstr);
@ -213,27 +220,39 @@ class ApplicationEditForm extends Form
$this->out->elementEnd('li');
$this->out->elementStart('li');
// TRANS: Form input field instructions.
$instruction = _('URL of the homepage of this application');
// TRANS: Form input field label.
$this->out->input('source_url', _('Source URL'),
($this->out->arg('source_url')) ? $this->out->arg('source_url') : $source_url,
_('URL of the homepage of this application'));
$instruction);
$this->out->elementEnd('li');
$this->out->elementStart('li');
// TRANS: Form input field instructions.
$instruction = _('Organization responsible for this application');
// TRANS: Form input field label.
$this->out->input('organization', _('Organization'),
($this->out->arg('organization')) ? $this->out->arg('organization') : $organization,
_('Organization responsible for this application'));
$instruction);
$this->out->elementEnd('li');
$this->out->elementStart('li');
// TRANS: Form input field instructions.
$instruction = _('URL for the homepage of the organization');
// TRANS: Form input field label.
$this->out->input('homepage', _('Homepage'),
($this->out->arg('homepage')) ? $this->out->arg('homepage') : $homepage,
_('URL for the homepage of the organization'));
$instruction);
$this->out->elementEnd('li');
$this->out->elementStart('li');
// TRANS: Form input field instructions.
$instruction = _('URL to redirect to after authentication');
// TRANS: Form input field label.
$this->out->input('callback_url', ('Callback URL'),
($this->out->arg('callback_url')) ? $this->out->arg('callback_url') : $callback_url,
_('URL to redirect to after authentication'));
$instruction);
$this->out->elementEnd('li');
$this->out->elementStart('li', array('id' => 'application_types'));
@ -255,6 +274,7 @@ class ApplicationEditForm extends Form
$this->out->element('label', array('for' => 'app_type-browser',
'class' => 'radio'),
// TRANS: Radio button label for application type
_('Browser'));
$attrs = array('name' => 'app_type',
@ -271,7 +291,9 @@ class ApplicationEditForm extends Form
$this->out->element('label', array('for' => 'app_type-desktop',
'class' => 'radio'),
// TRANS: Radio button label for application type
_('Desktop'));
// TRANS: Form guide.
$this->out->element('p', 'form_guide', _('Type of application, browser or desktop'));
$this->out->elementEnd('li');
@ -294,6 +316,7 @@ class ApplicationEditForm extends Form
$this->out->element('label', array('for' => 'default_access_type-ro',
'class' => 'radio'),
// TRANS: Radio button label for access type.
_('Read-only'));
$attrs = array('name' => 'default_access_type',
@ -312,7 +335,9 @@ class ApplicationEditForm extends Form
$this->out->element('label', array('for' => 'default_access_type-rw',
'class' => 'radio'),
// TRANS: Radio button label for access type.
_('Read-write'));
// TRANS: Form guide.
$this->out->element('p', 'form_guide', _('Default access for this application: read-only, or read-write'));
$this->out->elementEnd('li');
@ -328,9 +353,13 @@ class ApplicationEditForm extends Form
function formActions()
{
$this->out->submit('cancel', _('Cancel'), 'submit form_action-primary',
// TRANS: Button label
$this->out->submit('cancel', _m('BUTTON','Cancel'), 'submit form_action-primary',
// TRANS: Submit button title
'cancel', _('Cancel'));
$this->out->submit('save', _('Save'), 'submit form_action-secondary',
// TRANS: Button label
$this->out->submit('save', _m('BUTTON','Save'), 'submit form_action-secondary',
// TRANS: Submit button title
'save', _('Save'));
}
}

View File

@ -88,7 +88,6 @@ class ApplicationList extends Widget
function showApplication()
{
$user = common_current_user();
$this->out->elementStart('li', array('class' => 'application',
@ -133,11 +132,16 @@ class ApplicationList extends Widget
$this->out->elementStart('li');
$access = ($this->application->access_type & Oauth_application::$writeAccess)
? 'read-write' : 'read-only';
// TRANS: Application access type
$readWriteText = _('read-write');
// TRANS: Application access type
$readOnlyText = _('read-only');
$txt = 'Approved ' . common_date_string($appUser->modified) .
" - $access access.";
$access = ($this->application->access_type & Oauth_application::$writeAccess)
? $readWriteText : $readOnlyText;
$modifiedDate = common_date_string($appUser->modified);
// TRANS: Used in application list. %1$s is a modified date, %2$s is access type (read-write or read-only)
$txt = sprintf(_('Approved %1$s - "%2$s" access.'),$modifiedDate,$access);
$this->out->raw($txt);
$this->out->elementEnd('li');
@ -151,7 +155,8 @@ class ApplicationList extends Widget
$this->out->elementStart('fieldset');
$this->out->hidden('id', $this->application->id);
$this->out->hidden('token', common_session_token());
$this->out->submit('revoke', _('Revoke'));
// TRANS: Button label
$this->out->submit('revoke', _m('BUTTON','Revoke'));
$this->out->elementEnd('fieldset');
$this->out->elementEnd('form');
$this->out->elementEnd('li');

View File

@ -58,11 +58,14 @@ class AtomGroupNoticeFeed extends AtomNoticeFeed
parent::__construct($indent);
$this->group = $group;
// TRANS: Title in atom group notice feed. %s is a group name.
$title = sprintf(_("%s timeline"), $group->nickname);
$this->setTitle($title);
$sitename = common_config('site', 'name');
$subtitle = sprintf(
// TRANS: Message is used as a subtitle in atom group notice feed.
// TRANS: %1$s is a group name, %2$s is a site name.
_('Updates from %1$s on %2$s!'),
$group->nickname,
$sitename

View File

@ -64,11 +64,14 @@ class AtomUserNoticeFeed extends AtomNoticeFeed
$this->setActivitySubject($profile->asActivityNoun('subject'));
}
// TRANS: Title in atom user notice feed. %s is a user name.
$title = sprintf(_("%s timeline"), $user->nickname);
$this->setTitle($title);
$sitename = common_config('site', 'name');
$subtitle = sprintf(
// TRANS: Message is used as a subtitle in atom user notice feed.
// TRANS: %1$s is a user name, %2$s is a site name.
_('Updates from %1$s on %2$s!'),
$user->nickname, $sitename
);

View File

@ -84,6 +84,7 @@ class AttachmentList extends Widget
if (empty($att)) return 0;
$this->out->elementStart('dl', array('id' =>'attachments',
'class' => 'entry-content'));
// TRANS: DT element label in attachment list.
$this->out->element('dt', null, _('Attachments'));
$this->out->elementStart('dd');
$this->out->elementStart('ol', array('class' => 'attachments'));
@ -260,6 +261,7 @@ class Attachment extends AttachmentListItem
'class' => 'entry-content'));
if (!empty($this->oembed->author_name)) {
$this->out->elementStart('dl', 'vcard author');
// TRANS: DT element label in attachment list item.
$this->out->element('dt', null, _('Author'));
$this->out->elementStart('dd', 'fn');
if (empty($this->oembed->author_url)) {
@ -273,6 +275,7 @@ class Attachment extends AttachmentListItem
}
if (!empty($this->oembed->provider)) {
$this->out->elementStart('dl', 'vcard');
// TRANS: DT element label in attachment list item.
$this->out->element('dt', null, _('Provider'));
$this->out->elementStart('dd', 'fn');
if (empty($this->oembed->provider_url)) {

View File

@ -122,6 +122,8 @@ class Command
}
Event::handle('EndCommandGetProfile', array($this, $arg, &$profile));
if (!$profile) {
// TRANS: Message given requesting a profile for a non-existing user.
// TRANS: %s is the nickname of the user for which the profile could not be found.
throw new CommandException(sprintf(_('Could not find a user with nickname %s'), $arg));
}
return $profile;
@ -140,6 +142,8 @@ class Command
}
Event::handle('EndCommandGetUser', array($this, $arg, &$user));
if (!$user){
// TRANS: Message given getting a non-existing user.
// TRANS: %s is the nickname of the user that could not be found.
throw new CommandException(sprintf(_('Could not find a local user with nickname %s'),
$arg));
}
@ -225,6 +229,8 @@ class NudgeCommand extends Command
}
// XXX: notify by IM
// XXX: notify by SMS
// TRANS: Message given having nudged another user.
// TRANS: %s is the nickname of the user that was nudged.
$channel->output($this->user, sprintf(_('Nudge sent to %s'),
$recipient->nickname));
}
@ -328,12 +334,16 @@ class JoinCommand extends Command
Event::handle('EndJoinGroup', array($group, $cur));
}
} catch (Exception $e) {
$channel->error($cur, sprintf(_('Could not join user %s to group %s'),
// TRANS: Message given having failed to add a user to a group.
// TRANS: %1$s is the nickname of the user, %2$s is the nickname of the group.
$channel->error($cur, sprintf(_('Could not join user %1$s to group %2$s'),
$cur->nickname, $group->nickname));
return;
}
$channel->output($cur, sprintf(_('%s joined group %s'),
// TRANS: Message given having added a user to a group.
// TRANS: %1$s is the nickname of the user, %2$s is the nickname of the group.
$channel->output($cur, sprintf(_('%1$s joined group %2$s'),
$cur->nickname,
$group->nickname));
}
@ -370,12 +380,16 @@ class DropCommand extends Command
Event::handle('EndLeaveGroup', array($group, $cur));
}
} catch (Exception $e) {
$channel->error($cur, sprintf(_('Could not remove user %s to group %s'),
// TRANS: Message given having failed to remove a user from a group.
// TRANS: %1$s is the nickname of the user, %2$s is the nickname of the group.
$channel->error($cur, sprintf(_('Could not remove user %1$s from group %2$s'),
$cur->nickname, $group->nickname));
return;
}
$channel->output($cur, sprintf(_('%s left group %s'),
// TRANS: Message given having removed a user from a group.
// TRANS: %1$s is the nickname of the user, %2$s is the nickname of the group.
$channel->output($cur, sprintf(_('%1$s left group %2$s'),
$cur->nickname,
$group->nickname));
}
@ -395,18 +409,24 @@ class WhoisCommand extends Command
{
$recipient = $this->getProfile($this->other);
// TRANS: Whois output.
// TRANS: %1$s nickname of the queried user, %2$s is their profile URL.
$whois = sprintf(_("%1\$s (%2\$s)"), $recipient->nickname,
$recipient->profileurl);
if ($recipient->fullname) {
// TRANS: Whois output. %s is the full name of the queried user.
$whois .= "\n" . sprintf(_('Fullname: %s'), $recipient->fullname);
}
if ($recipient->location) {
// TRANS: Whois output. %s is the location of the queried user.
$whois .= "\n" . sprintf(_('Location: %s'), $recipient->location);
}
if ($recipient->homepage) {
// TRANS: Whois output. %s is the homepage of the queried user.
$whois .= "\n" . sprintf(_('Homepage: %s'), $recipient->homepage);
}
if ($recipient->bio) {
// TRANS: Whois output. %s is the bio information of the queried user.
$whois .= "\n" . sprintf(_('About: %s'), $recipient->bio);
}
$channel->output($this->user, $whois);
@ -447,7 +467,9 @@ class MessageCommand extends Command
$this->text = common_shorten_links($this->text);
if (Message::contentTooLong($this->text)) {
$channel->error($this->user, sprintf(_('Message too long - maximum is %d characters, you sent %d'),
// TRANS: Message given if content is too long.
// TRANS: %1$d is the maximum number of characters, %2$d is the number of submitted characters.
$channel->error($this->user, sprintf(_('Message too long - maximum is %1$d characters, you sent %2$d'),
Message::maxContent(), mb_strlen($this->text)));
return;
}
@ -465,6 +487,8 @@ class MessageCommand extends Command
$message = Message::saveNew($this->user->id, $other->id, $this->text, $channel->source());
if ($message) {
$message->notify();
// TRANS: Message given have sent a direct message to another user.
// TRANS: %s is the name of the other user.
$channel->output($this->user, sprintf(_('Direct message to %s sent'), $this->other));
} else {
$channel->error($this->user, _('Error sending direct message.'));
@ -500,6 +524,8 @@ class RepeatCommand extends Command
if ($repeat) {
// TRANS: Message given having repeated a notice from another user.
// TRANS: %s is the name of the user for which the notice was repeated.
$channel->output($this->user, sprintf(_('Notice from %s repeated'), $recipient->nickname));
} else {
$channel->error($this->user, _('Error repeating notice.'));

View File

@ -49,10 +49,14 @@ class DelUserQueueHandler extends QueueHandler
return true;
}
try {
if (!$user->hasRole(Profile_role::DELETED)) {
common_log(LOG_INFO, "User {$user->nickname} is not pending deletion; aborting.");
return true;
}
} catch (UserNoProfileException $unp) {
common_log(LOG_INFO, "Deleting user {$user->nickname} with no profile... probably a good idea!");
}
$notice = $this->getNextBatch($user);
if ($notice->N) {

View File

@ -100,6 +100,7 @@ class HTMLOutputter extends XMLOutputter
$type = common_negotiate_type($cp, $sp);
if (!$type) {
// TRANS: Client exception 406
throw new ClientException(_('This page is not available in a '.
'media type you accept'), 406);
}

View File

@ -586,7 +586,9 @@ abstract class ImPlugin extends Plugin
function onGetImTransports(&$transports)
{
$transports[$this->transport] = array('display' => $this->getDisplayName());
$transports[$this->transport] = array(
'display' => $this->getDisplayName(),
'daemon_screenname' => $this->daemon_screenname());
}
function onSendImConfirmationCode($transport, $screenname, $code, $user)

578
lib/installer.php Normal file
View File

@ -0,0 +1,578 @@
<?php
/**
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2009, StatusNet, Inc.
*
* 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 Installation
* @package Installation
*
* @author Adrian Lang <mail@adrianlang.de>
* @author Brenda Wallace <shiny@cpan.org>
* @author Brett Taylor <brett@webfroot.co.nz>
* @author Brion Vibber <brion@pobox.com>
* @author CiaranG <ciaran@ciarang.com>
* @author Craig Andrews <candrews@integralblue.com>
* @author Eric Helgeson <helfire@Erics-MBP.local>
* @author Evan Prodromou <evan@status.net>
* @author Robin Millette <millette@controlyourself.ca>
* @author Sarven Capadisli <csarven@status.net>
* @author Tom Adams <tom@holizz.com>
* @author Zach Copley <zach@status.net>
* @license GNU Affero General Public License http://www.gnu.org/licenses/
* @version 0.9.x
* @link http://status.net
*/
abstract class Installer
{
/** Web site info */
public $sitename, $server, $path, $fancy;
/** DB info */
public $host, $dbname, $dbtype, $username, $password, $db;
/** Administrator info */
public $adminNick, $adminPass, $adminEmail, $adminUpdates;
/** Should we skip writing the configuration file? */
public $skipConfig = false;
public static $dbModules = array(
'mysql' => array(
'name' => 'MySQL',
'check_module' => 'mysql', // mysqli?
'installer' => 'mysql_db_installer',
),
'pgsql' => array(
'name' => 'PostgreSQL',
'check_module' => 'pgsql',
'installer' => 'pgsql_db_installer',
),
);
/**
* Attempt to include a PHP file and report if it worked, while
* suppressing the annoying warning messages on failure.
*/
private function haveIncludeFile($filename) {
$old = error_reporting(error_reporting() & ~E_WARNING);
$ok = include_once($filename);
error_reporting($old);
return $ok;
}
/**
* Check if all is ready for installation
*
* @return void
*/
function checkPrereqs()
{
$pass = true;
if (file_exists(INSTALLDIR.'/config.php')) {
$this->warning('Config file "config.php" already exists.');
$pass = false;
}
if (version_compare(PHP_VERSION, '5.2.3', '<')) {
$errors[] = 'Require PHP version 5.2.3 or greater.';
$pass = false;
}
// Look for known library bugs
$str = "abcdefghijklmnopqrstuvwxyz";
$replaced = preg_replace('/[\p{Cc}\p{Cs}]/u', '*', $str);
if ($str != $replaced) {
$this->warning('PHP is linked to a version of the PCRE library ' .
'that does not support Unicode properties. ' .
'If you are running Red Hat Enterprise Linux / ' .
'CentOS 5.4 or earlier, see <a href="' .
'http://status.net/wiki/Red_Hat_Enterprise_Linux#PCRE_library' .
'">our documentation page</a> on fixing this.');
$pass = false;
}
$reqs = array('gd', 'curl',
'xmlwriter', 'mbstring', 'xml', 'dom', 'simplexml');
foreach ($reqs as $req) {
if (!$this->checkExtension($req)) {
$this->warning(sprintf('Cannot load required extension: <code>%s</code>', $req));
$pass = false;
}
}
// Make sure we have at least one database module available
$missingExtensions = array();
foreach (self::$dbModules as $type => $info) {
if (!$this->checkExtension($info['check_module'])) {
$missingExtensions[] = $info['check_module'];
}
}
if (count($missingExtensions) == count(self::$dbModules)) {
$req = implode(', ', $missingExtensions);
$this->warning(sprintf('Cannot find a database extension. You need at least one of %s.', $req));
$pass = false;
}
if (!is_writable(INSTALLDIR)) {
$this->warning(sprintf('Cannot write config file to: <code>%s</code></p>', INSTALLDIR),
sprintf('On your server, try this command: <code>chmod a+w %s</code>', INSTALLDIR));
$pass = false;
}
// Check the subdirs used for file uploads
$fileSubdirs = array('avatar', 'background', 'file');
foreach ($fileSubdirs as $fileSubdir) {
$fileFullPath = INSTALLDIR."/$fileSubdir/";
if (!is_writable($fileFullPath)) {
$this->warning(sprintf('Cannot write to %s directory: <code>%s</code>', $fileSubdir, $fileFullPath),
sprintf('On your server, try this command: <code>chmod a+w %s</code>', $fileFullPath));
$pass = false;
}
}
return $pass;
}
/**
* Checks if a php extension is both installed and loaded
*
* @param string $name of extension to check
*
* @return boolean whether extension is installed and loaded
*/
function checkExtension($name)
{
if (extension_loaded($name)) {
return true;
} elseif (function_exists('dl') && ini_get('enable_dl') && !ini_get('safe_mode')) {
// dl will throw a fatal error if it's disabled or we're in safe mode.
// More fun, it may not even exist under some SAPIs in 5.3.0 or later...
$soname = $name . '.' . PHP_SHLIB_SUFFIX;
if (PHP_SHLIB_SUFFIX == 'dll') {
$soname = "php_" . $soname;
}
return @dl($soname);
} else {
return false;
}
}
/**
* Basic validation on the database paramters
* Side effects: error output if not valid
*
* @return boolean success
*/
function validateDb()
{
$fail = false;
if (empty($this->host)) {
$this->updateStatus("No hostname specified.", true);
$fail = true;
}
if (empty($this->database)) {
$this->updateStatus("No database specified.", true);
$fail = true;
}
if (empty($this->username)) {
$this->updateStatus("No username specified.", true);
$fail = true;
}
if (empty($this->sitename)) {
$this->updateStatus("No sitename specified.", true);
$fail = true;
}
return !$fail;
}
/**
* Basic validation on the administrator user paramters
* Side effects: error output if not valid
*
* @return boolean success
*/
function validateAdmin()
{
$fail = false;
if (empty($this->adminNick)) {
$this->updateStatus("No initial StatusNet user nickname specified.", true);
$fail = true;
}
if ($this->adminNick && !preg_match('/^[0-9a-z]{1,64}$/', $this->adminNick)) {
$this->updateStatus('The user nickname "' . htmlspecialchars($this->adminNick) .
'" is invalid; should be plain letters and numbers no longer than 64 characters.', true);
$fail = true;
}
// @fixme hardcoded list; should use User::allowed_nickname()
// if/when it's safe to have loaded the infrastructure here
$blacklist = array('main', 'admin', 'twitter', 'settings', 'rsd.xml', 'favorited', 'featured', 'favoritedrss', 'featuredrss', 'rss', 'getfile', 'api', 'groups', 'group', 'peopletag', 'tag', 'user', 'message', 'conversation', 'bookmarklet', 'notice', 'attachment', 'search', 'index.php', 'doc', 'opensearch', 'robots.txt', 'xd_receiver.html', 'facebook');
if (in_array($this->adminNick, $blacklist)) {
$this->updateStatus('The user nickname "' . htmlspecialchars($this->adminNick) .
'" is reserved.', true);
$fail = true;
}
if (empty($this->adminPass)) {
$this->updateStatus("No initial StatusNet user password specified.", true);
$fail = true;
}
return !$fail;
}
/**
* Set up the database with the appropriate function for the selected type...
* Saves database info into $this->db.
*
* @return mixed array of database connection params on success, false on failure
*/
function setupDatabase()
{
if ($this->db) {
throw new Exception("Bad order of operations: DB already set up.");
}
$method = self::$dbModules[$this->dbtype]['installer'];
$db = call_user_func(array($this, $method),
$this->host,
$this->database,
$this->username,
$this->password);
$this->db = $db;
return $this->db;
}
/**
* Set up a database on PostgreSQL.
* Will output status updates during the operation.
*
* @param string $host
* @param string $database
* @param string $username
* @param string $password
* @return mixed array of database connection params on success, false on failure
*
* @fixme escape things in the connection string in case we have a funny pass etc
*/
function Pgsql_Db_installer($host, $database, $username, $password)
{
$connstring = "dbname=$database host=$host user=$username";
//No password would mean trust authentication used.
if (!empty($password)) {
$connstring .= " password=$password";
}
$this->updateStatus("Starting installation...");
$this->updateStatus("Checking database...");
$conn = pg_connect($connstring);
if ($conn ===false) {
$this->updateStatus("Failed to connect to database: $connstring");
return false;
}
//ensure database encoding is UTF8
$record = pg_fetch_object(pg_query($conn, 'SHOW server_encoding'));
if ($record->server_encoding != 'UTF8') {
$this->updateStatus("StatusNet requires UTF8 character encoding. Your database is ". htmlentities($record->server_encoding));
return false;
}
$this->updateStatus("Running database script...");
//wrap in transaction;
pg_query($conn, 'BEGIN');
$res = $this->runDbScript('statusnet_pg.sql', $conn, 'pgsql');
if ($res === false) {
$this->updateStatus("Can't run database script.", true);
return false;
}
foreach (array('sms_carrier' => 'SMS carrier',
'notice_source' => 'notice source',
'foreign_services' => 'foreign service')
as $scr => $name) {
$this->updateStatus(sprintf("Adding %s data to database...", $name));
$res = $this->runDbScript($scr.'.sql', $conn, 'pgsql');
if ($res === false) {
$this->updateStatus(sprintf("Can't run %d script.", $name), true);
return false;
}
}
pg_query($conn, 'COMMIT');
if (empty($password)) {
$sqlUrl = "pgsql://$username@$host/$database";
} else {
$sqlUrl = "pgsql://$username:$password@$host/$database";
}
$db = array('type' => 'pgsql', 'database' => $sqlUrl);
return $db;
}
/**
* Set up a database on MySQL.
* Will output status updates during the operation.
*
* @param string $host
* @param string $database
* @param string $username
* @param string $password
* @return mixed array of database connection params on success, false on failure
*
* @fixme be consistent about using mysqli vs mysql!
* @fixme escape things in the connection string in case we have a funny pass etc
*/
function Mysql_Db_installer($host, $database, $username, $password)
{
$this->updateStatus("Starting installation...");
$this->updateStatus("Checking database...");
$conn = mysql_connect($host, $username, $password);
if (!$conn) {
$this->updateStatus("Can't connect to server '$host' as '$username'.", true);
return false;
}
$this->updateStatus("Changing to database...");
$res = mysql_select_db($database, $conn);
if (!$res) {
$this->updateStatus("Can't change to database.", true);
return false;
}
$this->updateStatus("Running database script...");
$res = $this->runDbScript('statusnet.sql', $conn);
if ($res === false) {
$this->updateStatus("Can't run database script.", true);
return false;
}
foreach (array('sms_carrier' => 'SMS carrier',
'notice_source' => 'notice source',
'foreign_services' => 'foreign service')
as $scr => $name) {
$this->updateStatus(sprintf("Adding %s data to database...", $name));
$res = $this->runDbScript($scr.'.sql', $conn);
if ($res === false) {
$this->updateStatus(sprintf("Can't run %d script.", $name), true);
return false;
}
}
$sqlUrl = "mysqli://$username:$password@$host/$database";
$db = array('type' => 'mysql', 'database' => $sqlUrl);
return $db;
}
/**
* Write a stock configuration file.
*
* @return boolean success
*
* @fixme escape variables in output in case we have funny chars, apostrophes etc
*/
function writeConf()
{
// assemble configuration file in a string
$cfg = "<?php\n".
"if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }\n\n".
// site name
"\$config['site']['name'] = '{$this->sitename}';\n\n".
// site location
"\$config['site']['server'] = '{$this->server}';\n".
"\$config['site']['path'] = '{$this->path}'; \n\n".
// checks if fancy URLs are enabled
($this->fancy ? "\$config['site']['fancy'] = true;\n\n":'').
// database
"\$config['db']['database'] = '{$this->db['database']}';\n\n".
($this->db['type'] == 'pgsql' ? "\$config['db']['quote_identifiers'] = true;\n\n":'').
"\$config['db']['type'] = '{$this->db['type']}';\n\n";
// write configuration file out to install directory
$res = file_put_contents(INSTALLDIR.'/config.php', $cfg);
return $res;
}
/**
* Install schema into the database
*
* @param string $filename location of database schema file
* @param dbconn $conn connection to database
* @param string $type type of database, currently mysql or pgsql
*
* @return boolean - indicating success or failure
*/
function runDbScript($filename, $conn, $type = 'mysqli')
{
$sql = trim(file_get_contents(INSTALLDIR . '/db/' . $filename));
$stmts = explode(';', $sql);
foreach ($stmts as $stmt) {
$stmt = trim($stmt);
if (!mb_strlen($stmt)) {
continue;
}
// FIXME: use PEAR::DB or PDO instead of our own switch
switch ($type) {
case 'mysqli':
$res = mysql_query($stmt, $conn);
if ($res === false) {
$error = mysql_error();
}
break;
case 'pgsql':
$res = pg_query($conn, $stmt);
if ($res === false) {
$error = pg_last_error();
}
break;
default:
$this->updateStatus("runDbScript() error: unknown database type ". $type ." provided.");
}
if ($res === false) {
$this->updateStatus("ERROR ($error) for SQL '$stmt'");
return $res;
}
}
return true;
}
/**
* Create the initial admin user account.
* Side effect: may load portions of StatusNet framework.
* Side effect: outputs program info
*/
function registerInitialUser()
{
define('STATUSNET', true);
define('LACONICA', true); // compatibility
require_once INSTALLDIR . '/lib/common.php';
$data = array('nickname' => $this->adminNick,
'password' => $this->adminPass,
'fullname' => $this->adminNick);
if ($this->adminEmail) {
$data['email'] = $this->adminEmail;
}
$user = User::register($data);
if (empty($user)) {
return false;
}
// give initial user carte blanche
$user->grantRole('owner');
$user->grantRole('moderator');
$user->grantRole('administrator');
// Attempt to do a remote subscribe to update@status.net
// Will fail if instance is on a private network.
if ($this->adminUpdates && class_exists('Ostatus_profile')) {
try {
$oprofile = Ostatus_profile::ensureProfileURL('http://update.status.net/');
Subscription::start($user->getProfile(), $oprofile->localProfile());
$this->updateStatus("Set up subscription to <a href='http://update.status.net/'>update@status.net</a>.");
} catch (Exception $e) {
$this->updateStatus("Could not set up subscription to <a href='http://update.status.net/'>update@status.net</a>.", true);
}
}
return true;
}
/**
* The beef of the installer!
* Create database, config file, and admin user.
*
* Prerequisites: validation of input data.
*
* @return boolean success
*/
function doInstall()
{
$this->db = $this->setupDatabase();
if (!$this->db) {
// database connection failed, do not move on to create config file.
return false;
}
if (!$this->skipConfig) {
$this->updateStatus("Writing config file...");
$res = $this->writeConf();
if (!$res) {
$this->updateStatus("Can't write config file.", true);
return false;
}
}
if (!empty($this->adminNick)) {
// Okay, cross fingers and try to register an initial user
if ($this->registerInitialUser()) {
$this->updateStatus(
"An initial user with the administrator role has been created."
);
} else {
$this->updateStatus(
"Could not create initial StatusNet user (administrator).",
true
);
return false;
}
}
/*
TODO https needs to be considered
*/
$link = "http://".$this->server.'/'.$this->path;
$this->updateStatus("StatusNet has been installed at $link");
$this->updateStatus(
"<strong>DONE!</strong> You can visit your <a href='$link'>new StatusNet site</a> (login as '$this->adminNick'). If this is your first StatusNet install, you may want to poke around our <a href='http://status.net/wiki/Getting_started'>Getting Started guide</a>."
);
return true;
}
/**
* Output a pre-install-time warning message
* @param string $message HTML ok, but should be plaintext-able
* @param string $submessage HTML ok, but should be plaintext-able
*/
abstract function warning($message, $submessage='');
/**
* Output an install-time progress message
* @param string $message HTML ok, but should be plaintext-able
* @param boolean $error true if this should be marked as an error condition
*/
abstract function updateStatus($status, $error=false);
}

View File

@ -305,7 +305,8 @@ function get_all_languages() {
'fi' => array('q' => 1, 'lang' => 'fi', 'name' => 'Finnish', 'direction' => 'ltr'),
'fa' => array('q' => 1, 'lang' => 'fa', 'name' => 'Persian', 'direction' => 'rtl'),
'fr-fr' => array('q' => 1, 'lang' => 'fr', 'name' => 'French', 'direction' => 'ltr'),
'ga' => array('q' => 0.5, 'lang' => 'ga', 'name' => 'Galician', 'direction' => 'ltr'),
'ga' => array('q' => 0.5, 'lang' => 'ga', 'name' => 'Irish', 'direction' => 'ltr'),
'gl' => array('q' => 0.8, 'lang' => 'gl', 'name' => 'Galician', 'direction' => 'ltr'),
'he' => array('q' => 0.5, 'lang' => 'he', 'name' => 'Hebrew', 'direction' => 'rtl'),
'hsb' => array('q' => 0.8, 'lang' => 'hsb', 'name' => 'Upper Sorbian', 'direction' => 'ltr'),
'ia' => array('q' => 0.8, 'lang' => 'ia', 'name' => 'Interlingua', 'direction' => 'ltr'),

View File

@ -170,8 +170,10 @@ function mail_to_user(&$user, $subject, $body, $headers=array(), $address=null)
function mail_confirm_address($user, $code, $nickname, $address)
{
// TRANS: Subject for address confirmation email
$subject = _('Email address confirmation');
// TRANS: Body for address confirmation email.
$body = sprintf(_("Hey, %s.\n\n".
"Someone just entered this email address on %s.\n\n" .
"If it was you, and you want to confirm your entry, ".
@ -237,11 +239,13 @@ function mail_subscribe_notify_profile($listenee, $other)
$headers = _mail_prepare_headers('subscribe', $listenee->nickname, $other->nickname);
$headers['From'] = mail_notify_from();
$headers['To'] = $name . ' <' . $listenee->email . '>';
// TRANS: Subject of new-subscriber notification e-mail
$headers['Subject'] = sprintf(_('%1$s is now listening to '.
'your notices on %2$s.'),
$other->getBestName(),
common_config('site', 'name'));
// TRANS: Main body of new-subscriber notification e-mail
$body = sprintf(_('%1$s is now listening to your notices on %2$s.'."\n\n".
"\t".'%3$s'."\n\n".
'%4$s'.
@ -255,10 +259,13 @@ function mail_subscribe_notify_profile($listenee, $other)
common_config('site', 'name'),
$other->profileurl,
($other->location) ?
// TRANS: Profile info line in new-subscriber notification e-mail
sprintf(_("Location: %s"), $other->location) . "\n" : '',
($other->homepage) ?
// TRANS: Profile info line in new-subscriber notification e-mail
sprintf(_("Homepage: %s"), $other->homepage) . "\n" : '',
($other->bio) ?
// TRANS: Profile info line in new-subscriber notification e-mail
sprintf(_("Bio: %s"), $other->bio) . "\n\n" : '',
common_config('site', 'name'),
common_local_url('emailsettings'));
@ -287,9 +294,11 @@ function mail_new_incoming_notify($user)
$headers['From'] = $user->incomingemail;
$headers['To'] = $name . ' <' . $user->email . '>';
// TRANS: Subject of notification mail for new posting email address
$headers['Subject'] = sprintf(_('New email address for posting to %s'),
common_config('site', 'name'));
// TRANS: Body of notification mail for new posting email address
$body = sprintf(_("You have a new posting address on %1\$s.\n\n".
"Send email to %2\$s to post new messages.\n\n".
"More email instructions at %3\$s.\n\n".
@ -414,6 +423,7 @@ function mail_send_sms_notice_address($notice, $smsemail, $incomingemail)
$headers['From'] = ($incomingemail) ? $incomingemail : mail_notify_from();
$headers['To'] = $to;
// TRANS: Subject line for SMS-by-email notification messages
$headers['Subject'] = sprintf(_('%s status'),
$other->getBestName());
@ -440,11 +450,11 @@ function mail_confirm_sms($code, $nickname, $address)
$headers['From'] = mail_notify_from();
$headers['To'] = $nickname . ' <' . $address . '>';
// TRANS: Subject line for SMS-by-email address confirmation message
$headers['Subject'] = _('SMS confirmation');
// FIXME: I18N
$body = "$nickname: confirm you own this phone number with this code:";
// TRANS: Main body heading for SMS-by-email address confirmation message
$body = sprintf(_("%s: confirm you own this phone number with this code:"), $nickname);
$body .= "\n\n";
$body .= $code;
$body .= "\n\n";
@ -464,10 +474,12 @@ function mail_confirm_sms($code, $nickname, $address)
function mail_notify_nudge($from, $to)
{
common_init_locale($to->language);
// TRANS: Subject for 'nudge' notification email
$subject = sprintf(_('You\'ve been nudged by %s'), $from->nickname);
$from_profile = $from->getProfile();
// TRANS: Body for 'nudge' notification email
$body = sprintf(_("%1\$s (%2\$s) is wondering what you are up to ".
"these days and is inviting you to post some news.\n\n".
"So let's hear from you :)\n\n".
@ -514,10 +526,12 @@ function mail_notify_message($message, $from=null, $to=null)
}
common_init_locale($to->language);
// TRANS: Subject for direct-message notification email
$subject = sprintf(_('New private message from %s'), $from->nickname);
$from_profile = $from->getProfile();
// TRANS: Body for direct-message notification email
$body = sprintf(_("%1\$s (%2\$s) sent you a private message:\n\n".
"------------------------------------------------------\n".
"%3\$s\n".
@ -565,8 +579,10 @@ function mail_notify_fave($other, $user, $notice)
common_init_locale($other->language);
// TRANS: Subject for favorite notification email
$subject = sprintf(_('%s (@%s) added your notice as a favorite'), $bestname, $user->nickname);
// TRANS: Body for favorite notification email
$body = sprintf(_("%1\$s (@%7\$s) just added your notice from %2\$s".
" as one of their favorites.\n\n" .
"The URL of your notice is:\n\n" .
@ -622,24 +638,25 @@ function mail_notify_attn($user, $notice)
common_init_locale($user->language);
if ($notice->conversation != $notice->id) {
$conversationEmailText = "The full conversation can be read here:\n\n".
"\t%5\$s\n\n ";
if ($notice->hasConversation()) {
$conversationUrl = common_local_url('conversation',
array('id' => $notice->conversation)).'#notice-'.$notice->id;
// TRANS: Line in @-reply notification e-mail. %s is conversation URL.
$conversationEmailText = sprintf(_("The full conversation can be read here:\n\n".
"\t%s"), $conversationUrl) . "\n\n";
} else {
$conversationEmailText = "%5\$s";
$conversationUrl = null;
$conversationEmailText = '';
}
$subject = sprintf(_('%s (@%s) sent a notice to your attention'), $bestname, $sender->nickname);
// TRANS: Body of @-reply notification e-mail.
$body = sprintf(_("%1\$s (@%9\$s) just sent a notice to your attention (an '@-reply') on %2\$s.\n\n".
"The notice is here:\n\n".
"\t%3\$s\n\n" .
"It reads:\n\n".
"\t%4\$s\n\n" .
$conversationEmailText .
"%5\$s" .
"You can reply back here:\n\n".
"\t%6\$s\n\n" .
"The list of all @-replies for you here:\n\n" .
@ -652,7 +669,7 @@ function mail_notify_attn($user, $notice)
common_local_url('shownotice',
array('notice' => $notice->id)),//%3
$notice->content,//%4
$conversationUrl,//%5
$conversationEmailText,//%5
common_local_url('newnotice',
array('replyto' => $sender->nickname, 'inreplyto' => $notice->id)),//%6
common_local_url('replies',

View File

@ -212,8 +212,8 @@ class NoticeForm extends Form
$this->out->checkbox('notice_data-geo', _('Share my location'), true);
$this->out->elementEnd('div');
$this->out->inlineScript(' var NoticeDataGeo_text = {'.
'ShareDisable: "'._('Do not share my location').'",'.
'ErrorTimeout: "'._('Sorry, retrieving your geo location is taking longer than expected, please try again later').'"'.
'ShareDisable: ' .json_encode(_('Do not share my location')).','.
'ErrorTimeout: ' .json_encode(_('Sorry, retrieving your geo location is taking longer than expected, please try again later')).
'}');
}

View File

@ -426,10 +426,18 @@ class NoticeListItem extends Widget
if (empty($name)) {
$latdms = $this->decimalDegreesToDMS(abs($lat));
$londms = $this->decimalDegreesToDMS(abs($lon));
// TRANS: Used in coordinates as abbreviation of north
$north = _('N');
// TRANS: Used in coordinates as abbreviation of south
$south = _('S');
// TRANS: Used in coordinates as abbreviation of east
$east = _('E');
// TRANS: Used in coordinates as abbreviation of west
$west = _('W');
$name = sprintf(
_('%1$u°%2$u\'%3$u"%4$s %5$u°%6$u\'%7$u"%8$s'),
$latdms['deg'],$latdms['min'], $latdms['sec'],($lat>0?_('N'):_('S')),
$londms['deg'],$londms['min'], $londms['sec'],($lon>0?_('E'):_('W')));
$latdms['deg'],$latdms['min'], $latdms['sec'],($lat>0? $north:$south),
$londms['deg'],$londms['min'], $londms['sec'],($lon>0? $east:$west));
}
$url = $location->getUrl();
@ -543,18 +551,7 @@ class NoticeListItem extends Widget
function showContext()
{
$hasConversation = false;
if (!empty($this->notice->conversation)) {
$conversation = Notice::conversationStream(
$this->notice->conversation,
1,
1
);
if ($conversation->N > 0) {
$hasConversation = true;
}
}
if ($hasConversation) {
if ($this->notice->hasConversation()) {
$conv = Conversation::staticGet(
'id',
$this->notice->conversation

View File

@ -41,7 +41,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
* @link http://status.net/
*/
class ProfileFormAction extends Action
class ProfileFormAction extends RedirectingAction
{
var $profile = null;
@ -101,29 +101,6 @@ class ProfileFormAction extends Action
}
}
/**
* Return to the calling page based on hidden arguments
*
* @return void
*/
function returnToArgs()
{
foreach ($this->args as $k => $v) {
if ($k == 'returnto-action') {
$action = $v;
} else if (substr($k, 0, 9) == 'returnto-') {
$args[substr($k, 9)] = $v;
}
}
if ($action) {
common_redirect(common_local_url($action, $args), 303);
} else {
$this->clientError(_("No return-to arguments."));
}
}
/**
* handle a POST request
*

96
lib/redirectingaction.php Normal file
View File

@ -0,0 +1,96 @@
<?php
/**
* Superclass for actions that redirect to a given return-to page on completion.
*
* PHP version 5
*
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2009-2010, StatusNet, Inc.
*
* 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 Action
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @author Brion Vibber <brion@status.net>
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/
*/
if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
/**
* Superclass for actions that redirect to a given return-to page on completion.
*
* @category Action
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @author Brion Vibber <brion@status.net>
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/
*/
class RedirectingAction extends Action
{
/**
* Redirect browser to the page our hidden parameters requested,
* or if none given, to the url given by $this->defaultReturnTo().
*
* To be called only after successful processing.
*
* @fixme rename this -- it obscures Action::returnToArgs() which
* returns a list of arguments, and is a bit confusing.
*
* @return void
*/
function returnToArgs()
{
// Now, gotta figure where we go back to
$action = false;
$args = array();
$params = array();
foreach ($this->args as $k => $v) {
if ($k == 'returnto-action') {
$action = $v;
} else if (substr($k, 0, 15) == 'returnto-param-') {
$params[substr($k, 15)] = $v;
} elseif (substr($k, 0, 9) == 'returnto-') {
$args[substr($k, 9)] = $v;
}
}
if ($action) {
common_redirect(common_local_url($action, $args, $params), 303);
} else {
$url = $this->defaultReturnToUrl();
}
common_redirect($url, 303);
}
/**
* If we reached this form without returnto arguments, where should
* we go? May be overridden by subclasses to a reasonable destination
* for that action; default implementation throws an exception.
*
* @return string URL
*/
function defaultReturnTo()
{
$this->clientError(_("No return-to arguments."));
}
}

View File

@ -31,6 +31,7 @@ class StatusNet
{
protected static $have_config;
protected static $is_api;
protected static $plugins = array();
/**
* Configure and instantiate a plugin into the current configuration.
@ -74,9 +75,22 @@ class StatusNet
$inst->$aname = $avalue;
}
}
// Record activated plugins for later display/config dump
self::$plugins[] = array($name, $attrs);
return true;
}
/**
* Get a list of activated plugins in this process.
* @return array of (string $name, array $args) pairs
*/
public static function getActivePlugins()
{
return self::$plugins;
}
/**
* Initialize, or re-initialize, StatusNet global configuration
* and plugins.
@ -237,6 +251,7 @@ class StatusNet
global $_server, $_path, $config;
Event::clearHandlers();
self::$plugins = array();
// try to figure out where we are. $server and $path
// can be set by including module, else we guess based

View File

@ -862,7 +862,14 @@ function common_xml_safe_str($str)
function common_tag_link($tag)
{
$canonical = common_canonical_tag($tag);
if (common_config('singleuser', 'enabled')) {
// regular TagAction isn't set up in 1user mode
$url = common_local_url('showstream',
array('nickname' => common_config('singleuser', 'nickname'),
'tag' => $canonical));
} else {
$url = common_local_url('tag', array('tag' => $canonical));
}
$xs = new XMLStringer();
$xs->elementStart('span', 'tag');
$xs->element('a', array('href' => $url,
@ -1043,24 +1050,38 @@ function common_date_string($dt)
if ($now < $t) { // that shouldn't happen!
return common_exact_date($dt);
} else if ($diff < 60) {
// TRANS: Used in notices to indicate when the notice was made compared to now.
return _('a few seconds ago');
} else if ($diff < 92) {
// TRANS: Used in notices to indicate when the notice was made compared to now.
return _('about a minute ago');
} else if ($diff < 3300) {
// XXX: should support plural.
// TRANS: Used in notices to indicate when the notice was made compared to now.
return sprintf(_('about %d minutes ago'), round($diff/60));
} else if ($diff < 5400) {
// TRANS: Used in notices to indicate when the notice was made compared to now.
return _('about an hour ago');
} else if ($diff < 22 * 3600) {
// XXX: should support plural.
// TRANS: Used in notices to indicate when the notice was made compared to now.
return sprintf(_('about %d hours ago'), round($diff/3600));
} else if ($diff < 37 * 3600) {
// TRANS: Used in notices to indicate when the notice was made compared to now.
return _('about a day ago');
} else if ($diff < 24 * 24 * 3600) {
// XXX: should support plural.
// TRANS: Used in notices to indicate when the notice was made compared to now.
return sprintf(_('about %d days ago'), round($diff/(24*3600)));
} else if ($diff < 46 * 24 * 3600) {
// TRANS: Used in notices to indicate when the notice was made compared to now.
return _('about a month ago');
} else if ($diff < 330 * 24 * 3600) {
// XXX: should support plural.
// TRANS: Used in notices to indicate when the notice was made compared to now.
return sprintf(_('about %d months ago'), round($diff/(30*24*3600)));
} else if ($diff < 480 * 24 * 3600) {
// TRANS: Used in notices to indicate when the notice was made compared to now.
return _('about a year ago');
} else {
return common_exact_date($dt);
@ -1263,12 +1284,38 @@ function common_mtrand($bytes)
return $enc;
}
/**
* Record the given URL as the return destination for a future
* form submission, to be read by common_get_returnto().
*
* @param string $url
*
* @fixme as a session-global setting, this can allow multiple forms
* to conflict and overwrite each others' returnto destinations if
* the user has multiple tabs or windows open.
*
* Should refactor to index with a token or otherwise only pass the
* data along its intended path.
*/
function common_set_returnto($url)
{
common_ensure_session();
$_SESSION['returnto'] = $url;
}
/**
* Fetch a return-destination URL previously recorded by
* common_set_returnto().
*
* @return mixed URL string or null
*
* @fixme as a session-global setting, this can allow multiple forms
* to conflict and overwrite each others' returnto destinations if
* the user has multiple tabs or windows open.
*
* Should refactor to index with a token or otherwise only pass the
* data along its intended path.
*/
function common_get_returnto()
{
common_ensure_session();

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

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