diff options
Diffstat (limited to 'phpBB/includes/mcp')
-rw-r--r-- | phpBB/includes/mcp/info/mcp_ban.php | 5 | ||||
-rw-r--r-- | phpBB/includes/mcp/info/mcp_logs.php | 5 | ||||
-rw-r--r-- | phpBB/includes/mcp/info/mcp_main.php | 5 | ||||
-rw-r--r-- | phpBB/includes/mcp/info/mcp_notes.php | 5 | ||||
-rw-r--r-- | phpBB/includes/mcp/info/mcp_pm_reports.php | 5 | ||||
-rw-r--r-- | phpBB/includes/mcp/info/mcp_queue.php | 7 | ||||
-rw-r--r-- | phpBB/includes/mcp/info/mcp_reports.php | 5 | ||||
-rw-r--r-- | phpBB/includes/mcp/info/mcp_warn.php | 5 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_ban.php | 5 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_forum.php | 65 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_front.php | 136 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_logs.php | 13 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_main.php | 695 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_notes.php | 17 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_pm_reports.php | 34 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_post.php | 63 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_queue.php | 1147 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_reports.php | 110 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_topic.php | 83 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_warn.php | 40 |
20 files changed, 1361 insertions, 1089 deletions
diff --git a/phpBB/includes/mcp/info/mcp_ban.php b/phpBB/includes/mcp/info/mcp_ban.php index 383df30498..a3a1e0ef9a 100644 --- a/phpBB/includes/mcp/info/mcp_ban.php +++ b/phpBB/includes/mcp/info/mcp_ban.php @@ -2,9 +2,8 @@ /** * * @package mcp -* @version $Id$ * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -35,5 +34,3 @@ class mcp_ban_info { } } - -?>
\ No newline at end of file diff --git a/phpBB/includes/mcp/info/mcp_logs.php b/phpBB/includes/mcp/info/mcp_logs.php index fe2f9fa1d7..fc30a600c0 100644 --- a/phpBB/includes/mcp/info/mcp_logs.php +++ b/phpBB/includes/mcp/info/mcp_logs.php @@ -2,9 +2,8 @@ /** * * @package mcp -* @version $Id$ * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -35,5 +34,3 @@ class mcp_logs_info { } } - -?>
\ No newline at end of file diff --git a/phpBB/includes/mcp/info/mcp_main.php b/phpBB/includes/mcp/info/mcp_main.php index 9755cdfc07..705715cbeb 100644 --- a/phpBB/includes/mcp/info/mcp_main.php +++ b/phpBB/includes/mcp/info/mcp_main.php @@ -2,9 +2,8 @@ /** * * @package mcp -* @version $Id$ * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -36,5 +35,3 @@ class mcp_main_info { } } - -?>
\ No newline at end of file diff --git a/phpBB/includes/mcp/info/mcp_notes.php b/phpBB/includes/mcp/info/mcp_notes.php index afe232e5b5..a77b461bbd 100644 --- a/phpBB/includes/mcp/info/mcp_notes.php +++ b/phpBB/includes/mcp/info/mcp_notes.php @@ -2,9 +2,8 @@ /** * * @package mcp -* @version $Id$ * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -34,5 +33,3 @@ class mcp_notes_info { } } - -?>
\ No newline at end of file diff --git a/phpBB/includes/mcp/info/mcp_pm_reports.php b/phpBB/includes/mcp/info/mcp_pm_reports.php index 103f560597..07dc564b19 100644 --- a/phpBB/includes/mcp/info/mcp_pm_reports.php +++ b/phpBB/includes/mcp/info/mcp_pm_reports.php @@ -2,9 +2,8 @@ /** * * @package mcp -* @version $Id$ * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -35,5 +34,3 @@ class mcp_pm_reports_info { } } - -?>
\ No newline at end of file diff --git a/phpBB/includes/mcp/info/mcp_queue.php b/phpBB/includes/mcp/info/mcp_queue.php index 7a256642b9..68cac5abd2 100644 --- a/phpBB/includes/mcp/info/mcp_queue.php +++ b/phpBB/includes/mcp/info/mcp_queue.php @@ -2,9 +2,8 @@ /** * * @package mcp -* @version $Id$ * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -22,6 +21,8 @@ class mcp_queue_info 'modes' => array( 'unapproved_topics' => array('title' => 'MCP_QUEUE_UNAPPROVED_TOPICS', 'auth' => 'aclf_m_approve', 'cat' => array('MCP_QUEUE')), 'unapproved_posts' => array('title' => 'MCP_QUEUE_UNAPPROVED_POSTS', 'auth' => 'aclf_m_approve', 'cat' => array('MCP_QUEUE')), + 'deleted_topics' => array('title' => 'MCP_QUEUE_DELETED_TOPICS', 'auth' => 'aclf_m_approve', 'cat' => array('MCP_QUEUE')), + 'deleted_posts' => array('title' => 'MCP_QUEUE_DELETED_POSTS', 'auth' => 'aclf_m_approve', 'cat' => array('MCP_QUEUE')), 'approve_details' => array('title' => 'MCP_QUEUE_APPROVE_DETAILS', 'auth' => 'acl_m_approve,$id || (!$id && aclf_m_approve)', 'cat' => array('MCP_QUEUE')), ), ); @@ -35,5 +36,3 @@ class mcp_queue_info { } } - -?>
\ No newline at end of file diff --git a/phpBB/includes/mcp/info/mcp_reports.php b/phpBB/includes/mcp/info/mcp_reports.php index 3893ba5abb..cb6962a1d5 100644 --- a/phpBB/includes/mcp/info/mcp_reports.php +++ b/phpBB/includes/mcp/info/mcp_reports.php @@ -2,9 +2,8 @@ /** * * @package mcp -* @version $Id$ * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -35,5 +34,3 @@ class mcp_reports_info { } } - -?>
\ No newline at end of file diff --git a/phpBB/includes/mcp/info/mcp_warn.php b/phpBB/includes/mcp/info/mcp_warn.php index 2b0b09f75a..d5ac1eedbf 100644 --- a/phpBB/includes/mcp/info/mcp_warn.php +++ b/phpBB/includes/mcp/info/mcp_warn.php @@ -2,9 +2,8 @@ /** * * @package mcp -* @version $Id$ * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -36,5 +35,3 @@ class mcp_warn_info { } } - -?>
\ No newline at end of file diff --git a/phpBB/includes/mcp/mcp_ban.php b/phpBB/includes/mcp/mcp_ban.php index d9f5eb8f22..d3bc336293 100644 --- a/phpBB/includes/mcp/mcp_ban.php +++ b/phpBB/includes/mcp/mcp_ban.php @@ -2,9 +2,8 @@ /** * * @package mcp -* @version $Id$ * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -215,5 +214,3 @@ class mcp_ban } } } - -?>
\ No newline at end of file diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index 04e0e70f1d..6df3320a97 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -2,9 +2,8 @@ /** * * @package mcp -* @version $Id$ * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -23,6 +22,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info) { global $template, $db, $user, $auth, $cache, $module; global $phpEx, $phpbb_root_path, $config; + global $request, $phpbb_dispatcher, $phpbb_container; $user->add_lang(array('viewtopic', 'viewforum')); @@ -34,7 +34,10 @@ function mcp_forum_view($id, $mode, $action, $forum_info) if ($merge_select) { // Fixes a "bug" that makes forum_view use the same ordering as topic_view - unset($_POST['sk'], $_POST['sd'], $_REQUEST['sk'], $_REQUEST['sd']); + $request->overwrite('sk', null); + $request->overwrite('sd', null); + $request->overwrite('sk', null, \phpbb\request\request_interface::POST); + $request->overwrite('sd', null, \phpbb\request\request_interface::POST); } $forum_id = $forum_info['forum_id']; @@ -95,9 +98,12 @@ function mcp_forum_view($id, $mode, $action, $forum_info) $sort_by_sql = $sort_order_sql = array(); mcp_sorting('viewforum', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id); - $forum_topics = ($total == -1) ? $forum_info['forum_topics'] : $total; + $forum_topics = ($total == -1) ? $forum_info['forum_topics_approved'] : $total; $limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : ''; + $base_url = $url . "&i=$id&action=$action&mode=$mode&sd=$sort_dir&sk=$sort_key&st=$sort_days" . (($merge_select) ? $selected_ids : ''); + phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $forum_topics, $topics_per_page, $start); + $template->assign_vars(array( 'ACTION' => $action, 'FORUM_NAME' => $forum_info['forum_name'], @@ -110,6 +116,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info) 'S_CAN_REPORT' => $auth->acl_get('m_report', $forum_id), 'S_CAN_DELETE' => $auth->acl_get('m_delete', $forum_id), + 'S_CAN_RESTORE' => $auth->acl_get('m_approve', $forum_id), 'S_CAN_MERGE' => $auth->acl_get('m_merge', $forum_id), 'S_CAN_MOVE' => $auth->acl_get('m_move', $forum_id), 'S_CAN_FORK' => $auth->acl_get('m_', $forum_id), @@ -126,9 +133,8 @@ function mcp_forum_view($id, $mode, $action, $forum_info) 'S_MCP_ACTION' => $url . "&i=$id&forum_action=$action&mode=$mode&start=$start" . (($merge_select) ? $selected_ids : ''), - 'PAGINATION' => generate_pagination($url . "&i=$id&action=$action&mode=$mode&sd=$sort_dir&sk=$sort_key&st=$sort_days" . (($merge_select) ? $selected_ids : ''), $forum_topics, $topics_per_page, $start), - 'PAGE_NUMBER' => on_page($forum_topics, $topics_per_page, $start), - 'TOTAL_TOPICS' => ($forum_topics == 1) ? $user->lang['VIEW_FORUM_TOPIC'] : sprintf($user->lang['VIEW_FORUM_TOPICS'], $forum_topics), + 'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $forum_topics, $topics_per_page, $start), + 'TOTAL_TOPICS' => $user->lang('VIEW_FORUM_TOPICS', (int) $forum_topics), )); // Grab icons @@ -146,10 +152,12 @@ 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') . " + $phpbb_content_visibility = $phpbb_container->get('content.visibility'); + + $sql = 'SELECT t.topic_id + FROM ' . TOPICS_TABLE . ' t + WHERE t.forum_id = ' . $forum_id . ' + AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.') . " $limit_time_sql ORDER BY t.topic_type DESC, $sort_order_sql"; $result = $db->sql_query_limit($sql, $topics_per_page, $start); @@ -184,11 +192,11 @@ function mcp_forum_view($id, $mode, $action, $forum_info) { if ($config['load_db_lastread']) { - $topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $topic_rows, array($forum_id => $forum_info['mark_time']), array()); + $topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $topic_rows, array($forum_id => $forum_info['mark_time'])); } else { - $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list, array()); + $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list); } } @@ -198,7 +206,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info) $row = &$topic_rows[$topic_id]; - $replies = ($auth->acl_get('m_approve', $forum_id)) ? $row['topic_replies_real'] : $row['topic_replies']; + $replies = $phpbb_content_visibility->get_count('topic_posts', $row, $forum_id) - 1; if ($row['topic_status'] == ITEM_MOVED) { @@ -215,18 +223,21 @@ function mcp_forum_view($id, $mode, $action, $forum_info) $topic_title = censor_text($row['topic_title']); - $topic_unapproved = (!$row['topic_approved'] && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false; - $posts_unapproved = ($row['topic_approved'] && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false; + $topic_unapproved = ($row['topic_visibility'] == ITEM_UNAPPROVED && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false; + $posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false; + $topic_deleted = $row['topic_visibility'] == ITEM_DELETED; $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? $url . '&i=queue&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . '&t=' . $row['topic_id'] : ''; + $u_mcp_queue = (!$u_mcp_queue && $topic_deleted) ? $url . '&i=queue&mode=deleted_topics&t=' . $topic_id : $u_mcp_queue; $topic_row = array( 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', + 'TOPIC_IMG_STYLE' => $folder_img, 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), - 'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'), 'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '', 'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '', 'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '', 'UNAPPROVED_IMG' => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '', + 'DELETED_IMG' => ($topic_deleted) ? $user->img('icon_topic_deleted', 'POSTS_DELETED') : '', 'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), @@ -240,7 +251,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info) 'TOPIC_TYPE' => $topic_type, 'TOPIC_TITLE' => $topic_title, - 'REPLIES' => ($auth->acl_get('m_approve', $row['forum_id'])) ? $row['topic_replies_real'] : $row['topic_replies'], + 'REPLIES' => $phpbb_content_visibility->get_count('topic_posts', $row, $row['forum_id']) - 1, 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']), 'FIRST_POST_TIME' => $user->format_date($row['topic_time']), 'LAST_POST_SUBJECT' => $row['topic_last_post_subject'], @@ -249,6 +260,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info) 'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && empty($row['topic_moved_id']) && $auth->acl_get('m_report', $row['forum_id'])) ? true : false, 'S_TOPIC_UNAPPROVED' => $topic_unapproved, 'S_POSTS_UNAPPROVED' => $posts_unapproved, + 'S_TOPIC_DELETED' => $topic_deleted, 'S_UNREAD_TOPIC' => $unread_topic, ); @@ -283,6 +295,17 @@ function mcp_forum_view($id, $mode, $action, $forum_info) )); } + /** + * Modify the topic data before it is assigned to the template in MCP + * + * @event core.mcp_view_forum_modify_topicrow + * @var array row Array with topic data + * @var array topic_row Template array with topic data + * @since 3.1-A1 + */ + $vars = array('row', 'topic_row'); + extract($phpbb_dispatcher->trigger_event('core.mcp_view_forum_modify_topicrow', compact($vars))); + $template->assign_block_vars('topicrow', $topic_row); } unset($topic_rows); @@ -433,7 +456,7 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id) confirm_box(false, 'MERGE_TOPICS', $s_hidden_fields); } - $redirect = request_var('redirect', "index.$phpEx"); + $redirect = request_var('redirect', "{$phpbb_root_path}viewtopic.$phpEx?f=$to_forum_id&t=$to_topic_id"); $redirect = reapply_sid($redirect); if (!$success_msg) @@ -442,9 +465,7 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id) } else { - meta_refresh(3, append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$to_forum_id&t=$to_topic_id")); + meta_refresh(3, $redirect); trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link); } } - -?>
\ No newline at end of file diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php index af262baa29..44cab5d910 100644 --- a/phpBB/includes/mcp/mcp_front.php +++ b/phpBB/includes/mcp/mcp_front.php @@ -2,9 +2,8 @@ /** * * @package mcp -* @version $Id$ * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -39,16 +38,14 @@ 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) . ') - AND post_approved = 0'; + WHERE ' . $db->sql_in_set('forum_id', $forum_list) . ' + AND post_visibility = ' . ITEM_UNAPPROVED; $result = $db->sql_query($sql); $total = (int) $db->sql_fetchfield('total'); $db->sql_freeresult($result); 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,8 +59,8 @@ function mcp_front_view($id, $mode, $action) $sql = 'SELECT post_id FROM ' . POSTS_TABLE . ' - WHERE forum_id IN (0, ' . implode(', ', $forum_list) . ') - AND post_approved = 0 + WHERE ' . $db->sql_in_set('forum_id', $forum_list) . ' + AND post_visibility = ' . ITEM_UNAPPROVED . ' ORDER BY post_time DESC'; $result = $db->sql_query_limit($sql, 5); @@ -81,7 +78,7 @@ function mcp_front_view($id, $mode, $action) if ($total) { - $sql = 'SELECT p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.username, u.username_clean, u.user_colour, t.topic_id, t.topic_title, t.topic_first_post_id, p.forum_id + $sql = 'SELECT p.post_id, p.post_subject, p.post_time, p.post_attachment, p.poster_id, p.post_username, u.username, u.username_clean, u.user_colour, t.topic_id, t.topic_title, t.topic_first_post_id, p.forum_id FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u WHERE ' . $db->sql_in_set('p.post_id', $post_list) . ' AND t.topic_id = p.topic_id @@ -91,17 +88,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,12 +100,13 @@ 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'], - 'POST_TIME' => $user->format_date($row['post_time'])) - ); + 'POST_TIME' => $user->format_date($row['post_time']), + 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['post_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', + )); } $db->sql_freeresult($result); } @@ -126,22 +118,9 @@ function mcp_front_view($id, $mode, $action) $template->assign_vars(array( 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_MCP_QUEUE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue"), + 'L_UNAPPROVED_TOTAL' => $user->lang('UNAPPROVED_POSTS_TOTAL', (int) $total), + 'S_HAS_UNAPPROVED_POSTS'=> ($total != 0), )); - - if ($total == 0) - { - $template->assign_vars(array( - 'L_UNAPPROVED_TOTAL' => $user->lang['UNAPPROVED_POSTS_ZERO_TOTAL'], - 'S_HAS_UNAPPROVED_POSTS' => false) - ); - } - else - { - $template->assign_vars(array( - 'L_UNAPPROVED_TOTAL' => ($total == 1) ? $user->lang['UNAPPROVED_POST_TOTAL'] : sprintf($user->lang['UNAPPROVED_POSTS_TOTAL'], $total), - 'S_HAS_UNAPPROVED_POSTS' => true) - ); - } } } @@ -159,31 +138,29 @@ 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', + $sql_ary = array( + 'SELECT' => 'r.report_time, p.post_id, p.post_subject, p.post_time, p.post_attachment, 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', 'FROM' => array( REPORTS_TABLE => 'r', REPORTS_REASONS_TABLE => 'rr', TOPICS_TABLE => 't', USERS_TABLE => array('u', 'u2'), - POSTS_TABLE => 'p' + POSTS_TABLE => 'p', ), 'LEFT_JOIN' => array( array( 'FROM' => array(FORUMS_TABLE => 'f'), - 'ON' => 'f.forum_id = p.forum_id' - ) + 'ON' => 'f.forum_id = p.forum_id', + ), ), 'WHERE' => 'r.post_id = p.post_id @@ -193,25 +170,20 @@ 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' - )); + 'ORDER_BY' => 'p.post_time DESC', + ); + $sql = $db->sql_build_query('SELECT', $sql_ary); $result = $db->sql_query_limit($sql, 5); 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,29 +196,20 @@ 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']), 'POST_TIME' => $user->format_date($row['post_time']), + 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['post_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', )); } } - if ($total == 0) - { - $template->assign_vars(array( - 'L_REPORTS_TOTAL' => $user->lang['REPORTS_ZERO_TOTAL'], - 'S_HAS_REPORTS' => false) - ); - } - else - { - $template->assign_vars(array( - 'L_REPORTS_TOTAL' => ($total == 1) ? $user->lang['REPORT_TOTAL'] : sprintf($user->lang['REPORTS_TOTAL'], $total), - 'S_HAS_REPORTS' => true) - ); - } + $template->assign_vars(array( + 'L_REPORTS_TOTAL' => $user->lang('REPORTS_TOTAL', (int) $total), + 'S_HAS_REPORTS' => ($total != 0), + )); } } @@ -269,14 +232,14 @@ function mcp_front_view($id, $mode, $action) { include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx); - $sql = $db->sql_build_query('SELECT', array( - 'SELECT' => 'r.report_id, r.report_time, p.msg_id, p.message_subject, p.message_time, p.to_address, p.bcc_address, 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', + $sql_ary = array( + 'SELECT' => 'r.report_id, r.report_time, p.msg_id, p.message_subject, p.message_time, p.to_address, p.bcc_address, p.message_attachment, 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', 'FROM' => array( REPORTS_TABLE => 'r', REPORTS_REASONS_TABLE => 'rr', USERS_TABLE => array('u', 'u2'), - PRIVMSGS_TABLE => 'p' + PRIVMSGS_TABLE => 'p', ), 'WHERE' => 'r.pm_id = p.msg_id @@ -286,8 +249,9 @@ function mcp_front_view($id, $mode, $action) AND r.user_id = u.user_id AND p.author_id = u2.user_id', - 'ORDER_BY' => 'p.message_time DESC' - )); + 'ORDER_BY' => 'p.message_time DESC', + ); + $sql = $db->sql_build_query('SELECT', $sql_ary); $result = $db->sql_query_limit($sql, 5); $pm_by_id = $pm_list = array(); @@ -320,24 +284,15 @@ function mcp_front_view($id, $mode, $action) 'REPORT_TIME' => $user->format_date($row['report_time']), 'PM_TIME' => $user->format_date($row['message_time']), 'RECIPIENTS' => implode(', ', $address_list[$row['msg_id']]), + 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $row['message_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', )); } } - if ($total == 0) - { - $template->assign_vars(array( - 'L_PM_REPORTS_TOTAL' => $user->lang['PM_REPORTS_ZERO_TOTAL'], - 'S_HAS_PM_REPORTS' => false) - ); - } - else - { - $template->assign_vars(array( - 'L_PM_REPORTS_TOTAL' => ($total == 1) ? $user->lang['PM_REPORT_TOTAL'] : sprintf($user->lang['PM_REPORTS_TOTAL'], $total), - 'S_HAS_PM_REPORTS' => true) - ); - } + $template->assign_vars(array( + 'L_PM_REPORTS_TOTAL' => $user->lang('PM_REPORTS_TOTAL', (int) $total), + 'S_HAS_PM_REPORTS' => ($total != 0), + )); } // Latest 5 logs @@ -347,9 +302,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); @@ -376,5 +328,3 @@ function mcp_front_view($id, $mode, $action) $template->assign_var('S_MCP_ACTION', append_sid("{$phpbb_root_path}mcp.$phpEx")); make_jumpbox(append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=forum_view'), 0, false, 'm_', true); } - -?>
\ No newline at end of file diff --git a/phpBB/includes/mcp/mcp_logs.php b/phpBB/includes/mcp/mcp_logs.php index 73ff72c177..f706840492 100644 --- a/phpBB/includes/mcp/mcp_logs.php +++ b/phpBB/includes/mcp/mcp_logs.php @@ -2,9 +2,8 @@ /** * * @package mcp -* @version $Id$ * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -172,10 +171,12 @@ class mcp_logs $log_count = 0; $start = view_log('mod', $log_data, $log_count, $config['topics_per_page'], $start, $forum_list, $topic_id, 0, $sql_where, $sql_sort, $keywords); + $base_url = $this->u_action . "&$u_sort_param$keywords_param"; + phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start); + $template->assign_vars(array( - 'PAGE_NUMBER' => on_page($log_count, $config['topics_per_page'], $start), - 'TOTAL' => ($log_count == 1) ? $user->lang['TOTAL_LOG'] : sprintf($user->lang['TOTAL_LOGS'], $log_count), - 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param$keywords_param", $log_count, $config['topics_per_page'], $start), + 'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $log_count, $config['topics_per_page'], $start), + 'TOTAL' => $user->lang('TOTAL_LOGS', (int) $log_count), 'L_TITLE' => $user->lang['MCP_LOGS'], @@ -214,5 +215,3 @@ class mcp_logs } } } - -?>
\ No newline at end of file diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index 0cef8933fc..4f27d32a5a 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -2,9 +2,8 @@ /** * * @package mcp -* @version $Id$ * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -34,7 +33,7 @@ class mcp_main function main($id, $mode) { global $auth, $db, $user, $template, $action; - global $config, $phpbb_root_path, $phpEx; + global $config, $phpbb_root_path, $phpEx, $request; $quickmod = ($mode == 'quickmod') ? true : false; @@ -109,27 +108,48 @@ class mcp_main case 'delete_topic': $user->add_lang('viewtopic'); - $topic_ids = (!$quickmod) ? request_var('topic_id_list', array(0)) : array(request_var('t', 0)); + // f parameter is not reliable for permission usage, however we just use it to decide + // which permission we will check later on. So if it is manipulated, we will still catch it later on. + $forum_id = $request->variable('f', 0); + $topic_ids = (!$quickmod) ? $request->variable('topic_id_list', array(0)) : array($request->variable('t', 0)); + $soft_delete = (($request->is_set_post('confirm') && !$request->is_set_post('delete_permanent')) || !$auth->acl_get('m_delete', $forum_id)) ? true : false; if (!sizeof($topic_ids)) { trigger_error('NO_TOPIC_SELECTED'); } - mcp_delete_topic($topic_ids); + mcp_delete_topic($topic_ids, $soft_delete, ($soft_delete) ? $request->variable('delete_reason', '', true) : ''); break; case 'delete_post': $user->add_lang('posting'); - $post_ids = (!$quickmod) ? request_var('post_id_list', array(0)) : array(request_var('p', 0)); + // f parameter is not reliable for permission usage, however we just use it to decide + // which permission we will check later on. So if it is manipulated, we will still catch it later on. + $forum_id = $request->variable('f', 0); + $post_ids = (!$quickmod) ? $request->variable('post_id_list', array(0)) : array($request->variable('p', 0)); + $soft_delete = (($request->is_set_post('confirm') && !$request->is_set_post('delete_permanent')) || !$auth->acl_get('m_delete', $forum_id)) ? true : false; if (!sizeof($post_ids)) { trigger_error('NO_POST_SELECTED'); } - mcp_delete_post($post_ids); + mcp_delete_post($post_ids, $soft_delete, ($soft_delete) ? $request->variable('delete_reason', '', true) : ''); + break; + + case 'restore_topic': + $user->add_lang('posting'); + + $topic_ids = (!$quickmod) ? $request->variable('topic_id_list', array(0)) : array($request->variable('t', 0)); + + if (!sizeof($topic_ids)) + { + trigger_error('NO_TOPIC_SELECTED'); + } + + mcp_restore_topic($topic_ids); break; } @@ -332,131 +352,22 @@ function change_topic_type($action, $topic_ids) if (confirm_box(true)) { - if ($new_topic_type != POST_GLOBAL) + $sql = 'UPDATE ' . TOPICS_TABLE . " + SET topic_type = $new_topic_type + WHERE " . $db->sql_in_set('topic_id', $topic_ids); + $db->sql_query($sql); + + if (($new_topic_type == POST_GLOBAL) && sizeof($topic_ids)) { + // Delete topic shadows for global announcements + $sql = 'DELETE FROM ' . TOPICS_TABLE . ' + WHERE ' . $db->sql_in_set('topic_moved_id', $topic_ids); + $db->sql_query($sql); + $sql = 'UPDATE ' . TOPICS_TABLE . " SET topic_type = $new_topic_type - WHERE " . $db->sql_in_set('topic_id', $topic_ids) . ' - AND forum_id <> 0'; + WHERE " . $db->sql_in_set('topic_id', $topic_ids); $db->sql_query($sql); - - // Reset forum id if a global topic is within the array - $to_forum_id = request_var('to_forum_id', 0); - - if ($to_forum_id) - { - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_type = $new_topic_type, forum_id = $to_forum_id - WHERE " . $db->sql_in_set('topic_id', $topic_ids) . ' - AND forum_id = 0'; - $db->sql_query($sql); - - // Update forum_ids for all posts - $sql = 'UPDATE ' . POSTS_TABLE . " - SET forum_id = $to_forum_id - WHERE " . $db->sql_in_set('topic_id', $topic_ids) . ' - AND forum_id = 0'; - $db->sql_query($sql); - - // Do a little forum sync stuff - $sql = 'SELECT SUM(t.topic_replies + t.topic_approved) as topic_posts, COUNT(t.topic_approved) as topics_authed - FROM ' . TOPICS_TABLE . ' t - WHERE ' . $db->sql_in_set('t.topic_id', $topic_ids); - $result = $db->sql_query($sql); - $row_data = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $sync_sql = array(); - - if ($row_data['topic_posts']) - { - $sync_sql[$to_forum_id][] = 'forum_posts = forum_posts + ' . (int) $row_data['topic_posts']; - } - - if ($row_data['topics_authed']) - { - $sync_sql[$to_forum_id][] = 'forum_topics = forum_topics + ' . (int) $row_data['topics_authed']; - } - - $sync_sql[$to_forum_id][] = 'forum_topics_real = forum_topics_real + ' . (int) sizeof($topic_ids); - - foreach ($sync_sql as $forum_id_key => $array) - { - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET ' . implode(', ', $array) . ' - WHERE forum_id = ' . $forum_id_key; - $db->sql_query($sql); - } - - sync('forum', 'forum_id', $to_forum_id); - } - } - else - { - // Get away with those topics already being a global announcement by re-calculating $topic_ids - $sql = 'SELECT topic_id - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . ' - AND forum_id <> 0'; - $result = $db->sql_query($sql); - - $topic_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $topic_ids[] = $row['topic_id']; - } - $db->sql_freeresult($result); - - if (sizeof($topic_ids)) - { - // Delete topic shadows for global announcements - $sql = 'DELETE FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_moved_id', $topic_ids); - $db->sql_query($sql); - - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_type = $new_topic_type, forum_id = 0 - WHERE " . $db->sql_in_set('topic_id', $topic_ids); - $db->sql_query($sql); - - // Update forum_ids for all posts - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET forum_id = 0 - WHERE ' . $db->sql_in_set('topic_id', $topic_ids); - $db->sql_query($sql); - - // Do a little forum sync stuff - $sql = 'SELECT SUM(t.topic_replies + t.topic_approved) as topic_posts, COUNT(t.topic_approved) as topics_authed - FROM ' . TOPICS_TABLE . ' t - WHERE ' . $db->sql_in_set('t.topic_id', $topic_ids); - $result = $db->sql_query($sql); - $row_data = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $sync_sql = array(); - - if ($row_data['topic_posts']) - { - $sync_sql[$forum_id][] = 'forum_posts = forum_posts - ' . (int) $row_data['topic_posts']; - } - - if ($row_data['topics_authed']) - { - $sync_sql[$forum_id][] = 'forum_topics = forum_topics - ' . (int) $row_data['topics_authed']; - } - - $sync_sql[$forum_id][] = 'forum_topics_real = forum_topics_real - ' . (int) sizeof($topic_ids); - - foreach ($sync_sql as $forum_id_key => $array) - { - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET ' . implode(', ', $array) . ' - WHERE forum_id = ' . $forum_id_key; - $db->sql_query($sql); - } - - sync('forum', 'forum_id', $forum_id); - } } $success_msg = (sizeof($topic_ids) == 1) ? 'TOPIC_TYPE_CHANGED' : 'TOPICS_TYPE_CHANGED'; @@ -473,41 +384,7 @@ function change_topic_type($action, $topic_ids) } else { - // Global topic involved? - $global_involved = false; - - if ($new_topic_type != POST_GLOBAL) - { - $sql = 'SELECT forum_id - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . ' - AND forum_id = 0'; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $global_involved = true; - } - } - - if ($global_involved) - { - global $template; - - $template->assign_vars(array( - 'S_FORUM_SELECT' => make_forum_select(request_var('f', $forum_id), false, false, true, true), - 'S_CAN_LEAVE_SHADOW' => false, - 'ADDITIONAL_MSG' => (sizeof($topic_ids) == 1) ? $user->lang['SELECT_FORUM_GLOBAL_ANNOUNCEMENT'] : $user->lang['SELECT_FORUM_GLOBAL_ANNOUNCEMENTS']) - ); - - confirm_box(false, $l_new_type, build_hidden_fields($s_hidden_fields), 'mcp_move.html'); - } - else - { - confirm_box(false, $l_new_type, build_hidden_fields($s_hidden_fields)); - } + confirm_box(false, $l_new_type, build_hidden_fields($s_hidden_fields)); } $redirect = request_var('redirect', "index.$phpEx"); @@ -531,6 +408,7 @@ function mcp_move_topic($topic_ids) { global $auth, $user, $db, $template; global $phpEx, $phpbb_root_path; + global $request; // Here we limit the operation to one forum only $forum_id = check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_move'), true); @@ -584,8 +462,8 @@ function mcp_move_topic($topic_ids) if (!$to_forum_id || $additional_msg) { - unset($_POST['confirm']); - unset($_REQUEST['confirm_key']); + $request->overwrite('confirm', null, \phpbb\request\request_interface::POST); + $request->overwrite('confirm_key', null); } if (confirm_box(true)) @@ -598,66 +476,43 @@ function mcp_move_topic($topic_ids) $forum_sync_data[$forum_id] = current($topic_data); $forum_sync_data[$to_forum_id] = $forum_data; - // Real topics added to target forum - $topics_moved = sizeof($topic_data); - - // Approved topics added to target forum - $topics_authed_moved = 0; - - // Posts (topic replies + topic post if approved) added to target forum - $topic_posts_added = 0; - - // Posts (topic replies + topic post if approved and not global announcement) removed from source forum - $topic_posts_removed = 0; - - // Real topics removed from source forum (all topics without global announcements) - $topics_removed = 0; - - // Approved topics removed from source forum (except global announcements) - $topics_authed_removed = 0; + $topics_moved = $topics_moved_unapproved = $topics_moved_softdeleted = 0; + $posts_moved = $posts_moved_unapproved = $posts_moved_softdeleted = 0; foreach ($topic_data as $topic_id => $topic_info) { - if ($topic_info['topic_approved']) + if ($topic_info['topic_visibility'] == ITEM_APPROVED) { - $topics_authed_moved++; - $topic_posts_added++; + $topics_moved++; } - - $topic_posts_added += $topic_info['topic_replies']; - - if ($topic_info['topic_type'] != POST_GLOBAL) + elseif ($topic_info['topic_visibility'] == ITEM_UNAPPROVED) { - $topics_removed++; - $topic_posts_removed += $topic_info['topic_replies']; - - if ($topic_info['topic_approved']) - { - $topics_authed_removed++; - $topic_posts_removed++; - } + $topics_moved_unapproved++; } + elseif ($topic_info['topic_visibility'] == ITEM_DELETED) + { + $topics_moved_softdeleted++; + } + + $posts_moved += $topic_info['topic_posts_approved']; + $posts_moved_unapproved += $topic_info['topic_posts_unapproved']; + $posts_moved_softdeleted += $topic_info['topic_posts_softdeleted']; } $db->sql_transaction('begin'); - $sync_sql = array(); - - if ($topic_posts_added) - { - $sync_sql[$to_forum_id][] = 'forum_posts = forum_posts + ' . $topic_posts_added; - } + // Move topics, but do not resync yet + move_topics($topic_ids, $to_forum_id, false); - if ($topics_authed_moved) + if ($request->is_set_post('move_lock_topics') && $auth->acl_get('m_lock', $to_forum_id)) { - $sync_sql[$to_forum_id][] = 'forum_topics = forum_topics + ' . (int) $topics_authed_moved; + $sql = 'UPDATE ' . TOPICS_TABLE . ' + SET topic_status = ' . ITEM_LOCKED . ' + WHERE ' . $db->sql_in_set('topic_id', $topic_ids); + $db->sql_query($sql); } - $sync_sql[$to_forum_id][] = 'forum_topics_real = forum_topics_real + ' . (int) $topics_moved; - - // Move topics, but do not resync yet - move_topics($topic_ids, $to_forum_id, false); - + $shadow_topics = 0; $forum_ids = array($to_forum_id); foreach ($topic_data as $topic_id => $row) { @@ -665,31 +520,23 @@ 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) + if ($leave_shadow && $row['topic_visibility'] == ITEM_APPROVED && $row['topic_type'] != POST_GLOBAL) { $shadow = array( 'forum_id' => (int) $row['forum_id'], 'icon_id' => (int) $row['icon_id'], 'topic_attachment' => (int) $row['topic_attachment'], - 'topic_approved' => 1, // a shadow topic is always approved + 'topic_visibility' => ITEM_APPROVED, // a shadow topic is always approved 'topic_reported' => 0, // a shadow topic is never reported 'topic_title' => (string) $row['topic_title'], 'topic_poster' => (int) $row['topic_poster'], 'topic_time' => (int) $row['topic_time'], 'topic_time_limit' => (int) $row['topic_time_limit'], 'topic_views' => (int) $row['topic_views'], - 'topic_replies' => (int) $row['topic_replies'], - 'topic_replies_real' => (int) $row['topic_replies_real'], + 'topic_posts_approved' => (int) $row['topic_posts_approved'], + 'topic_posts_unapproved'=> (int) $row['topic_posts_unapproved'], + 'topic_posts_softdeleted'=> (int) $row['topic_posts_softdeleted'], 'topic_status' => ITEM_MOVED, 'topic_type' => POST_NORMAL, 'topic_first_post_id' => (int) $row['topic_first_post_id'], @@ -715,25 +562,45 @@ function mcp_move_topic($topic_ids) $db->sql_query('INSERT INTO ' . TOPICS_TABLE . $db->sql_build_array('INSERT', $shadow)); // Shadow topics only count on new "topics" and not posts... a shadow topic alone has 0 posts - $topics_removed--; - $topics_authed_removed--; + $shadow_topics++; } } unset($topic_data); - if ($topic_posts_removed) + $sync_sql = array(); + if ($posts_moved) { - $sync_sql[$forum_id][] = 'forum_posts = forum_posts - ' . $topic_posts_removed; + $sync_sql[$to_forum_id][] = 'forum_posts_approved = forum_posts_approved + ' . (int) $posts_moved; + $sync_sql[$forum_id][] = 'forum_posts_approved = forum_posts_approved - ' . (int) $posts_moved; } - - if ($topics_removed) + if ($posts_moved_unapproved) + { + $sync_sql[$to_forum_id][] = 'forum_posts_unapproved = forum_posts_unapproved + ' . (int) $posts_moved_unapproved; + $sync_sql[$forum_id][] = 'forum_posts_unapproved = forum_posts_unapproved - ' . (int) $posts_moved_unapproved; + } + if ($posts_moved_softdeleted) { - $sync_sql[$forum_id][] = 'forum_topics_real = forum_topics_real - ' . (int) $topics_removed; + $sync_sql[$to_forum_id][] = 'forum_posts_softdeleted = forum_posts_softdeleted + ' . (int) $posts_moved_softdeleted; + $sync_sql[$forum_id][] = 'forum_posts_softdeleted = forum_posts_softdeleted - ' . (int) $posts_moved_softdeleted; } - if ($topics_authed_removed) + if ($topics_moved) + { + $sync_sql[$to_forum_id][] = 'forum_topics_approved = forum_topics_approved + ' . (int) $topics_moved; + if ($topics_moved - $shadow_topics > 0) + { + $sync_sql[$forum_id][] = 'forum_topics_approved = forum_topics_approved - ' . (int) ($topics_moved - $shadow_topics); + } + } + if ($topics_moved_unapproved) + { + $sync_sql[$to_forum_id][] = 'forum_topics_unapproved = forum_topics_unapproved + ' . (int) $topics_moved_unapproved; + $sync_sql[$forum_id][] = 'forum_topics_unapproved = forum_topics_unapproved - ' . (int) $topics_moved_unapproved; + } + if ($topics_moved_softdeleted) { - $sync_sql[$forum_id][] = 'forum_topics = forum_topics - ' . (int) $topics_authed_removed; + $sync_sql[$to_forum_id][] = 'forum_topics_softdeleted = forum_topics_softdeleted + ' . (int) $topics_moved_softdeleted; + $sync_sql[$forum_id][] = 'forum_topics_softdeleted = forum_topics_softdeleted - ' . (int) $topics_moved_softdeleted; } $success_msg = (sizeof($topic_ids) == 1) ? 'TOPIC_MOVED_SUCCESS' : 'TOPICS_MOVED_SUCCESS'; @@ -755,6 +622,7 @@ function mcp_move_topic($topic_ids) $template->assign_vars(array( 'S_FORUM_SELECT' => make_forum_select($to_forum_id, $forum_id, false, true, true, true), 'S_CAN_LEAVE_SHADOW' => true, + 'S_CAN_LOCK_TOPIC' => ($auth->acl_get('m_lock', $to_forum_id)) ? true : false, 'ADDITIONAL_MSG' => $additional_msg) ); @@ -782,25 +650,98 @@ function mcp_move_topic($topic_ids) } /** +* Restore Topics +*/ +function mcp_restore_topic($topic_ids) +{ + global $auth, $user, $db, $phpEx, $phpbb_root_path, $request, $phpbb_container; + + if (!check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_approve'))) + { + return; + } + + $redirect = $request->variable('redirect', build_url(array('action', 'quickmod'))); + $forum_id = $request->variable('f', 0); + + $s_hidden_fields = build_hidden_fields(array( + 'topic_id_list' => $topic_ids, + 'f' => $forum_id, + 'action' => 'restore_topic', + 'redirect' => $redirect, + )); + $success_msg = ''; + + if (confirm_box(true)) + { + $success_msg = (sizeof($topic_ids) == 1) ? 'TOPIC_RESTORED_SUCCESS' : 'TOPICS_RESTORED_SUCCESS'; + + $data = get_topic_data($topic_ids); + + $phpbb_content_visibility = $phpbb_container->get('content.visibility'); + foreach ($data as $topic_id => $row) + { + $return = $phpbb_content_visibility->set_topic_visibility(ITEM_APPROVED, $topic_id, $row['forum_id'], $user->data['user_id'], time(), ''); + if (!empty($return)) + { + add_log('mod', $row['forum_id'], $topic_id, 'LOG_RESTORE_TOPIC', $row['topic_title'], $row['topic_first_poster_name']); + } + } + } + else + { + confirm_box(false, (sizeof($topic_ids) == 1) ? 'RESTORE_TOPIC' : 'RESTORE_TOPICS', $s_hidden_fields); + } + + $topic_id = $request->variable('t', 0); + if (!$request->is_set('quickmod', \phpbb\request\request_interface::REQUEST)) + { + $redirect = $request->variable('redirect', "index.$phpEx"); + $redirect = reapply_sid($redirect); + $redirect_message = 'PAGE'; + } + else if ($topic_id) + { + $redirect = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $topic_id); + $redirect_message = 'TOPIC'; + } + else + { + $redirect = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id); + $redirect_message = 'FORUM'; + } + + if (!$success_msg) + { + redirect($redirect); + } + else + { + meta_refresh(3, $redirect); + trigger_error($user->lang[$success_msg] . '<br /><br />' . sprintf($user->lang['RETURN_' . $redirect_message], '<a href="' . $redirect . '">', '</a>')); + } +} + +/** * Delete Topics */ -function mcp_delete_topic($topic_ids) +function mcp_delete_topic($topic_ids, $is_soft = false, $soft_delete_reason = '', $action = 'delete_topic') { - global $auth, $user, $db, $phpEx, $phpbb_root_path; + global $auth, $user, $db, $phpEx, $phpbb_root_path, $request, $phpbb_container; if (!check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_delete'))) { return; } - $redirect = request_var('redirect', build_url(array('action', 'quickmod'))); - $forum_id = request_var('f', 0); + $redirect = $request->variable('redirect', build_url(array('action', 'quickmod'))); + $forum_id = $request->variable('f', 0); - $s_hidden_fields = build_hidden_fields(array( + $s_hidden_fields = array( 'topic_id_list' => $topic_ids, 'f' => $forum_id, - 'action' => 'delete_topic', - 'redirect' => $redirect) + 'action' => $action, + 'redirect' => $redirect, ); $success_msg = ''; @@ -818,23 +759,81 @@ function mcp_delete_topic($topic_ids) } else { - add_log('mod', $row['forum_id'], $topic_id, 'LOG_DELETE_TOPIC', $row['topic_title'], $row['topic_first_poster_name']); + // Only soft delete non-shadow topics + if ($is_soft) + { + $phpbb_content_visibility = $phpbb_container->get('content.visibility'); + $return = $phpbb_content_visibility->set_topic_visibility(ITEM_DELETED, $topic_id, $row['forum_id'], $user->data['user_id'], time(), $soft_delete_reason); + if (!empty($return)) + { + add_log('mod', $row['forum_id'], $topic_id, 'LOG_SOFTDELETE_TOPIC', $row['topic_title'], $row['topic_first_poster_name']); + } + } + else + { + add_log('mod', $row['forum_id'], $topic_id, 'LOG_DELETE_TOPIC', $row['topic_title'], $row['topic_first_poster_name']); + } } } - $return = delete_topics('topic_id', $topic_ids); + if (!$is_soft) + { + $return = delete_topics('topic_id', $topic_ids); + } } else { - confirm_box(false, (sizeof($topic_ids) == 1) ? 'DELETE_TOPIC' : 'DELETE_TOPICS', $s_hidden_fields); + global $template; + + $user->add_lang('posting'); + + $only_softdeleted = false; + if ($auth->acl_get('m_delete', $forum_id) && $auth->acl_get('m_softdelete', $forum_id)) + { + // If there are only soft deleted topics, we display a message why the option is not available + $sql = 'SELECT topic_id + FROM ' . TOPICS_TABLE . ' + WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . ' + AND topic_visibility <> ' . ITEM_DELETED; + $result = $db->sql_query_limit($sql, 1); + $only_softdeleted = !$db->sql_fetchfield('topic_id'); + $db->sql_freeresult($result); + } + + $template->assign_vars(array( + 'S_SOFTDELETED' => $only_softdeleted, + 'S_TOPIC_MODE' => true, + 'S_ALLOWED_DELETE' => $auth->acl_get('m_delete', $forum_id), + 'S_ALLOWED_SOFTDELETE' => $auth->acl_get('m_softdelete', $forum_id), + 'S_DELETE_REASON' => $auth->acl_get('m_softdelete', $forum_id), + )); + + $l_confirm = (sizeof($topic_ids) == 1) ? 'DELETE_TOPIC' : 'DELETE_TOPICS'; + if ($only_softdeleted) + { + $l_confirm .= '_PERMANENTLY'; + $s_hidden_fields['delete_permanent'] = '1'; + } + else if (!$auth->acl_get('m_softdelete', $forum_id)) + { + $s_hidden_fields['delete_permanent'] = '1'; + } + + confirm_box(false, $l_confirm, build_hidden_fields($s_hidden_fields), 'confirm_delete_body.html'); } - if (!isset($_REQUEST['quickmod'])) + $topic_id = $request->variable('t', 0); + if (!$request->is_set('quickmod', \phpbb\request\request_interface::REQUEST)) { - $redirect = request_var('redirect', "index.$phpEx"); + $redirect = $request->variable('redirect', "index.$phpEx"); $redirect = reapply_sid($redirect); $redirect_message = 'PAGE'; } + else if ($is_soft && $topic_id) + { + $redirect = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $topic_id); + $redirect_message = 'TOPIC'; + } else { $redirect = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id); @@ -855,27 +854,93 @@ function mcp_delete_topic($topic_ids) /** * Delete Posts */ -function mcp_delete_post($post_ids) +function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '', $action = 'delete_post') { - global $auth, $user, $db, $phpEx, $phpbb_root_path; + global $auth, $user, $db, $phpEx, $phpbb_root_path, $request, $phpbb_container; - if (!check_ids($post_ids, POSTS_TABLE, 'post_id', array('m_delete'))) + if (!check_ids($post_ids, POSTS_TABLE, 'post_id', array('m_softdelete'))) { return; } - $redirect = request_var('redirect', build_url(array('action', 'quickmod'))); - $forum_id = request_var('f', 0); + $redirect = $request->variable('redirect', build_url(array('action', 'quickmod'))); + $forum_id = $request->variable('f', 0); - $s_hidden_fields = build_hidden_fields(array( + $s_hidden_fields = array( 'post_id_list' => $post_ids, 'f' => $forum_id, - 'action' => 'delete_post', - 'redirect' => $redirect) + 'action' => $action, + 'redirect' => $redirect, ); $success_msg = ''; - if (confirm_box(true)) + if (confirm_box(true) && $is_soft) + { + $post_info = get_post_data($post_ids); + + $topic_info = $approve_log = 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; + } + + $approve_log[] = array( + 'forum_id' => $post_data['forum_id'], + 'topic_id' => $post_data['topic_id'], + 'post_subject' => $post_data['post_subject'], + 'poster_id' => $post_data['poster_id'], + 'post_username' => $post_data['post_username'], + 'username' => $post_data['username'], + ); + } + + $phpbb_content_visibility = $phpbb_container->get('content.visibility'); + foreach ($topic_info as $topic_id => $topic_data) + { + $phpbb_content_visibility->set_post_visibility(ITEM_DELETED, $topic_data['posts'], $topic_id, $topic_data['forum_id'], $user->data['user_id'], time(), $soft_delete_reason, isset($topic_data['first_post']), isset($topic_data['last_post'])); + } + $affected_topics = sizeof($topic_info); + // None of the topics is really deleted, so a redirect won't hurt much. + $deleted_topics = 0; + + $success_msg = (sizeof($post_info) == 1) ? 'POST_DELETED_SUCCESS' : 'POSTS_DELETED_SUCCESS'; + + foreach ($approve_log as $row) + { + $post_username = ($row['poster_id'] == ANONYMOUS && !empty($row['post_username'])) ? $row['post_username'] : $row['username']; + add_log('mod', $row['forum_id'], $row['topic_id'], 'LOG_SOFTDELETE_POST', $row['post_subject'], $post_username); + } + + $topic_id = $request->variable('t', 0); + + // Return links + $return_link = array(); + if ($affected_topics == 1 && $topic_id) + { + $return_link[] = sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id") . '">', '</a>'); + } + $return_link[] = sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id) . '">', '</a>'); + + } + else if (confirm_box(true)) { if (!function_exists('delete_posts')) { @@ -918,7 +983,7 @@ function mcp_delete_post($post_ids) $deleted_topics = ($row = $db->sql_fetchrow($result)) ? ($affected_topics - $row['topics_left']) : $affected_topics; $db->sql_freeresult($result); - $topic_id = request_var('t', 0); + $topic_id = $request->variable('t', 0); // Return links $return_link = array(); @@ -956,10 +1021,45 @@ function mcp_delete_post($post_ids) } else { - confirm_box(false, (sizeof($post_ids) == 1) ? 'DELETE_POST' : 'DELETE_POSTS', $s_hidden_fields); + global $template; + + $user->add_lang('posting'); + + $only_softdeleted = false; + if ($auth->acl_get('m_delete', $forum_id) && $auth->acl_get('m_softdelete', $forum_id)) + { + // If there are only soft deleted posts, we display a message why the option is not available + $sql = 'SELECT post_id + FROM ' . POSTS_TABLE . ' + WHERE ' . $db->sql_in_set('post_id', $post_ids) . ' + AND post_visibility <> ' . ITEM_DELETED; + $result = $db->sql_query_limit($sql, 1); + $only_softdeleted = !$db->sql_fetchfield('post_id'); + $db->sql_freeresult($result); + } + + $template->assign_vars(array( + 'S_SOFTDELETED' => $only_softdeleted, + 'S_ALLOWED_DELETE' => $auth->acl_get('m_delete', $forum_id), + 'S_ALLOWED_SOFTDELETE' => $auth->acl_get('m_softdelete', $forum_id), + 'S_DELETE_REASON' => $auth->acl_get('m_softdelete', $forum_id), + )); + + $l_confirm = (sizeof($post_ids) == 1) ? 'DELETE_POST' : 'DELETE_POSTS'; + if ($only_softdeleted) + { + $l_confirm .= '_PERMANENTLY'; + $s_hidden_fields['delete_permanent'] = '1'; + } + else if (!$auth->acl_get('m_softdelete', $forum_id)) + { + $s_hidden_fields['delete_permanent'] = '1'; + } + + confirm_box(false, $l_confirm, build_hidden_fields($s_hidden_fields), 'confirm_delete_body.html'); } - $redirect = request_var('redirect', "index.$phpEx"); + $redirect = $request->variable('redirect', "index.$phpEx"); $redirect = reapply_sid($redirect); if (!$success_msg) @@ -1036,37 +1136,32 @@ function mcp_fork_topic($topic_ids) if ($additional_msg) { - unset($_POST['confirm']); - unset($_REQUEST['confirm_key']); + $request->overwrite('confirm', null, \phpbb\request\request_interface::POST); + $request->overwrite('confirm_key', null); } if (confirm_box(true)) { $topic_data = get_topic_data($topic_ids, 'f_post'); - $total_posts = 0; + $total_topics = $total_topics_unapproved = $total_topics_softdeleted = 0; + $total_posts = $total_posts_unapproved = $total_posts_softdeleted = 0; $new_topic_id_list = array(); - foreach ($topic_data as $topic_id => $topic_row) { if (!isset($search_type) && $topic_row['enable_indexing']) { // Select the search method and do some additional checks to ensure it can actually be utilised - $search_type = basename($config['search_type']); - - if (!file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx)) - { - trigger_error('NO_SUCH_SEARCH_MODULE'); - } + $search_type = $config['search_type']; if (!class_exists($search_type)) { - include("{$phpbb_root_path}includes/search/$search_type.$phpEx"); + trigger_error('NO_SUCH_SEARCH_MODULE'); } $error = false; - $search = new $search_type($error); + $search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user); $search_mode = 'post'; if ($error) @@ -1083,13 +1178,14 @@ function mcp_fork_topic($topic_ids) 'forum_id' => (int) $to_forum_id, 'icon_id' => (int) $topic_row['icon_id'], 'topic_attachment' => (int) $topic_row['topic_attachment'], - 'topic_approved' => 1, + 'topic_visibility' => (int) $topic_row['topic_visibility'], 'topic_reported' => 0, 'topic_title' => (string) $topic_row['topic_title'], 'topic_poster' => (int) $topic_row['topic_poster'], 'topic_time' => (int) $topic_row['topic_time'], - 'topic_replies' => (int) $topic_row['topic_replies_real'], - 'topic_replies_real' => (int) $topic_row['topic_replies_real'], + 'topic_posts_approved' => (int) $topic_row['topic_posts_approved'], + 'topic_posts_unapproved' => (int) $topic_row['topic_posts_unapproved'], + 'topic_posts_softdeleted' => (int) $topic_row['topic_posts_softdeleted'], 'topic_status' => (int) $topic_row['topic_status'], 'topic_type' => (int) $topic_row['topic_type'], 'topic_first_poster_name' => (string) $topic_row['topic_first_poster_name'], @@ -1110,6 +1206,19 @@ function mcp_fork_topic($topic_ids) $new_topic_id = $db->sql_nextid(); $new_topic_id_list[$topic_id] = $new_topic_id; + switch ($topic_row['topic_visibility']) + { + case ITEM_APPROVED: + $total_topics++; + break; + case ITEM_UNAPPROVED: + $total_topics_unapproved++; + break; + case ITEM_DELETED: + $total_topics_softdeleted++; + break; + } + if ($topic_row['poll_start']) { $poll_rows = array(); @@ -1150,7 +1259,6 @@ function mcp_fork_topic($topic_ids) continue; } - $total_posts += sizeof($post_rows); foreach ($post_rows as $row) { $sql_ary = array( @@ -1160,7 +1268,7 @@ function mcp_fork_topic($topic_ids) 'icon_id' => (int) $row['icon_id'], 'poster_ip' => (string) $row['poster_ip'], 'post_time' => (int) $row['post_time'], - 'post_approved' => 1, + 'post_visibility' => (int) $row['post_visibility'], 'post_reported' => 0, 'enable_bbcode' => (int) $row['enable_bbcode'], 'enable_smilies' => (int) $row['enable_smilies'], @@ -1184,6 +1292,19 @@ function mcp_fork_topic($topic_ids) $db->sql_query('INSERT INTO ' . POSTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); $new_post_id = $db->sql_nextid(); + switch ($row['post_visibility']) + { + case ITEM_APPROVED: + $total_posts++; + break; + case ITEM_UNAPPROVED: + $total_posts_unapproved++; + break; + case ITEM_DELETED: + $total_posts_softdeleted++; + break; + } + // Copy whether the topic is dotted markread('post', $to_forum_id, $new_topic_id, 0, $row['poster_id']); @@ -1276,23 +1397,19 @@ function mcp_fork_topic($topic_ids) } // Sync new topics, parent forums and board stats - sync('topic', 'topic_id', $new_topic_id_list); - - $sync_sql = array(); - - $sync_sql[$to_forum_id][] = 'forum_posts = forum_posts + ' . $total_posts; - $sync_sql[$to_forum_id][] = 'forum_topics = forum_topics + ' . sizeof($new_topic_id_list); - $sync_sql[$to_forum_id][] = 'forum_topics_real = forum_topics_real + ' . sizeof($new_topic_id_list); - - foreach ($sync_sql as $forum_id_key => $array) - { - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET ' . implode(', ', $array) . ' - WHERE forum_id = ' . $forum_id_key; - $db->sql_query($sql); - } + $sql = 'UPDATE ' . FORUMS_TABLE . ' + SET forum_posts_approved = forum_posts_approved + ' . $total_posts . ', + forum_posts_unapproved = forum_posts_unapproved + ' . $total_posts_unapproved . ', + forum_posts_softdeleted = forum_posts_softdeleted + ' . $total_posts_softdeleted . ', + forum_topics_approved = forum_topics_approved + ' . $total_topics . ', + forum_topics_unapproved = forum_topics_unapproved + ' . $total_topics_unapproved . ', + forum_topics_softdeleted = forum_topics_softdeleted + ' . $total_topics_softdeleted . ' + WHERE forum_id = ' . $to_forum_id; + $db->sql_query($sql); + sync('topic', 'topic_id', $new_topic_id_list); sync('forum', 'forum_id', $to_forum_id); + set_config_count('num_topics', sizeof($new_topic_id_list), true); set_config_count('num_posts', $total_posts, true); @@ -1335,5 +1452,3 @@ function mcp_fork_topic($topic_ids) trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link); } } - -?>
\ No newline at end of file diff --git a/phpBB/includes/mcp/mcp_notes.php b/phpBB/includes/mcp/mcp_notes.php index 02a89c0251..12fcbfe91e 100644 --- a/phpBB/includes/mcp/mcp_notes.php +++ b/phpBB/includes/mcp/mcp_notes.php @@ -2,9 +2,8 @@ /** * * @package mcp -* @version $Id$ * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -174,13 +173,13 @@ class mcp_notes } // Generate the appropriate user information for the user we are looking at - if (!function_exists('get_user_avatar')) + if (!function_exists('phpbb_get_user_avatar')) { include($phpbb_root_path . 'includes/functions_display.' . $phpEx); } $rank_title = $rank_img = ''; - $avatar_img = get_user_avatar($userrow['user_avatar'], $userrow['user_avatar_type'], $userrow['user_avatar_width'], $userrow['user_avatar_height']); + $avatar_img = phpbb_get_user_avatar($userrow); $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); $sort_by_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_DATE'], 'c' => $user->lang['SORT_IP'], 'd' => $user->lang['SORT_ACTION']); @@ -216,6 +215,9 @@ class mcp_notes } } + $base_url = $this->u_action . "&$u_sort_param$keywords_param"; + phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start); + $template->assign_vars(array( 'U_POST_ACTION' => $this->u_action, 'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false, @@ -226,9 +228,8 @@ class mcp_notes 'L_TITLE' => $user->lang['MCP_NOTES_USER'], - 'PAGE_NUMBER' => on_page($log_count, $config['topics_per_page'], $start), - 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param$keywords_param", $log_count, $config['topics_per_page'], $start), - 'TOTAL_REPORTS' => ($log_count == 1) ? $user->lang['LIST_REPORT'] : sprintf($user->lang['LIST_REPORTS'], $log_count), + 'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $log_count, $config['topics_per_page'], $start), + 'TOTAL_REPORTS' => $user->lang('LIST_REPORTS', (int) $log_count), 'RANK_TITLE' => $rank_title, 'JOINED' => $user->format_date($userrow['user_regdate']), @@ -247,5 +248,3 @@ class mcp_notes } } - -?>
\ No newline at end of file diff --git a/phpBB/includes/mcp/mcp_pm_reports.php b/phpBB/includes/mcp/mcp_pm_reports.php index 0a33c80a90..f0452b37a5 100644 --- a/phpBB/includes/mcp/mcp_pm_reports.php +++ b/phpBB/includes/mcp/mcp_pm_reports.php @@ -2,9 +2,8 @@ /** * * @package mcp -* @version $Id$ * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -34,7 +33,7 @@ class mcp_pm_reports function main($id, $mode) { global $auth, $db, $user, $template, $cache; - global $config, $phpbb_root_path, $phpEx, $action; + global $config, $phpbb_root_path, $phpEx, $action, $phpbb_container; include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); include_once($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx); @@ -90,6 +89,10 @@ class mcp_pm_reports trigger_error('NO_REPORT'); } + $phpbb_notifications = $phpbb_container->get('notification_manager'); + + $phpbb_notifications->mark_notifications_read_by_parent('report_pm', $report_id, $user->data['user_id']); + $pm_id = $report['pm_id']; $report_id = $report['report_id']; @@ -112,17 +115,9 @@ class mcp_pm_reports } // Process message, leave it uncensored - $message = $pm_info['message_text']; + $parse_flags = ($pm_info['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; + $message = generate_text_for_display($pm_info['message_text'], $pm_info['bbcode_uid'], $pm_info['bbcode_bitfield'], $parse_flags, false); - if ($pm_info['bbcode_bitfield']) - { - include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx); - $bbcode = new bbcode($pm_info['bbcode_bitfield']); - $bbcode->bbcode_second_pass($message, $pm_info['bbcode_uid'], $pm_info['bbcode_bitfield']); - } - - $message = bbcode_nl2br($message); - $message = smiley_text($message); $report['report_text'] = make_clickable(bbcode_nl2br($report['report_text'])); if ($pm_info['message_attachment'] && $auth->acl_get('u_pm_download')) @@ -294,12 +289,16 @@ class mcp_pm_reports 'REPORT_ID' => $row['report_id'], 'REPORT_TIME' => $user->format_date($row['report_time']), - 'RECIPIENTS' => implode(', ', $address_list[$row['msg_id']]), + 'RECIPIENTS' => implode($user->lang['COMMA_SEPARATOR'], $address_list[$row['msg_id']]), + 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $row['message_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', )); } } } + $base_url = $this->u_action . "&st=$sort_days&sk=$sort_key&sd=$sort_dir"; + phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $total, $config['topics_per_page'], $start); + // Now display the page $template->assign_vars(array( 'L_EXPLAIN' => ($mode == 'pm_reports') ? $user->lang['MCP_PM_REPORTS_OPEN_EXPLAIN'] : $user->lang['MCP_PM_REPORTS_CLOSED_EXPLAIN'], @@ -309,10 +308,9 @@ class mcp_pm_reports 'S_MCP_ACTION' => $this->u_action, 'S_CLOSED' => ($mode == 'pm_reports_closed') ? true : false, - 'PAGINATION' => generate_pagination($this->u_action . "&st=$sort_days&sk=$sort_key&sd=$sort_dir", $total, $config['topics_per_page'], $start), - 'PAGE_NUMBER' => on_page($total, $config['topics_per_page'], $start), + 'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $total, $config['topics_per_page'], $start), 'TOTAL' => $total, - 'TOTAL_REPORTS' => ($total == 1) ? $user->lang['LIST_REPORT'] : sprintf($user->lang['LIST_REPORTS'], $total), + 'TOTAL_REPORTS' => $user->lang('LIST_REPORTS', (int) $total), ) ); @@ -321,5 +319,3 @@ class mcp_pm_reports } } } - -?>
\ No newline at end of file diff --git a/phpBB/includes/mcp/mcp_post.php b/phpBB/includes/mcp/mcp_post.php index ba45037a18..06f27655ae 100644 --- a/phpBB/includes/mcp/mcp_post.php +++ b/phpBB/includes/mcp/mcp_post.php @@ -2,9 +2,8 @@ /** * * @package mcp -* @version $Id$ * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -126,17 +125,8 @@ function mcp_post_details($id, $mode, $action) $post_unread = (isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']]) ? true : false; // Process message, leave it uncensored - $message = $post_info['post_text']; - - if ($post_info['bbcode_bitfield']) - { - include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx); - $bbcode = new bbcode($post_info['bbcode_bitfield']); - $bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']); - } - - $message = bbcode_nl2br($message); - $message = smiley_text($message); + $parse_flags = ($post_info['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; + $message = generate_text_for_display($post_info['post_text'], $post_info['bbcode_uid'], $post_info['bbcode_bitfield'], $parse_flags, false); if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) { @@ -175,6 +165,33 @@ function mcp_post_details($id, $mode, $action) } } + // Deleting information + if ($post_info['post_visibility'] == ITEM_DELETED && $post_info['post_delete_user']) + { + // User having deleted the post also being the post author? + if (!$post_info['post_delete_user'] || $post_info['post_delete_user'] == $post_info['poster_id']) + { + $display_username = get_username_string('full', $post_info['poster_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']); + } + else + { + $sql = 'SELECT user_id, username, user_colour + FROM ' . USERS_TABLE . ' + WHERE user_id = ' . (int) $post_info['post_delete_user']; + $result = $db->sql_query($sql); + $user_delete_row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + $display_username = get_username_string('full', $post_info['post_delete_user'], $user_delete_row['username'], $user_delete_row['user_colour']); + } + + $user->add_lang('viewtopic'); + $l_deleted_by = $user->lang('DELETED_INFORMATION', $display_username, $user->format_date($post_info['post_delete_time'], false, true)); + } + else + { + $l_deleted_by = ''; + } + $template->assign_vars(array( 'U_MCP_ACTION' => "$url&i=main&quickmod=1&mode=post_details", // Use this for mode paramaters 'U_POST_ACTION' => "$url&i=$id&mode=post_details", // Use this for action parameters @@ -186,10 +203,13 @@ function mcp_post_details($id, $mode, $action) 'S_CAN_DELETE_POST' => $auth->acl_get('m_delete', $post_info['forum_id']), 'S_POST_REPORTED' => ($post_info['post_reported']) ? true : false, - 'S_POST_UNAPPROVED' => (!$post_info['post_approved']) ? true : false, + 'S_POST_UNAPPROVED' => ($post_info['post_visibility'] == ITEM_UNAPPROVED) ? true : false, + 'S_POST_DELETED' => ($post_info['post_visibility'] == ITEM_DELETED) ? true : false, 'S_POST_LOCKED' => ($post_info['post_edit_locked']) ? true : false, 'S_USER_NOTES' => true, 'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false, + 'DELETED_MESSAGE' => $l_deleted_by, + 'DELETE_REASON' => $post_info['post_delete_reason'], 'U_EDIT' => ($auth->acl_get('m_edit', $post_info['forum_id'])) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=edit&f={$post_info['forum_id']}&p={$post_info['post_id']}") : '', 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=mcp_chgposter&field=username&select_single=true'), @@ -206,6 +226,7 @@ function mcp_post_details($id, $mode, $action) 'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", "f={$post_info['forum_id']}&start={$start}") . '">', '</a>'), 'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', $user->lang['POST_UNAPPROVED']), + 'DELETED_IMG' => $user->img('icon_topic_deleted', $user->lang['POST_DELETED']), 'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']), 'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']), @@ -394,7 +415,7 @@ function mcp_post_details($id, $mode, $action) */ function change_poster(&$post_info, $userdata) { - global $auth, $db, $config, $phpbb_root_path, $phpEx; + global $auth, $db, $config, $phpbb_root_path, $phpEx, $user; if (empty($userdata) || $userdata['user_id'] == $post_info['user_id']) { @@ -416,7 +437,7 @@ function change_poster(&$post_info, $userdata) } // Adjust post counts... only if the post is approved (else, it was not added the users post count anyway) - if ($post_info['post_postcount'] && $post_info['post_approved']) + if ($post_info['post_postcount'] && $post_info['post_visibility'] == ITEM_APPROVED) { $sql = 'UPDATE ' . USERS_TABLE . ' SET user_posts = user_posts - 1 @@ -465,15 +486,13 @@ function change_poster(&$post_info, $userdata) } // refresh search cache of this post - $search_type = basename($config['search_type']); + $search_type = $config['search_type']; - if (file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx)) + if (class_exists($search_type)) { - require("{$phpbb_root_path}includes/search/$search_type.$phpEx"); - // We do some additional checks in the module to ensure it can actually be utilised $error = false; - $search = new $search_type($error); + $search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user); if (!$error && method_exists($search, 'destroy_cache')) { @@ -497,5 +516,3 @@ function change_poster(&$post_info, $userdata) // Now add log entry add_log('mod', $post_info['forum_id'], $post_info['topic_id'], 'LOG_MCP_CHANGE_POSTER', $post_info['topic_title'], $from_username, $to_username); } - -?>
\ No newline at end of file diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 764461fa53..db461d07fa 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -2,9 +2,8 @@ /** * * @package mcp -* @version $Id$ * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -26,15 +25,15 @@ class mcp_queue var $p_master; var $u_action; - function mcp_queue(&$p_master) + public function mcp_queue(&$p_master) { $this->p_master = &$p_master; } - function main($id, $mode) + public function main($id, $mode) { - global $auth, $db, $user, $template, $cache; - global $config, $phpbb_root_path, $phpEx, $action; + global $auth, $db, $user, $template, $cache, $request; + global $config, $phpbb_root_path, $phpEx, $action, $phpbb_container; include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); @@ -46,25 +45,99 @@ class mcp_queue switch ($action) { case 'approve': - case 'disapprove': + case 'restore': include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); - $post_id_list = request_var('post_id_list', array(0)); + $post_id_list = $request->variable('post_id_list', array(0)); + $topic_id_list = $request->variable('topic_id_list', array(0)); - if (!sizeof($post_id_list)) + if (!empty($post_id_list)) + { + self::approve_posts($action, $post_id_list, 'queue', $mode); + } + else if (!empty($topic_id_list)) + { + self::approve_topics($action, $topic_id_list, 'queue', $mode); + } + else { trigger_error('NO_POST_SELECTED'); } + break; + + case 'delete': + $post_id_list = $request->variable('post_id_list', array(0)); + $topic_id_list = $request->variable('topic_id_list', array(0)); - if ($action == 'approve') + if (!empty($post_id_list)) + { + if (!function_exists('mcp_delete_post')) + { + global $phpbb_root_path, $phpEx; + include($phpbb_root_path . 'includes/mcp/mcp_main.' . $phpEx); + } + mcp_delete_post($post_id_list, false, '', $action); + } + else if (!empty($topic_id_list)) { - approve_post($post_id_list, 'queue', $mode); + if (!function_exists('mcp_delete_topic')) + { + global $phpbb_root_path, $phpEx; + include($phpbb_root_path . 'includes/mcp/mcp_main.' . $phpEx); + } + mcp_delete_topic($topic_id_list, false, '', $action); } else { - disapprove_post($post_id_list, 'queue', $mode); + trigger_error('NO_POST_SELECTED'); } + break; + case 'disapprove': + $post_id_list = $request->variable('post_id_list', array(0)); + $topic_id_list = $request->variable('topic_id_list', array(0)); + + if (!empty($topic_id_list) && $mode == 'deleted_topics') + { + if (!function_exists('mcp_delete_topics')) + { + global $phpbb_root_path, $phpEx; + include($phpbb_root_path . 'includes/mcp/mcp_main.' . $phpEx); + } + mcp_delete_topic($topic_id_list, false, '', 'disapprove'); + return; + } + + if (!class_exists('messenger')) + { + include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); + } + + if (!empty($topic_id_list)) + { + $post_visibility = ($mode == 'deleted_topics') ? ITEM_DELETED : ITEM_UNAPPROVED; + $sql = 'SELECT post_id + FROM ' . POSTS_TABLE . ' + WHERE post_visibility = ' . $post_visibility . ' + AND ' . $db->sql_in_set('topic_id', $topic_id_list); + $result = $db->sql_query($sql); + + $post_id_list = array(); + while ($row = $db->sql_fetchrow($result)) + { + $post_id_list[] = (int) $row['post_id']; + } + $db->sql_freeresult($result); + } + + if (!empty($post_id_list)) + { + self::disapprove_posts($post_id_list, 'queue', $mode); + } + else + { + trigger_error('NO_POST_SELECTED'); + } break; } @@ -79,12 +152,16 @@ class mcp_queue $post_id = request_var('p', 0); $topic_id = request_var('t', 0); + $phpbb_notifications = $phpbb_container->get('notification_manager'); + if ($topic_id) { $topic_info = get_topic_data(array($topic_id), 'm_approve'); if (isset($topic_info[$topic_id]['topic_first_post_id'])) { $post_id = (int) $topic_info[$topic_id]['topic_first_post_id']; + + $phpbb_notifications->mark_notifications_read('topic_in_queue', $topic_id, $user->data['user_id']); } else { @@ -92,6 +169,8 @@ class mcp_queue } } + $phpbb_notifications->mark_notifications_read('post_in_queue', $post_id, $user->data['user_id']); + $post_info = get_post_data(array($post_id), 'm_approve', true); if (!sizeof($post_info)) @@ -106,8 +185,8 @@ class mcp_queue $template->assign_vars(array( 'S_TOPIC_REVIEW' => true, 'S_BBCODE_ALLOWED' => $post_info['enable_bbcode'], - 'TOPIC_TITLE' => $post_info['topic_title']) - ); + 'TOPIC_TITLE' => $post_info['topic_title'], + )); } $extensions = $attachments = $topic_tracking_info = array(); @@ -127,17 +206,8 @@ class mcp_queue $post_unread = (isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']]) ? true : false; // Process message, leave it uncensored - $message = $post_info['post_text']; - - if ($post_info['bbcode_bitfield']) - { - include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx); - $bbcode = new bbcode($post_info['bbcode_bitfield']); - $bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']); - } - - $message = bbcode_nl2br($message); - $message = smiley_text($message); + $parse_flags = ($post_info['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; + $message = generate_text_for_display($post_info['post_text'], $post_info['bbcode_uid'], $post_info['bbcode_bitfield'], $parse_flags, false); if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) { @@ -170,12 +240,39 @@ class mcp_queue foreach ($attachments as $attachment) { $template->assign_block_vars('attachment', array( - 'DISPLAY_ATTACHMENT' => $attachment) - ); + 'DISPLAY_ATTACHMENT' => $attachment, + )); } } } + // Deleting information + if ($post_info['post_visibility'] == ITEM_DELETED && $post_info['post_delete_user']) + { + // User having deleted the post also being the post author? + if (!$post_info['post_delete_user'] || $post_info['post_delete_user'] == $post_info['poster_id']) + { + $display_username = get_username_string('full', $post_info['poster_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']); + } + else + { + $sql = 'SELECT u.user_id, u.username, u.user_colour + FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u + WHERE p.post_id = ' . $post_info['post_id'] . ' + AND p.post_delete_user = u.user_id'; + $result = $db->sql_query($sql); + $post_delete_userinfo = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + $display_username = get_username_string('full', $post_info['post_delete_user'], $post_delete_userinfo['username'], $post_delete_userinfo['user_colour']); + } + + $l_deleted_by = $user->lang('DELETED_INFORMATION', $display_username, $user->format_date($post_info['post_delete_time'], false, true)); + } + else + { + $l_deleted_by = ''; + } + $post_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&p=' . $post_info['post_id'] . '#p' . $post_info['post_id']); $topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']); @@ -184,9 +281,12 @@ class mcp_queue 'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&p=$post_id&f=$forum_id"), 'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']), 'S_POST_REPORTED' => $post_info['post_reported'], - 'S_POST_UNAPPROVED' => !$post_info['post_approved'], + 'S_POST_UNAPPROVED' => ($post_info['post_visibility'] == ITEM_UNAPPROVED), 'S_POST_LOCKED' => $post_info['post_edit_locked'], 'S_USER_NOTES' => true, + 'S_POST_DELETED' => ($post_info['post_visibility'] == ITEM_DELETED), + 'DELETED_MESSAGE' => $l_deleted_by, + 'DELETE_REASON' => $post_info['post_delete_reason'], 'U_EDIT' => ($auth->acl_get('m_edit', $post_info['forum_id'])) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=edit&f={$post_info['forum_id']}&p={$post_info['post_id']}") : '', 'U_MCP_APPROVE' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), @@ -198,7 +298,8 @@ class mcp_queue 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), - 'RETURN_QUEUE' => sprintf($user->lang['RETURN_QUEUE'], '<a href="' . append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue' . (($topic_id) ? '&mode=unapproved_topics' : '&mode=unapproved_posts')) . "&start=$start\">", '</a>'), + + 'RETURN_QUEUE' => sprintf($user->lang['RETURN_QUEUE'], '<a href="' . append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue' . (($topic_id) ? '&mode=unapproved_topics' : '&mode=unapproved_posts')) . '&start=' . $start . '">', '</a>'), 'RETURN_POST' => sprintf($user->lang['RETURN_POST'], '<a href="' . $post_url . '">', '</a>'), 'RETURN_TOPIC_SIMPLE' => sprintf($user->lang['RETURN_TOPIC_SIMPLE'], '<a href="' . $topic_url . '">', '</a>'), 'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']), @@ -225,9 +326,16 @@ class mcp_queue case 'unapproved_topics': case 'unapproved_posts': + case 'deleted_topics': + case 'deleted_posts': + $m_perm = 'm_approve'; + $is_topics = ($mode == 'unapproved_topics' || $mode == 'deleted_topics') ? true : false; + $is_restore = ($mode == 'deleted_posts' || $mode == 'deleted_topics') ? true : false; + $visibility_const = (!$is_restore) ? ITEM_UNAPPROVED : ITEM_DELETED; + $user->add_lang(array('viewtopic', 'viewforum')); - $topic_id = request_var('t', 0); + $topic_id = $request->variable('t', 0); $forum_info = array(); if ($topic_id) @@ -243,7 +351,7 @@ class mcp_queue $forum_id = $topic_info['forum_id']; } - $forum_list_approve = get_forum_list('m_approve', false, true); + $forum_list_approve = get_forum_list($m_perm, false, true); $forum_list_read = array_flip(get_forum_list('f_read', true, true)); // Flipped so we can isset() the forum IDs // Remove forums we cannot read @@ -269,20 +377,16 @@ 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)"; + $sql = 'SELECT SUM(forum_topics_approved) as sum_forum_topics + 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'); + $forum_info['forum_topics_approved'] = (int) $db->sql_fetchfield('sum_forum_topics'); $db->sql_freeresult($result); } else { - $forum_info = get_forum_data(array($forum_id), 'm_approve'); + $forum_info = get_forum_data(array($forum_id), $m_perm); if (!sizeof($forum_info)) { @@ -291,7 +395,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>'; @@ -305,21 +408,22 @@ class mcp_queue $sort_by_sql = $sort_order_sql = array(); mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id); - $forum_topics = ($total == -1) ? $forum_info['forum_topics'] : $total; + $forum_topics = ($total == -1) ? $forum_info['forum_topics_approved'] : $total; $limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : ''; $forum_names = array(); - if ($mode == 'unapproved_posts') + if (!$is_topics) { $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) - AND p.post_approved = 0 - " . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . ' + 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_visibility = ' . $visibility_const . ' + ' . (($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 + AND (t.topic_visibility <> p.post_visibility + OR t.topic_delete_user = 0) $limit_time_sql ORDER BY $sort_order_sql"; $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); @@ -335,7 +439,7 @@ class mcp_queue if (sizeof($post_ids)) { - $sql = 'SELECT t.topic_id, t.topic_title, t.forum_id, p.post_id, p.post_subject, p.post_username, p.poster_id, p.post_time, u.username, u.username_clean, u.user_colour + $sql = 'SELECT t.topic_id, t.topic_title, t.forum_id, p.post_id, p.post_subject, p.post_username, p.poster_id, p.post_time, p.post_attachment, u.username, u.username_clean, u.user_colour FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u WHERE ' . $db->sql_in_set('p.post_id', $post_ids) . ' AND t.topic_id = p.topic_id @@ -346,10 +450,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); @@ -367,10 +468,11 @@ class mcp_queue } else { - $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) - AND topic_approved = 0 + $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_attachment AS post_attachment, t.topic_first_poster_name AS username, t.topic_first_poster_colour AS user_colour + FROM ' . TOPICS_TABLE . ' t + WHERE ' . $db->sql_in_set('forum_id', $forum_list) . ' + AND topic_visibility = ' . $visibility_const . " + AND topic_delete_user <> 0 $limit_time_sql ORDER BY $sort_order_sql"; $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); @@ -378,10 +480,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); @@ -405,20 +504,14 @@ 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']; + $row['post_username'] = $row['username'] ?: $user->lang['GUEST']; } $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']}" : '')), @@ -428,572 +521,708 @@ 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'], + 'TOPIC_ID' => $row['topic_id'], + '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'])) - ); + 'POST_TIME' => $user->format_date($row['post_time']), + 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['post_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', + )); } unset($rowset, $forum_names); + $base_url = $this->u_action . "&f=$forum_id&st=$sort_days&sk=$sort_key&sd=$sort_dir"; + phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $total, $config['topics_per_page'], $start); + // Now display the page $template->assign_vars(array( - 'L_DISPLAY_ITEMS' => ($mode == 'unapproved_posts') ? $user->lang['DISPLAY_POSTS'] : $user->lang['DISPLAY_TOPICS'], - 'L_EXPLAIN' => ($mode == 'unapproved_posts') ? $user->lang['MCP_QUEUE_UNAPPROVED_POSTS_EXPLAIN'] : $user->lang['MCP_QUEUE_UNAPPROVED_TOPICS_EXPLAIN'], - 'L_TITLE' => ($mode == 'unapproved_posts') ? $user->lang['MCP_QUEUE_UNAPPROVED_POSTS'] : $user->lang['MCP_QUEUE_UNAPPROVED_TOPICS'], + 'L_DISPLAY_ITEMS' => (!$is_topics) ? $user->lang['DISPLAY_POSTS'] : $user->lang['DISPLAY_TOPICS'], + 'L_EXPLAIN' => $user->lang['MCP_QUEUE_' . strtoupper($mode) . '_EXPLAIN'], + 'L_TITLE' => $user->lang['MCP_QUEUE_' . strtoupper($mode)], 'L_ONLY_TOPIC' => ($topic_id) ? sprintf($user->lang['ONLY_TOPIC'], $topic_info['topic_title']) : '', 'S_FORUM_OPTIONS' => $forum_options, 'S_MCP_ACTION' => build_url(array('t', 'f', 'sd', 'st', 'sk')), - 'S_TOPICS' => ($mode == 'unapproved_posts') ? false : true, + 'S_TOPICS' => $is_topics, + 'S_RESTORE' => $is_restore, - 'PAGINATION' => generate_pagination($this->u_action . "&f=$forum_id&st=$sort_days&sk=$sort_key&sd=$sort_dir", $total, $config['topics_per_page'], $start), - 'PAGE_NUMBER' => on_page($total, $config['topics_per_page'], $start), + 'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $total, $config['topics_per_page'], $start), 'TOPIC_ID' => $topic_id, - 'TOTAL' => ($total == 1) ? (($mode == 'unapproved_posts') ? $user->lang['VIEW_TOPIC_POST'] : $user->lang['VIEW_FORUM_TOPIC']) : sprintf((($mode == 'unapproved_posts') ? $user->lang['VIEW_TOPIC_POSTS'] : $user->lang['VIEW_FORUM_TOPICS']), $total), + 'TOTAL' => $user->lang(((!$is_topics) ? 'VIEW_TOPIC_POSTS' : 'VIEW_FORUM_TOPICS'), (int) $total), )); $this->tpl_name = 'mcp_queue'; break; } } -} -/** -* Approve Post/Topic -*/ -function approve_post($post_id_list, $id, $mode) -{ - global $db, $template, $user, $config; - global $phpEx, $phpbb_root_path; - - if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve'))) + /** + * Approve/Restore posts + * + * @param $action string Action we perform on the posts ('approve' or 'restore') + * @param $post_id_list array IDs of the posts to approve/restore + * @param $id mixed Category of the current active module + * @param $mode string Active module + * @return null + */ + static public function approve_posts($action, $post_id_list, $id, $mode) { - trigger_error('NOT_AUTHORISED'); - } + global $db, $template, $user, $config, $request, $phpbb_container; + global $phpEx, $phpbb_root_path; - $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' => 'approve', - 'redirect' => $redirect) - ); - - $post_info = get_post_data($post_id_list, 'm_approve'); + if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve'))) + { + trigger_error('NOT_AUTHORISED'); + } - if (confirm_box(true)) - { - $notify_poster = (isset($_REQUEST['notify_poster'])) ? true : false; + $redirect = $request->variable('redirect', build_url(array('quickmod'))); + $success_msg = $post_url = ''; + $approve_log = array(); - // 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 + $s_hidden_fields = build_hidden_fields(array( + 'i' => $id, + 'mode' => $mode, + 'post_id_list' => $post_id_list, + 'action' => $action, + 'redirect' => $redirect, + )); - $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(); + $post_info = get_post_data($post_id_list, 'm_approve'); - foreach ($post_info as $post_id => $post_data) + if (confirm_box(true)) { - if ($post_data['post_approved']) - { - $post_approved_list[] = $post_id; - continue; - } + $notify_poster = ($action == 'approve' && isset($_REQUEST['notify_poster'])); - $topic_id_list[$post_data['topic_id']] = 1; + $topic_info = array(); - if ($post_data['forum_id']) + // Group the posts by topic_id + foreach ($post_info as $post_id => $post_data) { - $forum_id_list[$post_data['forum_id']] = 1; - } + if ($post_data['post_visibility'] == ITEM_APPROVED) + { + continue; + } + $topic_id = (int) $post_data['topic_id']; - // 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. ;) - 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_info[$topic_id]['posts'][] = (int) $post_id; + $topic_info[$topic_id]['forum_id'] = (int) $post_data['forum_id']; - // Topic or Post. ;) - if ($post_data['topic_first_post_id'] == $post_id) - { - if ($post_data['forum_id']) + // Refresh the first post, if the time or id is older then the current one + if ($post_id <= $post_data['topic_first_post_id'] || $post_data['post_time'] <= $post_data['topic_time']) { - $total_topics++; + $topic_info[$topic_id]['first_post'] = true; } - $topic_approve_sql[] = $post_data['topic_id']; + + // Refresh the last post, if the time or id is newer then the current one + if ($post_id >= $post_data['topic_last_post_id'] || $post_data['post_time'] >= $post_data['topic_last_post_time']) + { + $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']; $approve_log[] = array( - 'type' => 'topic', - 'post_subject' => $post_data['post_subject'], 'forum_id' => $post_data['forum_id'], 'topic_id' => $post_data['topic_id'], + 'post_subject' => $post_data['post_subject'], ); } - else + + $phpbb_content_visibility = $phpbb_container->get('content.visibility'); + foreach ($topic_info as $topic_id => $topic_data) { - $approve_log[] = array( - 'type' => 'post', - 'post_subject' => $post_data['post_subject'], - 'forum_id' => $post_data['forum_id'], - 'topic_id' => $post_data['topic_id'], - ); + $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 ($post_data['forum_id']) + if (sizeof($post_info) >= 1) { - $total_posts++; + $success_msg = (sizeof($post_info) == 1) ? 'POST_' . strtoupper($action) . 'D_SUCCESS' : 'POSTS_' . strtoupper($action) . 'D_SUCCESS'; + } - // 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']) + foreach ($approve_log as $log_data) + { + add_log('mod', $log_data['forum_id'], $log_data['topic_id'], 'LOG_POST_' . strtoupper($action) . 'D', $log_data['post_subject']); + } + + // Only send out the mails, when the posts are being approved + if ($action == 'approve') + { + $phpbb_notifications = $phpbb_container->get('notification_manager'); + + // Handle notifications + foreach ($post_info as $post_id => $post_data) { - $total_posts += $post_data['topic_replies']; + $phpbb_notifications->delete_notifications('post_in_queue', $post_id); + + $phpbb_notifications->add_notifications(array( + 'quote', + 'bookmark', + 'post', + ), $post_data); + + $phpbb_notifications->mark_notifications_read(array( + 'quote', + 'bookmark', + 'post', + ), $post_data['post_id'], $user->data['user_id']); + + // Notify Poster? + if ($notify_poster) + { + if ($post_data['poster_id'] == ANONYMOUS) + { + continue; + } + + $phpbb_notifications->add_notifications('approve_post', $post_data); + } } } - - $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++) + else { - unset($post_info[$post_approved_list[$i]]); - } + $show_notify = false; - if (sizeof($topic_approve_sql)) - { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_approved = 1 - WHERE ' . $db->sql_in_set('topic_id', $topic_approve_sql); - $db->sql_query($sql); - } + if ($action == 'approve') + { + foreach ($post_info as $post_data) + { + if ($post_data['poster_id'] == ANONYMOUS) + { + continue; + } + else + { + $show_notify = true; + break; + } + } + } - if (sizeof($post_approve_sql)) - { - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET post_approved = 1 - WHERE ' . $db->sql_in_set('post_id', $post_approve_sql); - $db->sql_query($sql); + $template->assign_vars(array( + 'S_NOTIFY_POSTER' => $show_notify, + 'S_' . strtoupper($action) => true, + )); + + confirm_box(false, strtoupper($action) . '_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html'); } - unset($topic_approve_sql, $post_approve_sql); + $redirect = $request->variable('redirect', "index.$phpEx"); + $redirect = reapply_sid($redirect); - foreach ($approve_log as $log_data) + if (!$success_msg) { - add_log('mod', $log_data['forum_id'], $log_data['topic_id'], ($log_data['type'] == 'topic') ? 'LOG_TOPIC_APPROVED' : 'LOG_POST_APPROVED', $log_data['post_subject']); + redirect($redirect); } - - if (sizeof($user_posts_sql)) + else { - // Try to minimize the query count by merging users with the same post count additions - $user_posts_update = array(); + meta_refresh(3, $redirect); - foreach ($user_posts_sql as $user_id => $user_posts) + // If approving one post, also give links back to post... + $add_message = ''; + if (sizeof($post_info) == 1 && $post_url) { - $user_posts_update[$user_posts][] = $user_id; + $add_message = '<br /><br />' . sprintf($user->lang['RETURN_POST'], '<a href="' . $post_url . '">', '</a>'); } - foreach ($user_posts_update as $user_posts => $user_id_ary) + $message = $user->lang[$success_msg] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>') . $add_message; + + if ($request->is_ajax()) { - $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); + $json_response = new \phpbb\json_response; + $json_response->send(array( + 'MESSAGE_TITLE' => $user->lang['INFORMATION'], + 'MESSAGE_TEXT' => $message, + 'REFRESH_DATA' => null, + 'visible' => true, + )); } - } - if ($total_topics) - { - set_config_count('num_topics', $total_topics, true); + trigger_error($message); } + } - if ($total_posts) + /** + * Approve/Restore topics + * + * @param $action string Action we perform on the posts ('approve' or 'restore') + * @param $topic_id_list array IDs of the topics to approve/restore + * @param $id mixed Category of the current active module + * @param $mode string Active module + * @return null + */ + static public function approve_topics($action, $topic_id_list, $id, $mode) + { + global $db, $template, $user, $config; + global $phpEx, $phpbb_root_path, $request, $phpbb_container; + + if (!check_ids($topic_id_list, TOPICS_TABLE, 'topic_id', array('m_approve'))) { - set_config_count('num_posts', $total_posts, true); + trigger_error('NOT_AUTHORISED'); } - 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); + $redirect = $request->variable('redirect', build_url(array('quickmod'))); + $success_msg = $topic_url = ''; + $approve_log = array(); - $messenger = new messenger(); + $s_hidden_fields = build_hidden_fields(array( + 'i' => $id, + 'mode' => $mode, + 'topic_id_list' => $topic_id_list, + 'action' => $action, + 'redirect' => $redirect, + )); - // Notify Poster? - if ($notify_poster) - { - foreach ($post_info as $post_id => $post_data) - { - if ($post_data['poster_id'] == ANONYMOUS) - { - continue; - } + $topic_info = get_topic_data($topic_id_list, 'm_approve'); - $email_template = ($post_data['post_id'] == $post_data['topic_first_post_id'] && $post_data['post_id'] == $post_data['topic_last_post_id']) ? 'topic_approved' : 'post_approved'; - - $messenger->template($email_template, $post_data['user_lang']); + if (confirm_box(true)) + { + $notify_poster = ($action == 'approve' && isset($_REQUEST['notify_poster'])) ? true : false; - $messenger->to($post_data['user_email'], $post_data['username']); - $messenger->im($post_data['user_jabber'], $post_data['username']); + $phpbb_content_visibility = $phpbb_container->get('content.visibility'); + foreach ($topic_info as $topic_id => $topic_data) + { + $phpbb_content_visibility->set_topic_visibility(ITEM_APPROVED, $topic_id, $topic_data['forum_id'], $user->data['user_id'], time(), ''); - $messenger->assign_vars(array( - 'USERNAME' => htmlspecialchars_decode($post_data['username']), - 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_data['post_subject'])), - 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_data['topic_title'])), + $topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$topic_data['forum_id']}&t={$topic_id}"); - 'U_VIEW_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f={$post_data['forum_id']}&t={$post_data['topic_id']}&e=0", - 'U_VIEW_POST' => generate_board_url() . "/viewtopic.$phpEx?f={$post_data['forum_id']}&t={$post_data['topic_id']}&p=$post_id&e=$post_id") + $approve_log[] = array( + 'forum_id' => $topic_data['forum_id'], + 'topic_id' => $topic_data['topic_id'], + 'topic_title' => $topic_data['topic_title'], ); - - $messenger->send($post_data['user_notify_type']); } - } - - $messenger->save_queue(); - // Send out normal user notifications - $email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']); - - foreach ($post_info as $post_id => $post_data) - { - if ($post_id == $post_data['topic_first_post_id'] && $post_id == $post_data['topic_last_post_id']) + if (sizeof($topic_info) >= 1) { - // Forum Notifications - user_notification('post', $post_data['topic_title'], $post_data['topic_title'], $post_data['forum_name'], $post_data['forum_id'], $post_data['topic_id'], $post_id); + $success_msg = (sizeof($topic_info) == 1) ? 'TOPIC_' . strtoupper($action) . 'D_SUCCESS' : 'TOPICS_' . strtoupper($action) . 'D_SUCCESS'; } - else + + foreach ($approve_log as $log_data) { - // Topic Notifications - user_notification('reply', $post_data['post_subject'], $post_data['topic_title'], $post_data['forum_name'], $post_data['forum_id'], $post_data['topic_id'], $post_id); + add_log('mod', $log_data['forum_id'], $log_data['topic_id'], 'LOG_TOPIC_' . strtoupper($action) . 'D', $log_data['topic_title']); } - } - if (sizeof($post_id_list) == 1) - { - $post_data = $post_info[$post_id_list[0]]; - $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']; - } - unset($post_info); + // Only send out the mails, when the posts are being approved + if ($action == 'approve') + { + // Handle notifications + $phpbb_notifications = $phpbb_container->get('notification_manager'); - if ($total_topics) - { - $success_msg = ($total_topics == 1) ? 'TOPIC_APPROVED_SUCCESS' : 'TOPICS_APPROVED_SUCCESS'; + foreach ($topic_info as $topic_id => $topic_data) + { + $phpbb_notifications->delete_notifications('topic_in_queue', $post_data['topic_id']); + $phpbb_notifications->add_notifications(array( + 'quote', + 'topic', + ), $post_data); + + $phpbb_notifications->mark_notifications_read('quote', $post_data['post_id'], $user->data['user_id']); + $phpbb_notifications->mark_notifications_read('topic', $post_data['topic_id'], $user->data['user_id']); + + if ($notify_poster) + { + $phpbb_notifications->add_notifications('approve_topic', $post_data); + } + } + } } else { - $success_msg = (sizeof($post_id_list) + sizeof($post_approved_list) == 1) ? 'POST_APPROVED_SUCCESS' : 'POSTS_APPROVED_SUCCESS'; - } - } - else - { - $show_notify = false; + $show_notify = false; - if ($config['email_enable'] || $config['jab_enable']) - { - foreach ($post_info as $post_data) + if ($action == 'approve') { - if ($post_data['poster_id'] == ANONYMOUS) - { - continue; - } - else + foreach ($topic_info as $topic_data) { - $show_notify = true; - break; + if ($topic_data['topic_poster'] == ANONYMOUS) + { + continue; + } + else + { + $show_notify = true; + break; + } } } - } - $template->assign_vars(array( - 'S_NOTIFY_POSTER' => $show_notify, - 'S_APPROVE' => true) - ); + $template->assign_vars(array( + 'S_NOTIFY_POSTER' => $show_notify, + 'S_' . strtoupper($action) => true, + )); - confirm_box(false, 'APPROVE_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html'); - } + confirm_box(false, strtoupper($action) . '_TOPIC' . ((sizeof($topic_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html'); + } - $redirect = request_var('redirect', "index.$phpEx"); - $redirect = reapply_sid($redirect); + $redirect = $request->variable('redirect', "index.$phpEx"); + $redirect = reapply_sid($redirect); - if (!$success_msg) - { - redirect($redirect); - } - else - { - meta_refresh(3, $redirect); - - // If approving one post, also give links back to post... - $add_message = ''; - if (sizeof($post_id_list) == 1 && !empty($post_url)) + if (!$success_msg) { - $add_message = '<br /><br />' . sprintf($user->lang['RETURN_POST'], '<a href="' . $post_url . '">', '</a>'); + redirect($redirect); } + else + { + meta_refresh(3, $redirect); - trigger_error($user->lang[$success_msg] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], "<a href=\"$redirect\">", '</a>') . $add_message); - } -} - -/** -* Disapprove Post/Topic -*/ -function disapprove_post($post_id_list, $id, $mode) -{ - global $db, $template, $user, $config; - global $phpEx, $phpbb_root_path; - - if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve'))) - { - trigger_error('NOT_AUTHORISED'); - } + // If approving one topic, also give links back to topic... + $add_message = ''; + if (sizeof($topic_info) == 1 && $topic_url) + { + $add_message = '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $topic_url . '">', '</a>'); + } - $redirect = request_var('redirect', build_url(array('t', 'mode', 'quickmod')) . "&mode=$mode"); - $reason = utf8_normalize_nfc(request_var('reason', '', true)); - $reason_id = request_var('reason_id', 0); - $success_msg = $additional_msg = ''; + $message = $user->lang[$success_msg] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>') . $add_message; - $s_hidden_fields = build_hidden_fields(array( - 'i' => $id, - 'mode' => $mode, - 'post_id_list' => $post_id_list, - 'action' => 'disapprove', - 'redirect' => $redirect) - ); + 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, + )); + } - $notify_poster = (isset($_REQUEST['notify_poster'])) ? true : false; - $disapprove_reason = ''; + trigger_error($message); + } + } - if ($reason_id) + /** + * Disapprove Post + * + * @param $post_id_list array IDs of the posts to disapprove/delete + * @param $id mixed Category of the current active module + * @param $mode string Active module + * @return null + */ + static public function disapprove_posts($post_id_list, $id, $mode) { - $sql = 'SELECT reason_title, reason_description - FROM ' . REPORTS_REASONS_TABLE . " - WHERE reason_id = $reason_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row || (!$reason && strtolower($row['reason_title']) == 'other')) + global $db, $template, $user, $config, $phpbb_container; + global $phpEx, $phpbb_root_path, $request; + + if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve'))) { - $additional_msg = $user->lang['NO_REASON_DISAPPROVAL']; - unset($_REQUEST['confirm_key']); - unset($_POST['confirm_key']); - unset($_POST['confirm']); + trigger_error('NOT_AUTHORISED'); } - else - { - // If the reason is defined within the language file, we will use the localized version, else just use the database entry... - $disapprove_reason = (strtolower($row['reason_title']) != 'other') ? ((isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])])) ? $user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])] : $row['reason_description']) : ''; - $disapprove_reason .= ($reason) ? "\n\n" . $reason : ''; - if (isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])])) + $redirect = $request->variable('redirect', build_url(array('t', 'mode', 'quickmod')) . "&mode=$mode"); + $reason = $request->variable('reason', '', true); + $reason_id = $request->variable('reason_id', 0); + $success_msg = $additional_msg = ''; + + $s_hidden_fields = build_hidden_fields(array( + 'i' => $id, + 'mode' => $mode, + 'post_id_list' => $post_id_list, + 'action' => 'disapprove', + 'redirect' => $redirect, + )); + + $notify_poster = $request->is_set('notify_poster'); + $disapprove_reason = ''; + + if ($reason_id) + { + $sql = 'SELECT reason_title, reason_description + FROM ' . REPORTS_REASONS_TABLE . " + WHERE reason_id = $reason_id"; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (!$row || (!$reason && strtolower($row['reason_title']) == 'other')) { - $disapprove_reason_lang = strtoupper($row['reason_title']); + $additional_msg = $user->lang['NO_REASON_DISAPPROVAL']; + + $request->overwrite('confirm', null, \phpbb\request\request_interface::POST); + $request->overwrite('confirm_key', null, \phpbb\request\request_interface::POST); + $request->overwrite('confirm_key', null, \phpbb\request\request_interface::REQUEST); } + else + { + // If the reason is defined within the language file, we will use the localized version, else just use the database entry... + $disapprove_reason = (strtolower($row['reason_title']) != 'other') ? ((isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])])) ? $user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])] : $row['reason_description']) : ''; + $disapprove_reason .= ($reason) ? "\n\n" . $reason : ''; - $email_disapprove_reason = $disapprove_reason; + if (isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])])) + { + $disapprove_reason_lang = strtoupper($row['reason_title']); + } + } } - } - $post_info = get_post_data($post_id_list, 'm_approve'); + $post_info = get_post_data($post_id_list, 'm_approve'); - if (confirm_box(true)) - { - $disapprove_log = $disapprove_log_topics = $disapprove_log_posts = array(); - $topic_replies_real = $post_disapprove_list = array(); - - // Build a list of posts to be unapproved and get the related topics real replies count + $is_disapproving = false; foreach ($post_info as $post_id => $post_data) { - $post_disapprove_list[$post_id] = $post_data['topic_id']; - if (!isset($topic_replies_real[$post_data['topic_id']])) + if ($post_data['post_visibility'] == ITEM_DELETED) { - $topic_replies_real[$post_data['topic_id']] = $post_data['topic_replies_real']; + continue; } + + $is_disapproving = true; } - // Now we build the log array - foreach ($post_disapprove_list as $post_id => $topic_id) + if (confirm_box(true)) { - // If the count of disapproved posts for the topic is greater - // than topic's real replies count, the whole topic is disapproved/deleted - if (sizeof(array_keys($post_disapprove_list, $topic_id)) > $topic_replies_real[$topic_id]) + $disapprove_log = $disapprove_log_topics = $disapprove_log_posts = array(); + $topic_posts_unapproved = $post_disapprove_list = $topic_information = array(); + + // Build a list of posts to be disapproved and get the related topics real replies count + foreach ($post_info as $post_id => $post_data) { - // Don't write the log more than once for every topic - if (!isset($disapprove_log_topics[$topic_id])) + $post_disapprove_list[$post_id] = $post_data['topic_id']; + if (!isset($topic_posts_unapproved[$post_data['topic_id']])) { - // Build disapproved topics log - $disapprove_log_topics[$topic_id] = array( - 'type' => 'topic', - 'post_subject' => $post_info[$post_id]['topic_title'], - 'forum_id' => $post_info[$post_id]['forum_id'], - 'topic_id' => 0, // useless to log a topic id, as it will be deleted - ); + $topic_information[$post_data['topic_id']] = $post_data; + $topic_posts_unapproved[$post_data['topic_id']] = 0; } + $topic_posts_unapproved[$post_data['topic_id']]++; } - else + + // Now we build the log array + foreach ($post_disapprove_list as $post_id => $topic_id) { - // Build disapproved posts log - $disapprove_log_posts[] = array( - 'type' => 'post', - 'post_subject' => $post_info[$post_id]['post_subject'], - 'forum_id' => $post_info[$post_id]['forum_id'], - 'topic_id' => $post_info[$post_id]['topic_id'], - ); + // If the count of disapproved posts for the topic is equal + // to the number of unapproved posts in the topic, and there are no different + // posts, we disapprove the hole topic + if ($topic_information[$topic_id]['topic_posts_approved'] == 0 && + $topic_information[$topic_id]['topic_posts_softdeleted'] == 0 && + $topic_information[$topic_id]['topic_posts_unapproved'] == $topic_posts_unapproved[$topic_id]) + { + // Don't write the log more than once for every topic + if (!isset($disapprove_log_topics[$topic_id])) + { + // Build disapproved topics log + $disapprove_log_topics[$topic_id] = array( + 'type' => 'topic', + 'post_subject' => $post_info[$post_id]['topic_title'], + 'forum_id' => $post_info[$post_id]['forum_id'], + 'topic_id' => 0, // useless to log a topic id, as it will be deleted + 'post_username' => ($post_info[$post_id]['poster_id'] == ANONYMOUS && !empty($post_info[$post_id]['post_username'])) ? $post_info[$post_id]['post_username'] : $post_info[$post_id]['username'], + ); + } + } + else + { + // Build disapproved posts log + $disapprove_log_posts[] = array( + 'type' => 'post', + 'post_subject' => $post_info[$post_id]['post_subject'], + 'forum_id' => $post_info[$post_id]['forum_id'], + 'topic_id' => $post_info[$post_id]['topic_id'], + 'post_username' => ($post_info[$post_id]['poster_id'] == ANONYMOUS && !empty($post_info[$post_id]['post_username'])) ? $post_info[$post_id]['post_username'] : $post_info[$post_id]['username'], + ); + } } - } - // Get disapproved posts/topics counts separately - $num_disapproved_topics = sizeof($disapprove_log_topics); - $num_disapproved_posts = sizeof($disapprove_log_posts); + // Get disapproved posts/topics counts separately + $num_disapproved_topics = sizeof($disapprove_log_topics); + $num_disapproved_posts = sizeof($disapprove_log_posts); - // Build the whole log - $disapprove_log = array_merge($disapprove_log_topics, $disapprove_log_posts); + // Build the whole log + $disapprove_log = array_merge($disapprove_log_topics, $disapprove_log_posts); - // Unset unneeded arrays - unset($post_data, $disapprove_log_topics, $disapprove_log_posts); + // Unset unneeded arrays + unset($post_data, $disapprove_log_topics, $disapprove_log_posts); - // Let's do the job - delete disapproved posts - if (sizeof($post_disapprove_list)) - { - if (!function_exists('delete_posts')) + // Let's do the job - delete disapproved posts + if (sizeof($post_disapprove_list)) { - include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx); - } + if (!function_exists('delete_posts')) + { + include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); + } - // We do not check for permissions here, because the moderator allowed approval/disapproval should be allowed to delete the disapproved posts - // Note: function delete_posts triggers related forums/topics sync, - // so we don't need to call update_post_information later and to adjust real topic replies or forum topics count manually - delete_posts('post_id', array_keys($post_disapprove_list)); + // We do not check for permissions here, because the moderator allowed approval/disapproval should be allowed to delete the disapproved posts + // Note: function delete_posts triggers related forums/topics sync, + // so we don't need to call update_post_information later and to adjust real topic replies or forum topics count manually + delete_posts('post_id', array_keys($post_disapprove_list)); - foreach ($disapprove_log as $log_data) - { - add_log('mod', $log_data['forum_id'], $log_data['topic_id'], ($log_data['type'] == 'topic') ? 'LOG_TOPIC_DISAPPROVED' : 'LOG_POST_DISAPPROVED', $log_data['post_subject'], $disapprove_reason); + foreach ($disapprove_log as $log_data) + { + if ($is_disapproving) + { + $l_log_message = ($log_data['type'] == 'topic') ? 'LOG_TOPIC_DISAPPROVED' : 'LOG_POST_DISAPPROVED'; + add_log('mod', $log_data['forum_id'], $log_data['topic_id'], $l_log_message, $log_data['post_subject'], $disapprove_reason); + } + else + { + $l_log_message = ($log_data['type'] == 'topic') ? 'LOG_DELETE_TOPIC' : 'LOG_DELETE_POST'; + add_log('mod', $log_data['forum_id'], $log_data['topic_id'], $l_log_message, $log_data['post_subject'], $log_data['post_username']); + } + } } - } - $messenger = new messenger(); + $phpbb_notifications = $phpbb_container->get('notification_manager'); - // Notify Poster? - if ($notify_poster) - { $lang_reasons = array(); foreach ($post_info as $post_id => $post_data) { - if ($post_data['poster_id'] == ANONYMOUS) + $disapprove_all_posts_in_topic = $topic_information[$topic_id]['topic_posts_approved'] == 0 && + $topic_information[$topic_id]['topic_posts_softdeleted'] == 0 && + $topic_information[$topic_id]['topic_posts_unapproved'] == $topic_posts_unapproved[$topic_id]; + + $phpbb_notifications->delete_notifications('post_in_queue', $post_id); + + // Do we disapprove the whole topic? Remove potential notifications + if ($disapprove_all_posts_in_topic) { - continue; + $phpbb_notifications->delete_notifications('topic_in_queue', $post_data['topic_id']); } - if (isset($disapprove_reason_lang)) + // Notify Poster? + if ($notify_poster) { - // Okay we need to get the reason from the posters language - if (!isset($lang_reasons[$post_data['user_lang']])) + if ($post_data['poster_id'] == ANONYMOUS) { - // Assign the current users translation as the default, this is not ideal but getting the board default adds another layer of complexity. - $lang_reasons[$post_data['user_lang']] = $user->lang['report_reasons']['DESCRIPTION'][$disapprove_reason_lang]; + continue; + } - // Only load up the language pack if the language is different to the current one - if ($post_data['user_lang'] != $user->lang_name && file_exists($phpbb_root_path . '/language/' . $post_data['user_lang'] . '/mcp.' . $phpEx)) + $post_data['disapprove_reason'] = ''; + if (isset($disapprove_reason_lang)) + { + // Okay we need to get the reason from the posters language + if (!isset($lang_reasons[$post_data['user_lang']])) { - // Load up the language pack - $lang = array(); - @include($phpbb_root_path . '/language/' . basename($post_data['user_lang']) . '/mcp.' . $phpEx); + // Assign the current users translation as the default, this is not ideal but getting the board default adds another layer of complexity. + $lang_reasons[$post_data['user_lang']] = $user->lang['report_reasons']['DESCRIPTION'][$disapprove_reason_lang]; - // If we find the reason in this language pack use it - if (isset($lang['report_reasons']['DESCRIPTION'][$disapprove_reason_lang])) + // Only load up the language pack if the language is different to the current one + if ($post_data['user_lang'] != $user->lang_name && file_exists($phpbb_root_path . '/language/' . $post_data['user_lang'] . '/mcp.' . $phpEx)) { - $lang_reasons[$post_data['user_lang']] = $lang['report_reasons']['DESCRIPTION'][$disapprove_reason_lang]; - } + // Load up the language pack + $lang = array(); + @include($phpbb_root_path . '/language/' . basename($post_data['user_lang']) . '/mcp.' . $phpEx); + + // If we find the reason in this language pack use it + if (isset($lang['report_reasons']['DESCRIPTION'][$disapprove_reason_lang])) + { + $lang_reasons[$post_data['user_lang']] = $lang['report_reasons']['DESCRIPTION'][$disapprove_reason_lang]; + } - unset($lang); // Free memory + unset($lang); // Free memory + } } - } - $email_disapprove_reason = $lang_reasons[$post_data['user_lang']]; - $email_disapprove_reason .= ($reason) ? "\n\n" . $reason : ''; - } + $post_data['disapprove_reason'] = $lang_reasons[$post_data['user_lang']]; + $post_data['disapprove_reason'] .= ($reason) ? "\n\n" . $reason : ''; + } - $email_template = ($post_data['post_id'] == $post_data['topic_first_post_id'] && $post_data['post_id'] == $post_data['topic_last_post_id']) ? 'topic_disapproved' : 'post_disapproved'; - $messenger->template($email_template, $post_data['user_lang']); + if ($disapprove_all_posts_in_topic && $topic_information[$topic_id]['topic_posts_unapproved'] == 1) + { + // If there is only 1 post when disapproving the topic, + // we send the user a "disapprove topic" notification... + $phpbb_notifications->add_notifications('disapprove_topic', $post_data); + } + else + { + // ... otherwise there are multiple unapproved posts and + // all of them are disapproved as posts. + $phpbb_notifications->add_notifications('disapprove_post', $post_data); + } + } + } - $messenger->to($post_data['user_email'], $post_data['username']); - $messenger->im($post_data['user_jabber'], $post_data['username']); + unset($lang_reasons, $post_info, $disapprove_reason, $disapprove_reason_lang); - $messenger->assign_vars(array( - 'USERNAME' => htmlspecialchars_decode($post_data['username']), - 'REASON' => htmlspecialchars_decode($email_disapprove_reason), - 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_data['post_subject'])), - 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_data['topic_title']))) - ); - $messenger->send($post_data['user_notify_type']); + if ($num_disapproved_topics) + { + $success_msg = ($num_disapproved_topics == 1) ? 'TOPIC' : 'TOPICS'; + } + else + { + $success_msg = ($num_disapproved_posts == 1) ? 'POST' : 'POSTS'; } - unset($lang_reasons); - } - unset($post_info, $disapprove_reason, $email_disapprove_reason, $disapprove_reason_lang); - - $messenger->save_queue(); - - if ($num_disapproved_topics) - { - $success_msg = ($num_disapproved_topics == 1) ? 'TOPIC_DISAPPROVED_SUCCESS' : 'TOPICS_DISAPPROVED_SUCCESS'; + if ($is_disapproving) + { + $success_msg .= '_DISAPPROVED_SUCCESS'; + } + else + { + $success_msg .= '_DELETED_SUCCESS'; + } } else { - $success_msg = ($num_disapproved_posts == 1) ? 'POST_DISAPPROVED_SUCCESS' : 'POSTS_DISAPPROVED_SUCCESS'; - } - } - else - { - include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx); + if (!function_exists('display_reasons')) + { + include($phpbb_root_path . 'includes/functions_display.' . $phpEx); + } - display_reasons($reason_id); + $show_notify = false; - $show_notify = false; + foreach ($post_info as $post_data) + { + if ($post_data['poster_id'] == ANONYMOUS) + { + continue; + } + else + { + $show_notify = true; + break; + } + } - foreach ($post_info as $post_data) - { - if ($post_data['poster_id'] == ANONYMOUS) + $l_confirm_msg = 'DISAPPROVE_POST'; + $confirm_template = 'mcp_approve.html'; + if ($is_disapproving) { - continue; + display_reasons($reason_id); } else { - $show_notify = true; - break; + $user->add_lang('posting'); + + $l_confirm_msg = 'DELETE_POST_PERMANENTLY'; + $confirm_template = 'confirm_delete_body.html'; } + $l_confirm_msg .= ((sizeof($post_id_list) == 1) ? '' : 'S'); + + $template->assign_vars(array( + 'S_NOTIFY_POSTER' => $show_notify, + 'S_APPROVE' => false, + 'REASON' => ($is_disapproving) ? $reason : '', + 'ADDITIONAL_MSG' => $additional_msg, + )); + + confirm_box(false, $l_confirm_msg, $s_hidden_fields, $confirm_template); } - $template->assign_vars(array( - 'S_NOTIFY_POSTER' => $show_notify, - 'S_APPROVE' => false, - 'REASON' => $reason, - 'ADDITIONAL_MSG' => $additional_msg) - ); + $redirect = $request->variable('redirect', "index.$phpEx"); + $redirect = reapply_sid($redirect); - confirm_box(false, 'DISAPPROVE_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html'); - } + if (!$success_msg) + { + redirect($redirect); + } + else + { + $message = $user->lang[$success_msg] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'); - $redirect = request_var('redirect', "index.$phpEx"); - $redirect = reapply_sid($redirect); + 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' => false, + )); + } - if (!$success_msg) - { - redirect($redirect); - } - else - { - meta_refresh(3, $redirect); - trigger_error($user->lang[$success_msg] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], "<a href=\"$redirect\">", '</a>')); + meta_refresh(3, $redirect); + trigger_error($message); + } } } - -?>
\ No newline at end of file diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index b13c8b20c6..8db5bb9727 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -2,9 +2,8 @@ /** * * @package mcp -* @version $Id$ * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -34,7 +33,7 @@ class mcp_reports function main($id, $mode) { global $auth, $db, $user, $template, $cache; - global $config, $phpbb_root_path, $phpEx, $action; + global $config, $phpbb_root_path, $phpEx, $action, $phpbb_container; include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); @@ -72,7 +71,7 @@ class mcp_reports // closed reports are accessed by report id $report_id = request_var('r', 0); - $sql = 'SELECT r.post_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour + $sql = 'SELECT r.post_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, r.reported_post_text, r.reported_post_uid, r.reported_post_bitfield, r.reported_post_enable_magic_url, r.reported_post_enable_smilies, r.reported_post_enable_bbcode, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour FROM ' . REPORTS_TABLE . ' r, ' . REPORTS_REASONS_TABLE . ' rr, ' . USERS_TABLE . ' u WHERE ' . (($report_id) ? 'r.report_id = ' . $report_id : "r.post_id = $post_id") . ' AND rr.reason_id = r.reason_id @@ -88,6 +87,10 @@ class mcp_reports trigger_error('NO_REPORT'); } + $phpbb_notifications = $phpbb_container->get('notification_manager'); + + $phpbb_notifications->mark_notifications_read('report_post', $post_id, $user->data['user_id']); + if (!$report_id && $report['report_closed']) { trigger_error('REPORT_CLOSED'); @@ -95,6 +98,10 @@ class mcp_reports $post_id = $report['post_id']; $report_id = $report['report_id']; + + $parse_post_flags = $report['reported_post_enable_bbcode'] ? OPTION_FLAG_BBCODE : 0; + $parse_post_flags += $report['reported_post_enable_smilies'] ? OPTION_FLAG_SMILIES : 0; + $parse_post_flags += $report['reported_post_enable_magic_url'] ? OPTION_FLAG_LINKS : 0; $post_info = get_post_data(array($post_id), 'm_report', true); @@ -117,8 +124,9 @@ class mcp_reports $template->assign_vars(array( 'S_TOPIC_REVIEW' => true, 'S_BBCODE_ALLOWED' => $post_info['enable_bbcode'], - 'TOPIC_TITLE' => $post_info['topic_title']) - ); + 'TOPIC_TITLE' => $post_info['topic_title'], + 'REPORTED_POST_ID' => $post_id, + )); } $topic_tracking_info = $extensions = $attachments = array(); @@ -136,18 +144,7 @@ class mcp_reports $post_unread = (isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']]) ? true : false; - // Process message, leave it uncensored - $message = $post_info['post_text']; - - if ($post_info['bbcode_bitfield']) - { - include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx); - $bbcode = new bbcode($post_info['bbcode_bitfield']); - $bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']); - } - $message = bbcode_nl2br($message); - $message = smiley_text($message); $report['report_text'] = make_clickable(bbcode_nl2br($report['report_text'])); if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) @@ -168,7 +165,7 @@ class mcp_reports if (sizeof($attachments)) { $update_count = array(); - parse_attachments($post_info['forum_id'], $message, $attachments, $update_count); + parse_attachments($post_info['forum_id'], $report['reported_post_text'], $attachments, $update_count); } // Display not already displayed Attachments for this post, we already parsed them. ;) @@ -190,7 +187,7 @@ class mcp_reports 'S_CLOSE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']), 'S_POST_REPORTED' => $post_info['post_reported'], - 'S_POST_UNAPPROVED' => !$post_info['post_approved'], + 'S_POST_UNAPPROVED' => ($post_info['post_visibility'] == ITEM_UNAPPROVED), 'S_POST_LOCKED' => $post_info['post_edit_locked'], 'S_REPORT_CLOSED' => $report['report_closed'], 'S_USER_NOTES' => true, @@ -228,7 +225,7 @@ class mcp_reports 'REPORTER_NAME' => get_username_string('username', $report['user_id'], $report['username'], $report['user_colour']), 'U_VIEW_REPORTER_PROFILE' => get_username_string('profile', $report['user_id'], $report['username'], $report['user_colour']), - 'POST_PREVIEW' => $message, + 'POST_PREVIEW' => generate_text_for_display($report['reported_post_text'], $report['reported_post_uid'], $report['reported_post_bitfield'], $parse_post_flags, false), 'POST_SUBJECT' => ($post_info['post_subject']) ? $post_info['post_subject'] : $user->lang['NO_SUBJECT'], 'POST_DATE' => $user->format_date($post_info['post_time']), 'POST_IP' => $post_info['poster_ip'], @@ -296,11 +293,11 @@ class mcp_reports $global_id = $forum_list[0]; - $sql = 'SELECT SUM(forum_topics) as sum_forum_topics + $sql = 'SELECT SUM(forum_topics_approved) as sum_forum_topics 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'); + $forum_info['forum_topics_approved'] = (int) $db->sql_fetchfield('sum_forum_topics'); $db->sql_freeresult($result); } else @@ -314,7 +311,6 @@ class mcp_reports $forum_info = $forum_info[$forum_id]; $forum_list = array($forum_id); - $global_id = $forum_id; } $forum_list[] = 0; @@ -333,7 +329,7 @@ class mcp_reports $sort_by_sql = $sort_order_sql = array(); mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id); - $forum_topics = ($total == -1) ? $forum_info['forum_topics'] : $total; + $forum_topics = ($total == -1) ? $forum_info['forum_topics_approved'] : $total; $limit_time_sql = ($sort_days) ? 'AND r.report_time >= ' . (time() - ($sort_days * 86400)) : ''; if ($mode == 'reports') @@ -370,7 +366,7 @@ class mcp_reports if (sizeof($report_ids)) { - $sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, p.post_id, p.post_subject, p.post_username, p.poster_id, p.post_time, u.username, u.username_clean, u.user_colour, r.user_id as reporter_id, ru.username as reporter_name, ru.user_colour as reporter_colour, r.report_time, r.report_id + $sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, p.post_id, p.post_subject, p.post_username, p.poster_id, p.post_time, p.post_attachment, u.username, u.username_clean, u.user_colour, r.user_id as reporter_id, ru.username as reporter_name, ru.user_colour as reporter_colour, r.report_time, r.report_id FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u, ' . USERS_TABLE . ' ru WHERE ' . $db->sql_in_set('r.report_id', $report_ids) . ' AND t.topic_id = p.topic_id @@ -384,14 +380,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']}"), @@ -405,19 +395,23 @@ 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']), 'REPORT_ID' => $row['report_id'], 'REPORT_TIME' => $user->format_date($row['report_time']), - 'TOPIC_TITLE' => $row['topic_title']) - ); + 'TOPIC_TITLE' => $row['topic_title'], + 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['post_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', + )); } $db->sql_freeresult($result); unset($report_ids, $row); } + $base_url = $this->u_action . "&f=$forum_id&t=$topic_id&st=$sort_days&sk=$sort_key&sd=$sort_dir"; + phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $total, $config['topics_per_page'], $start); + // Now display the page $template->assign_vars(array( 'L_EXPLAIN' => ($mode == 'reports') ? $user->lang['MCP_REPORTS_OPEN_EXPLAIN'] : $user->lang['MCP_REPORTS_CLOSED_EXPLAIN'], @@ -428,11 +422,10 @@ class mcp_reports 'S_FORUM_OPTIONS' => $forum_options, 'S_CLOSED' => ($mode == 'reports_closed') ? true : false, - 'PAGINATION' => generate_pagination($this->u_action . "&f=$forum_id&t=$topic_id&st=$sort_days&sk=$sort_key&sd=$sort_dir", $total, $config['topics_per_page'], $start), - 'PAGE_NUMBER' => on_page($total, $config['topics_per_page'], $start), + 'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $total, $config['topics_per_page'], $start), 'TOPIC_ID' => $topic_id, 'TOTAL' => $total, - 'TOTAL_REPORTS' => ($total == 1) ? $user->lang['LIST_REPORT'] : sprintf($user->lang['LIST_REPORTS'], $total), + 'TOTAL_REPORTS' => $user->lang('LIST_REPORTS', (int) $total), ) ); @@ -448,7 +441,7 @@ class mcp_reports function close_report($report_id_list, $mode, $action, $pm = false) { global $db, $template, $user, $config, $auth; - global $phpEx, $phpbb_root_path; + global $phpEx, $phpbb_root_path, $phpbb_container; $pm_where = ($pm) ? ' AND r.post_id = 0 ' : ' AND r.pm_id = 0 '; $id_column = ($pm) ? 'pm_id' : 'post_id'; @@ -634,11 +627,11 @@ function close_report($report_id_list, $mode, $action, $pm = false) } } - $messenger = new messenger(); - // Notify reporters if (sizeof($notify_reporters)) { + $phpbb_notifications = $phpbb_container->get('notification_manager'); + foreach ($notify_reporters as $report_id => $reporter) { if ($reporter['user_id'] == ANONYMOUS) @@ -648,30 +641,25 @@ function close_report($report_id_list, $mode, $action, $pm = false) $post_id = $reporter[$id_column]; - $messenger->template((($pm) ? 'pm_report_' : 'report_') . $action . 'd', $reporter['user_lang']); - - $messenger->to($reporter['user_email'], $reporter['username']); - $messenger->im($reporter['user_jabber'], $reporter['username']); - if ($pm) { - $messenger->assign_vars(array( - 'USERNAME' => htmlspecialchars_decode($reporter['username']), - 'CLOSER_NAME' => htmlspecialchars_decode($user->data['username']), - 'PM_SUBJECT' => htmlspecialchars_decode(censor_text($post_info[$post_id]['message_subject'])), - )); + $phpbb_notifications->add_notifications('report_pm_closed', array_merge($post_info[$post_id], array( + 'reporter' => $reporter['user_id'], + 'closer_id' => $user->data['user_id'], + 'from_user_id' => $post_info[$post_id]['author_id'], + ))); + + $phpbb_notifications->delete_notifications('report_pm', $post_id); } else { - $messenger->assign_vars(array( - 'USERNAME' => htmlspecialchars_decode($reporter['username']), - 'CLOSER_NAME' => htmlspecialchars_decode($user->data['username']), - 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_info[$post_id]['post_subject'])), - 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_info[$post_id]['topic_title']))) - ); - } + $phpbb_notifications->add_notifications('report_post_closed', array_merge($post_info[$post_id], array( + 'reporter' => $reporter['user_id'], + 'closer_id' => $user->data['user_id'], + ))); - $messenger->send($reporter['user_notify_type']); + $phpbb_notifications->delete_notifications('report_post', $post_id); + } } } @@ -686,8 +674,6 @@ function close_report($report_id_list, $mode, $action, $pm = false) unset($notify_reporters, $post_info, $reports); - $messenger->save_queue(); - $success_msg = (sizeof($report_id_list) == 1) ? "{$pm_prefix}REPORT_" . strtoupper($action) . 'D_SUCCESS' : "{$pm_prefix}REPORTS_" . strtoupper($action) . 'D_SUCCESS'; } else @@ -725,5 +711,3 @@ function close_report($report_id_list, $mode, $action, $pm = false) trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_forum . $return_topic . sprintf($user->lang['RETURN_PAGE'], "<a href=\"$redirect\">", '</a>')); } } - -?>
\ No newline at end of file diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index 8e0e89e3da..9c294b96c8 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -2,9 +2,8 @@ /** * * @package mcp -* @version $Id$ * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -22,7 +21,7 @@ if (!defined('IN_PHPBB')) function mcp_topic_view($id, $mode, $action) { global $phpEx, $phpbb_root_path, $config; - global $template, $db, $user, $auth, $cache; + global $template, $db, $user, $auth, $cache, $phpbb_container; $url = append_sid("{$phpbb_root_path}mcp.$phpEx?" . extra_url()); @@ -85,8 +84,8 @@ function mcp_topic_view($id, $mode, $action) $subject = $topic_info['topic_title']; } - // Approve posts? - if ($action == 'approve' && $auth->acl_get('m_approve', $topic_info['forum_id'])) + // Restore or pprove posts? + if (($action == 'restore' || $action == 'approve') && $auth->acl_get('m_approve', $topic_info['forum_id'])) { include($phpbb_root_path . 'includes/mcp/mcp_queue.' . $phpEx); include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); @@ -99,7 +98,7 @@ function mcp_topic_view($id, $mode, $action) if (!$sort) { - approve_post($post_id_list, $id, $mode); + mcp_queue::approve_posts($action, $post_id_list, $id, $mode); } } @@ -113,17 +112,11 @@ function mcp_topic_view($id, $mode, $action) mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $topic_info['forum_id'], $topic_id, $where_sql); $limit_time_sql = ($sort_days) ? 'AND p.post_time >= ' . (time() - ($sort_days * 86400)) : ''; + $phpbb_content_visibility = $phpbb_container->get('content.visibility'); if ($total == -1) { - if ($auth->acl_get('m_approve', $topic_info['forum_id'])) - { - $total = $topic_info['topic_replies_real'] + 1; - } - else - { - $total = $topic_info['topic_replies'] + 1; - } + $total = $phpbb_content_visibility->get_count('topic_posts', $topic_info, $topic_info['forum_id']); } $posts_per_page = max(0, request_var('posts_per_page', intval($config['posts_per_page']))); @@ -146,8 +139,8 @@ function mcp_topic_view($id, $mode, $action) $sql = 'SELECT u.username, u.username_clean, u.user_colour, p.* FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u WHERE ' . (($action == 'reports') ? 'p.post_reported = 1 AND ' : '') . ' - p.topic_id = ' . $topic_id . ' ' . - ((!$auth->acl_get('m_approve', $topic_info['forum_id'])) ? ' AND p.post_approved = 1 ' : '') . ' + p.topic_id = ' . $topic_id . ' + AND ' . $phpbb_content_visibility->get_visibility_sql('post', $topic_info['forum_id'], 'p.') . ' AND p.poster_id = u.user_id ' . $limit_time_sql . ' ORDER BY ' . $sort_order_sql; @@ -183,7 +176,7 @@ function mcp_topic_view($id, $mode, $action) $topic_tracking_info = get_complete_topic_tracking($topic_info['forum_id'], $topic_id); } - $has_unapproved_posts = false; + $has_unapproved_posts = $has_deleted_posts = false; // Grab extensions $extensions = $attachments = array(); @@ -214,13 +207,8 @@ function mcp_topic_view($id, $mode, $action) $message = $row['post_text']; $post_subject = ($row['post_subject'] != '') ? $row['post_subject'] : $topic_info['topic_title']; - if ($row['bbcode_bitfield']) - { - $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']); - } - - $message = bbcode_nl2br($message); - $message = smiley_text($message); + $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; + $message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags, false); if (!empty($attachments[$row['post_id']])) { @@ -228,11 +216,16 @@ function mcp_topic_view($id, $mode, $action) parse_attachments($topic_info['forum_id'], $message, $attachments[$row['post_id']], $update_count); } - if (!$row['post_approved']) + if ($row['post_visibility'] == ITEM_UNAPPROVED) { $has_unapproved_posts = true; } + if ($row['post_visibility'] == ITEM_DELETED) + { + $has_deleted_posts = true; + } + $post_unread = (isset($topic_tracking_info[$topic_id]) && $row['post_time'] > $topic_tracking_info[$topic_id]) ? true : false; $template->assign_block_vars('postrow', array( @@ -250,7 +243,8 @@ function mcp_topic_view($id, $mode, $action) 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), 'S_POST_REPORTED' => ($row['post_reported'] && $auth->acl_get('m_report', $topic_info['forum_id'])), - 'S_POST_UNAPPROVED' => (!$row['post_approved'] && $auth->acl_get('m_approve', $topic_info['forum_id'])), + 'S_POST_UNAPPROVED' => ($row['post_visibility'] == ITEM_UNAPPROVED && $auth->acl_get('m_approve', $topic_info['forum_id'])), + 'S_POST_DELETED' => ($row['post_visibility'] == ITEM_DELETED && $auth->acl_get('m_approve', $topic_info['forum_id'])), 'S_CHECKED' => (($submitted_id_list && !in_array(intval($row['post_id']), $submitted_id_list)) || in_array(intval($row['post_id']), $checked_ids)) ? true : false, 'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false, @@ -307,6 +301,12 @@ function mcp_topic_view($id, $mode, $action) 'post_ids' => $post_id_list, )); + $base_url = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&t={$topic_info['topic_id']}&mode=$mode&action=$action&to_topic_id=$to_topic_id&posts_per_page=$posts_per_page&st=$sort_days&sk=$sort_key&sd=$sort_dir"); + if ($posts_per_page) + { + phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $total, $posts_per_page, $start); + } + $template->assign_vars(array( 'TOPIC_TITLE' => $topic_info['topic_title'], 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $topic_info['forum_id'] . '&t=' . $topic_info['topic_id']), @@ -320,6 +320,7 @@ function mcp_topic_view($id, $mode, $action) 'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'), + 'DELETED_IMG' => $user->img('icon_topic_deleted', 'POST_DELETED_RESTORE'), 'INFO_IMG' => $user->img('icon_post_info', 'VIEW_INFO'), 'S_MCP_ACTION' => "$url&i=$id&mode=$mode&action=$action&start=$start", @@ -328,6 +329,7 @@ function mcp_topic_view($id, $mode, $action) 'S_CAN_MERGE' => ($auth->acl_get('m_merge', $topic_info['forum_id'])) ? true : false, 'S_CAN_DELETE' => ($auth->acl_get('m_delete', $topic_info['forum_id'])) ? true : false, 'S_CAN_APPROVE' => ($has_unapproved_posts && $auth->acl_get('m_approve', $topic_info['forum_id'])) ? true : false, + 'S_CAN_RESTORE' => ($has_deleted_posts && $auth->acl_get('m_approve', $topic_info['forum_id'])) ? true : false, 'S_CAN_LOCK' => ($auth->acl_get('m_lock', $topic_info['forum_id'])) ? true : false, 'S_CAN_REPORT' => ($auth->acl_get('m_report', $topic_info['forum_id'])) ? true : false, 'S_CAN_SYNC' => $auth->acl_get('m_', $topic_info['forum_id']), @@ -345,9 +347,8 @@ function mcp_topic_view($id, $mode, $action) 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$topic_info['forum_id']}&t={$topic_info['topic_id']}&start=$start") . '">', '</a>'), 'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", "f={$topic_info['forum_id']}&start=$start") . '">', '</a>'), - 'PAGE_NUMBER' => on_page($total, $posts_per_page, $start), - 'PAGINATION' => (!$posts_per_page) ? '' : generate_pagination(append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&t={$topic_info['topic_id']}&mode=$mode&action=$action&to_topic_id=$to_topic_id&posts_per_page=$posts_per_page&st=$sort_days&sk=$sort_key&sd=$sort_dir"), $total, $posts_per_page, $start), - 'TOTAL_POSTS' => ($total == 1) ? $user->lang['VIEW_TOPIC_POST'] : sprintf($user->lang['VIEW_TOPIC_POSTS'], $total), + 'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $total, $posts_per_page, $start), + 'TOTAL_POSTS' => $user->lang('VIEW_TOPIC_POSTS', (int) $total), )); } @@ -444,7 +445,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject) if ($sort_order_sql[0] == 'u') { - $sql = 'SELECT p.post_id, p.forum_id, p.post_approved + $sql = 'SELECT p.post_id, p.forum_id, p.post_visibility FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u WHERE p.topic_id = $topic_id AND p.poster_id = u.user_id @@ -453,7 +454,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject) } else { - $sql = 'SELECT p.post_id, p.forum_id, p.post_approved + $sql = 'SELECT p.post_id, p.forum_id, p.post_visibility FROM ' . POSTS_TABLE . " p WHERE p.topic_id = $topic_id $limit_time_sql @@ -466,7 +467,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject) while ($row = $db->sql_fetchrow($result)) { // If split from selected post (split_beyond), we split the unapproved items too. - if (!$row['post_approved'] && !$auth->acl_get('m_approve', $row['forum_id'])) + if ($row['post_visibility'] == ITEM_UNAPPROVED && !$auth->acl_get('m_approve', $row['forum_id'])) { // continue; } @@ -493,10 +494,10 @@ function split_topic($action, $topic_id, $to_forum_id, $subject) $icon_id = request_var('icon', 0); $sql_ary = array( - 'forum_id' => $to_forum_id, - 'topic_title' => $subject, - 'icon_id' => $icon_id, - 'topic_approved'=> 1 + 'forum_id' => $to_forum_id, + 'topic_title' => $subject, + 'icon_id' => $icon_id, + 'topic_visibility' => 1 ); $sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); @@ -573,7 +574,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject) confirm_box(false, ($action == 'split_all') ? 'SPLIT_TOPIC_ALL' : 'SPLIT_TOPIC_BEYOND', $s_hidden_fields); } - $redirect = request_var('redirect', "index.$phpEx"); + $redirect = request_var('redirect', "{$phpbb_root_path}viewtopic.$phpEx?f=$to_forum_id&t=$to_topic_id"); $redirect = reapply_sid($redirect); if (!$success_msg) @@ -582,7 +583,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject) } else { - meta_refresh(3, append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$to_forum_id&t=$to_topic_id")); + meta_refresh(3, $redirect); trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link); } } @@ -682,7 +683,7 @@ function merge_posts($topic_id, $to_topic_id) confirm_box(false, 'MERGE_POSTS', $s_hidden_fields); } - $redirect = request_var('redirect', "index.$phpEx"); + $redirect = request_var('redirect', "{$phpbb_root_path}viewtopic.$phpEx?f=$to_forum_id&t=$to_topic_id"); $redirect = reapply_sid($redirect); if (!$success_msg) @@ -691,9 +692,7 @@ function merge_posts($topic_id, $to_topic_id) } else { - meta_refresh(3, append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$to_forum_id&t=$to_topic_id")); + meta_refresh(3, $redirect); trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link); } } - -?>
\ No newline at end of file diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php index 1016204ff8..3ffd75ac78 100644 --- a/phpBB/includes/mcp/mcp_warn.php +++ b/phpBB/includes/mcp/mcp_warn.php @@ -2,9 +2,8 @@ /** * * @package mcp -* @version $Id$ * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -176,6 +175,9 @@ class mcp_warn )); } + $base_url = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=warn&mode=list&st=$st&sk=$sk&sd=$sd"); + phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $user_count, $config['topics_per_page'], $start); + $template->assign_vars(array( 'U_POST_ACTION' => $this->u_action, 'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false, @@ -183,9 +185,8 @@ class mcp_warn 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days, - 'PAGE_NUMBER' => on_page($user_count, $config['topics_per_page'], $start), - 'PAGINATION' => generate_pagination(append_sid("{$phpbb_root_path}mcp.$phpEx", "i=warn&mode=list&st=$st&sk=$sk&sd=$sd"), $user_count, $config['topics_per_page'], $start), - 'TOTAL_USERS' => ($user_count == 1) ? $user->lang['LIST_USER'] : sprintf($user->lang['LIST_USERS'], $user_count), + 'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $user_count, $config['topics_per_page'], $start), + 'TOTAL_USERS' => $user->lang('LIST_USERS', (int) $user_count), )); } @@ -252,7 +253,7 @@ class mcp_warn // Check if can send a notification if ($config['allow_privmsg']) { - $auth2 = new auth(); + $auth2 = new \phpbb\auth\auth(); $auth2->acl($user_row); $s_can_notify = ($auth2->acl_get('u_readpm')) ? true : false; unset($auth2); @@ -288,28 +289,17 @@ class mcp_warn // We want to make the message available here as a reminder // Parse the message and subject - $message = censor_text($user_row['post_text']); - - // Second parse bbcode here - if ($user_row['bbcode_bitfield']) - { - include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx); - - $bbcode = new bbcode($user_row['bbcode_bitfield']); - $bbcode->bbcode_second_pass($message, $user_row['bbcode_uid'], $user_row['bbcode_bitfield']); - } - - $message = bbcode_nl2br($message); - $message = smiley_text($message); + $parse_flags = OPTION_FLAG_SMILIES | ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0); + $message = generate_text_for_display($user_row['post_text'], $user_row['bbcode_uid'], $user_row['bbcode_bitfield'], $parse_flags, true); // Generate the appropriate user information for the user we are looking at - if (!function_exists('get_user_avatar')) + if (!function_exists('phpbb_get_user_avatar')) { include($phpbb_root_path . 'includes/functions_display.' . $phpEx); } get_user_rank($user_row['user_rank'], $user_row['user_posts'], $rank_title, $rank_img, $rank_img_src); - $avatar_img = get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height']); + $avatar_img = phpbb_get_user_avatar($user_row); $template->assign_vars(array( 'U_POST_ACTION' => $this->u_action, @@ -375,7 +365,7 @@ class mcp_warn // Check if can send a notification if ($config['allow_privmsg']) { - $auth2 = new auth(); + $auth2 = new \phpbb\auth\auth(); $auth2->acl($user_row); $s_can_notify = ($auth2->acl_get('u_readpm')) ? true : false; unset($auth2); @@ -408,13 +398,13 @@ class mcp_warn } // Generate the appropriate user information for the user we are looking at - if (!function_exists('get_user_avatar')) + if (!function_exists('phpbb_get_user_avatar')) { include($phpbb_root_path . 'includes/functions_display.' . $phpEx); } get_user_rank($user_row['user_rank'], $user_row['user_posts'], $rank_title, $rank_img, $rank_img_src); - $avatar_img = get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height']); + $avatar_img = phpbb_get_user_avatar($user_row); // OK, they didn't submit a warning so lets build the page for them to do so $template->assign_vars(array( @@ -507,5 +497,3 @@ function add_warning($user_row, $warning, $send_pm = true, $post_id = 0) add_log('mod', $row['forum_id'], $row['topic_id'], 'LOG_USER_WARNING', $user_row['username']); } - -?>
\ No newline at end of file |