public function delete() { // Hooks titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $this); $post = new titania_post(); // Remove posts and topic $sql = 'SELECT post_id FROM ' . TITANIA_POSTS_TABLE . ' WHERE topic_id = ' . (int) $this->queue_topic_id; $result = phpbb::$db->sql_query($sql); while ($row = phpbb::$db->sql_fetchrow($result)) { $post->post_id = $row['post_id']; $post->hard_delete(); } phpbb::$db->sql_freeresult($result); // Clear the revision queue id from the revisions table $sql = 'UPDATE ' . TITANIA_REVISIONS_TABLE . ' SET revision_queue_id = 0 WHERE revision_id = ' . $this->revision_id; phpbb::$db->sql_query($sql); // Assplode parent::delete(); }
/** * Remove complete category * * @param sync|null $sync If given sync class, category counts are resynchronized * @return null */ public function delete($sync = null) { // This should be the correct diff value each time $diff = 2; // Resync tree $sql = 'UPDATE ' . $this->sql_table . "\n\t\t\tSET right_id = right_id - {$diff}\n\t\t\tWHERE left_id < {$this->right_id} AND right_id > {$this->right_id}"; phpbb::$db->sql_query($sql); $sql = 'UPDATE ' . $this->sql_table . "\n\t\t\tSET left_id = left_id - {$diff}, right_id = right_id - {$diff}\n\t\t\tWHERE left_id > {$this->right_id}"; phpbb::$db->sql_query($sql); // Delete content $sql = 'DELETE FROM ' . TITANIA_CONTRIB_IN_CATEGORIES_TABLE . ' WHERE category_id = ' . $this->category_id; phpbb::$db->sql_query($sql); // Delete self parent::delete(); // Resync counters if ($sync) { $sync->categories('count'); } // Destroy category cache $this->destroy_cache(); }
/** * Delete this contribution */ public function delete() { // Delete Revisions $revision = new titania_revision($this); $sql = 'SELECT * FROM ' . TITANIA_REVISIONS_TABLE . ' WHERE contrib_id = ' . $this->contrib_id; $result = phpbb::$db->sql_query($sql); while ($row = phpbb::$db->sql_fetchrow($result)) { $revision->__set_array($row); $revision->delete(); } phpbb::$db->sql_freeresult($result); // Delete Support/Discussion/Queue Discussion Topics $topic = new titania_topic(); $sql = 'SELECT * FROM ' . TITANIA_TOPICS_TABLE . ' WHERE ' . phpbb::$db->sql_in_set('topic_type', array(TITANIA_SUPPORT, TITANIA_QUEUE_DISCUSSION)) . ' AND parent_id = ' . $this->contrib_id; $result = phpbb::$db->sql_query($sql); while ($row = phpbb::$db->sql_fetchrow($result)) { $topic->__set_array($row); $topic->delete(); } phpbb::$db->sql_freeresult($result); // Change the status to new (handles resetting counts) $this->change_status(TITANIA_CONTRIB_NEW); // Remove any attention items $sql = 'DELETE FROM ' . TITANIA_ATTENTION_TABLE . ' WHERE attention_object_type = ' . TITANIA_CONTRIB . ' AND attention_object_id = ' . $this->contrib_id; phpbb::$db->sql_query($sql); // Delete the release topic if ($this->contrib_release_topic_id) { phpbb::_include('functions_admin', 'delete_topics'); delete_topics('topic_id', $this->contrib_release_topic_id); } // Delete from categories $this->update_category_count('-'); $sql = ' DELETE FROM ' . TITANIA_CONTRIB_IN_CATEGORIES_TABLE . ' WHERE contrib_id = ' . $this->contrib_id; phpbb::$db->sql_query($sql); repository::trigger_cron($this->config); // Self delete parent::delete(); }
/** * 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(); }