function delete($deleteMails = false){ MailAccountContacts::deleteByAccount($this); if ($deleteMails) { session_commit(); ini_set('memory_limit', '1024M'); LinkedObjects::delete(array("(`object_id` IN (SELECT `object_id` FROM `".TABLE_PREFIX."mail_contents` WHERE `account_id` = " . DB::escape($this->getId()).")) or (`rel_object_id` IN (SELECT `object_id` FROM `".TABLE_PREFIX."mail_contents` WHERE `account_id` = " . DB::escape($this->getId())."))")); SearchableObjects::delete(array("`rel_object_id` IN (SELECT `object_id` FROM `".TABLE_PREFIX."mail_contents` WHERE `account_id` = " . DB::escape($this->getId()).") ")); ReadObjects::delete("`rel_object_id` IN (SELECT `object_id` FROM `".TABLE_PREFIX."mail_contents` WHERE `account_id` = " . DB::escape($this->getId()).") "); $account_email_ids = MailContents::findAll(array('id' => true, 'conditions' => '`account_id` = ' . DB::escape($this->getId()), 'include_trashed' => true)); if (count($account_email_ids) > 0) { MailDatas::delete('id IN ('.implode(',', $account_email_ids).')'); MailContents::delete('`account_id` = ' . DB::escape($this->getId())); } } if ($this->getIsImap()) { MailAccountImapFolders::delete('account_id = ' . $this->getId()); } parent::delete(); }
function clearReads() { return ReadObjects::delete(array("`rel_object_id` = ?", $this->getId())); }
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(); }
function clearReads() { return ReadObjects::delete(array("`rel_object_manager` = ? AND `rel_object_id` = ?", $this->getObjectManagerName(), $this->getId())); }