Example #1
0
    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();
    }
Example #2
0
 /**
  * Submit data for storing into the database
  *
  * @return bool
  */
 public function submit()
 {
     if (!$this->user_id) {
         throw new exception('No user_id!');
     }
     return parent::submit();
 }
Example #3
0
    /**
     * 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();
    }
Example #4
0
 public function report($reason = '', $notify_reporter = false)
 {
     // Mark the post as reported
     $this->post_reported = true;
     // Setup the attention object and submit it
     $attention = new titania_attention();
     $attention->__set_array(array('attention_type' => TITANIA_ATTENTION_REPORTED, 'attention_object_type' => TITANIA_POST, 'attention_object_id' => $this->post_id, 'attention_poster_id' => $this->post_user_id, 'attention_post_time' => $this->post_time, 'attention_url' => $this->get_url(), 'attention_title' => $this->post_subject, 'attention_description' => $reason, 'notify_reporter' => $notify_reporter));
     $attention->submit();
     // Update the postcount and mark as reported for the topic and submit it
     $this->update_topic_postcount();
     $this->topic->topic_reported = true;
     $this->topic->submit();
     // Self submission
     parent::submit();
     // Hooks
     titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $this);
 }
Example #5
0
    /**
     * 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();
    }
Example #6
0
    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();
    }