Beispiel #1
0
 protected function _doCreateUser()
 {
     $recArr = $this->readInputRecord();
     $this->setActiveRecord($recArr);
     if (count($recArr) == 0) {
         return;
     }
     if ($this->_checkDupUsername()) {
         $errorMessage = $this->GetMessage("USERNAME_USED");
         $errors['fld_username'] = $errorMessage;
         $this->processFormObjError($errors);
         return;
     }
     if ($this->_checkDupEmail()) {
         $errorMessage = $this->GetMessage("EMAIL_USED");
         $errors['fld_email'] = $errorMessage;
         $this->processFormObjError($errors);
         return;
     }
     try {
         $this->ValidateForm();
     } catch (ValidationException $e) {
         $this->processFormObjError($e->m_Errors);
         return;
     }
     $recArr['create_by'] = "0";
     $recArr['update_by'] = "0";
     $password = BizSystem::ClientProxy()->GetFormInputs("fld_password");
     $recArr['password'] = hash(HASH_ALG, $password);
     $this->_doInsert($recArr);
     //set default user role to member
     $userinfo = $this->getActiveRecord();
     $userRoleObj = BizSystem::getObject('system.do.UserRoleDO');
     foreach (BizSystem::getObject('system.do.RoleDO')->directfetch("[default]='1'") as $roleRec) {
         $roleId = $roleRec['Id'];
         $uesrRoleArr = array("user_id" => $userinfo['Id'], "role_id" => $roleId);
         $userRoleObj->insertRecord($uesrRoleArr);
     }
     //set default group to member
     $userGroupObj = BizSystem::getObject('system.do.UserGroupDO');
     foreach (BizSystem::getObject('system.do.GroupDO')->directfetch("[default]='1'") as $groupRec) {
         $groupId = $groupRec['Id'];
         $uesrGroupArr = array("user_id" => $userinfo['Id'], "group_id" => $groupId);
         $userGroupObj->insertRecord($uesrGroupArr);
     }
     //record event log
     global $g_BizSystem;
     $eventlog = BizSystem::getService(EVENTLOG_SERVICE);
     $logComment = array($userinfo['username'], $_SERVER['REMOTE_ADDR']);
     $eventlog->log("USER_MANAGEMENT", "MSG_USER_REGISTERED", $logComment);
     //send user email
     $emailObj = BizSystem::getService(USER_EMAIL_SERVICE);
     $emailObj->UserWelcomeEmail($userinfo['Id']);
     //init profile for future use like redirect to my account view
     $profile = $g_BizSystem->InituserProfile($userinfo['username']);
     return $userinfo;
 }
Beispiel #2
0
 /**
  * Update account with user inputs
  *
  * @return void
  */
 public function UpdateAccount()
 {
     $currentRec = $this->fetchData();
     $recArr = $this->readInputRecord();
     $this->setActiveRecord($recArr);
     try {
         $this->ValidateForm();
     } catch (ValidationException $e) {
         $this->processFormObjError($e->m_Errors);
         return;
     }
     if (count($recArr) == 0) {
         return;
     }
     $password = BizSystem::ClientProxy()->GetFormInputs("fld_password");
     if ($password) {
         $recArr['password'] = hash(HASH_ALG, $password);
     }
     if ($this->_doUpdate($recArr, $currentRec) == false) {
         return;
     }
     $this->processPostAction();
     /***		
             $this->_doUpdate($recArr, $currentRec);
             
             // if 'notify email' option is checked, send confirmation email to user email address
             // ...
             
             $this->m_Notices[] = $this->GetMessage("USER_DATA_UPDATED");
     
            	//run eventlog        
             $eventlog 	= BizSystem::getService(EVENTLOG_SERIVCE);        
         	$eventlog->log("USER_MANAGEMENT", "MSG_USER_RESET_PASSWORD");        
             
             $this->rerender();
     ***/
 }
Beispiel #3
0
 /**
  * Generate an unique token for future validation
  *
  * @param array $userProfile user profile array
  * @return mixed $token array or false
  */
 protected function GenerateToken($userProfile)
 {
     $token = uniqid();
     $recArr = array("user_id" => $userProfile['Id'], "token" => $token, "expiration" => date("Y-m-d H:i:s", time() + 86400 * 2));
     $tokenObj = BizSystem::getObject('system.do.UserPassTokenDO');
     try {
         if ($tokenObj->insertRecord($recArr)) {
             $recArr = $tokenObj->getActiveRecord();
             return $recArr;
         } else {
             return false;
         }
     } catch (BDOException $e) {
         $errorMsg = $e->getMessage();
         BizSystem::log(LOG_ERR, "DATAOBJ", "DataObj error = " . $errorMsg);
         BizSystem::ClientProxy()->showErrorMessage($errorMsg);
         return false;
     }
 }
Beispiel #4
0
 /**
  * Update login time
  *
  * @return void
  */
 protected function UpdateloginTime()
 {
     $userObj = BizSystem::getObject('system.do.UserDO');
     try {
         $curRecs = $userObj->directFetch("[username]='" . $this->username . "'", 1);
         $dataRec = new DataRecord($curRecs[0], $userObj);
         $dataRec['lastlogin'] = date("Y-m-d H:i:s");
         $ok = $dataRec->save();
         if (!$ok) {
             $errorMsg = $userObj->getErrorMessage();
             BizSystem::log(LOG_ERR, "DATAOBJ", "DataObj error = " . $errorMsg);
             BizSystem::ClientProxy()->showErrorMessage($errorMsg);
             return false;
         }
     } catch (BDOException $e) {
         $errorMsg = $e->getMessage();
         BizSystem::log(LOG_ERR, "DATAOBJ", "DataObj error = " . $errorMsg);
         BizSystem::ClientProxy()->showErrorMessage($errorMsg);
         return false;
     }
     return true;
 }
 public function validateForm()
 {
     //validate password
     $password = BizSystem::ClientProxy()->GetFormInputs("fld_password");
     $validateSvc = BizSystem::getService(VALIDATE_SERVICE);
     if (!$validateSvc->betweenLength($password, 6, 50)) {
         $errorMessage = $this->GetMessage("PASSWORD_LENGTH");
         $this->m_ValidateErrors['fld_password'] = $errorMessage;
         throw new ValidationException($this->m_ValidateErrors);
         return false;
     }
     // disable password validation if they are empty
     $password = BizSystem::ClientProxy()->GetFormInputs("fld_password");
     $password_repeat = BizSystem::ClientProxy()->GetFormInputs("fld_password_repeat");
     if (!$password_repeat) {
         $this->getElement("fld_password")->m_Validator = null;
     }
     if (!$password) {
         $this->getElement("fld_password_repeat")->m_Validator = null;
     }
     if ($password != "" && $password != $password_repeat) {
         $passRepeatElem = $this->getElement("fld_password_repeat");
         $errorMessage = $this->GetMessage("PASSOWRD_REPEAT_NOTSAME", array($passRepeatElem->m_Label));
         $this->m_ValidateErrors['fld_password_repeat'] = $errorMessage;
         throw new ValidationException($this->m_ValidateErrors);
         return false;
     }
     return true;
 }
Beispiel #6
0
 /**
  * check duplication of email address
  *
  * @return boolean
  */
 protected function _checkDupEmail()
 {
     $email = BizSystem::ClientProxy()->GetFormInputs("fld_email");
     $userDO = $this->getDataObj();
     $records = $userDO->directFetch("[email]='{$email}'", 1);
     if (count($records) == 1) {
         return true;
     }
     return false;
 }