コード例 #1
0
ファイル: manager.php プロジェクト: Git-Host/email
 /**
  * @param CTenant $oTenant
  *
  * @throws CApiManagerException(Errs::TenantsManager_QuotaLimitExided) 1707
  * @throws CApiManagerException(Errs::TenantsManager_TenantUpdateFailed) 1703
  * @throws $oException
  *
  * @return bool
  */
 public function updateTenant(CTenant $oTenant)
 {
     $bResult = false;
     try {
         if ($oTenant->validate()) {
             if ($oTenant->IsDefault && 0 === $oTenant->IdTenant) {
                 $this->oSettings->SetConf('Helpdesk/AdminEmailAccount', $oTenant->HelpdeskAdminEmailAccount);
                 $this->oSettings->SetConf('Helpdesk/ClientIframeUrl', $oTenant->HelpdeskClientIframeUrl);
                 $this->oSettings->SetConf('Helpdesk/AgentIframeUrl', $oTenant->HelpdeskAgentIframeUrl);
                 $this->oSettings->SetConf('Helpdesk/SiteName', $oTenant->HelpdeskSiteName);
                 $this->oSettings->SetConf('Helpdesk/StyleAllow', $oTenant->HelpdeskStyleAllow);
                 $this->oSettings->SetConf('Helpdesk/StyleImage', $oTenant->HelpdeskStyleImage);
                 $this->oSettings->SetConf('Helpdesk/StyleText', $oTenant->HelpdeskStyleText);
                 $this->oSettings->SetConf('Helpdesk/FetcherType', $oTenant->HelpdeskFetcherType);
                 $this->oSettings->SetConf('Common/LoginStyleImage', $oTenant->LoginStyleImage);
                 $this->oSettings->SetConf('Common/AppStyleImage', $oTenant->AppStyleImage);
                 $this->oSettings->SetConf('Helpdesk/FacebookAllow', $oTenant->HelpdeskFacebookAllow);
                 $this->oSettings->SetConf('Helpdesk/FacebookId', $oTenant->HelpdeskFacebookId);
                 $this->oSettings->SetConf('Helpdesk/FacebookSecret', $oTenant->HelpdeskFacebookSecret);
                 $this->oSettings->SetConf('Helpdesk/GoogleAllow', $oTenant->HelpdeskGoogleAllow);
                 $this->oSettings->SetConf('Helpdesk/GoogleId', $oTenant->HelpdeskGoogleId);
                 $this->oSettings->SetConf('Helpdesk/GoogleSecret', $oTenant->HelpdeskGoogleSecret);
                 $this->oSettings->SetConf('Helpdesk/TwitterAllow', $oTenant->HelpdeskTwitterAllow);
                 $this->oSettings->SetConf('Helpdesk/TwitterId', $oTenant->HelpdeskTwitterId);
                 $this->oSettings->SetConf('Helpdesk/TwitterSecret', $oTenant->HelpdeskTwitterSecret);
                 $this->oSettings->SetConf('Sip/AllowSip', $oTenant->SipAllow);
                 $this->oSettings->SetConf('Sip/Realm', $oTenant->SipRealm);
                 $this->oSettings->SetConf('Sip/WebsocketProxyUrl', $oTenant->SipWebsocketProxyUrl);
                 $this->oSettings->SetConf('Sip/OutboundProxyUrl', $oTenant->SipOutboundProxyUrl);
                 $this->oSettings->SetConf('Sip/CallerID', $oTenant->SipCallerID);
                 $this->oSettings->SetConf('Twilio/AllowTwilio', $oTenant->TwilioAllow);
                 $this->oSettings->SetConf('Twilio/PhoneNumber', $oTenant->TwilioPhoneNumber);
                 $this->oSettings->SetConf('Twilio/AccountSID', $oTenant->TwilioAccountSID);
                 $this->oSettings->SetConf('Twilio/AuthToken', $oTenant->TwilioAuthToken);
                 $this->oSettings->SetConf('Twilio/AppSID', $oTenant->TwilioAppSID);
                 $this->oSettings->SetConf('Common/InvitationEmail', $oTenant->InviteNotificationEmailAccount);
                 $this->oSettings->SetConf('Socials', $oTenant->getSocialsForSettings());
                 $bResult = $this->oSettings->SaveToXml();
             } else {
                 if (null !== $oTenant->GetObsoleteValue('QuotaInMB')) {
                     $iQuota = $oTenant->QuotaInMB;
                     if (0 < $iQuota) {
                         $iSize = $this->getTenantAllocatedSize($oTenant->IdTenant);
                         if ($iSize > $iQuota) {
                             throw new CApiManagerException(Errs::TenantsManager_QuotaLimitExided);
                         }
                     }
                 }
                 if (!$this->oStorage->updateTenant($oTenant)) {
                     throw new CApiManagerException(Errs::TenantsManager_TenantUpdateFailed);
                 }
                 if (null !== $oTenant->GetObsoleteValue('IsDisabled')) {
                     /* @var $oDomainsApi CApiDomainsManager */
                     $oDomainsApi = CApi::Manager('domains');
                     if (!$oDomainsApi->enableOrDisableDomainsByTenantId($oTenant->IdTenant, !$oTenant->IsDisabled)) {
                         $oException = $oDomainsApi->GetLastException();
                         if ($oException) {
                             throw $oException;
                         }
                     }
                 }
             }
         }
         $bResult = true;
     } catch (CApiBaseException $oException) {
         $bResult = false;
         $this->setLastException($oException);
     }
     return $bResult;
 }