예제 #1
0
 function delete($deleteMails = false)
 {
     MailAccountUsers::deleteByAccount($this);
     if ($deleteMails) {
         session_commit();
         LinkedObjects::delete(array("(`object_id` IN (SELECT `id` FROM `" . TABLE_PREFIX . "mail_contents` WHERE `account_id` = " . DB::escape($this->getId()) . ") and `object_manager` = 'MailContents') \n\t\t\t\tor (`rel_object_id` IN (SELECT `id` FROM `" . TABLE_PREFIX . "mail_contents` WHERE `account_id` = " . DB::escape($this->getId()) . ") and `rel_object_manager` = 'MailContents')"));
         SearchableObjects::delete(array("`rel_object_manager` = 'MailContents' AND `rel_object_id` IN (SELECT `id` FROM `" . TABLE_PREFIX . "mail_contents` WHERE `account_id` = " . DB::escape($this->getId()) . ") "));
         ReadObjects::delete("`rel_object_manager` = 'MailContents' AND `rel_object_id` IN (SELECT `id` FROM `" . TABLE_PREFIX . "mail_contents` WHERE `account_id` = " . DB::escape($this->getId()) . ") ");
         $account_emails = MailContents::findAll(array('conditions' => '`account_id` = ' . DB::escape($this->getId()), 'include_trashed' => true));
         foreach ($account_emails as $email) {
             $email->delete();
         }
         //MailContents::delete('`account_id` = ' . DB::escape($this->getId()));
     }
     if ($this->getIsImap()) {
         MailAccountImapFolders::delete('account_id = ' . $this->getId());
     }
     parent::delete();
 }