/** * @param int $iAccountId * @return bool */ public function DeleteAccount($iAccountId) { $bResult = false; if ($this->oConnection->Execute($this->oCommandCreator->GetAccountInfo($iAccountId))) { $oRow = $this->oConnection->GetNextRecord(); if ($oRow) { $bIsDefaultAccount = (bool) $oRow->def_acct; $bIsMailingList = (bool) $oRow->mailing_list; $iUserId = (int) $oRow->id_user; $this->oConnection->FreeResult(); if ($bIsMailingList) { $bResult = $this->oConnection->Execute($this->oCommandCreator->DeleteAccount($iAccountId)); $bResult &= $this->oConnection->Execute($this->oCommandCreator->ClearMailingListMembers($iAccountId)); } else { $bResult = false; if ($bIsDefaultAccount) { $aAccountsId = $this->GetUserIdList($iUserId); if (is_array($aAccountsId) && 0 < count($aAccountsId)) { $bResult = true; foreach ($aAccountsId as $iAccountIdItem) { $bResult &= $this->deleteAccountRequests($iAccountIdItem); } // Webmail $bResult &= $this->oConnection->Execute($this->oCommandCreator->DeleteUser($iUserId)); $bResult &= $this->oConnection->Execute($this->oCommandCreator->DeleteAUser($iUserId)); $bResult &= $this->oConnection->Execute($this->oCommandCreator->DeleteSenders($iUserId)); $bResult &= $this->oConnection->Execute($this->oCommandCreator->DeleteIdentitiesByUserId($iUserId)); // Calendar $bResult &= $this->oConnection->Execute($this->oCommandCreator->DeleteCalendarEvents($iUserId)); $bResult &= $this->oConnection->Execute($this->oCommandCreator->DeleteCalendarCalendars($iUserId)); $bResult &= $this->oConnection->Execute($this->oCommandCreator->DeleteCalendarUserData($iUserId)); $bResult &= $this->oConnection->Execute($this->oCommandCreator->DeleteCalendarPublications($iUserId)); $bResult &= $this->oConnection->Execute($this->oCommandCreator->DeleteCalendarSharing($iUserId)); $this->throwDbExceptionIfExist(); } } else { $bResult = $this->deleteAccountRequests($iAccountId); } } } else { $this->oConnection->FreeResult(); } } $this->throwDbExceptionIfExist(); return (bool) $bResult; }