/**
  * Validate the form
  *
  * As it is better for translation utilities to set the labels etc. translated,
  * the MUtil default is to disable translation.
  *
  * However, this also disables the translation of validation messages, which we
  * cannot set translated. The MUtil form is extended so it can make this switch.
  *
  * @param  array   $data
  * @param  boolean $disableTranslateValidators Extra switch
  * @return boolean
  */
 public function isValid($data, $disableTranslateValidators = null)
 {
     $valid = parent::isValid($data, $disableTranslateValidators);
     if ($valid === false && $this->forceRules === false) {
         $messages = $this->getMessages();
         // If we don't enforce password rules, we pass validation but leave error messages in place.
         if (count($messages) == 1 && array_key_exists('new_password', $messages)) {
             $valid = true;
         }
     }
     if ($valid) {
         $this->user->setPassword($data['new_password']);
     } else {
         if ($this->getAskOld() && isset($data['old_password'])) {
             if ($data['old_password'] === strtoupper($data['old_password'])) {
                 $this->addError($this->_('Caps Lock seems to be on!'));
             }
         }
         $this->populate($data);
     }
     return $valid;
 }
 /**
  * Validate the form
  *
  * As it is better for translation utilities to set the labels etc. translated,
  * the MUtil default is to disable translation.
  *
  * However, this also disables the translation of validation messages, which we
  * cannot set translated. The MUtil form is extended so it can make this switch.
  *
  * @param  array   $data
  * @param  boolean $disableTranslateValidators Extra switch
  * @return boolean
  */
 public function isValid($data, $disableTranslateValidators = null)
 {
     $this->_user = $this->loader->getUser(isset($data[$this->usernameFieldName]) ? $data[$this->usernameFieldName] : null, isset($data[$this->organizationFieldName]) ? $data[$this->organizationFieldName] : '');
     return parent::isValid($data, $disableTranslateValidators);
 }
 /**
  * Function for overruling the display of the reset form.
  *
  * @param \Gems_Form_AutoLoadFormAbstract $form Rset password or reset request form
  * @param mixed $errors
  */
 protected function displayResetForm(\Gems_Form_AutoLoadFormAbstract $form, $errors)
 {
     if ($form instanceof \Gems_User_Validate_GetUserInterface) {
         $user = $form->getUser();
     }
     if ($form instanceof \Gems_User_Form_ResetRequestForm) {
         $this->html->h3($this->_('Request password reset'));
         $p = $this->html->pInfo();
         if ($form->getOrganizationIsVisible()) {
             $p->append($this->_('Please enter your organization and your username or e-mail address. '));
         } else {
             $p->append($this->_('Please enter your username or e-mail address. '));
         }
         $this->html->p($this->_('We will then send you an e-mail with a link. The link will bring you to a page where you can set a new password of your choice.'));
     } elseif ($form instanceof \Gems_User_Form_ChangePasswordForm) {
         $this->setCurrentOrganizationTo($user);
         if ($user->hasPassword()) {
             $this->html->h3($this->_('Execute password reset'));
             $p = $this->html->pInfo($this->_('We received your password reset request.'));
         } else {
             // New user
             $this->html->h3(sprintf($this->_('Welcome to %s'), $this->project->getName()));
             $p = $this->html->pInfo($this->_('Welcome to this website.'));
         }
         $p->append(' ');
         $p->append($this->_('Please enter your password of choice twice.'));
     }
     if ($errors) {
         $this->addMessage($errors);
     }
     if (isset($user)) {
         $this->setCurrentOrganizationTo($user);
     }
     $formContainer = \MUtil_Html::create('div', array('class' => 'resetPassword'), $form);
     $this->html->append($formContainer);
 }