public function newUser($aParam) { if (is_array($aParam) && count($aParam)) { $oModelUserParm = new Admin_Model_UserParam(); $oModelUserNewAccount = new Admin_Model_UserNewAccount(); $oGenerateSessionId = new AppCms2_GenereteSessionId(); $oBootstrap = Zend_Controller_Front::getInstance()->getParam("bootstrap"); $sOptions = $oBootstrap->getOptions(); try { $this->_db->beginTransaction(); $nTime = time(); $sSalt = md5(sha1($nTime . $sOptions["resources"]["frontController"]["salt"] . $nTime)); $oRow = $this->createRow(); if ($oRow instanceof Zend_Db_Table_Row_Abstract) { if (!isset($aParam["role_id"])) { $oRow->user_role_id = 1; } else { $oRow->user_role_id = $aParam["role_id"]; } $oRow->email_address = $aParam["email_address"]; $oRow->password = md5(md5($aParam["password"]) . $sSalt); $oRow->salt = $sSalt; $oRow->created_date = $nTime; $oRow->is_active = $aParam["is_active"]; $nUserId = $oRow->save(); if ($oModelUserParm->newUserParam($nUserId, $aParam)) { $sConfirmCode = $oGenerateSessionId->generate(); if ($oModelUserNewAccount->addConfirmCode($nUserId, $sConfirmCode)) { $this->_db->commit(); return $sConfirmCode; } } } } catch (Zend_Exception $e) { $this->_db->rollBack(); return null; } } return null; }
public function confirmnewaccountAction() { $this->_helper->viewRenderer->setNoRender(); $this->_helper->getHelper("layout")->disableLayout(); $oModelUser = new Admin_Model_User(); $oModelUserNewAccount = new Admin_Model_UserNewAccount(); $sActivatingCode = $this->_request->getParam("code"); if (isset($sActivatingCode) && is_string($sActivatingCode) && strlen($sActivatingCode) == 32) { $nUserId = $oModelUserNewAccount->confirmNewAccount($sActivatingCode); if (!is_numeric($nUserId)) { $this->_redirect("admin/user/login"); } if ($oModelUser->activatingNewUser($nUserId)) { $sEmailAddress = $oModelUser->findEmailAddress($nUserId); $oModelUserNewAccount->deleteConfirmCode($sActivatingCode); $oMail = new AppCms2_Controller_Plugin_Mail(); $oMail->sendUserAccountActivation($sEmailAddress); } } $this->_redirect("admin/user/login"); }