コード例 #1
0
ファイル: AjaxAdmin.php プロジェクト: ashishvazirani/food
 public function adminForgotPass()
 {
     if (isset($this->data['email_address'])) {
         if ($res = yii::app()->functions->isAdminExist($this->data['email_address'])) {
             $new_pass = yii::app()->functions->generateCode();
             $params = array('lost_password_code' => $new_pass, 'password' => md5($new_pass));
             if ($this->updateData("{{admin_user}}", $params, 'admin_id', $res[0]['admin_id'])) {
                 $this->code = 1;
                 $this->msg = Yii::t("default", "An email address was sent to your.");
                 $tpl = EmailTPL::adminForgotPassword($new_pass);
                 $sender = Yii::app()->functions->getOptionAdmin('website_contact_email');
                 $to = $res[0]['email_address'];
                 if (!sendEmail($to, $sender, t("Admin Forgot Password"), $tpl)) {
                     $this->details = "failed {$new_pass}";
                 } else {
                     $this->details = "ok mail {$new_pass}";
                 }
             } else {
                 $this->msg = Yii::t("default", "ERROR: Cannot update.");
             }
         } else {
             $this->msg = Yii::t("default", "Sorry but we cannot find your email address.");
         }
     } else {
         $this->msg = Yii::t("default", "Email address is required");
     }
 }