예제 #1
0
 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;
 }
예제 #2
0
 public function registerAction()
 {
     $this->_helper->layout()->setLayout("borrower/layout_login");
     $oModelUser = new Admin_Model_User();
     $oFormRegister = new Admin_Form_RegisterBorrower();
     $aPostData = array();
     $aParam = array();
     $sSuccess = "";
     $aSeparators = array("-", "/", ".", "+", " ");
     if ($this->_request->isPost()) {
         $aPostData = $this->_request->getPost();
         if ($oFormRegister->isValid($aPostData)) {
             $sEmailAddress = $oFormRegister->getValue("email_address");
             $nUserId = $oModelUser->findUserByEmailAddress($sEmailAddress, 2);
             if (!$nUserId) {
                 $aParam["role_id"] = 6;
                 $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"] = str_replace($aSeparators, "", $oFormRegister->getValue("phone_number"));
                 $aParam["is_active"] = (int) $oFormRegister->getValue("is_active");
                 $aParam["statute"] = $oFormRegister->getValue("statute");
                 $sConfirmCode = $oModelUser->newUser($aParam);
                 $aParam["confirm_code"] = $sConfirmCode;
                 if ($sConfirmCode) {
                     $oMail = new AppCms2_Controller_Plugin_Mail();
                     $oMail->sendUserAccountRegistration($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)
                     $sSuccess = "OK";
                 } else {
                     $sSuccess = "NO OK";
                 }
             } else {
                 if ($oModelUser->editRow($nUserId, array("password" => md5($oFormRegister->getValue("user_password")), "is_active" => 1))) {
                     $sSuccess = "OK";
                 }
             }
         }
     }
     $this->view->oFormRegister = $oFormRegister;
     $this->view->sSuccess = $sSuccess;
 }