Beispiel #1
0
 /**
  * Creates WebMail account.
  * 
  * @param CAccount &$oAccount Object instance with prepopulated account properties.
  * 
  * @return bool
  */
 public function createAccount(CAccount &$oAccount)
 {
     $bResult = false;
     $bUserExist = true;
     $iUserId = $oAccount->IdUser;
     if (0 === $iUserId && !$oAccount->IsMailingList) {
         $bUserExist = false;
         if ($this->oConnection->Execute($this->oCommandCreator->createAUserQuery())) {
             $iUserId = $this->oConnection->GetLastInsertId('a_users', 'id_user');
         }
         if (0 < $iUserId) {
             $oAccount->IdUser = $iUserId;
             $oAccount->User->IdUser = $iUserId;
             $oAccount->User->CreatedTime = time();
             $bUserExist = $this->oConnection->Execute($this->oCommandCreator->createUserQuery($oAccount->User));
         }
     }
     if ($bUserExist) {
         if ($this->oConnection->Execute($this->oCommandCreator->createAccountQuery($oAccount))) {
             $oAccount->IdAccount = $this->oConnection->GetLastInsertId('awm_accounts', 'id_acct');
             $bResult = true;
         }
     }
     $this->throwDbExceptionIfExist();
     return $bResult;
 }