Пример #1
0
	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();
	}