function delete($delete_db_record = true) { $rows = DB::executeAll("SELECT count(`object_id`) as `c` FROM `".TABLE_PREFIX."mail_contents` WHERE `conversation_id` = " . DB::escape($this->getConversationId())); if (is_array($rows) && count($rows) > 0) { if ($rows[0]['c'] < 2) { // if no other emails in conversation, delete conversation DB::execute("DELETE FROM `".TABLE_PREFIX."mail_conversations` WHERE `id` = " . DB::escape($this->getCOnversationId())); } } if ($delete_db_record) { return parent::delete(); } else { return $this->mark_as_deleted(); } }