Пример #1
0
 /**
  * @return array
  */
 public function AjaxAccountCreate()
 {
     $mResult = false;
     $oNewAccount = null;
     $oAccount = $this->getDefaultAccountFromParam();
     $oApiDomains = \CApi::Manager('domains');
     $oDomain = $oApiDomains->getDefaultDomain();
     if ($oDomain) {
         $oNewAccount = new \CAccount($oDomain);
         $oNewAccount->IdUser = $oAccount->IdUser;
         $oNewAccount->IsDefaultAccount = false;
         $this->populateAccountFromHttpPost(false, $oNewAccount);
         if ($this->oApiUsers->createAccount($oNewAccount)) {
             $mResult = true;
         } else {
             $iClientErrorCode = \ProjectCore\Notifications::CanNotCreateAccount;
             $oException = $this->oApiUsers->GetLastException();
             if ($oException) {
                 switch ($oException->getCode()) {
                     case \Errs::WebMailManager_AccountDisabled:
                     case \Errs::UserManager_AccountAuthenticationFailed:
                     case \Errs::WebMailManager_AccountAuthentication:
                     case \Errs::WebMailManager_NewUserRegistrationDisabled:
                     case \Errs::WebMailManager_AccountWebmailDisabled:
                         $iClientErrorCode = \ProjectCore\Notifications::AuthError;
                         break;
                     case \Errs::UserManager_AccountConnectToMailServerFailed:
                     case \Errs::WebMailManager_AccountConnectToMailServerFailed:
                         $iClientErrorCode = \ProjectCore\Notifications::MailServerError;
                         break;
                     case \Errs::UserManager_LicenseKeyInvalid:
                     case \Errs::UserManager_AccountCreateUserLimitReached:
                     case \Errs::UserManager_LicenseKeyIsOutdated:
                         $iClientErrorCode = \ProjectCore\Notifications::LicenseProblem;
                         break;
                     case \Errs::Db_ExceptionError:
                         $iClientErrorCode = \ProjectCore\Notifications::DataBaseError;
                         break;
                 }
             }
             return $this->FalseResponse($oAccount, __FUNCTION__, $iClientErrorCode);
         }
     }
     if ($mResult && $oNewAccount) {
         $aExtensions = $oAccount->getExtensionList();
         $mResult = array('IdAccount' => $oNewAccount->IdAccount, 'Extensions' => $aExtensions);
     } else {
         $mResult = false;
     }
     return $this->DefaultResponse($oAccount, __FUNCTION__, $mResult);
 }