Exemple #1
0
 protected function postInsert()
 {
     $this->profile->setUserId($this->getId());
     $this->profile->save(false);
     /*$this->sendEmail('user-register.tpl');*/
     if ($this->user_type == 'admin') {
         DatabaseObject_StaticUtility::addClubNumber($this->_db, $this->university_id);
         DatabaseObject_StaticUtility::addTypeClubNumber($this->_db, $this->type_id);
     }
     /*****creat account balance now.*/
     if (!$this->accountbalanceExists()) {
         $this->accountBalanceSummary->user_id = $this->getId();
         $this->accountBalanceSummary->save(false);
     }
     unset($_SESSION['referral']);
     //remove the current referral session
     //echo "at post insert person: ".$this->referral_id;
     if ($this->referral_id != '') {
         $referralUser = new DatabaseObject_User($this->_db);
         if ($referralUser->loadByRefereeId($this->referral_id)) {
             $referralAccountAndRewardPointProcessor = new AccountBalanceAndRewardPointProcessor($this->_db, $referralUser);
             $trackingId = $referralAccountAndRewardPointProcessor->updatePendingRewardPointsAndBalanceForUser('REWARD_ADDITION', 4, 'caused_by_user_id', $this->getId(), 'Reward points awarded for the referral of user ' . $this->first_name . ' ' . $this->last_name);
             $referralAccountAndRewardPointProcessor->postPendingRewardPointsAndBalanceForUser($trackingId);
         }
         //DatabaseObject_Helper_UserManager::addRewardPointToUser($this->_db, $this->referral_id, '4', 'from referred new member registration', $_SERVER['REMOTE_ADDR'], $this->username, $this->getId(), $this->referee_id);
     }
     $userAccountBalanceAndRewardPointProcessor = new AccountBalanceAndRewardPointProcessor($this->_db, $this);
     $trackingId = $userAccountBalanceAndRewardPointProcessor->updatePendingRewardPointsAndBalanceForUser('REWARD_ADDITION', 8, 'caused_by_user_id', $this->getId(), 'Reward points awarded for registration');
     $userAccountBalanceAndRewardPointProcessor->postPendingRewardPointsAndBalanceForUser($trackingId);
     return true;
 }