From 43d041bdecb5e564ad48efdf4702cad3714c7837 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 16 Oct 2012 14:20:23 +0200 Subject: [PATCH] [feature/soft-delete] Removed unused old functions PHPBB3-9567 --- phpBB/includes/content_visibility.php | 164 --------------------- phpBB/includes/mcp/mcp_queue.php | 200 -------------------------- 2 files changed, 364 deletions(-) diff --git a/phpBB/includes/content_visibility.php b/phpBB/includes/content_visibility.php index 8854981303..8bfdfd2917 100644 --- a/phpBB/includes/content_visibility.php +++ b/phpBB/includes/content_visibility.php @@ -550,168 +550,4 @@ class phpbb_content_visibility $db->sql_query($sql); } } - - /** - * One function to rule them all... and unhide posts and topics. This could - * reasonably be broken up, I straight copied this code from the mcp_queue.php - * file here for global access. - * @param $mode - string - member of the set {'approve', 'restore'} - * @param $post_info - array - Contains info from post U topics table about - * the posts/topics in question - * @param $post_id_list - array of ints - the set of posts being worked on - */ - static public function unhide_posts_topics($mode, $post_info, $post_id_list) - { - global $db, $config; - - // If Topic -> total_topics = total_topics+1, total_posts = total_posts+1, forum_topics = forum_topics+1, forum_posts = forum_posts+1 - // If Post -> total_posts = total_posts+1, forum_posts = forum_posts+1, topic_replies = topic_replies+1 - - $total_topics = $total_posts = 0; - $topic_approve_sql = $post_approve_sql = $topic_id_list = $forum_id_list = $approve_log = array(); - $user_posts_sql = $post_approved_list = array(); - - foreach ($post_info as $post_id => $post_data) - { - if ($post_data['post_visibility'] == ITEM_APPROVED) - { - $post_approved_list[] = $post_id; - continue; - } - - $topic_id_list[$post_data['topic_id']] = 1; - - if ($post_data['forum_id']) - { - $forum_id_list[$post_data['forum_id']] = 1; - } - - // User post update (we do not care about topic or post, since user topics are strictly connected to posts) - // But we care about forums where post counts get not increased. ;) - if ($post_data['post_postcount']) - { - $user_posts_sql[$post_data['poster_id']] = (empty($user_posts_sql[$post_data['poster_id']])) ? 1 : $user_posts_sql[$post_data['poster_id']] + 1; - } - - // Topic or Post. ;) - if ($post_data['topic_first_post_id'] == $post_id) - { - if ($post_data['forum_id']) - { - $total_topics++; - } - $topic_approve_sql[] = $post_data['topic_id']; - - $approve_log[] = array( - 'type' => 'topic', - 'post_subject' => $post_data['post_subject'], - 'forum_id' => $post_data['forum_id'], - 'topic_id' => $post_data['topic_id'], - ); - } - else - { - $approve_log[] = array( - 'type' => 'post', - 'post_subject' => $post_data['post_subject'], - 'forum_id' => $post_data['forum_id'], - 'topic_id' => $post_data['topic_id'], - ); - } - - if ($post_data['forum_id']) - { - $total_posts++; - - // Increment by topic_replies if we approve a topic... - // This works because we do not adjust the topic_replies when re-approving a topic after an edit. - if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_replies']) - { - $total_posts += $post_data['topic_replies']; - } - } - - $post_approve_sql[] = $post_id; - } - - $post_id_list = array_values(array_diff($post_id_list, $post_approved_list)); - for ($i = 0, $size = sizeof($post_approved_list); $i < $size; $i++) - { - unset($post_info[$post_approved_list[$i]]); - } - - if (sizeof($topic_approve_sql)) - { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_visibility = ' . ITEM_APPROVED . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_approve_sql); - $db->sql_query($sql); - } - - if (sizeof($post_approve_sql)) - { - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET post_visibility = ' . ITEM_APPROVED . ' - WHERE ' . $db->sql_in_set('post_id', $post_approve_sql); - $db->sql_query($sql); - } - - unset($topic_approve_sql, $post_approve_sql); - - foreach ($approve_log as $log_data) - { - add_log('mod', $log_data['forum_id'], $log_data['topic_id'], ($log_data['type'] == 'topic') ? 'LOG_TOPIC_' . strtoupper($mode) . 'D' : 'LOG_POST_' . strtoupper($mode) . 'D', $log_data['post_subject']); - } - - if (sizeof($user_posts_sql)) - { - // Try to minimize the query count by merging users with the same post count additions - $user_posts_update = array(); - - foreach ($user_posts_sql as $user_id => $user_posts) - { - $user_posts_update[$user_posts][] = $user_id; - } - - foreach ($user_posts_update as $user_posts => $user_id_ary) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_posts = user_posts + ' . $user_posts . ' - WHERE ' . $db->sql_in_set('user_id', $user_id_ary); - $db->sql_query($sql); - } - } - - if ($total_topics) - { - set_config_count('num_topics', $total_topics, true); - } - - if ($total_posts) - { - set_config_count('num_posts', $total_posts, true); - } - - if (!function_exists('sync')) - { - global $phpbb_root_path, $phpEx; - include ($phpbb_root_path . 'includes/functions_admin.'.$phpEx); - } - - sync('topic', 'topic_id', array_keys($topic_id_list), true); - sync('forum', 'forum_id', array_keys($forum_id_list), true, true); - unset($topic_id_list, $forum_id_list); - - if ($total_topics) - { - //@todo: plurals! - $success_msg = ($total_topics == 1) ? 'TOPIC_APPROVED_SUCCESS' : 'TOPICS_APPROVED_SUCCESS'; - } - else - { - $success_msg = (sizeof($post_id_list) + sizeof($post_approved_list) == 1) ? 'POST_APPROVED_SUCCESS' : 'POSTS_APPROVED_SUCCESS'; - } - - return $success_msg; - } } diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index f4a78525c8..5e7c53c8de 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -466,206 +466,6 @@ class mcp_queue } } - /** - * Restore Posts - * - * @param $post_id_list array IDs of the posts to restore - * @param $id mixed Category of the current active module - * @param $mode string Active module - * @return void - */ - function restore_posts($post_id_list, $id, $mode) - { - global $db, $template, $user, $config; - global $phpEx, $phpbb_root_path, $request; - - if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve'))) - { - trigger_error('NOT_AUTHORISED'); - } - - $redirect = request_var('redirect', build_url(array('quickmod'))); - $success_msg = ''; - - $s_hidden_fields = build_hidden_fields(array( - 'i' => $id, - 'mode' => $mode, - 'post_id_list' => $post_id_list, - 'action' => 'restore', - 'redirect' => $redirect, - )); - - $post_info = get_post_data($post_id_list, 'm_approve'); - - if (confirm_box(true)) - { - $topic_info = array(); - - // Group the posts by topic_id - foreach ($post_info as $post_id => $post_data) - { - if ($post_data['post_visibility'] == ITEM_APPROVED) - { - continue; - } - $topic_id = (int) $post_data['topic_id']; - - $topic_info[$topic_id]['posts'][] = (int) $post_id; - $topic_info[$topic_id]['forum_id'] = (int) $post_data['forum_id']; - - if ($post_id == $post_data['topic_first_post_id']) - { - $topic_info[$topic_id]['first_post'] = true; - } - - if ($post_id == $post_data['topic_last_post_id']) - { - $topic_info[$topic_id]['last_post'] = true; - } - - $post_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$post_data['forum_id']}&t={$post_data['topic_id']}&p={$post_data['post_id']}") . '#p' . $post_data['post_id']; - } - - foreach ($topic_info as $topic_id => $topic_data) - { - phpbb_content_visibility::set_post_visibility(ITEM_APPROVED, $topic_data['posts'], $topic_id, $topic_data['forum_id'], $user->data['user_id'], time(), '', isset($topic_data['first_post']), isset($topic_data['last_post'])); - } - - if (sizeof($post_info) >= 1) - { - $success_msg = (sizeof($post_info) == 1) ? 'POST_RESTORED_SUCCESS' : 'POSTS_RESTORED_SUCCESS'; - } - } - else - { - $template->assign_vars(array( - 'S_APPROVE' => true, - )); - - confirm_box(false, 'RESTORE_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html'); - } - - $redirect = request_var('redirect', "index.$phpEx"); - $redirect = reapply_sid($redirect); - - if (!$success_msg) - { - redirect($redirect); - } - else - { - // If restoring one post, also give links back to post... - $add_message = ''; - if (sizeof($post_id_list) == 1 && !empty($post_url)) - { - $add_message = '

' . sprintf($user->lang['RETURN_POST'], '', ''); - } - - $message = $user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_PAGE'], "", '') . $add_message; - - if ($request->is_ajax()) - { - $json_response = new phpbb_json_response; - $json_response->send(array( - 'MESSAGE_TITLE' => $user->lang['INFORMATION'], - 'MESSAGE_TEXT' => $message, - 'REFRESH_DATA' => null, - 'visible' => true, - )); - } - - meta_refresh(3, $redirect); - trigger_error($message); - } - } - - /** - * Restore topics - * - * @param $topic_id_list array IDs of the topics to restore - * @param $id mixed Category of the current active module - * @param $mode string Active module - * @return void - */ - function restore_topics($topic_id_list, $id, $mode) - { - global $db, $template, $user, $config; - global $phpEx, $phpbb_root_path, $request; - - if (!check_ids($topic_id_list, TOPICS_TABLE, 'topic_id', array('m_approve'))) - { - trigger_error('NOT_AUTHORISED'); - } - - $redirect = request_var('redirect', build_url(array('quickmod'))); - $success_msg = ''; - - $s_hidden_fields = build_hidden_fields(array( - 'i' => $id, - 'mode' => $mode, - 'topic_id_list' => $topic_id_list, - 'action' => 'restore', - 'redirect' => $redirect, - )); - - $topic_info = get_topic_data($topic_id_list, 'm_approve'); - - if (confirm_box(true)) - { - foreach ($topic_info as $topic_id => $topic_data) - { - phpbb_content_visibility::set_post_visibility(ITEM_APPROVED, $topic_id, $topic_data['forum_id'], $user->data['user_id'], time(), ''); - $topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$topic_data['forum_id']}&t={$topic_id}"); - } - - if (sizeof($topic_info) >= 1) - { - $success_msg = 'TOPIC' . ((sizeof($topic_info) == 1) ? '' : 'S') . '_RESTORED_SUCCESS'; - } - } - else - { - $template->assign_vars(array( - 'S_APPROVE' => true, - )); - - confirm_box(false, 'RESTORE_TOPIC' . ((sizeof($topic_info) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html'); - } - - $redirect = request_var('redirect', "index.$phpEx"); - $redirect = reapply_sid($redirect); - - if (!$success_msg) - { - redirect($redirect); - } - else - { - // If restoring one topic, also give links back to topic... - $add_message = ''; - if (sizeof($topic_info) == 1 && !empty($topic_url)) - { - $add_message = '

' . sprintf($user->lang['RETURN_TOPIC'], '', ''); - } - - $message = $user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_PAGE'], "", '') . $add_message; - - if ($request->is_ajax()) - { - $json_response = new phpbb_json_response; - $json_response->send(array( - 'MESSAGE_TITLE' => $user->lang['INFORMATION'], - 'MESSAGE_TEXT' => $message, - 'REFRESH_DATA' => null, - 'visible' => true, - )); - } - - meta_refresh(3, $redirect); - trigger_error($message); - } - } - /** * Approve/Restore posts *