diff options
| author | Joas Schilling <nickvergessen@gmx.de> | 2012-10-06 03:59:49 +0200 |
|---|---|---|
| committer | Joas Schilling <nickvergessen@gmx.de> | 2012-10-06 03:59:49 +0200 |
| commit | 009bd698fb46a529f09d9d9a63748e63eec62895 (patch) | |
| tree | 10be1a621ecbf4d4ebbf9305d437aa5500472d40 /phpBB/includes/content_visibility.php | |
| parent | 3088855aa6c9bed9a15f3bd4ab1113d37be916a5 (diff) | |
| download | forums-009bd698fb46a529f09d9d9a63748e63eec62895.tar forums-009bd698fb46a529f09d9d9a63748e63eec62895.tar.gz forums-009bd698fb46a529f09d9d9a63748e63eec62895.tar.bz2 forums-009bd698fb46a529f09d9d9a63748e63eec62895.tar.xz forums-009bd698fb46a529f09d9d9a63748e63eec62895.zip | |
[feature/soft-delete] Update and simplify the logic on delete_post()
Todo: delete_topic case
PHPBB3-9567
Diffstat (limited to 'phpBB/includes/content_visibility.php')
| -rw-r--r-- | phpBB/includes/content_visibility.php | 25 |
1 files changed, 10 insertions, 15 deletions
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 |
