X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fpasswordsettings.php;h=db36b612a29becfa806733c885e57ff955504f48;hb=c00491cd7a29a9ef16d6e6bfa54505d4c9a522fe;hp=6658d279f29f19ff1dad35eceffa0b3d861018d5;hpb=8e58f241739b97bd53f78035781f16e2067a31d9;p=quix0rs-gnu-social.git diff --git a/actions/passwordsettings.php b/actions/passwordsettings.php index 6658d279f2..db36b612a2 100644 --- a/actions/passwordsettings.php +++ b/actions/passwordsettings.php @@ -32,7 +32,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } -require_once INSTALLDIR.'/lib/accountsettingsaction.php'; + /** * Change password @@ -45,7 +45,7 @@ require_once INSTALLDIR.'/lib/accountsettingsaction.php'; * @link http://status.net/ */ -class PasswordsettingsAction extends AccountSettingsAction +class PasswordsettingsAction extends SettingsAction { /** * Title of the page @@ -55,7 +55,8 @@ class PasswordsettingsAction extends AccountSettingsAction function title() { - return _('Change password'); + // TRANS: Title for page where to change password. + return _m('TITLE','Change password'); } /** @@ -66,6 +67,7 @@ class PasswordsettingsAction extends AccountSettingsAction function getInstructions() { + // TRANS: Instructions for page where to change password. return _('Change your password.'); } @@ -86,34 +88,42 @@ class PasswordsettingsAction extends AccountSettingsAction 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()); $this->elementStart('ul', 'form_data'); - // Users who logged in with OpenID will not have a pwd + // 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'); @@ -127,13 +137,13 @@ class PasswordsettingsAction extends AccountSettingsAction * * @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; @@ -147,13 +157,15 @@ class PasswordsettingsAction extends AccountSettingsAction $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; } @@ -161,15 +173,16 @@ class PasswordsettingsAction extends AccountSettingsAction $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); @@ -177,19 +190,20 @@ class PasswordsettingsAction extends AccountSettingsAction $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); } }