X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fpasswordsettings.php;h=db36b612a29becfa806733c885e57ff955504f48;hb=c00491cd7a29a9ef16d6e6bfa54505d4c9a522fe;hp=cd4beac3f2120a9c83a81f4ddc8a4e98c8573777;hpb=7f3c1ac2beca8f0e21c002930a5df6dc2d9415ad;p=quix0rs-gnu-social.git diff --git a/actions/passwordsettings.php b/actions/passwordsettings.php index cd4beac3f2..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,12 +88,14 @@ 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()); @@ -100,20 +104,26 @@ class PasswordsettingsAction extends AccountSettingsAction // 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,26 +173,37 @@ 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; } - $original = clone($user); + $success = false; + if(Event::handle('StartChangePassword', array($user, $oldpassword, $newpassword))){ + //no handler changed the password, so change the password internally + $original = clone($user); - $user->password = common_munge_password($newpassword, $user->id); + $user->password = common_munge_password($newpassword, $user->id); - $val = $user->validate(); - if ($val !== true) { - $this->showForm(_('Error saving user; invalid.')); - return; - } + $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; + if (!$user->update($original)) { + // 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)); } + // TRANS: Form validation notice on page where to change password. $this->showForm(_('Password saved.'), true); } }