Author: david
Date: Thu Sep 17 15:40:47 2009
New Revision: 3384

Log:
Fix password.  Add password confirmation field.

Modified:
   trunk/apps/qubit/modules/user/actions/editAction.class.php
   trunk/apps/qubit/modules/user/config/view.yml
   trunk/apps/qubit/modules/user/templates/editSuccess.php

Modified: trunk/apps/qubit/modules/user/actions/editAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/user/actions/editAction.class.php  Thu Sep 17 
15:33:23 2009        (r3383)
+++ trunk/apps/qubit/modules/user/actions/editAction.class.php  Thu Sep 17 
15:40:47 2009        (r3384)
@@ -23,6 +23,7 @@
     'username',
     'email',
     'password',
+    'confirmPassword',
     'groups'
   );
 
@@ -41,6 +42,7 @@
         $this->form->setWidget($name, new sfWidgetFormInput);
         break;
       case 'password':
+      case 'confirmPassword':
         $this->form->setDefault($name, null);
         $this->form->setValidator($name, new sfValidatorString);
         $this->form->setWidget($name, new sfWidgetFormInputPassword);
@@ -86,6 +88,11 @@
 
     $this->form = new sfForm;
     $this->form->getValidatorSchema()->setOption('allow_extra_fields', true);
+    $this->form->getValidatorSchema()->setPostValidator(new 
sfValidatorSchemaCompare(
+      'password', '==', 'confirmPassword',
+      array(),
+      array('invalid' => 'Your password confirmation did not match you 
password.')
+    ));
 
     // HACK: Use static::$NAMES in PHP 5.3,
     // http://php.net/oop5.late-static-bindings
@@ -126,6 +133,12 @@
   {
     $this->user->username = $this->form->getValue('username');
     $this->user->email = $this->form->getValue('email');
+
+    if (0 < strlen(trim($this->form->getValue('password'))))
+    {
+      $this->user->setPassword($this->form->getValue('password'));
+    }
+
     $this->user->save();
 
     $this->updateUserGroups();
@@ -139,7 +152,12 @@
   {
     $newGroupIds = $formGroupIds = array();
 
-    foreach ($this->form->getValue('groups') as $groupId)
+    if (null == ($groups = $this->form->getValue('groups')))
+    {
+      return;
+    }
+
+    foreach ($groups as $groupId)
     {
       $newGroupIds[$groupId] = $formGroupIds[$groupId] = $groupId;
     }

Modified: trunk/apps/qubit/modules/user/config/view.yml
==============================================================================
--- trunk/apps/qubit/modules/user/config/view.yml       Thu Sep 17 15:33:23 
2009        (r3383)
+++ trunk/apps/qubit/modules/user/config/view.yml       Thu Sep 17 15:40:47 
2009        (r3384)
@@ -1,2 +1,2 @@
 editSuccess:
-  javascripts: [autocomplete, multiDelete, 
/sfDrupalPlugin/vendor/drupal/misc/collapse, 
/sfDrupalPlugin/vendor/drupal/misc/textarea]
\ No newline at end of file
+  javascripts: [autocomplete, multiDelete, 
/sfDrupalPlugin/vendor/drupal/misc/collapse, 
/sfDrupalPlugin/vendor/drupal/misc/textarea, 
/sfDrupalPlugin/vendor/drupal/modules/user/user]
\ No newline at end of file

Modified: trunk/apps/qubit/modules/user/templates/editSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/user/templates/editSuccess.php     Thu Sep 17 
15:33:23 2009        (r3383)
+++ trunk/apps/qubit/modules/user/templates/editSuccess.php     Thu Sep 17 
15:40:47 2009        (r3384)
@@ -32,14 +32,38 @@
   <?php echo render_field($form->username, $user) ?>
   <?php echo render_field($form->email, $user) ?>
 
-  <div class="form-item">
-    <?php if (isset($sf_request->id)): ?>
-    <?php echo $form->password->label(__('change password'))->renderLabel() ?>
-    <?php else: ?>
-    <?php echo $form->password->label(__('password'))->renderLabel() ?>
-    <?php endif; ?>
-
-    <?php echo $form->password->render() ?>
+  <div>
+    <?php $settings = json_encode(array('password' => array('strengthTitle' => 
'Password strength:', 'hasWeaknesses' => 'To make your password stronger:', 
'tooShort' => 'Make it at least six characters', 'addLowerCase' => 'Add 
lowercase letters', 'addUpperCase' => 'Add uppercase letters', 'addNumbers' => 
'Add numbers', 'addPunctuation' => 'Add punctuation', 'sameAsUsername' => 'Make 
it different from your username', 'confirmSuccess' => 'yes', 'confirmFailure' 
=> 'no', 'confirmTitle' => 'Passwords match:', 'username' => ''))) ?>
+<?php echo javascript_tag(<<<EOF
+jQuery.extend(Drupal.settings, $settings);
+EOF
+) ?>
+    <?php echo $form->password->renderError() ?>
+    <table class="inline">
+      <thead>
+      <tr>
+        <th>
+          <?php if (isset($sf_request->id)): ?>
+          <?php echo $form->password->label(__('change 
password'))->renderLabel() ?>
+          <?php else: ?>
+          <?php echo $form->password->label(__('password'))->renderLabel() ?>
+          <?php endif; ?>
+        </th>
+        <th>
+          <?php echo $form->password->label(__('confirm 
password'))->renderLabel() ?>
+        </th>
+      </thead>
+      <tbody>
+      <tr>
+        <td>
+          <?php echo $form->password->render(array('class' => 
'password-field')) ?>
+        </td>
+        <td>
+          <?php echo $form->confirmPassword->render(array('class' => 
'password-confirm')) ?>
+        </td>
+      </tr>
+      </tbody>
+    </table>
   </div>
 </fieldset>
 

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to