示例#1
0
 public function isValid($sValue, $mContext = null)
 {
     $sValue = (string) $sValue;
     if (isset($sValue)) {
         $oModelUser = new Admin_Model_User();
         $nUserId = $oModelUser->findUserByEmailAddress($sValue);
         if (!is_numeric($nUserId)) {
             return true;
         }
     }
     $this->_error(self::IS_EXIST);
     return false;
 }
 public function registerAction()
 {
     $this->getFileUploadScript();
     $oModelUser = new Admin_Model_User();
     $oModelVUser = new Admin_Model_VUser();
     $oFormRegister = new Admin_Form_Register();
     $aPostData = array();
     $aParam = array();
     $sSuccess = "";
     if ($this->_request->isPost()) {
         $aPostData = $this->_request->getPost();
         if ($aPostData["user_edit_id"]) {
             $oFormRegister->removeElement("email_address");
             $oFormRegister->removeElement("email_address_confirm");
             $oFormRegister->removeElement("password");
         }
         if ($oFormRegister->isValid($aPostData)) {
             $bIsEdit = $oFormRegister->getValue("user_edit_id");
             if ($bIsEdit) {
                 $nUserId = (int) $oFormRegister->getValue("user_edit_id");
                 $aParam["role_id"] = $oFormRegister->getValue("role_id");
                 $aParam["first_name"] = $oFormRegister->getValue("first_name");
                 $aParam["last_name"] = $oFormRegister->getValue("last_name");
                 $aParam["phone_number"] = $oFormRegister->getValue("phone_number");
                 $aParam["user_category_id"] = (int) $oFormRegister->getValue("user_category_id") != 0 ? $oFormRegister->getValue("user_category_id") : null;
                 $aParam["is_active"] = (int) $oFormRegister->getValue("is_active");
                 if ($aParam["is_active"]) {
                     $sEmailAddress = $oModelUser->findEmailAddress($nUserId);
                     if ($oModelUser->findUserByEmailAddress($sEmailAddress, 0) == $nUserId) {
                         $oMail = new AppCms2_Controller_Plugin_Mail();
                         $oMail->sendUserAccountActivation($sEmailAddress, $aParam);
                         //mail do użytkownika z informacją o aktywacji konta w systemie
                     }
                 } else {
                     $sEmailAddress = $oModelUser->findEmailAddress($nUserId);
                     if ($oModelUser->findUserByEmailAddress($sEmailAddress, 0) == $nUserId) {
                         $oMail = new AppCms2_Controller_Plugin_Mail();
                         $oMail->sendUserAccountDeactivation($sEmailAddress, array("user_id" => $nUserId));
                         //mail do użytkownika z informacją o deaktywacji konta w systemie
                     }
                 }
                 $oModelUser->editUser($nUserId, $aParam);
                 $this->_redirect("admin/settings/register");
             } else {
                 $sEmailAddress = $oFormRegister->getValue("email_address");
                 $nUserId = $oModelUser->findUserByEmailAddress($sEmailAddress, 2);
                 if (!$nUserId) {
                     $aParam["role_id"] = $oFormRegister->getValue("role_id");
                     $aParam["first_name"] = $oFormRegister->getValue("first_name");
                     $aParam["last_name"] = $oFormRegister->getValue("last_name");
                     $aParam["email_address"] = $oFormRegister->getValue("email_address");
                     $aParam["email_address_confirm"] = $oFormRegister->getValue("email_address_confirm");
                     $aParam["password"] = $oFormRegister->getValue("password");
                     $aParam["phone_number"] = $oFormRegister->getValue("phone_number");
                     $aParam["user_category_id"] = (int) $oFormRegister->getValue("user_category_id") != 0 ? $oFormRegister->getValue("user_category_id") : null;
                     $aParam["is_active"] = (int) $oFormRegister->getValue("is_active");
                     $sConfirmCode = $oModelUser->newUser($aParam);
                     $aParam["confirm_code"] = $sConfirmCode;
                     if ($sConfirmCode) {
                         if ($aParam["is_active"]) {
                             $oMail = new AppCms2_Controller_Plugin_Mail();
                             $oMail->sendUserAccountRegistrationAndActivation($sEmailAddress, $aParam);
                             //mail do użytkownika z informacją o rejestracji i aktywacji konta w systemie (w tym mailu wysłane jest hasło)
                             $oMail = new AppCms2_Controller_Plugin_Mail();
                             $oMail->sendAdminConfirmRegistrationAndActivation($aParam);
                             //mail do administratora z informacją o rejestracji i aktywacji konta w systemie (w tym mailu wysłane jest hasło)
                         } else {
                             $oMail = new AppCms2_Controller_Plugin_Mail();
                             $oMail->sendUserAccountRegistration($sEmailAddress, $aParam);
                             //mail do użytkownika z informacją o rejestracji konta w systemie (w tym mailu wysłane jest hasło) konto jest nieaktywne
                             $oMail = new AppCms2_Controller_Plugin_Mail();
                             $oMail->sendAdminConfirmRegistration($aParam);
                             //mail do administratora z informacją o rejestracji konta w systemie (w tym mailu wysłane jest hasło) konto jest nieaktywne
                         }
                         $sSuccess = "OK";
                     } else {
                         $sSuccess = "NO OK";
                     }
                 } else {
                     $oBootstrap = Zend_Controller_Front::getInstance()->getParam("bootstrap");
                     $sOptions = $oBootstrap->getOptions();
                     $nTime = time();
                     $sSalt = md5(sha1($nTime . $sOptions["resources"]["frontController"]["salt"] . $nTime));
                     $sPassword = md5(md5($aParam["password"]) . $sSalt);
                     if ($oModelUser->editRow($nUserId, array("password" => $sPassword, "salt" => $sSalt, "created_date" => $nTime, "is_active" => 1))) {
                         $sSuccess = "OK";
                     }
                 }
             }
             $oFormRegister->clearForm();
         }
     }
     $this->view->oFormRegister = $oFormRegister;
     $this->view->aAllUser = $oModelVUser->getAll()->toArray();
     $this->view->sSuccess = $sSuccess;
 }
示例#3
0
 public function passwordremindAction()
 {
     $this->_helper->layout()->setLayout("borrower/layout_login");
     $oModelUser = new Admin_Model_User();
     $oModelVUser = new Admin_Model_VUser();
     $oModelUserNewPassword = new Admin_Model_UserNewPassword();
     $oFormPasswordRemind = new Admin_Form_PasswordRemind();
     $oGenereteSessionId = new AppCms2_GenereteSessionId();
     $aPostData = array();
     $sSuccess = "";
     if ($this->_request->isPost()) {
         $aPostData = $this->_request->getPost();
         if ($oFormPasswordRemind->isValid($aPostData)) {
             $sEmailAddress = $oFormPasswordRemind->getValue("user_email_address");
             $nUserId = $oModelUser->findUserByEmailAddress($sEmailAddress);
             if (is_numeric($nUserId)) {
                 $aParam = $oModelVUser->getUserParam($nUserId)->toArray();
                 $aParam["salt"] = $oModelUser->getUserSalt($nUserId);
                 $aParam = array_merge($aParam, $oGenereteSessionId->generatePassword($aParam["salt"]));
                 if ($oModelUserNewPassword->addPassword($nUserId, $aParam)) {
                     $sEmailAddress = $oModelUser->findEmailAddress($nUserId);
                     $oMail = new AppCms2_Controller_Plugin_Mail();
                     $oMail->sendNewPassword($sEmailAddress, $aParam);
                     $sSuccess = "OK";
                 } else {
                     $sSuccess = "NO OK";
                 }
             } else {
                 $sSuccess = "USER";
             }
         }
     }
     $this->view->oFormPasswordRemind = $oFormPasswordRemind;
     $this->view->sSuccess = $sSuccess;
 }