diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2010-03-11 16:03:14 +0100 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2011-04-07 13:47:06 +0200 |
commit | 27fdcb4c7ec4aac68ba0a809473312ee83b50a66 (patch) | |
tree | c1cfbdb38e56d49c9b18c97c8560dac8caea4799 /phpBB/includes/mcp | |
parent | 3352141264993982215b714ac7a128854494ac1f (diff) | |
download | forums-27fdcb4c7ec4aac68ba0a809473312ee83b50a66.tar forums-27fdcb4c7ec4aac68ba0a809473312ee83b50a66.tar.gz forums-27fdcb4c7ec4aac68ba0a809473312ee83b50a66.tar.bz2 forums-27fdcb4c7ec4aac68ba0a809473312ee83b50a66.tar.xz forums-27fdcb4c7ec4aac68ba0a809473312ee83b50a66.zip |
[ticket/9684] Remove code in some more files especially includes/
Topic-Tracking is still missing.
PHPBB3-9684
Diffstat (limited to 'phpBB/includes/mcp')
-rw-r--r-- | phpBB/includes/mcp/mcp_forum.php | 8 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_front.php | 39 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_main.php | 24 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_queue.php | 61 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_reports.php | 11 |
5 files changed, 40 insertions, 103 deletions
diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index aad030a7d3..8d2b90cba9 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -150,10 +150,10 @@ function mcp_forum_view($id, $mode, $action, $forum_info) $read_tracking_join = $read_tracking_select = ''; } - $sql = "SELECT t.topic_id - FROM " . TOPICS_TABLE . " t - WHERE t.forum_id IN($forum_id, 0) - " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1') . " + $sql = 'SELECT t.topic_id + FROM ' . TOPICS_TABLE . ' t + WHERE t.forum_id = ' . $forum_id . ' + ' . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1') . " $limit_time_sql ORDER BY t.topic_type DESC, $sort_order_sql"; $result = $db->sql_query_limit($sql, $topics_per_page, $start); diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php index 7375e20d96..eca67c5ac1 100644 --- a/phpBB/includes/mcp/mcp_front.php +++ b/phpBB/includes/mcp/mcp_front.php @@ -39,7 +39,7 @@ function mcp_front_view($id, $mode, $action) { $sql = 'SELECT COUNT(post_id) AS total FROM ' . POSTS_TABLE . ' - WHERE forum_id IN (0, ' . implode(', ', $forum_list) . ') + WHERE ' . $db->sql_in_set('forum_id', $forum_list) . ' AND post_approved = 0'; $result = $db->sql_query($sql); $total = (int) $db->sql_fetchfield('total'); @@ -47,8 +47,6 @@ function mcp_front_view($id, $mode, $action) if ($total) { - $global_id = $forum_list[0]; - $sql = 'SELECT forum_id, forum_name FROM ' . FORUMS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_list); @@ -62,7 +60,7 @@ function mcp_front_view($id, $mode, $action) $sql = 'SELECT post_id FROM ' . POSTS_TABLE . ' - WHERE forum_id IN (0, ' . implode(', ', $forum_list) . ') + WHERE ' . $db->sql_in_set('forum_id', $forum_list) . ' AND post_approved = 0 ORDER BY post_time DESC'; $result = $db->sql_query_limit($sql, 5); @@ -91,17 +89,11 @@ function mcp_front_view($id, $mode, $action) while ($row = $db->sql_fetchrow($result)) { - $global_topic = ($row['forum_id']) ? false : true; - if ($global_topic) - { - $row['forum_id'] = $global_id; - } - $template->assign_block_vars('unapproved', array( 'U_POST_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $row['forum_id'] . '&p=' . $row['post_id']), - 'U_MCP_FORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=forum_view&f=' . $row['forum_id']) : '', + 'U_MCP_FORUM' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=forum_view&f=' . $row['forum_id']), 'U_MCP_TOPIC' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=topic_view&f=' . $row['forum_id'] . '&t=' . $row['topic_id']), - 'U_FORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : '', + 'U_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']), 'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']), 'AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour']), @@ -109,7 +101,7 @@ function mcp_front_view($id, $mode, $action) 'AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour']), 'U_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour']), - 'FORUM_NAME' => (!$global_topic) ? $forum_names[$row['forum_id']] : $user->lang['GLOBAL_ANNOUNCEMENT'], + 'FORUM_NAME' => $forum_names[$row['forum_id']], 'POST_ID' => $row['post_id'], 'TOPIC_TITLE' => $row['topic_title'], 'SUBJECT' => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'], @@ -159,15 +151,13 @@ function mcp_front_view($id, $mode, $action) WHERE r.post_id = p.post_id AND r.pm_id = 0 AND r.report_closed = 0 - AND p.forum_id IN (0, ' . implode(', ', $forum_list) . ')'; + AND ' . $db->sql_in_set('p.forum_id', $forum_list); $result = $db->sql_query($sql); $total = (int) $db->sql_fetchfield('total'); $db->sql_freeresult($result); if ($total) { - $global_id = $forum_list[0]; - $sql = $db->sql_build_query('SELECT', array( 'SELECT' => 'r.report_time, p.post_id, p.post_subject, p.post_time, u.username, u.username_clean, u.user_colour, u.user_id, u2.username as author_name, u2.username_clean as author_name_clean, u2.user_colour as author_colour, u2.user_id as author_id, t.topic_id, t.topic_title, f.forum_id, f.forum_name', @@ -193,7 +183,7 @@ function mcp_front_view($id, $mode, $action) AND p.topic_id = t.topic_id AND r.user_id = u.user_id AND p.poster_id = u2.user_id - AND p.forum_id IN (0, ' . implode(', ', $forum_list) . ')', + AND ' . $db->sql_in_set('p.forum_id', $forum_list), 'ORDER_BY' => 'p.post_time DESC' )); @@ -201,17 +191,11 @@ function mcp_front_view($id, $mode, $action) while ($row = $db->sql_fetchrow($result)) { - $global_topic = ($row['forum_id']) ? false : true; - if ($global_topic) - { - $row['forum_id'] = $global_id; - } - $template->assign_block_vars('report', array( 'U_POST_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['post_id'] . "&i=reports&mode=report_details"), - 'U_MCP_FORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . "&i=$id&mode=forum_view") : '', + 'U_MCP_FORUM' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . "&i=$id&mode=forum_view"), 'U_MCP_TOPIC' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id'] . "&i=$id&mode=topic_view"), - 'U_FORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : '', + 'U_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']), 'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']), 'REPORTER_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), @@ -224,7 +208,7 @@ function mcp_front_view($id, $mode, $action) 'AUTHOR_COLOUR' => get_username_string('colour', $row['author_id'], $row['author_name'], $row['author_colour']), 'U_AUTHOR' => get_username_string('profile', $row['author_id'], $row['author_name'], $row['author_colour']), - 'FORUM_NAME' => (!$global_topic) ? $row['forum_name'] : $user->lang['GLOBAL_ANNOUNCEMENT'], + 'FORUM_NAME' => $row['forum_name'], 'TOPIC_TITLE' => $row['topic_title'], 'SUBJECT' => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 'REPORT_TIME' => $user->format_date($row['report_time']), @@ -347,9 +331,6 @@ function mcp_front_view($id, $mode, $action) if (!empty($forum_list)) { - // Add forum_id 0 for global announcements - $forum_list[] = 0; - $log_count = false; $log = array(); view_log('mod', $log, $log_count, 5, 0, $forum_list); diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index b9964f48a7..212c8dcdaf 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -485,16 +485,13 @@ function mcp_move_topic($topic_ids) $topic_posts_added += $topic_info['topic_replies']; - if ($topic_info['topic_type'] != POST_GLOBAL) - { - $topics_removed++; - $topic_posts_removed += $topic_info['topic_replies']; + $topics_removed++; + $topic_posts_removed += $topic_info['topic_replies']; - if ($topic_info['topic_approved']) - { - $topics_authed_removed++; - $topic_posts_removed++; - } + if ($topic_info['topic_approved']) + { + $topics_authed_removed++; + $topic_posts_removed++; } } @@ -532,15 +529,6 @@ function mcp_move_topic($topic_ids) $forum_ids[] = $row['forum_id']; add_log('mod', $to_forum_id, $topic_id, 'LOG_MOVE', $row['forum_name'], $forum_data['forum_name']); - // If we have moved a global announcement, we need to correct the topic type - if ($row['topic_type'] == POST_GLOBAL) - { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_type = ' . POST_ANNOUNCE . ' - WHERE topic_id = ' . (int) $row['topic_id']; - $db->sql_query($sql); - } - // Leave a redirection if required and only if the topic is visible to users if ($leave_shadow && $row['topic_approved'] && $row['topic_type'] != POST_GLOBAL) { diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index a5e0e426be..0630f55b12 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -268,13 +268,11 @@ class mcp_queue trigger_error('NOT_MODERATOR'); } - $global_id = $forum_list[0]; - $forum_list = implode(', ', $forum_list); $sql = 'SELECT SUM(forum_topics) as sum_forum_topics - FROM ' . FORUMS_TABLE . " - WHERE forum_id IN (0, $forum_list)"; + FROM ' . FORUMS_TABLE . ' + WHERE ' . $db->sql_in_set('forum_id', $forum_list); $result = $db->sql_query($sql); $forum_info['forum_topics'] = (int) $db->sql_fetchfield('sum_forum_topics'); $db->sql_freeresult($result); @@ -290,7 +288,6 @@ class mcp_queue $forum_info = $forum_info[$forum_id]; $forum_list = $forum_id; - $global_id = $forum_id; } $forum_options = '<option value="0"' . (($forum_id == 0) ? ' selected="selected"' : '') . '>' . $user->lang['ALL_FORUMS'] . '</option>'; @@ -312,10 +309,10 @@ class mcp_queue if ($mode == 'unapproved_posts') { $sql = 'SELECT p.post_id - FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . " - WHERE p.forum_id IN (0, $forum_list) + FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . ' + WHERE ' . $db->sql_in_set('p.forum_id', $forum_list) . ' AND p.post_approved = 0 - " . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . ' + ' . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . ' ' . (($topic_id) ? 'AND p.topic_id = ' . $topic_id : '') . " AND t.topic_id = p.topic_id AND t.topic_first_post_id <> p.post_id @@ -345,10 +342,7 @@ class mcp_queue $post_data = $rowset = array(); while ($row = $db->sql_fetchrow($result)) { - if ($row['forum_id']) - { - $forum_names[] = $row['forum_id']; - } + $forum_names[] = $row['forum_id']; $post_data[$row['post_id']] = $row; } $db->sql_freeresult($result); @@ -368,7 +362,7 @@ class mcp_queue { $sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, t.topic_title AS post_subject, t.topic_time AS post_time, t.topic_poster AS poster_id, t.topic_first_post_id AS post_id, t.topic_first_poster_name AS username, t.topic_first_poster_colour AS user_colour FROM ' . TOPICS_TABLE . " t - WHERE forum_id IN (0, $forum_list) + WHERE " . $db->sql_in_set('forum_id', $forum_list) . " AND topic_approved = 0 $limit_time_sql ORDER BY $sort_order_sql"; @@ -377,10 +371,7 @@ class mcp_queue $rowset = array(); while ($row = $db->sql_fetchrow($result)) { - if ($row['forum_id']) - { - $forum_names[] = $row['forum_id']; - } + $forum_names[] = $row['forum_id']; $rowset[] = $row; } $db->sql_freeresult($result); @@ -404,12 +395,6 @@ class mcp_queue foreach ($rowset as $row) { - $global_topic = ($row['forum_id']) ? false : true; - if ($global_topic) - { - $row['forum_id'] = $global_id; - } - if (empty($row['post_username'])) { $row['post_username'] = $user->lang['GUEST']; @@ -417,7 +402,7 @@ class mcp_queue $template->assign_block_vars('postrow', array( 'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']), - 'U_VIEWFORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : '', + 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']), 'U_VIEWPOST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['post_id']) . (($mode == 'unapproved_posts') ? '#p' . $row['post_id'] : ''), 'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&start=$start&mode=approve_details&f={$row['forum_id']}&p={$row['post_id']}" . (($mode == 'unapproved_topics') ? "&t={$row['topic_id']}" : '')), @@ -427,7 +412,7 @@ class mcp_queue 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_ID' => $row['post_id'], - 'FORUM_NAME' => (!$global_topic) ? $forum_names[$row['forum_id']] : $user->lang['GLOBAL_ANNOUNCEMENT'], + 'FORUM_NAME' => $forum_names[$row['forum_id']], 'POST_SUBJECT' => ($row['post_subject'] != '') ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 'TOPIC_TITLE' => $row['topic_title'], 'POST_TIME' => $user->format_date($row['post_time'])) @@ -504,11 +489,7 @@ function approve_post($post_id_list, $id, $mode) } $topic_id_list[$post_data['topic_id']] = 1; - - if ($post_data['forum_id']) - { - $forum_id_list[$post_data['forum_id']] = 1; - } + $forum_id_list[$post_data['forum_id']] = 1; // User post update (we do not care about topic or post, since user posts are strictly connected to posts) // But we care about forums where post counts get not increased. ;) @@ -520,10 +501,7 @@ function approve_post($post_id_list, $id, $mode) // Topic or Post. ;) if ($post_data['topic_first_post_id'] == $post_id) { - if ($post_data['forum_id']) - { - $total_topics++; - } + $total_topics++; $topic_approve_sql[] = $post_data['topic_id']; $approve_log[] = array( @@ -543,16 +521,13 @@ function approve_post($post_id_list, $id, $mode) ); } - if ($post_data['forum_id']) - { - $total_posts++; + $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']; - } + // 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; diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index f6e46b57ee..a7275382e6 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -312,7 +312,6 @@ class mcp_reports $forum_info = $forum_info[$forum_id]; $forum_list = array($forum_id); - $global_id = $forum_id; } $forum_list[] = 0; @@ -382,14 +381,8 @@ class mcp_reports $report_data = $rowset = array(); while ($row = $db->sql_fetchrow($result)) { - $global_topic = ($row['forum_id']) ? false : true; - if ($global_topic) - { - $row['forum_id'] = $global_id; - } - $template->assign_block_vars('postrow', array( - 'U_VIEWFORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : '', + 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']), 'U_VIEWPOST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['post_id']) . '#p' . $row['post_id'], 'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=reports&start=$start&mode=report_details&f={$row['forum_id']}&r={$row['report_id']}"), @@ -403,7 +396,7 @@ class mcp_reports 'REPORTER' => get_username_string('username', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'U_REPORTER' => get_username_string('profile', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), - 'FORUM_NAME' => (!$global_topic) ? $forum_data[$row['forum_id']]['forum_name'] : $user->lang['GLOBAL_ANNOUNCEMENT'], + 'FORUM_NAME' => $forum_data[$row['forum_id']]['forum_name'], 'POST_ID' => $row['post_id'], 'POST_SUBJECT' => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 'POST_TIME' => $user->format_date($row['post_time']), |