protected function doClean($value)
 {
     $validatedString = parent::doClean($value);
     if ($this->hasOption('id')) {
         $specified_pass = ModeratorManagement::asMd5WithPrefix($validatedString);
         $former_pass = ModeratorManagement::getPasswordAsMd5($this->getOption('id'));
         if ($specified_pass != $former_pass) {
             throw new sfValidatorError($this, 'You have specified an invalid former password.');
         }
     } else {
         throw new sfValidatorError($this, 'id');
     }
 }
 protected function processForm(sfWebRequest $request, sfForm $form, $new = false)
 {
     $req_param = $request->getParameter($form->getName());
     $req_param['login']['login'] = strtolower($req_param['login']['login']);
     if (!isset($req_param['login']['is_moderator'])) {
         $req_param['login']['is_moderator'] = 'off';
     }
     if (!isset($req_param['login']['locked']) || is_null($req_param['login']['locked'])) {
         $req_param['login']['locked'] = 0;
     }
     $form->bind($req_param);
     if ($form->isValid()) {
         if (!$form->getObject()->isNew() || ModeratorManagement::checkForDoubloon($req_param['login']['login'])) {
             $moderator = $form->save();
             if ($new) {
                 ModeratorManagement::createXML($moderator->getLogin()->getLogin());
                 $this->getUser()->setFlash('notice', 'The moderator has been added.');
             } else {
                 $this->getUser()->setFlash('notice', 'The moderator has been updated.');
             }
             $this->redirect('moderator/index');
         } else {
             $this->getUser()->setFlash('error', 'This login already exists, please choose another.');
         }
     } else {
         $this->getUser()->setFlash('error', 'Required field(s) are missing or some field(s) are incorrect.', false);
     }
 }
 protected function processForm(sfWebRequest $request, sfForm $form, $new)
 {
     $req_param = $request->getParameter($form->getName());
     $req_param['birthdate'] = $req_param['birthdate']['year'] . "-" . $req_param['birthdate']['month'] . "-" . $req_param['birthdate']['day'];
     if ($new) {
         $req_param['created_at'] = date("Y-m-j H:i:s");
     }
     if (!isset($req_param['login']['locked']) || is_null($req_param['login']['locked'])) {
         $req_param['login']['locked'] = 0;
     }
     $form->bind($req_param);
     if ($form->isValid()) {
         if (!$form->getObject()->isNew() || ModeratorManagement::checkForDoubloon($req_param['login']['login'])) {
             $user = $form->save();
             $country = Doctrine::getTable('AddressCountry')->findOneById($req_param['address']['address_country_id']);
             if ($country) {
                 $countryName = $country->getName();
             } else {
                 $countryName = null;
             }
             $userSeg = Doctrine::getTable('UserSeg')->findOneById($req_param['user_seg_id']);
             if ($userSeg) {
                 $userSegDesignation = $userSeg->getDesignation();
             } else {
                 $userSegDesignation = null;
             }
             $userAwareness = Doctrine::getTable('UserAwareness')->findOneById($req_param['user_awareness_id']);
             if ($userAwareness) {
                 $userAwarenessDesignation = $userAwareness->getDesignation();
             } else {
                 $userAwarenessDesignation = null;
             }
             $userGender = Doctrine::getTable('UserGender')->findOneById($req_param['user_gender_id']);
             if ($userGender) {
                 $userGenderDesignation = $userGender->getDesignation();
             } else {
                 $userGenderDesignation = null;
             }
             $category = Doctrine::getTable('ActPublicCategory')->findOneById($req_param['act_public_category_id']);
             if ($category) {
                 $categoryDesignation = $category->getDesignation();
             } else {
                 $categoryDesignation = null;
             }
             $cityName = $req_param['address']['name'];
             if ($new) {
                 /*Duplication of certain data in the table user_archive, in a new entry*/
                 $this->values = array('age' => UserLib::getAge($req_param['birthdate']), 'created_at' => $req_param['created_at'], 'city_name' => $cityName, 'country' => $countryName, 'seg' => $userSegDesignation, 'awareness' => $userAwarenessDesignation, 'gender' => $userGenderDesignation, 'category' => $categoryDesignation, 'user_id' => $user->id);
                 $this->archiveForm = new UserArchiveForm();
                 $this->archiveForm->bind($this->values);
                 if ($this->archiveForm->isValid()) {
                     $this->archiveForm->save();
                 }
                 $this->getUser()->setFlash('notice', 'The user has been added.');
             } else {
                 /*Duplication of certain data in the table user_archive, in the existing entry*/
                 $updatedUserArchive = Doctrine::getTable('UserArchive')->findOneByUserId($user->id);
                 $updatedUserArchive->setCountry($countryName);
                 $updatedUserArchive->setCityName($cityName);
                 $updatedUserArchive->setSeg($userSegDesignation);
                 $updatedUserArchive->setAwareness($userAwarenessDesignation);
                 $updatedUserArchive->setGender($userGenderDesignation);
                 $updatedUserArchive->setCategory($categoryDesignation);
                 $updatedUserArchive->save();
                 $this->getUser()->setFlash('notice', 'The user has been updated.');
             }
             if ($req_param['direct_imputation']) {
                 $this->getRequest()->setParameter('user_id', $user->id);
                 $this->forward('use', 'index');
             } else {
                 $this->redirect('user/index');
             }
         } else {
             $this->getUser()->setFlash('error', 'This login already exists, please choose another.');
         }
     } else {
         $this->getUser()->setFlash('error', 'Required field(s) are missing or some field(s) are incorrect.', false);
     }
 }
 protected function processForm(sfWebRequest $request, sfForm $form, $new = false)
 {
     $req_param = $request->getParameter($form->getName());
     if (!isset($req_param['login']['is_moderator'])) {
         $req_param['login']['is_moderator'] = 'on';
     }
     if (!isset($req_param['login']['locked']) || is_null($req_param['login']['locked'])) {
         $req_param['login']['locked'] = 0;
     }
     $form->bind($req_param);
     if ($form->isValid()) {
         if (ModeratorManagement::checkForDoubloon($req_param['login']['login'])) {
             $moderator = $form->save();
             if ($new) {
                 ModeratorManagement::createXML($moderator->getLogin()->getLogin());
             }
             firstBootLib::editSecurity();
             $installPath = ProjectConfiguration::guessRootDir() . '/web/index.php';
             rename($installPath, 'install.php');
             $indexPath = ProjectConfiguration::guessRootDir() . '/web/genepi.php';
             rename($indexPath, 'index.php');
             firstBootLib::editUploadParameters();
             header("Location: " . "http://" . $_SERVER["SERVER_NAME"]);
             exit;
         } else {
             $this->getUser()->setFlash('error', 'This login already exists, please choose another.');
         }
     }
 }