|
From: <gem...@li...> - 2012-03-16 15:26:16
|
Revision: 554
http://gemstracker.svn.sourceforge.net/gemstracker/?rev=554&view=rev
Author: matijsdejong
Date: 2012-03-16 15:26:05 +0000 (Fri, 16 Mar 2012)
Log Message:
-----------
Moved changePasswordForm to User class
Modified Paths:
--------------
trunk/library/classes/Gems/Default/OptionAction.php
trunk/library/classes/Gems/User/User.php
trunk/library/languages/default-en.mo
trunk/library/languages/default-en.po
trunk/library/languages/default-nl.mo
trunk/library/languages/default-nl.po
Modified: trunk/library/classes/Gems/Default/OptionAction.php
===================================================================
--- trunk/library/classes/Gems/Default/OptionAction.php 2012-03-16 12:32:50 UTC (rev 553)
+++ trunk/library/classes/Gems/Default/OptionAction.php 2012-03-16 15:26:05 UTC (rev 554)
@@ -73,11 +73,6 @@
*/
public function changePasswordAction()
{
- /*************
- * Make form *
- *************/
- $form = $this->createForm();
-
$user = $this->loader->getCurrentUser();
if (! $user->canSetPassword()) {
@@ -85,67 +80,33 @@
return;
}
- if ($user->isPasswordResetRequired()) {
- $this->menu->setVisible(false);
+ /*************
+ * Make form *
+ *************/
+ $form = $user->getPasswordChangeForm();
- } elseif ($user->hasPassword()) {
- // Field current password
- //
- // This is only used when the password is already set, which may not always be the case
- // e.g. when using embedded login in Pulse.
- $element = new Zend_Form_Element_Password('old_password');
- $element->setLabel($this->_('Current password'));
- $element->setAttrib('size', 10);
- $element->setAttrib('maxlength', 20);
- $element->setRenderPassword(true);
- $element->setRequired(true);
- $element->addValidator(new Gems_User_UserPasswordValidator($user, $this->translate));
- $form->addElement($element);
- }
-
- // Field new password
- $element = new Zend_Form_Element_Password('new_password');
- $element->setLabel($this->_('New password'));
- $element->setAttrib('size', 10);
- $element->setAttrib('maxlength', 20);
- $element->setRequired(true);
- $element->setRenderPassword(true);
- $element->addValidator(new Gems_User_UserNewPasswordValidator($user));
- $element->addValidator(new MUtil_Validate_IsConfirmed('repeat_password', $this->_('Repeat password')));
- $form->addElement($element);
-
- // Field repeat password
- $element = new Zend_Form_Element_Password('repeat_password');
- $element->setLabel($this->_('Repeat password'));
- $element->setAttrib('size', 10);
- $element->setAttrib('maxlength', 20);
- $element->setRequired(true);
- $element->setRenderPassword(true);
- $element->addValidator(new MUtil_Validate_IsConfirmed('new_password', $this->_('New password')));
- $form->addElement($element);
-
// Show password info
if ($info = $user->reportPasswordWeakness()) {
- foreach ($info as &$line) {
- $line .= ',';
- }
- $line[strlen($line) - 1] = '.';
-
$element = new MUtil_Form_Element_Html('rules');
$element->setLabel($this->_('Password rules'));
- $element->div($this->_('A password:'))->ul($info);
- $form->addElement($element);
- $element = new Zend_Form_Element_Submit('submit');
- $element->setAttrib('class', 'button');
- $element->setLabel($this->_('Save'));
+ if (1 == count($info)) {
+ $element->div(sprintf($this->_('A password %s.'), reset($info)));
+ } else {
+ foreach ($info as &$line) {
+ $line .= ',';
+ }
+ $line[strlen($line) - 1] = '.';
+
+ $element->div($this->_('A password:'))->ul($info);
+ }
$form->addElement($element);
}
/****************
* Process form *
****************/
- if ($this->_request->isPost() && $form->isValid($_POST)) {
+ if ($this->_request->isPost() && $form->isValid($_POST, false)) {
$user->setPassword($_POST['new_password']);
$this->addMessage($this->_('New password is active.'));
@@ -167,7 +128,9 @@
$table->setAsFormLayout($form, true, true);
$table['tbody'][0][0]->class = 'label'; // Is only one row with formLayout, so all in output fields get class.
- if (! $user->isPasswordResetRequired() && ($links = $this->createMenuLinks())) {
+ if ($user->isPasswordResetRequired()) {
+ $this->menu->setVisible(false);
+ } elseif ($links = $this->createMenuLinks()) {
$table->tf(); // Add empty cell, no label
$linksCell = $table->tf($links);
}
Modified: trunk/library/classes/Gems/User/User.php
===================================================================
--- trunk/library/classes/Gems/User/User.php 2012-03-16 12:32:50 UTC (rev 553)
+++ trunk/library/classes/Gems/User/User.php 2012-03-16 15:26:05 UTC (rev 554)
@@ -515,6 +515,72 @@
}
/**
+ * Returns a form to change the possword for this user.
+ *
+ * @param boolean $askOld Ask for the old password, calculated when not set.
+ * @return Gems_Form
+ */
+ public function getPasswordChangeForm($askOld = null)
+ {
+ if (! $this->canSetPassword()) {
+ return;
+ }
+
+ if (null === $askOld) {
+ // By default only ask for the old password if the user just entered
+ // it but is required to change it.
+ $askOld = (! $this->isPasswordResetRequired());
+ }
+
+ $form = new Gems_Form();
+
+ // Never ask for the old password if it does not exist
+ //
+ // A password does not always exist, e.g. when using embedded login in Pulse
+ // or after creating a new user.
+ if ($askOld && $this->hasPassword()) {
+ // Field current password
+ $element = new Zend_Form_Element_Password('old_password');
+ $element->setLabel($this->translate->_('Current password'));
+ $element->setAttrib('size', 10);
+ $element->setAttrib('maxlength', 20);
+ $element->setRenderPassword(true);
+ $element->setRequired(true);
+ $element->addValidator(new Gems_User_UserPasswordValidator($this, $this->translate));
+ $form->addElement($element);
+ }
+
+ // Field new password
+ $element = new Zend_Form_Element_Password('new_password');
+ $element->setLabel($this->translate->_('New password'));
+ $element->setAttrib('size', 10);
+ $element->setAttrib('maxlength', 20);
+ $element->setRequired(true);
+ $element->setRenderPassword(true);
+ $element->addValidator(new Gems_User_UserNewPasswordValidator($this));
+ $element->addValidator(new MUtil_Validate_IsConfirmed('repeat_password', $this->translate->_('Repeat password')));
+ $form->addElement($element);
+
+ // Field repeat password
+ $element = new Zend_Form_Element_Password('repeat_password');
+ $element->setLabel($this->translate->_('Repeat password'));
+ $element->setAttrib('size', 10);
+ $element->setAttrib('maxlength', 20);
+ $element->setRequired(true);
+ $element->setRenderPassword(true);
+ $element->addValidator(new MUtil_Validate_IsConfirmed('new_password', $this->translate->_('New password')));
+ $form->addElement($element);
+
+ // Submit button
+ $element = new Zend_Form_Element_Submit('submit');
+ $element->setAttrib('class', 'button');
+ $element->setLabel($this->translate->_('Save'));
+ $form->addElement($element);
+
+ return $form;
+ }
+
+ /**
* Return a password reset key
*
* @return string
Modified: trunk/library/languages/default-en.mo
===================================================================
(Binary files differ)
Modified: trunk/library/languages/default-en.po
===================================================================
--- trunk/library/languages/default-en.po 2012-03-16 12:32:50 UTC (rev 553)
+++ trunk/library/languages/default-en.po 2012-03-16 15:26:05 UTC (rev 554)
@@ -2,7 +2,7 @@
msgstr ""
"Project-Id-Version: Pulse EN\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-03-15 15:34+0100\n"
+"POT-Creation-Date: 2012-03-16 16:16+0100\n"
"PO-Revision-Date: \n"
"Last-Translator: Matijs de Jong <mj...@ma...>\n"
"Language-Team: Erasmus MGZ <mat...@ma...>\n"
@@ -1439,8 +1439,6 @@
msgstr "User ID"
#: classes/Gems/Default/MailServerAction.php:90
-#: classes/Gems/Default/OptionAction.php:113
-#: classes/Gems/Default/OptionAction.php:118
#: classes/Gems/Default/SourceAction.php:95
#: classes/Gems/Default/StaffAction.php:161
msgid "Repeat password"
@@ -1478,52 +1476,56 @@
msgid "Email templates"
msgstr "Email templates"
-#: classes/Gems/Default/OptionAction.php:84
+#: classes/Gems/Default/OptionAction.php:79
msgid "You are not allowed to change your password."
msgstr "You are not allowed to change your password."
-#: classes/Gems/Default/OptionAction.php:96
-msgid "Current password"
-msgstr "Current password"
+#: classes/Gems/Default/OptionAction.php:91
+msgid "Password rules"
+msgstr "Password rules"
-#: classes/Gems/Default/OptionAction.php:107
-#: classes/Gems/Default/OptionAction.php:123
-msgid "New password"
-msgstr "New password"
+#: classes/Gems/Default/OptionAction.php:94
+#, php-format
+msgid "A password %s."
+msgstr "A password %s."
-#: classes/Gems/Default/OptionAction.php:137
+#: classes/Gems/Default/OptionAction.php:101
+msgid "A password:"
+msgstr "A password:"
+
+#: classes/Gems/Default/OptionAction.php:112
msgid "New password is active."
msgstr "New password is active."
-#: classes/Gems/Default/OptionAction.php:143
+#: classes/Gems/Default/OptionAction.php:118
msgid "Caps Lock seems to be on!"
msgstr "Caps Lock seems to be on!"
-#: classes/Gems/Default/OptionAction.php:181
+#: classes/Gems/Default/OptionAction.php:158
msgid "Login Name"
msgstr "Login Name"
-#: classes/Gems/Default/OptionAction.php:188
+#: classes/Gems/Default/OptionAction.php:165
#: classes/Gems/Default/OrganizationAction.php:129
#: classes/Gems/Default/RespondentAction.php:175
#: classes/Gems/Default/StaffAction.php:319
msgid "Language"
msgstr "Language"
-#: classes/Gems/Default/OptionAction.php:198
+#: classes/Gems/Default/OptionAction.php:175
#, php-format
msgid "Options"
msgstr "Options"
-#: classes/Gems/Default/OptionAction.php:207
+#: classes/Gems/Default/OptionAction.php:184
msgid "This overview provides information about the last login activity on your account."
msgstr "This overview provides information about the last login activity on your account."
-#: classes/Gems/Default/OptionAction.php:227
+#: classes/Gems/Default/OptionAction.php:204
msgid "Date / time"
msgstr "Date / time"
-#: classes/Gems/Default/OptionAction.php:238
+#: classes/Gems/Default/OptionAction.php:215
msgid "Item"
msgstr "Item"
@@ -3560,53 +3562,75 @@
#: classes/Gems/User/PasswordChecker.php:95
#, php-format
-msgid "A password should contain at least one uppercase character."
-msgid_plural "A password should contain at least %d uppercase characters."
-msgstr[0] "A password should contain at least one uppercase character."
-msgstr[1] "A password should contain at least %d uppercase characters."
+msgid "should contain at least one uppercase character"
+msgid_plural "should contain at least %d uppercase characters"
+msgstr[0] "should contain at least one uppercase character"
+msgstr[1] "should contain at least %d uppercase characters"
#: classes/Gems/User/PasswordChecker.php:112
#, php-format
-msgid "A password should contain at least one lowercase character."
-msgid_plural "A password should contain at least %d lowercase characters."
-msgstr[0] "A password should contain at least one lowercase character."
-msgstr[1] "A password should contain at least %d lowercase characters."
+msgid "should contain at least one lowercase character"
+msgid_plural "should contain at least %d lowercase characters"
+msgstr[0] "should contain at least one lowercase character"
+msgstr[1] "should contain at least %d lowercase characters"
#: classes/Gems/User/PasswordChecker.php:127
#, php-format
-msgid "A password should be at least %d characters long."
-msgstr "A password should be at least %d characters long."
+msgid "should be at least %d characters long"
+msgstr "should be at least %d characters long"
#: classes/Gems/User/PasswordChecker.php:145
#, php-format
-msgid "A password should contain at least one not alphabetic character."
-msgid_plural "A password should contain at least %d not alphabetic characters."
-msgstr[0] "A password should contain at least one not alphabetic character."
-msgstr[1] "A password should contain at least %d not alphabetic characters."
+msgid "should contain at least one non alphabetic character"
+msgid_plural "should contain at least %d non alphabetic characters"
+msgstr[0] "should contain at least one non alphabetic character"
+msgstr[1] "should contain at least %d non alphabetic characters"
-#: classes/Gems/User/PasswordChecker.php:165
+#: classes/Gems/User/PasswordChecker.php:148
+msgid "should not contain non alphabetic characters"
+msgstr "should not contain non alphabetic characters"
+
+#: classes/Gems/User/PasswordChecker.php:167
#, php-format
-msgid "A password should contain at least one not alphanumeric character."
-msgid_plural "A password should contain at least %d not alphanumeric characters."
-msgstr[0] "A password should contain at least one not alphanumeric character."
-msgstr[1] "A password should contain at least %d not alphanumeric characters."
+msgid "should contain at least one non alphanumeric character"
+msgid_plural "should contain at least %d non alphanumeric characters"
+msgstr[0] "should contain at least one non alphanumeric character"
+msgstr[1] "should contain at least %d non alphanumeric characters"
-#: classes/Gems/User/PasswordChecker.php:184
-msgid "A password should not contain the login name."
-msgstr "A password should not contain the login name."
+#: classes/Gems/User/PasswordChecker.php:170
+msgid "should not contain non alphanumeric characters"
+msgstr "should not contain non alphanumeric characters"
-#: classes/Gems/User/PasswordChecker.php:201
+#: classes/Gems/User/PasswordChecker.php:188
#, php-format
-msgid "A password should contain at least one number."
-msgid_plural "A password should contain at least %d numbers."
-msgstr[0] "A password should contain at least one number."
-msgstr[1] "A password should contain at least %d numbers."
+msgid "should not contain your login name \"%s\""
+msgstr "should not contain your login name \"%s\""
+#: classes/Gems/User/PasswordChecker.php:207
+#, php-format
+msgid "should contain at least one number"
+msgid_plural "should contain at least %d numbers"
+msgstr[0] "should contain at least one number"
+msgstr[1] "should contain at least %d numbers"
+
+#: classes/Gems/User/PasswordChecker.php:210
+msgid "may not contain numbers"
+msgstr "may not contain numbers"
+
#: classes/Gems/User/RadiusUserDefinition.php:175
msgid "Shared secret"
msgstr "Shared secret"
-#: classes/Gems/User/User.php:833
+#: classes/Gems/User/User.php:538
+msgid "Current password"
+msgstr "Current password"
+
+#: classes/Gems/User/User.php:549
+#: classes/Gems/User/User.php:565
+msgid "New password"
+msgstr "New password"
+
+#: classes/Gems/User/User.php:893
msgid "Cookies must be enabled for this site."
msgstr "Cookies must be enabled for this site."
Modified: trunk/library/languages/default-nl.mo
===================================================================
(Binary files differ)
Modified: trunk/library/languages/default-nl.po
===================================================================
--- trunk/library/languages/default-nl.po 2012-03-16 12:32:50 UTC (rev 553)
+++ trunk/library/languages/default-nl.po 2012-03-16 15:26:05 UTC (rev 554)
@@ -2,7 +2,7 @@
msgstr ""
"Project-Id-Version: Pulse NL\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-03-15 15:34+0100\n"
+"POT-Creation-Date: 2012-03-16 16:15+0100\n"
"PO-Revision-Date: \n"
"Last-Translator: Matijs de Jong <mj...@ma...>\n"
"Language-Team: Erasmus MGZ <mat...@ma...>\n"
@@ -1439,8 +1439,6 @@
msgstr "Gebruikers ID"
#: classes/Gems/Default/MailServerAction.php:90
-#: classes/Gems/Default/OptionAction.php:113
-#: classes/Gems/Default/OptionAction.php:118
#: classes/Gems/Default/SourceAction.php:95
#: classes/Gems/Default/StaffAction.php:161
msgid "Repeat password"
@@ -1478,52 +1476,56 @@
msgid "Email templates"
msgstr "Email sjabloon"
-#: classes/Gems/Default/OptionAction.php:84
+#: classes/Gems/Default/OptionAction.php:79
msgid "You are not allowed to change your password."
msgstr "U mag uw wachtwoord niet wijzigen."
-#: classes/Gems/Default/OptionAction.php:96
-msgid "Current password"
-msgstr "Huidig wachtwoord"
+#: classes/Gems/Default/OptionAction.php:91
+msgid "Password rules"
+msgstr "Wachtwoord regels"
-#: classes/Gems/Default/OptionAction.php:107
-#: classes/Gems/Default/OptionAction.php:123
-msgid "New password"
-msgstr "Nieuw wachtwoord"
+#: classes/Gems/Default/OptionAction.php:94
+#, php-format
+msgid "A password %s."
+msgstr "Een wachtwoord %s."
-#: classes/Gems/Default/OptionAction.php:137
+#: classes/Gems/Default/OptionAction.php:101
+msgid "A password:"
+msgstr "Een wachtwoord:"
+
+#: classes/Gems/Default/OptionAction.php:112
msgid "New password is active."
msgstr "Nieuwe wachtwoord geactiveerd."
-#: classes/Gems/Default/OptionAction.php:143
+#: classes/Gems/Default/OptionAction.php:118
msgid "Caps Lock seems to be on!"
msgstr "De Caps Lock toets lijkt aan te staan!"
-#: classes/Gems/Default/OptionAction.php:181
+#: classes/Gems/Default/OptionAction.php:158
msgid "Login Name"
msgstr "Login Naam"
-#: classes/Gems/Default/OptionAction.php:188
+#: classes/Gems/Default/OptionAction.php:165
#: classes/Gems/Default/OrganizationAction.php:129
#: classes/Gems/Default/RespondentAction.php:175
#: classes/Gems/Default/StaffAction.php:319
msgid "Language"
msgstr "Taal"
-#: classes/Gems/Default/OptionAction.php:198
+#: classes/Gems/Default/OptionAction.php:175
#, php-format
msgid "Options"
msgstr "Instellingen"
-#: classes/Gems/Default/OptionAction.php:207
+#: classes/Gems/Default/OptionAction.php:184
msgid "This overview provides information about the last login activity on your account."
msgstr "Dit overzicht geeft informatie over de recente inlog activiteit op uw account."
-#: classes/Gems/Default/OptionAction.php:227
+#: classes/Gems/Default/OptionAction.php:204
msgid "Date / time"
msgstr "Datum / tijd"
-#: classes/Gems/Default/OptionAction.php:238
+#: classes/Gems/Default/OptionAction.php:215
msgid "Item"
msgstr "Item"
@@ -3560,53 +3562,75 @@
#: classes/Gems/User/PasswordChecker.php:95
#, php-format
-msgid "A password should contain at least one uppercase character."
-msgid_plural "A password should contain at least %d uppercase characters."
-msgstr[0] "Het wachtwoord moet minstens een hoofdletter bevatten."
-msgstr[1] "Het wachtwoord moet minstens %d hoofdletters bevatten."
+msgid "should contain at least one uppercase character"
+msgid_plural "should contain at least %d uppercase characters"
+msgstr[0] "moet minstens één hoofdletter bevatten"
+msgstr[1] "moet minstens %d hoofdletters bevatten"
#: classes/Gems/User/PasswordChecker.php:112
#, php-format
-msgid "A password should contain at least one lowercase character."
-msgid_plural "A password should contain at least %d lowercase characters."
-msgstr[0] "Het wachtwoord moet minstens een kleine letter bevatten."
-msgstr[1] "Het wachtwoord moet minstens %d kleine letters bevatten."
+msgid "should contain at least one lowercase character"
+msgid_plural "should contain at least %d lowercase characters"
+msgstr[0] "moet minstens één kleine letter bevatten"
+msgstr[1] "moet minstens %d kleine letters bevatten"
#: classes/Gems/User/PasswordChecker.php:127
#, php-format
-msgid "A password should be at least %d characters long."
-msgstr "Het wachtwoordt moet minstens %d tekens lang zijn."
+msgid "should be at least %d characters long"
+msgstr "moet minstens %d tekens lang zijn"
#: classes/Gems/User/PasswordChecker.php:145
#, php-format
-msgid "A password should contain at least one not alphabetic character."
-msgid_plural "A password should contain at least %d not alphabetic characters."
-msgstr[0] "Het wachtwoord moet minstens een niet-alphabetisch teken bevatten."
-msgstr[1] "Het wachtwoord moet minstens %d niet-alphabetisch tekens bevatten."
+msgid "should contain at least one non alphabetic character"
+msgid_plural "should contain at least %d non alphabetic characters"
+msgstr[0] "moet minstens één niet-letter bevatten"
+msgstr[1] "moet minstens %d niet-letter bevatten"
-#: classes/Gems/User/PasswordChecker.php:165
+#: classes/Gems/User/PasswordChecker.php:148
+msgid "should not contain non alphabetic characters"
+msgstr "moet alleen uit letters bestaan"
+
+#: classes/Gems/User/PasswordChecker.php:167
#, php-format
-msgid "A password should contain at least one not alphanumeric character."
-msgid_plural "A password should contain at least %d not alphanumeric characters."
-msgstr[0] "Het wachtwoord moet minstens een teken anders dan getallen of letters bevatten."
-msgstr[1] "Het wachtwoord moet minstens %d tekens anders dan getallen of letters bevatten."
+msgid "should contain at least one non alphanumeric character"
+msgid_plural "should contain at least %d non alphanumeric characters"
+msgstr[0] "moet minstens één teken anders dan getallen of letters bevatten"
+msgstr[1] "moet minstens %d tekens anders dan getallen of letters bevatten"
-#: classes/Gems/User/PasswordChecker.php:184
-msgid "A password should not contain the login name."
-msgstr "Het wachtwoord mag niet de gebruikersnaam bevatten."
+#: classes/Gems/User/PasswordChecker.php:170
+msgid "should not contain non alphanumeric characters"
+msgstr "mag alleen letters en cijfers bevatten"
-#: classes/Gems/User/PasswordChecker.php:201
+#: classes/Gems/User/PasswordChecker.php:188
#, php-format
-msgid "A password should contain at least one number."
-msgid_plural "A password should contain at least %d numbers."
-msgstr[0] "Het wachtwoord moet minstens een getal bevatten."
-msgstr[1] "Het wachtwoord moet minstens %d getallen bevatten."
+msgid "should not contain your login name \"%s\""
+msgstr "mag niet je gebruikersnaam \"%s\" bevatten"
+#: classes/Gems/User/PasswordChecker.php:207
+#, php-format
+msgid "should contain at least one number"
+msgid_plural "should contain at least %d numbers"
+msgstr[0] "moet minstens één cijfer bevatten"
+msgstr[1] "moet minstens %d cijfers bevatten"
+
+#: classes/Gems/User/PasswordChecker.php:210
+msgid "may not contain numbers"
+msgstr "mag geen getallen bevatten"
+
#: classes/Gems/User/RadiusUserDefinition.php:175
msgid "Shared secret"
msgstr "Shared secret"
-#: classes/Gems/User/User.php:833
+#: classes/Gems/User/User.php:538
+msgid "Current password"
+msgstr "Huidig wachtwoord"
+
+#: classes/Gems/User/User.php:549
+#: classes/Gems/User/User.php:565
+msgid "New password"
+msgstr "Nieuw wachtwoord"
+
+#: classes/Gems/User/User.php:893
msgid "Cookies must be enabled for this site."
msgstr "Zonder cookies heeft u geen toegang tot deze site."
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|