exit(1);
}
-require_once INSTALLDIR.'/lib/accountsettingsaction.php';
+
/**
* Change password
* @link http://status.net/
*/
-class PasswordsettingsAction extends AccountSettingsAction
+class PasswordsettingsAction extends SettingsAction
{
/**
* Title of the page
function title()
{
- return _('Change password');
+ // TRANS: Title for page where to change password.
+ return _m('TITLE','Change password');
}
/**
function getInstructions()
{
+ // TRANS: Instructions for page where to change password.
return _('Change your password.');
}
function showContent()
{
$user = common_current_user();
+
$this->elementStart('form', array('method' => 'POST',
'id' => 'form_password',
'class' => 'form_settings',
'action' =>
common_local_url('passwordsettings')));
$this->elementStart('fieldset');
+ // TRANS: Fieldset legend on page where to change password.
$this->element('legend', null, _('Password change'));
$this->hidden('token', common_session_token());
// Users who logged in with OpenID won't have a pwd
if ($user->password) {
$this->elementStart('li');
+ // TRANS: Field label on page where to change password.
$this->password('oldpassword', _('Old password'));
$this->elementEnd('li');
}
$this->elementStart('li');
+ // TRANS: Field label on page where to change password.
$this->password('newpassword', _('New password'),
- _('6 or more characters'));
+ // TRANS: Field title on page where to change password.
+ _('6 or more characters.'));
$this->elementEnd('li');
$this->elementStart('li');
- $this->password('confirm', _('Confirm'),
- _('same as password above'));
+ // TRANS: Field label on page where to change password. In this field the new password should be typed a second time.
+ $this->password('confirm', _m('LABEL','Confirm'),
+ // TRANS: Field title on page where to change password.
+ _('Same as password above.'));
$this->elementEnd('li');
$this->elementEnd('ul');
- $this->submit('changepass', _('Change'));
+ // TRANS: Button text on page where to change password.
+ $this->submit('changepass', _m('BUTTON','Change'));
$this->elementEnd('fieldset');
$this->elementEnd('form');
*
* @return void
*/
-
function handlePost()
{
// CSRF protection
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
+ // TRANS: Client error displayed when the session token does not match or is not given.
$this->showForm(_('There was a problem with your session token. '.
'Try again, please.'));
return;
$newpassword = $this->arg('newpassword');
$confirm = $this->arg('confirm');
- # Some validation
+ // Some validation
if (strlen($newpassword) < 6) {
+ // TRANS: Form validation error on page where to change password.
$this->showForm(_('Password must be 6 or more characters.'));
return;
} else if (0 != strcmp($newpassword, $confirm)) {
- $this->showForm(_('Passwords don\'t match.'));
+ // TRANS: Form validation error on password change when password confirmation does not match.
+ $this->showForm(_('Passwords do not match.'));
return;
}
$oldpassword = $this->arg('oldpassword');
if (!common_check_user($user->nickname, $oldpassword)) {
- $this->showForm(_('Incorrect old password'));
+ // TRANS: Form validation error on page where to change password.
+ $this->showForm(_('Incorrect old password.'));
return;
}
}else{
$oldpassword = null;
}
- $errormsg = false;
- if(! Event::handle('ChangePassword', array($user->nickname, $oldpassword, $newpassword, &$errormsg))){
+ $success = false;
+ if(Event::handle('StartChangePassword', array($user, $oldpassword, $newpassword))){
//no handler changed the password, so change the password internally
$original = clone($user);
$val = $user->validate();
if ($val !== true) {
+ // TRANS: Form validation error on page where to change password.
$this->showForm(_('Error saving user; invalid.'));
return;
}
if (!$user->update($original)) {
- $this->serverError(_('Can\'t save new password.'));
- return;
+ // TRANS: Server error displayed on page where to change password when password change
+ // TRANS: could not be made because of a server error.
+ $this->serverError(_('Cannot save new password.'));
}
+ Event::handle('EndChangePassword', array($user));
}
- if($errormsg === false)
- $this->showForm(_('Password saved.'), true);
- else
- $this->showForm($errormsg);
+ // TRANS: Form validation notice on page where to change password.
+ $this->showForm(_('Password saved.'), true);
}
}