コード例 #1
0
ファイル: post.php プロジェクト: Gfksx/customisation-db
    /**
     * 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 = titania_count::get_flags(TITANIA_ACCESS_PUBLIC);
        if (titania_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 = TITANIA_ACCESS_AUTHORS;
            $flags = titania_count::get_flags(TITANIA_ACCESS_AUTHORS);
            if (titania_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 = TITANIA_ACCESS_TEAMS;
            }
        }
        // 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
        titania_search::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();
        // Check if the topic is empty
        $flags = titania_count::get_flags(TITANIA_ACCESS_TEAMS, true, true);
        if (titania_count::from_db($this->topic->topic_posts, $flags) <= 0) {
            // Remove any subscriptions to this topic
            $sql = 'DELETE FROM ' . TITANIA_WATCH_TABLE . '
				WHERE watch_object_type = ' . TITANIA_TOPIC . '
					AND watch_object_id = ' . $this->topic->topic_id;
            phpbb::$db->sql_query($sql);
            // Remove any tracking for this topic
            titania_tracking::clear_item(TITANIA_TOPIC, $this->topic->topic_id);
            // Delete the now empty topic
            $sql = 'DELETE FROM ' . TITANIA_TOPICS_TABLE . '
				WHERE topic_id = ' . $this->topic->topic_id;
            phpbb::$db->sql_query($sql);
        }
    }
コード例 #2
0
ファイル: post.php プロジェクト: Sajaki/customisation-db
    /**
     * 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();
        }
    }
コード例 #3
0
         $messenger->template($email_template, users_overlord::get_user($post->post_user_id, 'user_lang'));
         $messenger->to(users_overlord::get_user($post->post_user_id, 'user_email'), users_overlord::get_user($post->post_user_id, '_username'));
         $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode(users_overlord::get_user($post->post_user_id, '_username')), 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post->post_subject)), 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post->topic->topic_subject))));
         $messenger->send();
         phpbb::$user->set_custom_lang_path($lang_path);
     }
     // Delete the post
     $post->delete();
     redirect(titania_url::build_url(titania_url::$current_page));
 }
 // Approve the post
 if ($approve) {
     $post->post_approved = 1;
     // Increment the user's postcount if we must
     if (!$post->post_deleted && in_array($post->post_type, titania::$config->increment_postcount)) {
         phpbb::update_user_postcount($post->post_user_id);
     }
     $post->submit();
     // Load z topic
     $post->topic->topic_id = $post->topic_id;
     $post->topic->load();
     // Update first/last post?
     if ($post->topic->topic_first_post_time > $post->post_time) {
         $post->topic->sync_first_post();
     }
     if ($post->topic->topic_last_post_time < $post->post_time) {
         $post->topic->sync_last_post();
     }
     // Subscriptions?
     if ($post->topic->topic_last_post_id == $post->post_id) {
         phpbb::_include('functions_messenger', false, 'messenger');
コード例 #4
0
ファイル: post.php プロジェクト: Sajaki/customisation-db
 /**
  * Approve post.
  */
 protected function approve_post()
 {
     $this->post->post_approved = 1;
     // Increment the user's postcount if we must
     if (!$this->post->post_deleted && in_array($this->post->post_type, titania::$config->increment_postcount)) {
         phpbb::update_user_postcount($this->post->post_user_id);
     }
     $this->post->submit();
     // Load z topic
     $this->load_topic_object();
     // Update topics posted table
     $this->post->topic->update_posted_status('add', $this->post->post_user_id);
     // Update first/last post?
     if ($this->post->topic->topic_first_post_time > $this->post->post_time) {
         $this->post->topic->sync_first_post();
     }
     if ($this->post->topic->topic_last_post_time < $this->post->post_time) {
         $this->post->topic->sync_last_post();
     }
     $this->post->topic->submit();
     // Notify poster of approval.
     $message_vars = array('U_VIEW_TOPIC' => $this->path_helper->strip_url_params($this->post->topic->get_url(), 'sid'), 'U_VIEW_POST' => $this->path_helper->strip_url_params($this->post->get_url(), 'sid'));
     $this->notify_poster('approved', $message_vars);
     // Subscriptions?
     if ($this->post->topic->topic_first_post_id != $this->post->post_id && $this->post->topic->topic_last_post_id == $this->post->post_id) {
         $u_view = $this->post->topic->get_url(false, array('view' => 'unread', '#' => 'unread'));
         $message_vars = array('U_VIEW' => $this->path_helper->strip_url_params($u_view, 'sid'));
         $object_type = array(TITANIA_TOPIC, TITANIA_SUPPORT);
         $object_id = array($this->post->topic_id, $this->post->topic->parent_id);
         $this->send_notifications($object_type, $object_id, 'subscribe_notify_contrib', $message_vars);
     }
 }