public function check_passwords($attribute, $params)
 {
     if (!$this->hasErrors()) {
         $key = !empty($_GET["key"]) ? SiteHelper::checkedVaribal($_GET["key"], "string") : "";
         $confirm = CatalogUsersConfirm::findByAttributes(array("confirm_key" => $key));
         if (!empty($confirm) && sizeof($confirm) == 1) {
             $userModel = CatalogUsers::fetch($confirm[0]->user_id->id);
             if ($userModel->active == 0) {
                 $error = Yii::t("models", "Ваш аккаунт не активирован");
             }
         } else {
             $error = Yii::t("models", "Указан не верный ключ");
         }
         if (!empty($error)) {
             $this->addErrors(array("0" => $error));
         } else {
             $confirm[0]->delete();
         }
     }
 }
 public function check_exists_params($attribute, $params)
 {
     if (!$this->hasErrors()) {
         $userList = CatalogUsers::findByAttributes(array("email" => $this->email), 0);
         if (!empty($userList) && sizeof($userList) == 1) {
             // Если в базе уже сужествует запросы на восстановление, до удаляем его
             $existConfirm = CatalogUsersConfirm::findByAttributes(array("user_id" => $userList[0]->id, "type" => "lostpassword"));
             if (sizeof($existConfirm) > 0) {
                 $existConfirm[0]->delete();
             }
             if ($userList[0]->active == 0) {
                 $error = Yii::t("models", "Ваш аккаунт не активирован");
             }
         } else {
             $error = Yii::t("models", "Вы ввели не существующий EMAIL");
         }
         if (!empty($error)) {
             $this->addErrors(array("0" => $error));
         }
     }
 }
 /**
  * Displays the lost password page
  */
 public function actionLostConfirm()
 {
     $error = false;
     $lostConfirm = new CatalogUsersLost();
     $formNewsPassword = new CatalogUsersLostConfirm();
     $key = Yii::app()->request->getParam("key", "");
     if (!empty($key) && !isset($_GET["successfully"])) {
         $lostConfirm = CatalogUsersConfirm::findByAttributes(array("confirm_key" => $key));
         if (empty($lostConfirm) || sizeof($lostConfirm) == 0) {
             $error = true;
         }
     } else {
         $error = true;
     }
     if (empty($error) && !empty($_POST["CatalogUsersLostConfirm"])) {
         $formNewsPassword = new CatalogUsersLostConfirm();
         $formNewsPassword->setAttributesFromArray($_POST["CatalogUsersLostConfirm"]);
         if ($formNewsPassword->validate()) {
             $formNewsPassword->onLostPasswordConfirm(new CModelEvent($lostConfirm));
             $this->redirect($this->createUrl("default/lostconfirm/successfully/"));
         }
     }
     if (isset($_GET["successfully"])) {
         $error = false;
         $okMessage = "<b>Новый пароль успешно сохранен.</b><br/>Вы можете авторизоваться используя новый пароль";
     } else {
         $okMessage = null;
     }
     $this->render('lostconfirm', array('key' => $key, 'form' => $lostConfirm, 'formNewsPassword' => $formNewsPassword, "error" => $error, "okMessage" => $okMessage));
 }