From 009bd698fb46a529f09d9d9a63748e63eec62895 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 6 Oct 2012 03:59:49 +0200 Subject: [feature/soft-delete] Update and simplify the logic on delete_post() Todo: delete_topic case PHPBB3-9567 --- phpBB/includes/content_visibility.php | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'phpBB/includes/content_visibility.php') diff --git a/phpBB/includes/content_visibility.php b/phpBB/includes/content_visibility.php index 2b79868930..f8b632bbe8 100644 --- a/phpBB/includes/content_visibility.php +++ b/phpBB/includes/content_visibility.php @@ -359,28 +359,22 @@ class phpbb_content_visibility } /** - * Do the required math to hide a single post (going from approved to deleted) - * Notably, we do _not_ need the post ID to do this operation. We're only changing statistic caches - * @param $forum_id - int - the forum where the topic resides - * @param $current_time - int - passed for consistency instead of calling time() internally - * @param $data - array - contains information from the topics table about given topic - * @param $sql_data - array - populated with the SQL changes, may be empty at call time + * Remove post from topic and forum statistics + * + * @param $forum_id int Forum where the topic is found + * @param $data array Contains information from the topics table about given topic + * @param $sql_data array Populated with the SQL changes, may be empty at call time * @return void */ - //static public function remove_post_from_postcount($forum_id, $current_time, $data, &$sql_data) - static public function hide_post($forum_id, $current_time, $data, &$sql_data) + static public function remove_post_from_postcount($forum_id, $data, &$sql_data) { - $sql_data[TOPICS_TABLE] = 'topic_last_view_time = ' . $current_time; - if ($data['topic_replies'] > 0) - { - $sql_data[TOPICS_TABLE] .= ', topic_replies = topic_replies - 1,'; - } + $sql_data[TOPICS_TABLE] = ($sql_data[TOPICS_TABLE]) ? $sql_data[TOPICS_TABLE] . ', ' : '') . 'topic_replies = topic_replies - 1'; - $sql_data[FORUMS_TABLE] = 'forum_posts = forum_posts - 1'; + $sql_data[FORUMS_TABLE] = ($sql_data[FORUMS_TABLE]) ? $sql_data[FORUMS_TABLE] . ', ' : '') . 'forum_posts = forum_posts - 1'; if ($data['post_postcount']) { - $sql_data[USERS_TABLE] = 'user_posts = user_posts - 1'; + $sql_data[USERS_TABLE] = ($sql_data[USERS_TABLE]) ? $sql_data[USERS_TABLE] . ', ' : '') . 'user_posts = user_posts - 1'; } set_config_count('num_posts', -1, true); @@ -539,6 +533,7 @@ class phpbb_content_visibility if ($total_topics) { + //@todo: plurals! $success_msg = ($total_topics == 1) ? 'TOPIC_APPROVED_SUCCESS' : 'TOPICS_APPROVED_SUCCESS'; } else -- cgit v1.2.1