Exemplo n.º 1
0
 /**
  * @param	Account	$account
  * @param	int		$sync[optional] = null
  * @return	bool
  */
 function UpdateAccount($account, $sync = null)
 {
     $result = true;
     if ($this->DbStorage->Connect()) {
         if ($account->DefaultAccount) {
             $defaultAccountArray = $this->DbStorage->SelectAccountDataByLogin($account->Email, $account->MailIncLogin, true, $account->Id);
             if (is_array($defaultAccountArray) && count($defaultAccountArray) > 0) {
                 $this->SetError(ap_Utils::TakePhrase('WM_CANT_ADD_DEF_ACCT'));
                 $result = false;
             }
         }
         if ($result && $account->MailProtocol == WM_MAILPROTOCOL_POP3 && $sync != null) {
             $folders =& $this->DbStorage->GetFolders($account);
             if ($folders) {
                 $inboxFolder =& $folders->GetFolderByType(WM_FOLDERTYPE_Inbox);
                 if ($inboxFolder) {
                     $inboxFolder->SyncType = $sync;
                     $result &= $this->DbStorage->UpdateFolder($inboxFolder);
                 }
             }
         }
         if ($result && $account->MailProtocol == WM_MAILPROTOCOL_IMAP4 && $this->_account->_settings->TakeImapQuota) {
             if ($this->_account->ImapQuota === 1) {
                 $mbl = $this->GetQuota();
                 if (false !== $mbl && $mbl >= 0) {
                     $account->MailboxLimit = GetGoodBigInt($mbl);
                 }
             } else {
                 if ($this->_account->ImapQuota === -1 && $this->IsQuotaSupport()) {
                     $this->_account->ImapQuota = 0;
                 }
             }
             $result = $this->DbStorage->UpdateAccountImapQuota($account);
         }
         if ($result) {
             $result = $this->DbStorage->UpdateAccountData($account);
         }
         if ($result && $account->IsInternal) {
             $result &= $this->DbStorage->SaveMailAliases($account);
             $result &= $this->DbStorage->SaveMailForwards($account);
         }
     }
     return $result;
 }