/** * Hard delete a post */ public function hard_delete() { if (!$this->topic->topic_posts) { if (!$this->topic->load($this->topic_id)) { return false; } } // Update the postcount for the topic $this->update_topic_postcount(true); // Set the visibility appropriately if no posts are visibile to the public/authors $flags = count::get_flags(access::PUBLIC_LEVEL); if (count::from_db($this->topic->topic_posts, $flags) <= 0) { // There are no posts visible to the public, change it to authors level access $this->topic->topic_access = access::AUTHOR_LEVEL; $flags = count::get_flags(access::AUTHOR_LEVEL); if (count::from_db($this->topic->topic_posts, $flags) <= 0) { // There are no posts visible to authors, change it to teams level access $this->topic->topic_access = access::TEAM_LEVEL; } } // Sync the first topic post if required if ($this->post_id == $this->topic->topic_first_post_id) { $this->topic->sync_first_post($this->post_id); } // Sync the last topic post if required if ($this->post_id == $this->topic->topic_last_post_id) { $this->topic->sync_last_post($this->post_id); } // Submit the topic to store the updated information $this->topic->submit(); // Remove from the search index $this->search_manager->delete($this->post_type, $this->post_id); // @todo remove attachments and other things // Remove any attention items $sql = 'DELETE FROM ' . TITANIA_ATTENTION_TABLE . ' WHERE attention_object_type = ' . TITANIA_POST . ' AND attention_object_id = ' . $this->post_id; phpbb::$db->sql_query($sql); // Decrement the user's postcount if we must if (!$this->post_deleted && $this->post_approved && in_array($this->post_type, titania::$config->increment_postcount)) { phpbb::update_user_postcount($this->post_user_id, '-'); } // Hooks titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $this); // Initiate self-destruct mode parent::delete(); // Update topics posted table $this->topic->update_posted_status('remove', $this->post_user_id); // Check if the topic is empty $flags = count::get_flags(access::TEAM_LEVEL, true, true); if (count::from_db($this->topic->topic_posts, $flags) <= 0) { $this->topic->delete(); } }
public function delete() { $this->search_manager->delete(TITANIA_FAQ, $this->faq_id); // Update the FAQ count $sql = 'SELECT contrib_faq_count FROM ' . TITANIA_CONTRIBS_TABLE . ' WHERE contrib_id = ' . $this->contrib_id; phpbb::$db->sql_query($sql); $contrib_faq_count = phpbb::$db->sql_fetchfield('contrib_faq_count'); phpbb::$db->sql_freeresult(); $flags = count::update_flags($this->faq_access); $sql = 'UPDATE ' . TITANIA_CONTRIBS_TABLE . ' SET contrib_faq_count = \'' . phpbb::$db->sql_escape(count::decrement($contrib_faq_count, $flags)) . '\' WHERE contrib_id = ' . $this->contrib_id; phpbb::$db->sql_query($sql); parent::delete(); }