diff options
Diffstat (limited to 'phpBB/includes/mcp')
| -rw-r--r-- | phpBB/includes/mcp/info/mcp_ban.php | 16 | ||||
| -rw-r--r-- | phpBB/includes/mcp/info/mcp_logs.php | 16 | ||||
| -rw-r--r-- | phpBB/includes/mcp/info/mcp_main.php | 16 | ||||
| -rw-r--r-- | phpBB/includes/mcp/info/mcp_notes.php | 16 | ||||
| -rw-r--r-- | phpBB/includes/mcp/info/mcp_pm_reports.php | 16 | ||||
| -rw-r--r-- | phpBB/includes/mcp/info/mcp_queue.php | 18 | ||||
| -rw-r--r-- | phpBB/includes/mcp/info/mcp_reports.php | 16 | ||||
| -rw-r--r-- | phpBB/includes/mcp/info/mcp_warn.php | 16 | ||||
| -rw-r--r-- | phpBB/includes/mcp/mcp_ban.php | 20 | ||||
| -rw-r--r-- | phpBB/includes/mcp/mcp_forum.php | 114 | ||||
| -rw-r--r-- | phpBB/includes/mcp/mcp_front.php | 144 | ||||
| -rw-r--r-- | phpBB/includes/mcp/mcp_logs.php | 55 | ||||
| -rw-r--r-- | phpBB/includes/mcp/mcp_main.php | 806 | ||||
| -rw-r--r-- | phpBB/includes/mcp/mcp_notes.php | 30 | ||||
| -rw-r--r-- | phpBB/includes/mcp/mcp_pm_reports.php | 51 | ||||
| -rw-r--r-- | phpBB/includes/mcp/mcp_post.php | 85 | ||||
| -rw-r--r-- | phpBB/includes/mcp/mcp_queue.php | 1231 | ||||
| -rw-r--r-- | phpBB/includes/mcp/mcp_reports.php | 137 | ||||
| -rw-r--r-- | phpBB/includes/mcp/mcp_topic.php | 168 | ||||
| -rw-r--r-- | phpBB/includes/mcp/mcp_warn.php | 183 | 
20 files changed, 1822 insertions, 1332 deletions
| diff --git a/phpBB/includes/mcp/info/mcp_ban.php b/phpBB/includes/mcp/info/mcp_ban.php index 383df30498..4aedbc8558 100644 --- a/phpBB/includes/mcp/info/mcp_ban.php +++ b/phpBB/includes/mcp/info/mcp_ban.php @@ -1,16 +1,16 @@  <?php  /**  * -* @package mcp -* @version $Id$ -* @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file.  *  */ -/** -* @package module_install -*/  class mcp_ban_info  {  	function module() @@ -35,5 +35,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..c6482c1255 100644 --- a/phpBB/includes/mcp/info/mcp_logs.php +++ b/phpBB/includes/mcp/info/mcp_logs.php @@ -1,16 +1,16 @@  <?php  /**  * -* @package mcp -* @version $Id$ -* @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file.  *  */ -/** -* @package module_install -*/  class mcp_logs_info  {  	function module() @@ -35,5 +35,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..81ccdbd1cd 100644 --- a/phpBB/includes/mcp/info/mcp_main.php +++ b/phpBB/includes/mcp/info/mcp_main.php @@ -1,16 +1,16 @@  <?php  /**  * -* @package mcp -* @version $Id$ -* @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file.  *  */ -/** -* @package module_install -*/  class mcp_main_info  {  	function module() @@ -36,5 +36,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..4b8c255fe2 100644 --- a/phpBB/includes/mcp/info/mcp_notes.php +++ b/phpBB/includes/mcp/info/mcp_notes.php @@ -1,16 +1,16 @@  <?php  /**  * -* @package mcp -* @version $Id$ -* @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file.  *  */ -/** -* @package module_install -*/  class mcp_notes_info  {  	function module() @@ -34,5 +34,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 84f15b7107..8670b71084 100644 --- a/phpBB/includes/mcp/info/mcp_pm_reports.php +++ b/phpBB/includes/mcp/info/mcp_pm_reports.php @@ -1,16 +1,16 @@  <?php  /**  * -* @package mcp -* @version $Id$ -* @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file.  *  */ -/** -* @package module_install -*/  class mcp_pm_reports_info  {  	function module() @@ -35,5 +35,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..556c3902b0 100644 --- a/phpBB/includes/mcp/info/mcp_queue.php +++ b/phpBB/includes/mcp/info/mcp_queue.php @@ -1,16 +1,16 @@  <?php  /**  * -* @package mcp -* @version $Id$ -* @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file.  *  */ -/** -* @package module_install -*/  class mcp_queue_info  {  	function module() @@ -22,6 +22,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 +37,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..31fee19d79 100644 --- a/phpBB/includes/mcp/info/mcp_reports.php +++ b/phpBB/includes/mcp/info/mcp_reports.php @@ -1,16 +1,16 @@  <?php  /**  * -* @package mcp -* @version $Id$ -* @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file.  *  */ -/** -* @package module_install -*/  class mcp_reports_info  {  	function module() @@ -35,5 +35,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..d85499f280 100644 --- a/phpBB/includes/mcp/info/mcp_warn.php +++ b/phpBB/includes/mcp/info/mcp_warn.php @@ -1,16 +1,16 @@  <?php  /**  * -* @package mcp -* @version $Id$ -* @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file.  *  */ -/** -* @package module_install -*/  class mcp_warn_info  {  	function module() @@ -36,5 +36,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..e6fac3b80c 100644 --- a/phpBB/includes/mcp/mcp_ban.php +++ b/phpBB/includes/mcp/mcp_ban.php @@ -1,10 +1,13 @@  <?php  /**  * -* @package mcp -* @version $Id$ -* @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file.  *  */ @@ -16,9 +19,6 @@ if (!defined('IN_PHPBB'))  	exit;  } -/** -* @package mcp -*/  class mcp_ban  {  	var $u_action; @@ -172,7 +172,7 @@ class mcp_ban  				case 'user':  					$pre_fill = (string) $db->sql_fetchfield('username');  				break; -				 +  				case 'ip':  					$pre_fill = (string) $db->sql_fetchfield('user_ip');  				break; @@ -185,7 +185,7 @@ class mcp_ban  		}  		else if ($post_id)  		{ -			$post_info = get_post_data($post_id, 'm_ban'); +			$post_info = phpbb_get_post_data($post_id, 'm_ban');  			if (sizeof($post_info) && !empty($post_info[$post_id]))  			{ @@ -215,5 +215,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..0c6acaa908 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -1,10 +1,13 @@  <?php  /**  * -* @package mcp -* @version $Id$ -* @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file.  *  */ @@ -23,6 +26,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 +38,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']; @@ -70,6 +77,8 @@ function mcp_forum_view($id, $mode, $action, $forum_info)  		break;  	} +	$pagination = $phpbb_container->get('pagination'); +  	$selected_ids = '';  	if (sizeof($post_id_list) && $action != 'merge_topics')  	{ @@ -93,11 +102,14 @@ function mcp_forum_view($id, $mode, $action, $forum_info)  	$sort_days = $total = 0;  	$sort_key = $sort_dir = '';  	$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); +	phpbb_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 : ''); +	$pagination->generate_template_pagination($base_url, 'pagination', 'start', $forum_topics, $topics_per_page, $start); +  	$template->assign_vars(array(  		'ACTION'				=> $action,  		'FORUM_NAME'			=> $forum_info['forum_name'], @@ -110,6 +122,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 +139,7 @@ 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), +		'TOTAL_TOPICS'			=> $user->lang('VIEW_FORUM_TOPICS', (int) $forum_topics),  	));  	// Grab icons @@ -146,10 +157,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 +197,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 +211,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 +228,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 || $row['topic_visibility'] == ITEM_REAPPROVE)  && $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 +256,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 +265,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 +300,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.0-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); @@ -300,7 +328,7 @@ function mcp_resync_topics($topic_ids)  		trigger_error('NO_TOPIC_SELECTED');  	} -	if (!check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_'))) +	if (!phpbb_check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_')))  	{  		return;  	} @@ -350,14 +378,22 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id)  		return;  	} -	$topic_data = get_topic_data(array($to_topic_id), 'm_merge'); +	$sync_topics = array_merge($topic_ids, array($to_topic_id)); -	if (!sizeof($topic_data)) +	$topic_data = phpbb_get_topic_data($sync_topics, 'm_merge'); + +	if (!sizeof($topic_data) || empty($topic_data[$to_topic_id]))  	{  		$template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']);  		return;  	} +	$sync_forums = array(); +	foreach ($topic_data as $data) +	{ +		$sync_forums[$data['forum_id']] = $data['forum_id']; +	} +  	$topic_data = $topic_data[$to_topic_id];  	$post_id_list	= request_var('post_id_list', array(0)); @@ -384,7 +420,7 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id)  		return;  	} -	if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_merge'))) +	if (!phpbb_check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_merge')))  	{  		return;  	} @@ -408,7 +444,7 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id)  	{  		$to_forum_id = $topic_data['forum_id']; -		move_posts($post_id_list, $to_topic_id); +		move_posts($post_id_list, $to_topic_id, false);  		add_log('mod', $to_forum_id, $to_topic_id, 'LOG_MERGE', $topic_data['topic_title']);  		// Message and return links @@ -425,26 +461,22 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id)  		// Update the bookmarks table.  		phpbb_update_rows_avoiding_duplicates($db, BOOKMARKS_TABLE, 'topic_id', $topic_ids, $to_topic_id); +		// Re-sync the topics and forums because the auto-sync was deactivated in the call of  move_posts() +		sync('topic_reported', 'topic_id', $sync_topics); +		sync('topic_attachment', 'topic_id', $sync_topics); +		sync('topic', 'topic_id', $sync_topics, true); +		sync('forum', 'forum_id', $sync_forums, true, true); +  		// Link to the new topic  		$return_link .= (($return_link) ? '<br /><br />' : '') . sprintf($user->lang['RETURN_NEW_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $to_forum_id . '&t=' . $to_topic_id) . '">', '</a>'); -	} -	else -	{ -		confirm_box(false, 'MERGE_TOPICS', $s_hidden_fields); -	} - -	$redirect = request_var('redirect', "index.$phpEx"); -	$redirect = reapply_sid($redirect); +		$redirect = request_var('redirect', "{$phpbb_root_path}viewtopic.$phpEx?f=$to_forum_id&t=$to_topic_id"); +		$redirect = reapply_sid($redirect); -	if (!$success_msg) -	{ -		return; +		meta_refresh(3, $redirect); +		trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link);  	}  	else  	{ -		meta_refresh(3, append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$to_forum_id&t=$to_topic_id")); -		trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link); +		confirm_box(false, 'MERGE_TOPICS', $s_hidden_fields);  	}  } - -?>
\ No newline at end of file diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php index af262baa29..04206a6fcd 100644 --- a/phpBB/includes/mcp/mcp_front.php +++ b/phpBB/includes/mcp/mcp_front.php @@ -1,10 +1,13 @@  <?php  /**  * -* @package mcp -* @version $Id$ -* @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file.  *  */ @@ -39,16 +42,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 ' . $db->sql_in_set('post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE));  			$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 +63,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 ' . $db->sql_in_set('post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)) . '  					ORDER BY post_time DESC';  				$result = $db->sql_query_limit($sql, 5); @@ -81,7 +82,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 +92,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 +104,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 +122,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 +142,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 +174,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 +200,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 +236,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 +253,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 +288,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 +306,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 +332,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..92dcdb5499 100644 --- a/phpBB/includes/mcp/mcp_logs.php +++ b/phpBB/includes/mcp/mcp_logs.php @@ -1,10 +1,13 @@  <?php  /**  * -* @package mcp -* @version $Id$ -* @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file.  *  */ @@ -19,7 +22,6 @@ if (!defined('IN_PHPBB'))  /**  * mcp_logs  * Handling warning the users -* @package mcp  */  class mcp_logs  { @@ -34,7 +36,7 @@ class mcp_logs  	function main($id, $mode)  	{  		global $auth, $db, $user, $template; -		global $config, $phpbb_root_path, $phpEx; +		global $config, $phpbb_root_path, $phpEx, $phpbb_container, $phpbb_log;  		$user->add_lang('acp/common'); @@ -63,6 +65,8 @@ class mcp_logs  		$this->tpl_name = 'mcp_logs';  		$this->page_title = 'MCP_LOGS'; +		$pagination = $phpbb_container->get('pagination'); +  		$forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_')));  		$forum_list[] = 0; @@ -110,27 +114,33 @@ class mcp_logs  			{  				if ($deletemark && sizeof($marked))  				{ -					$sql = 'DELETE FROM ' . LOG_TABLE . ' -						WHERE log_type = ' . LOG_MOD . ' -							AND ' . $db->sql_in_set('forum_id', $forum_list) . ' -							AND ' . $db->sql_in_set('log_id', $marked); -					$db->sql_query($sql); +					$conditions = array( +						'forum_id'	=> array('IN' => $forum_list), +						'log_id'	=> array('IN' => $marked), +					); -					add_log('admin', 'LOG_CLEAR_MOD'); +					$phpbb_log->delete('mod', $conditions);  				}  				else if ($deleteall)  				{ -					$sql = 'DELETE FROM ' . LOG_TABLE . ' -						WHERE log_type = ' . LOG_MOD . ' -							AND ' . $db->sql_in_set('forum_id', $forum_list); +					$keywords = utf8_normalize_nfc(request_var('keywords', '', true)); + +					$conditions = array( +						'forum_id'	=> array('IN' => $forum_list), +						'keywords'	=> $keywords, +					); + +					if ($sort_days) +					{ +						$conditions['log_time'] = array('>=', time() - ($sort_days * 86400)); +					}  					if ($mode == 'topic_logs')  					{ -						$sql .= ' AND topic_id = ' . $topic_id; +						$conditions['topic_logs'] = $topic_id;  					} -					$db->sql_query($sql); -					add_log('admin', 'LOG_CLEAR_MOD'); +					$phpbb_log->delete('mod', $conditions);  				}  			}  			else @@ -172,10 +182,11 @@ 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"; +		$pagination->generate_template_pagination($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), +			'TOTAL'				=> $user->lang('TOTAL_LOGS', (int) $log_count),  			'L_TITLE'			=> $user->lang['MCP_LOGS'], @@ -214,5 +225,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..9f6125f256 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -1,10 +1,13 @@  <?php  /**  * -* @package mcp -* @version $Id$ -* @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file.  *  */ @@ -19,7 +22,6 @@ if (!defined('IN_PHPBB'))  /**  * mcp_main  * Handling mcp actions -* @package mcp  */  class mcp_main  { @@ -34,7 +36,8 @@ 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; +		global $phpbb_dispatcher;  		$quickmod = ($mode == 'quickmod') ? true : false; @@ -109,27 +112,58 @@ 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, $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, $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; + +			default: +				/** +				* This event allows you to handle custom quickmod options +				* +				* @event core.modify_quickmod_actions +				* @since 3.1.0-a4 +				*/ +				$phpbb_dispatcher->dispatch('core.modify_quickmod_actions');  			break;  		} @@ -153,7 +187,7 @@ class mcp_main  				$forum_id = request_var('f', 0); -				$forum_info = get_forum_data($forum_id, 'm_', true); +				$forum_info = phpbb_get_forum_data($forum_id, 'm_', true);  				if (!sizeof($forum_info))  				{ @@ -199,7 +233,7 @@ class mcp_main  */  function lock_unlock($action, $ids)  { -	global $auth, $user, $db, $phpEx, $phpbb_root_path; +	global $auth, $user, $db, $phpEx, $phpbb_root_path, $request;  	if ($action == 'lock' || $action == 'unlock')  	{ @@ -218,7 +252,7 @@ function lock_unlock($action, $ids)  	$orig_ids = $ids; -	if (!check_ids($ids, $table, $sql_id, array('m_lock'))) +	if (!phpbb_check_ids($ids, $table, $sql_id, array('m_lock')))  	{  		// Make sure that for f_user_lock only the lock action is triggered.  		if ($action != 'lock') @@ -228,7 +262,7 @@ function lock_unlock($action, $ids)  		$ids = $orig_ids; -		if (!check_ids($ids, $table, $sql_id, array('f_user_lock'))) +		if (!phpbb_check_ids($ids, $table, $sql_id, array('f_user_lock')))  		{  			return;  		} @@ -236,6 +270,7 @@ function lock_unlock($action, $ids)  	unset($orig_ids);  	$redirect = request_var('redirect', build_url(array('action', 'quickmod'))); +	$redirect = reapply_sid($redirect);  	$s_hidden_fields = build_hidden_fields(array(  		$sql_id . '_list'	=> $ids, @@ -251,7 +286,7 @@ function lock_unlock($action, $ids)  			WHERE ' . $db->sql_in_set($sql_id, $ids);  		$db->sql_query($sql); -		$data = ($action == 'lock' || $action == 'unlock') ? get_topic_data($ids) : get_post_data($ids); +		$data = ($action == 'lock' || $action == 'unlock') ? phpbb_get_topic_data($ids) : phpbb_get_post_data($ids);  		foreach ($data as $id => $row)  		{ @@ -259,24 +294,22 @@ function lock_unlock($action, $ids)  		}  		$success_msg = $l_prefix . ((sizeof($ids) == 1) ? '' : 'S') . '_' . (($action == 'lock' || $action == 'lock_post') ? 'LOCKED' : 'UNLOCKED') . '_SUCCESS'; -	} -	else -	{ -		confirm_box(false, strtoupper($action) . '_' . $l_prefix . ((sizeof($ids) == 1) ? '' : 'S'), $s_hidden_fields); -	} -	$redirect = request_var('redirect', "index.$phpEx"); -	$redirect = reapply_sid($redirect); +		meta_refresh(2, $redirect); +		$message = $user->lang[$success_msg]; -	if (!$success_msg) -	{ -		redirect($redirect); +		if (!$request->is_ajax()) +		{ +			$message .= '<br /><br />' . $user->lang('RETURN_PAGE', '<a href="' . $redirect . '">', '</a>'); +		} +		trigger_error($message);  	}  	else  	{ -		meta_refresh(2, $redirect); -		trigger_error($user->lang[$success_msg] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>')); +		confirm_box(false, strtoupper($action) . '_' . $l_prefix . ((sizeof($ids) == 1) ? '' : 'S'), $s_hidden_fields);  	} + +	redirect($redirect);  }  /** @@ -284,7 +317,7 @@ function lock_unlock($action, $ids)  */  function change_topic_type($action, $topic_ids)  { -	global $auth, $user, $db, $phpEx, $phpbb_root_path; +	global $auth, $user, $db, $phpEx, $phpbb_root_path, $request;  	switch ($action)  	{ @@ -313,7 +346,7 @@ function change_topic_type($action, $topic_ids)  		break;  	} -	$forum_id = check_ids($topic_ids, TOPICS_TABLE, 'topic_id', $check_acl, true); +	$forum_id = phpbb_check_ids($topic_ids, TOPICS_TABLE, 'topic_id', $check_acl, true);  	if ($forum_id === false)  	{ @@ -321,6 +354,7 @@ function change_topic_type($action, $topic_ids)  	}  	$redirect = request_var('redirect', build_url(array('action', 'quickmod'))); +	$redirect = reapply_sid($redirect);  	$s_hidden_fields = array(  		'topic_id_list'	=> $topic_ids, @@ -332,196 +366,51 @@ 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';  		if (sizeof($topic_ids))  		{ -			$data = get_topic_data($topic_ids); +			$data = phpbb_get_topic_data($topic_ids);  			foreach ($data as $topic_id => $row)  			{  				add_log('mod', $forum_id, $topic_id, 'LOG_TOPIC_TYPE_CHANGED', $row['topic_title']);  			}  		} -	} -	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']) -			); +		meta_refresh(2, $redirect); +		$message = $user->lang[$success_msg]; -			confirm_box(false, $l_new_type, build_hidden_fields($s_hidden_fields), 'mcp_move.html'); -		} -		else +		if (!$request->is_ajax())  		{ -			confirm_box(false, $l_new_type, build_hidden_fields($s_hidden_fields)); +			$message .= '<br /><br />' . $user->lang('RETURN_PAGE', '<a href="' . $redirect . '">', '</a>');  		} -	} - -	$redirect = request_var('redirect', "index.$phpEx"); -	$redirect = reapply_sid($redirect); - -	if (!$success_msg) -	{ -		redirect($redirect); +		trigger_error($message);  	}  	else  	{ -		meta_refresh(2, $redirect); -		trigger_error($user->lang[$success_msg] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>')); +		confirm_box(false, $l_new_type, build_hidden_fields($s_hidden_fields));  	} + +	redirect($redirect);  }  /** @@ -529,11 +418,11 @@ function change_topic_type($action, $topic_ids)  */  function mcp_move_topic($topic_ids)  { -	global $auth, $user, $db, $template; +	global $auth, $user, $db, $template, $phpbb_log, $request;  	global $phpEx, $phpbb_root_path;  	// Here we limit the operation to one forum only -	$forum_id = check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_move'), true); +	$forum_id = phpbb_check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_move'), true);  	if ($forum_id === false)  	{ @@ -553,7 +442,7 @@ function mcp_move_topic($topic_ids)  	if ($to_forum_id)  	{ -		$forum_data = get_forum_data($to_forum_id, 'f_post'); +		$forum_data = phpbb_get_forum_data($to_forum_id, 'f_post');  		if (!sizeof($forum_data))  		{ @@ -584,13 +473,13 @@ 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))  	{ -		$topic_data = get_topic_data($topic_ids); +		$topic_data = phpbb_get_topic_data($topic_ids);  		$leave_shadow = (isset($_POST['move_leave_shadow'])) ? true : false;  		$forum_sync_data = array(); @@ -598,98 +487,77 @@ 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) +			else if ($topic_info['topic_visibility'] == ITEM_UNAPPROVED || $topic_info['topic_visibility'] == ITEM_REAPPROVE)  			{ -				$topics_removed++; -				$topic_posts_removed += $topic_info['topic_replies']; - -				if ($topic_info['topic_approved']) -				{ -					$topics_authed_removed++; -					$topic_posts_removed++; -				} +				$topics_moved_unapproved++; +			} +			else if ($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)  		{ -			// Get the list of forums to resync, add a log entry +			// Get the list of forums to resync  			$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); -			} +			// We add the $to_forum_id twice, because 'forum_id' is updated +			// when the topic is moved again later. +			$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_MOVE', false, array( +				'forum_id'		=> (int) $to_forum_id, +				'topic_id'		=> (int) $topic_id, +				$row['forum_name'], +				$forum_data['forum_name'], +				(int) $row['forum_id'], +				(int) $forum_data['forum_id'], +			));  			// 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'], @@ -699,7 +567,7 @@ function mcp_move_topic($topic_ids)  					'topic_last_poster_id'	=>	(int) $row['topic_last_poster_id'],  					'topic_last_poster_colour'=>(string) $row['topic_last_poster_colour'],  					'topic_last_poster_name'=>	(string) $row['topic_last_poster_name'], -					'topic_last_post_subject'=>	(string)  $row['topic_last_post_subject'], +					'topic_last_post_subject'=>	(string) $row['topic_last_post_subject'],  					'topic_last_post_time'	=>	(int) $row['topic_last_post_time'],  					'topic_last_view_time'	=>	(int) $row['topic_last_view_time'],  					'topic_moved_id'		=>	(int) $row['topic_id'], @@ -715,25 +583,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[$forum_id][]	= 'forum_topics = forum_topics - ' . (int) $topics_authed_removed; +			$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[$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 +643,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 +671,98 @@ function mcp_move_topic($topic_ids)  }  /** -* Delete Topics +* Restore Topics  */ -function mcp_delete_topic($topic_ids) +function mcp_restore_topic($topic_ids)  { -	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'))) +	if (!phpbb_check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_approve')))  	{  		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(  		'topic_id_list'	=> $topic_ids,  		'f'				=> $forum_id, -		'action'		=> 'delete_topic', -		'redirect'		=> $redirect) +		'action'		=> 'restore_topic', +		'redirect'		=> $redirect, +	)); +	$success_msg = ''; + +	if (confirm_box(true)) +	{ +		$success_msg = (sizeof($topic_ids) == 1) ? 'TOPIC_RESTORED_SUCCESS' : 'TOPICS_RESTORED_SUCCESS'; + +		$data = phpbb_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, $is_soft = false, $soft_delete_reason = '', $action = 'delete_topic') +{ +	global $auth, $user, $db, $phpEx, $phpbb_root_path, $request, $phpbb_container; + +	if (!phpbb_check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_delete'))) +	{ +		return; +	} + +	$redirect = $request->variable('redirect', build_url(array('action', 'quickmod'))); +	$forum_id = $request->variable('f', 0); + +	$s_hidden_fields = array( +		'topic_id_list'	=> $topic_ids, +		'f'				=> $forum_id, +		'action'		=> $action, +		'redirect'		=> $redirect,  	);  	$success_msg = ''; @@ -808,7 +770,7 @@ function mcp_delete_topic($topic_ids)  	{  		$success_msg = (sizeof($topic_ids) == 1) ? 'TOPIC_DELETED_SUCCESS' : 'TOPICS_DELETED_SUCCESS'; -		$data = get_topic_data($topic_ids); +		$data = phpbb_get_topic_data($topic_ids);  		foreach ($data as $topic_id => $row)  		{ @@ -818,23 +780,80 @@ 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'], $soft_delete_reason); +					} +				} +				else +				{ +					add_log('mod', $row['forum_id'], $topic_id, 'LOG_DELETE_TOPIC', $row['topic_title'], $row['topic_first_poster_name'], $soft_delete_reason); +				}  			}  		} -		$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), +		)); + +		$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 +874,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 (!phpbb_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 = phpbb_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) ? $user->lang['POST_DELETED_SUCCESS'] : $user->lang['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, $soft_delete_reason); +		} + +		$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'))  		{ @@ -899,12 +984,12 @@ function mcp_delete_post($post_ids)  		$affected_topics = sizeof($topic_id_list);  		$db->sql_freeresult($result); -		$post_data = get_post_data($post_ids); +		$post_data = phpbb_get_post_data($post_ids);  		foreach ($post_data as $id => $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_DELETE_POST', $row['post_subject'], $post_username); +			add_log('mod', $row['forum_id'], $row['topic_id'], 'LOG_DELETE_POST', $row['post_subject'], $post_username, $soft_delete_reason);  		}  		// Now delete the posts, topics and forums are automatically resync'ed @@ -918,7 +1003,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 +1041,44 @@ 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), +		)); + +		$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) @@ -986,7 +1105,7 @@ function mcp_fork_topic($topic_ids)  	global $auth, $user, $db, $template, $config;  	global $phpEx, $phpbb_root_path; -	if (!check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_'))) +	if (!phpbb_check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_')))  	{  		return;  	} @@ -1005,7 +1124,7 @@ function mcp_fork_topic($topic_ids)  	if ($to_forum_id)  	{ -		$forum_data = get_forum_data($to_forum_id, 'f_post'); +		$forum_data = phpbb_get_forum_data($to_forum_id, 'f_post');  		if (!sizeof($topic_ids))  		{ @@ -1036,37 +1155,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'); +		$topic_data = phpbb_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 +1197,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 +1225,20 @@ 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: +				case ITEM_REAPPROVE: +					$total_topics_unapproved++; +				break; +				case ITEM_DELETED: +					$total_topics_softdeleted++; +				break; +			} +  			if ($topic_row['poll_start'])  			{  				$poll_rows = array(); @@ -1150,7 +1279,6 @@ function mcp_fork_topic($topic_ids)  				continue;  			} -			$total_posts += sizeof($post_rows);  			foreach ($post_rows as $row)  			{  				$sql_ary = array( @@ -1160,7 +1288,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 +1312,20 @@ 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: +					case ITEM_REAPPROVE: +						$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 +1418,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 +1473,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..465ee63a98 100644 --- a/phpBB/includes/mcp/mcp_notes.php +++ b/phpBB/includes/mcp/mcp_notes.php @@ -1,10 +1,13 @@  <?php  /**  * -* @package mcp -* @version $Id$ -* @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file.  *  */ @@ -19,7 +22,6 @@ if (!defined('IN_PHPBB'))  /**  * mcp_notes  * Displays notes about a user -* @package mcp  */  class mcp_notes  { @@ -73,7 +75,7 @@ class mcp_notes  	function mcp_notes_user_view($action)  	{  		global $phpEx, $phpbb_root_path, $config; -		global $template, $db, $user, $auth; +		global $template, $db, $user, $auth, $phpbb_container;  		$user_id = request_var('u', 0);  		$username = request_var('username', '', true); @@ -81,6 +83,7 @@ class mcp_notes  		$st	= request_var('st', 0);  		$sk	= request_var('sk', 'b');  		$sd	= request_var('sd', 'd'); +		$pagination = $phpbb_container->get('pagination');  		add_form_key('mcp_notes'); @@ -174,13 +177,9 @@ class mcp_notes  		}  		// Generate the appropriate user information for the user we are looking at -		if (!function_exists('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"; +		$pagination->generate_template_pagination($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,7 @@ 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), +			'TOTAL_REPORTS'		=> $user->lang('LIST_REPORTS', (int) $log_count),  			'RANK_TITLE'		=> $rank_title,  			'JOINED'			=> $user->format_date($userrow['user_regdate']), @@ -247,5 +247,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..03e4ed4722 100644 --- a/phpBB/includes/mcp/mcp_pm_reports.php +++ b/phpBB/includes/mcp/mcp_pm_reports.php @@ -1,10 +1,13 @@  <?php  /**  * -* @package mcp -* @version $Id$ -* @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file.  *  */ @@ -19,7 +22,6 @@ if (!defined('IN_PHPBB'))  /**  * mcp_reports  * Handling the reports queue -* @package mcp  */  class mcp_pm_reports  { @@ -34,12 +36,13 @@ 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);  		$start = request_var('start', 0); +		$pagination = $phpbb_container->get('pagination');  		$this->page_title = 'MCP_PM_REPORTS'; @@ -90,10 +93,14 @@ 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']; -				$pm_info = get_pm_data(array($pm_id)); +				$pm_info = phpbb_get_pm_data(array($pm_id));  				if (!sizeof($pm_info))  				{ @@ -112,17 +119,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')) @@ -174,7 +173,7 @@ class mcp_pm_reports  					'U_MCP_USER_NOTES'			=> append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $pm_info['author_id']),  					'U_MCP_WARN_REPORTER'		=> ($auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $report['user_id']) : '',  					'U_MCP_WARN_USER'			=> ($auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $pm_info['author_id']) : '', -					 +  					'EDIT_IMG'				=> $user->img('icon_post_edit', $user->lang['EDIT_POST']),  					'MINI_POST_IMG'			=> $user->img('icon_post_target', 'POST'), @@ -217,7 +216,7 @@ class mcp_pm_reports  				$sort_days = $total = 0;  				$sort_key = $sort_dir = '';  				$sort_by_sql = $sort_order_sql = array(); -				mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total); +				phpbb_mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total);  				$limit_time_sql = ($sort_days) ? 'AND r.report_time >= ' . (time() - ($sort_days * 86400)) : ''; @@ -294,25 +293,27 @@ 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"; +				$pagination->generate_template_pagination($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'],  					'L_TITLE'				=> ($mode == 'pm_reports') ? $user->lang['MCP_PM_REPORTS_OPEN'] : $user->lang['MCP_PM_REPORTS_CLOSED'], -					 +  					'S_PM'					=> true,  					'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),  					'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 +322,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 df5dc27996..1687409198 100644 --- a/phpBB/includes/mcp/mcp_post.php +++ b/phpBB/includes/mcp/mcp_post.php @@ -1,10 +1,13 @@  <?php  /**  * -* @package mcp -* @version $Id$ -* @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file.  *  */ @@ -30,7 +33,7 @@ function mcp_post_details($id, $mode, $action)  	$start	= request_var('start', 0);  	// Get post data -	$post_info = get_post_data(array($post_id), false, true); +	$post_info = phpbb_get_post_data(array($post_id), false, true);  	add_form_key('mcp_post_details'); @@ -40,7 +43,7 @@ function mcp_post_details($id, $mode, $action)  	}  	$post_info = $post_info[$post_id]; -	$url = append_sid("{$phpbb_root_path}mcp.$phpEx?" . extra_url()); +	$url = append_sid("{$phpbb_root_path}mcp.$phpEx?" . phpbb_extra_url());  	switch ($action)  	{ @@ -126,17 +129,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']))  	{ @@ -176,6 +170,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 @@ -187,10 +208,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 || $post_info['post_visibility'] == ITEM_REAPPROVE) ? 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'), @@ -207,6 +231,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']), @@ -274,8 +299,8 @@ function mcp_post_details($id, $mode, $action)  					'REPORT_ID'		=> $row['report_id'],  					'REASON_TITLE'	=> $row['reason_title'],  					'REASON_DESC'	=> $row['reason_description'], -					'REPORTER'		=> ($row['user_id'] != ANONYMOUS) ? $row['username'] : $user->lang['GUEST'], -					'U_REPORTER'	=> ($row['user_id'] != ANONYMOUS) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $row['user_id']) : '', +					'REPORTER'		=> get_username_string('username', $row['user_id'], $row['username']), +					'U_REPORTER'	=> get_username_string('profile', $row['user_id'], $row['username']),  					'USER_NOTIFY'	=> ($row['user_notify']) ? true : false,  					'REPORT_TIME'	=> $user->format_date($row['report_time']),  					'REPORT_TEXT'	=> bbcode_nl2br(trim($row['report_text'])), @@ -334,11 +359,11 @@ function mcp_post_details($id, $mode, $action)  			foreach ($users_ary as $user_id => $user_row)  			{  				$template->assign_block_vars('userrow', array( -					'USERNAME'		=> ($user_id == ANONYMOUS) ? $user->lang['GUEST'] : $user_row['username'], +					'USERNAME'		=> get_username_string('username', $user_id, $user_row['username']),  					'NUM_POSTS'		=> $user_row['postings'],  					'L_POST_S'		=> ($user_row['postings'] == 1) ? $user->lang['POST'] : $user->lang['POSTS'], -					'U_PROFILE'		=> ($user_id == ANONYMOUS) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $user_id), +					'U_PROFILE'		=> get_username_string('profile', $user_id, $user_row['username']),  					'U_SEARCHPOSTS' => append_sid("{$phpbb_root_path}search.$phpEx", 'author_id=' . $user_id . '&sr=topics'))  				);  			} @@ -395,7 +420,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'])  	{ @@ -417,7 +442,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 @@ -466,15 +491,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'))  		{ @@ -486,7 +509,7 @@ function change_poster(&$post_info, $userdata)  	$to_username = $userdata['username'];  	// Renew post info -	$post_info = get_post_data(array($post_id), false, true); +	$post_info = phpbb_get_post_data(array($post_id), false, true);  	if (!sizeof($post_info))  	{ @@ -498,5 +521,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 acf344fd3c..37ce3c6fc3 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -1,10 +1,13 @@  <?php  /**  * -* @package mcp -* @version $Id$ -* @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file.  *  */ @@ -19,22 +22,21 @@ if (!defined('IN_PHPBB'))  /**  * mcp_queue  * Handling the moderation queue -* @package mcp  */  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 +48,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; -				if ($action == 'approve') +			case 'delete': +				$post_id_list = $request->variable('post_id_list', array(0)); +				$topic_id_list = $request->variable('topic_id_list', array(0)); + +				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 : array(ITEM_UNAPPROVED, ITEM_REAPPROVE); +					$sql = 'SELECT post_id +						FROM ' . POSTS_TABLE . ' +						WHERE ' . $db->sql_in_set('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 +155,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'); +					$topic_info = phpbb_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,7 +172,9 @@ class mcp_queue  					}  				} -				$post_info = get_post_data(array($post_id), 'm_approve', true); +				$phpbb_notifications->mark_notifications_read('post_in_queue', $post_id, $user->data['user_id']); + +				$post_info = phpbb_get_post_data(array($post_id), 'm_approve', true);  				if (!sizeof($post_info))  				{ @@ -106,8 +188,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 +209,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 +243,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 +284,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 || $post_info['post_visibility'] == ITEM_REAPPROVE,  					'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 +301,7 @@ 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,14 +328,22 @@ 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) ? array(ITEM_UNAPPROVED, ITEM_REAPPROVE) : ITEM_DELETED; +  				$user->add_lang(array('viewtopic', 'viewforum')); -				$topic_id = request_var('t', 0); +				$topic_id = $request->variable('t', 0);  				$forum_info = array(); +				$pagination = $phpbb_container->get('pagination');  				if ($topic_id)  				{ -					$topic_info = get_topic_data(array($topic_id)); +					$topic_info = phpbb_get_topic_data(array($topic_id));  					if (!sizeof($topic_info))  					{ @@ -243,7 +354,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 +380,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 = phpbb_get_forum_data(array($forum_id), $m_perm);  					if (!sizeof($forum_info))  					{ @@ -291,7 +398,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>'; @@ -303,23 +409,24 @@ class mcp_queue  				$sort_days = $total = 0;  				$sort_key = $sort_dir = '';  				$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); +				phpbb_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 ' . $db->sql_in_set('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 +442,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 +453,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 +471,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  ' . $db->sql_in_set('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 +483,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 +507,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,574 +524,773 @@ 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"; +				$pagination->generate_template_pagination($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),  					'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'); -	} - -	$redirect = request_var('redirect', build_url(array('quickmod'))); -	$success_msg = ''; +		global $db, $template, $user, $config, $request, $phpbb_container; +		global $phpEx, $phpbb_root_path; -	$s_hidden_fields = build_hidden_fields(array( -		'i'				=> $id, -		'mode'			=> $mode, -		'post_id_list'	=> $post_id_list, -		'action'		=> 'approve', -		'redirect'		=> $redirect) -	); +		if (!phpbb_check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve'))) +		{ +			trigger_error('NOT_AUTHORISED'); +		} -	$post_info = get_post_data($post_id_list, 'm_approve'); +		$redirect = $request->variable('redirect', build_url(array('quickmod'))); +		$redirect = reapply_sid($redirect); +		$success_msg = $post_url = ''; +		$approve_log = array(); +		$num_topics = 0; -	if (confirm_box(true)) -	{ -		$notify_poster = (isset($_REQUEST['notify_poster'])) ? true : false; +		$s_hidden_fields = build_hidden_fields(array( +			'i'				=> $id, +			'mode'			=> $mode, +			'post_id_list'	=> $post_id_list, +			'action'		=> $action, +			'redirect'		=> $redirect, +		)); -		// 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 +		$post_info = phpbb_get_post_data($post_id_list, 'm_approve'); -		$total_topics = $total_posts = 0; -		$topic_approve_sql = $post_approve_sql = $topic_id_list = $forum_id_list = $approve_log = array(); -		$user_posts_sql = $post_approved_list = array(); - -		foreach ($post_info as $post_id => $post_data) +		if (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'])); +			} + +			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']);  			} -			if ($post_data['forum_id']) +			// Only send out the mails, when the posts are being approved +			if ($action == 'approve')  			{ -				$total_posts++; +				$phpbb_notifications = $phpbb_container->get('notification_manager'); -				// 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']) +				// Handle notifications +				foreach ($post_info as $post_id => $post_data)  				{ -					$total_posts += $post_data['topic_replies']; +					// A single topic approval may also happen here, so handle deleting the respective notification. +					if (!$post_data['topic_posts_approved']) +					{ +						$phpbb_notifications->delete_notifications('topic_in_queue', $post_data['topic_id']); + +						if ($post_data['post_visibility'] == ITEM_UNAPPROVED) +						{ +							$phpbb_notifications->add_notifications(array('topic'), $post_data); +						} +						if ($post_data['post_visibility'] != ITEM_APPROVED) +						{ +							$num_topics++; +						} +					} +					else +					{ +						// Only add notifications, if we are not reapproving post +						// When the topic was already approved, but was edited and +						// now needs re-approval, we don't want to notify the users +						// again. +						if ($post_data['post_visibility'] == ITEM_UNAPPROVED) +						{ +							$phpbb_notifications->add_notifications(array( +								'bookmark', +								'post', +							), $post_data); +						} +					} +					$phpbb_notifications->add_notifications(array('quote'), $post_data); +					$phpbb_notifications->delete_notifications('post_in_queue', $post_id); + +					$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; +						} + +						if (!$post_data['topic_posts_approved']) +						{ +							$phpbb_notifications->add_notifications('approve_post', $post_data); +						} +						else +						{ +							$phpbb_notifications->add_notifications('approve_topic', $post_data); +						} +					}  				}  			} -			$post_approve_sql[] = $post_id; -		} +			if ($num_topics >= 1) +			{ +				$success_msg = ($num_topics == 1) ? 'TOPIC_' . strtoupper($action) . 'D_SUCCESS' : 'TOPICS_' . strtoupper($action) . 'D_SUCCESS'; +			} +			else +			{ +				$success_msg = (sizeof($post_info) == 1) ? 'POST_' . strtoupper($action) . 'D_SUCCESS' : 'POSTS_' . strtoupper($action) . 'D_SUCCESS'; +			} -		$post_id_list = array_values(array_diff($post_id_list, $post_approved_list)); -		for ($i = 0, $size = sizeof($post_approved_list); $i < $size; $i++) -		{ -			unset($post_info[$post_approved_list[$i]]); -		} +			meta_refresh(3, $redirect); +			$message = $user->lang[$success_msg]; -		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 ($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, +				)); +			} +			$message .= '<br /><br />' . $user->lang('RETURN_PAGE', '<a href="' . $redirect . '">', '</a>'); -		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); +			// If approving one post, also give links back to post... +			if (sizeof($post_info) == 1 && $post_url) +			{ +				$message .= '<br /><br />' . $user->lang('RETURN_POST', '<a href="' . $post_url . '">', '</a>'); +			} +			trigger_error($message);  		} +		else +		{ +			$show_notify = false; -		unset($topic_approve_sql, $post_approve_sql); +			if ($action == 'approve') +			{ +				foreach ($post_info as $post_data) +				{ +					if (!$post_data['topic_posts_approved']) +					{ +						$num_topics++; +					} -		foreach ($approve_log as $log_data) -		{ -			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']); -		} +					if (!$show_notify && $post_data['poster_id'] != ANONYMOUS) +					{ +						$show_notify = true; +					} +				} +			} -		if (sizeof($user_posts_sql)) -		{ -			// Try to minimize the query count by merging users with the same post count additions -			$user_posts_update = array(); +			$template->assign_vars(array( +				'S_NOTIFY_POSTER'			=> $show_notify, +				'S_' . strtoupper($action)	=> true, +			)); -			foreach ($user_posts_sql as $user_id => $user_posts) +			// Create the confirm box message +			$action_msg = strtoupper($action); +			$num_posts = sizeof($post_id_list) - $num_topics; +			if ($num_topics > 0 && $num_posts <= 0)  			{ -				$user_posts_update[$user_posts][] = $user_id; +				$action_msg .= '_TOPIC' . (($num_topics == 1) ? '' : 'S');  			} - -			foreach ($user_posts_update as $user_posts => $user_id_ary) +			else  			{ -				$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); +				$action_msg .= '_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S');  			} +			confirm_box(false, $action_msg, $s_hidden_fields, 'mcp_approve.html');  		} -		if ($total_topics) -		{ -			set_config_count('num_topics', $total_topics, true); -		} +		redirect($redirect); +	} + +	/** +	* 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 ($total_posts) +		if (!phpbb_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'))); +		$redirect = reapply_sid($redirect); +		$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 = phpbb_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'; +		if (confirm_box(true)) +		{ +			$notify_poster = ($action == 'approve' && isset($_REQUEST['notify_poster'])) ? true : false; -				$messenger->template($email_template, $post_data['user_lang']); +			$phpbb_content_visibility = $phpbb_container->get('content.visibility'); +			$first_post_ids = array(); -				$messenger->to($post_data['user_email'], $post_data['username']); -				$messenger->im($post_data['user_jabber'], $post_data['username']); +			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(), ''); +				$first_post_ids[$topic_id] = (int) $topic_data['topic_first_post_id']; -				$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']); +			if (sizeof($topic_info) >= 1) +			{ +				$success_msg = (sizeof($topic_info) == 1) ? 'TOPIC_' . strtoupper($action) . 'D_SUCCESS' : 'TOPICS_' . strtoupper($action) . 'D_SUCCESS';  			} -		} -		$messenger->save_queue(); +			foreach ($approve_log as $log_data) +			{ +				add_log('mod', $log_data['forum_id'], $log_data['topic_id'], 'LOG_TOPIC_' . strtoupper($action) . 'D', $log_data['topic_title']); +			} -		// Send out normal user notifications -		$email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']); +			// Only send out the mails, when the posts are being approved +			if ($action == 'approve') +			{ +				// Grab the first post text as it's needed for the quote notification. +				$sql = 'SELECT topic_id, post_text +					FROM ' . POSTS_TABLE . ' +					WHERE ' . $db->sql_in_set('post_id', $first_post_ids); +				$result = $db->sql_query($sql); -		foreach ($post_info as $post_id => $post_data) -		{ -			$username = ($post_data['post_username']) ? $post_data['post_username'] : $post_data['username']; +				while ($row = $db->sql_fetchrow($result)) +				{ +					$topic_info[$row['topic_id']]['post_text'] = $row['post_text']; +				} +				$db->sql_freeresult($result); -			if ($post_id == $post_data['topic_first_post_id'] && $post_id == $post_data['topic_last_post_id']) -			{ -				// 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, $username); +				// Handle notifications +				$phpbb_notifications = $phpbb_container->get('notification_manager'); + +				foreach ($topic_info as $topic_id => $topic_data) +				{ +					$topic_data = array_merge($topic_data, array( +						'post_id'		=> $topic_data['topic_first_post_id'], +						'post_subject'	=> $topic_data['topic_title'], +						'post_time'		=> $topic_data['topic_time'], +						'poster_id'		=> $topic_data['topic_poster'], +						'post_username'	=> $topic_data['topic_first_poster_name'], +					)); + +					$phpbb_notifications->delete_notifications('topic_in_queue', $topic_id); + +					// Only add notifications, if we are not reapproving post +					// When the topic was already approved, but was edited and +					// now needs re-approval, we don't want to notify the users +					// again. +					if ($topic_data['topic_visibility'] == ITEM_UNAPPROVED) +					{ +						$phpbb_notifications->add_notifications(array( +							'quote', +							'topic', +						), $topic_data); +					} + +					$phpbb_notifications->mark_notifications_read('quote', $topic_data['post_id'], $user->data['user_id']); +					$phpbb_notifications->mark_notifications_read('topic', $topic_id, $user->data['user_id']); + +					if ($notify_poster) +					{ +						$phpbb_notifications->add_notifications('approve_topic', $topic_data); +					} +				}  			} -			else + +			meta_refresh(3, $redirect); +			$message = $user->lang[$success_msg]; + +			if ($request->is_ajax())  			{ -				// 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, $username); +				$json_response = new \phpbb\json_response; +				$json_response->send(array( +					'MESSAGE_TITLE'		=> $user->lang['INFORMATION'], +					'MESSAGE_TEXT'		=> $message, +					'REFRESH_DATA'		=> null, +					'visible'			=> true, +				));  			} -		} - -		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); +			$message .= '<br /><br />' . $user->lang('RETURN_PAGE', '<a href="' . $redirect . '">', '</a>'); -		if ($total_topics) -		{ -			$success_msg = ($total_topics == 1) ? 'TOPIC_APPROVED_SUCCESS' : 'TOPICS_APPROVED_SUCCESS'; +			// If approving one topic, also give links back to topic... +			if (sizeof($topic_info) == 1 && $topic_url) +			{ +				$message .= '<br /><br />' . $user->lang('RETURN_TOPIC', '<a href="' . $topic_url . '">', '</a>'); +			} +			trigger_error($message);  		}  		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) -		); -		confirm_box(false, 'APPROVE_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html'); -	} +			$template->assign_vars(array( +				'S_NOTIFY_POSTER'			=> $show_notify, +				'S_' . strtoupper($action)	=> true, +			)); -	$redirect = request_var('redirect', "index.$phpEx"); -	$redirect = reapply_sid($redirect); +			confirm_box(false, strtoupper($action) . '_TOPIC' . ((sizeof($topic_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html'); +		} -	if (!$success_msg) -	{  		redirect($redirect);  	} -	else + +	/** +	* 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)  	{ -		meta_refresh(3, $redirect); +		global $db, $template, $user, $config, $phpbb_container; +		global $phpEx, $phpbb_root_path, $request; -		// If approving one post, also give links back to post... -		$add_message = ''; -		if (sizeof($post_id_list) == 1 && !empty($post_url)) +		if (!phpbb_check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve')))  		{ -			$add_message = '<br /><br />' . sprintf($user->lang['RETURN_POST'], '<a href="' . $post_url . '">', '</a>'); +			trigger_error('NOT_AUTHORISED');  		} -		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'); -	} - -	$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 = ''; +		$redirect = $request->variable('redirect', build_url(array('t', 'mode', 'quickmod')) . "&mode=$mode"); +		$redirect = reapply_sid($redirect); +		$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) -	); +		$s_hidden_fields = build_hidden_fields(array( +			'i'				=> $id, +			'mode'			=> $mode, +			'post_id_list'	=> $post_id_list, +			'action'		=> 'disapprove', +			'redirect'		=> $redirect, +		)); -	$notify_poster = (isset($_REQUEST['notify_poster'])) ? true : false; -	$disapprove_reason = ''; +		$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')) -		{ -			$additional_msg = $user->lang['NO_REASON_DISAPPROVAL']; -			unset($_REQUEST['confirm_key']); -			unset($_POST['confirm_key']); -			unset($_POST['confirm']); -		} -		else +		if ($reason_id)  		{ -			// 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'])])) +			$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 = phpbb_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, $log_data['post_username']); +					} +					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 +							}  						} + +						$post_data['disapprove_reason'] = $lang_reasons[$post_data['user_lang']]; +						$post_data['disapprove_reason'] .= ($reason) ? "\n\n" . $reason : '';  					} -					$email_disapprove_reason = $lang_reasons[$post_data['user_lang']]; -					$email_disapprove_reason .= ($reason) ? "\n\n" . $reason : ''; +					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); +					}  				} +			} -				$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']); - -				$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']))) -				); +			if ($num_disapproved_topics) +			{ +				$success_msg = ($num_disapproved_topics == 1) ? 'TOPIC' : 'TOPICS'; +			} +			else +			{ +				$success_msg = ($num_disapproved_posts == 1) ? 'POST' : 'POSTS'; +			} -				$messenger->send($post_data['user_notify_type']); +			if ($is_disapproving) +			{ +				$success_msg .= '_DISAPPROVED_SUCCESS'; +			} +			else +			{ +				$success_msg .= '_DELETED_SUCCESS';  			} -			unset($lang_reasons); -		} -		unset($post_info, $disapprove_reason, $email_disapprove_reason, $disapprove_reason_lang); +			// If we came from viewtopic, we try to go back to it. +			if (strpos($redirect, $phpbb_root_path . 'viewtopic.' . $phpEx) === 0) +			{ +				if ($num_disapproved_topics == 0) +				{ +					// So we need to remove the post id part from the Url +					$redirect = str_replace("&p={$post_id_list[0]}#p{$post_id_list[0]}", '', $redirect); +				} +				else +				{ +					// However this is only possible if the topic still exists, +					// Otherwise we go back to the viewforum page +					$redirect = append_sid($phpbb_root_path . 'viewforum.' . $phpEx, 'f=' . $request->variable('f', 0)); +				} +			} -		$messenger->save_queue(); +			meta_refresh(3, $redirect); +			$message = $user->lang[$success_msg]; -		if ($num_disapproved_topics) -		{ -			$success_msg = ($num_disapproved_topics == 1) ? 'TOPIC_DISAPPROVED_SUCCESS' : 'TOPICS_DISAPPROVED_SUCCESS'; +			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, +				)); +			} +			$message .= '<br /><br />' . $user->lang('RETURN_PAGE', '<a href="' . $redirect . '">', '</a>'); +			trigger_error($message);  		}  		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'); -		$template->assign_vars(array( -			'S_NOTIFY_POSTER'	=> $show_notify, -			'S_APPROVE'			=> false, -			'REASON'			=> $reason, -			'ADDITIONAL_MSG'	=> $additional_msg) -		); +				$l_confirm_msg = 'DELETE_POST_PERMANENTLY'; +				$confirm_template = 'confirm_delete_body.html'; +			} +			$l_confirm_msg .= ((sizeof($post_id_list) == 1) ? '' : 'S'); -		confirm_box(false, 'DISAPPROVE_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html'); -	} +			$template->assign_vars(array( +				'S_NOTIFY_POSTER'	=> $show_notify, +				'S_APPROVE'			=> false, +				'REASON'			=> ($is_disapproving) ? $reason : '', +				'ADDITIONAL_MSG'	=> $additional_msg, +			)); -	$redirect = request_var('redirect', "index.$phpEx"); -	$redirect = reapply_sid($redirect); +			confirm_box(false, $l_confirm_msg, $s_hidden_fields, $confirm_template); +		} -	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>')); -	}  } - -?>
\ No newline at end of file diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index b13c8b20c6..a7d8bf18d6 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -1,10 +1,13 @@  <?php  /**  * -* @package mcp -* @version $Id$ -* @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file.  *  */ @@ -19,7 +22,6 @@ if (!defined('IN_PHPBB'))  /**  * mcp_reports  * Handling the reports queue -* @package mcp  */  class mcp_reports  { @@ -34,7 +36,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 +74,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 +90,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'); @@ -96,7 +102,11 @@ class mcp_reports  				$post_id = $report['post_id'];  				$report_id = $report['report_id']; -				$post_info = get_post_data(array($post_id), 'm_report', true); +				$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 = phpbb_get_post_data(array($post_id), 'm_report', true);  				if (!sizeof($post_info))  				{ @@ -117,8 +127,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(); @@ -135,19 +146,14 @@ 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; +				$message = generate_text_for_display( +					$report['reported_post_text'], +					$report['reported_post_uid'], +					$report['reported_post_bitfield'], +					$parse_post_flags, +					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'])) @@ -156,6 +162,7 @@ class mcp_reports  						FROM ' . ATTACHMENTS_TABLE . '  						WHERE post_msg_id = ' . $post_id . '  							AND in_message = 0 +							AND filetime <= ' . (int) $report['report_time'] . '  						ORDER BY filetime DESC';  					$result = $db->sql_query($sql); @@ -190,7 +197,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 || $post_info['post_visibility'] == ITEM_REAPPROVE,  					'S_POST_LOCKED'			=> $post_info['post_edit_locked'],  					'S_REPORT_CLOSED'		=> $report['report_closed'],  					'S_USER_NOTES'			=> true, @@ -262,7 +269,7 @@ class mcp_reports  				if ($topic_id)  				{ -					$topic_info = get_topic_data(array($topic_id)); +					$topic_info = phpbb_get_topic_data(array($topic_id));  					if (!sizeof($topic_info))  					{ @@ -296,16 +303,16 @@ 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  				{ -					$forum_info = get_forum_data(array($forum_id), 'm_report'); +					$forum_info = phpbb_get_forum_data(array($forum_id), 'm_report');  					if (!sizeof($forum_info))  					{ @@ -314,11 +321,11 @@ class mcp_reports  					$forum_info = $forum_info[$forum_id];  					$forum_list = array($forum_id); -					$global_id = $forum_id;  				}  				$forum_list[] = 0;  				$forum_data = array(); +				$pagination = $phpbb_container->get('pagination');  				$forum_options = '<option value="0"' . (($forum_id == 0) ? ' selected="selected"' : '') . '>' . $user->lang['ALL_FORUMS'] . '</option>';  				foreach ($forum_list_reports as $row) @@ -331,9 +338,9 @@ class mcp_reports  				$sort_days = $total = 0;  				$sort_key = $sort_dir = '';  				$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); +				phpbb_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 +377,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 +391,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 +406,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"; +				$pagination->generate_template_pagination($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 +433,9 @@ 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),  					'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 +451,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'; @@ -476,7 +479,7 @@ function close_report($report_id_list, $mode, $action, $pm = false)  	}  	else  	{ -		if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_report'))) +		if (!phpbb_check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_report')))  		{  			trigger_error('NOT_AUTHORISED');  		} @@ -486,7 +489,7 @@ function close_report($report_id_list, $mode, $action, $pm = false)  	{  		$redirect = request_var('redirect', build_url(array('mode', 'r', 'quickmod')) . '&mode=reports');  	} -	elseif ($action == 'delete' && strpos($user->data['session_page'], 'mode=pm_report_details') !== false) +	else if ($action == 'delete' && strpos($user->data['session_page'], 'mode=pm_report_details') !== false)  	{  		$redirect = request_var('redirect', build_url(array('mode', 'r', 'quickmod')) . '&mode=pm_reports');  	} @@ -512,7 +515,7 @@ function close_report($report_id_list, $mode, $action, $pm = false)  	if (confirm_box(true))  	{ -		$post_info = ($pm) ? get_pm_data($post_id_list) : get_post_data($post_id_list, 'm_report'); +		$post_info = ($pm) ? phpbb_get_pm_data($post_id_list) : phpbb_get_post_data($post_id_list, 'm_report');  		$sql = "SELECT r.report_id, r.$id_column, r.report_closed, r.user_id, r.user_notify, u.username, u.username_clean, u.user_email, u.user_jabber, u.user_lang, u.user_notify_type  			FROM " . REPORTS_TABLE . ' r, ' . USERS_TABLE . ' u @@ -585,7 +588,6 @@ function close_report($report_id_list, $mode, $action, $pm = false)  			}  			$db->sql_query($sql); -  			if (sizeof($close_report_posts))  			{  				if ($pm) @@ -622,20 +624,22 @@ function close_report($report_id_list, $mode, $action, $pm = false)  		}  		unset($close_report_posts, $close_report_topics); +		$phpbb_notifications = $phpbb_container->get('notification_manager'); +  		foreach ($reports as $report)  		{  			if ($pm)  			{  				add_log('mod', 0, 0, 'LOG_PM_REPORT_' .  strtoupper($action) . 'D', $post_info[$report['pm_id']]['message_subject']); +				$phpbb_notifications->delete_notifications('report_pm', $report['pm_id']);  			}  			else  			{  				add_log('mod', $post_info[$report['post_id']]['forum_id'], $post_info[$report['post_id']]['topic_id'], 'LOG_REPORT_' .  strtoupper($action) . 'D', $post_info[$report['post_id']]['post_subject']); +				$phpbb_notifications->delete_notifications('report_post', $report['post_id']);  			}  		} -		$messenger = new messenger(); -  		// Notify reporters  		if (sizeof($notify_reporters))  		{ @@ -648,30 +652,21 @@ 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'], +					)));  				}  				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']);  			}  		} @@ -686,8 +681,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 +718,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..1698b080c9 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -1,10 +1,13 @@  <?php  /**  * -* @package mcp -* @version $Id$ -* @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file.  *  */ @@ -22,14 +25,15 @@ 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()); +	$url = append_sid("{$phpbb_root_path}mcp.$phpEx?" . phpbb_extra_url());  	$user->add_lang('viewtopic'); +	$pagination = $phpbb_container->get('pagination');  	$topic_id = request_var('t', 0); -	$topic_info = get_topic_data(array($topic_id), false, true); +	$topic_info = phpbb_get_topic_data(array($topic_id), false, true);  	if (!sizeof($topic_info))  	{ @@ -85,8 +89,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 +103,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);  		}  	} @@ -110,20 +114,14 @@ function mcp_topic_view($id, $mode, $action)  	$sort_days = $total = 0;  	$sort_key = $sort_dir = '';  	$sort_by_sql = $sort_order_sql = array(); -	mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $topic_info['forum_id'], $topic_id, $where_sql); +	phpbb_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']))); @@ -136,18 +134,13 @@ function mcp_topic_view($id, $mode, $action)  	{  		$start = 0;  	} - -	// Make sure $start is set to the last page if it exceeds the amount -	if ($start < 0 || $start >= $total) -	{ -		$start = ($start < 0) ? 0 : floor(($total - 1) / $posts_per_page) * $posts_per_page; -	} +	$start = $pagination->validate_start($start, $posts_per_page, $total);  	$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 || $row['post_visibility'] == ITEM_REAPPROVE)  		{  			$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 || $row['post_visibility'] == ITEM_REAPPROVE) && $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, @@ -284,7 +278,7 @@ function mcp_topic_view($id, $mode, $action)  		// Has the user selected a topic for merge?  		if ($to_topic_id)  		{ -			$to_topic_info = get_topic_data(array($to_topic_id), 'm_merge'); +			$to_topic_info = phpbb_get_topic_data(array($to_topic_id), 'm_merge');  			if (!sizeof($to_topic_info))  			{ @@ -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) +	{ +		$pagination->generate_template_pagination($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,7 @@ 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), +		'TOTAL_POSTS'		=> $user->lang('VIEW_TOPIC_POSTS', (int) $total),  	));  } @@ -368,13 +368,13 @@ function split_topic($action, $topic_id, $to_forum_id, $subject)  		return;  	} -	if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_split'))) +	if (!phpbb_check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_split')))  	{  		return;  	}  	$post_id = $post_id_list[0]; -	$post_info = get_post_data(array($post_id)); +	$post_info = phpbb_get_post_data(array($post_id));  	if (!sizeof($post_info))  	{ @@ -398,7 +398,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject)  		return;  	} -	$forum_info = get_forum_data(array($to_forum_id), 'f_post'); +	$forum_info = phpbb_get_forum_data(array($to_forum_id), 'f_post');  	if (!sizeof($forum_info))  	{ @@ -438,13 +438,13 @@ function split_topic($action, $topic_id, $to_forum_id, $subject)  			$sort_days = $total = 0;  			$sort_key = $sort_dir = '';  			$sort_by_sql = $sort_order_sql = array(); -			mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id); +			phpbb_mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id);  			$limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : '';  			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 +453,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 +466,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 || $row['post_visibility'] == ITEM_REAPPROVE) && !$auth->acl_get('m_approve', $row['forum_id']))  				{  //					continue;  				} @@ -493,10 +493,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); @@ -505,7 +505,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject)  		$to_topic_id = $db->sql_nextid();  		move_posts($post_id_list, $to_topic_id); -		$topic_info = get_topic_data(array($topic_id)); +		$topic_info = phpbb_get_topic_data(array($topic_id));  		$topic_info = $topic_info[$topic_id];  		add_log('mod', $to_forum_id, $to_topic_id, 'LOG_SPLIT_DESTINATION', $subject); @@ -567,23 +567,15 @@ function split_topic($action, $topic_id, $to_forum_id, $subject)  		// Link back to both topics  		$return_link = sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']) . '">', '</a>') . '<br /><br />' . sprintf($user->lang['RETURN_NEW_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $to_forum_id . '&t=' . $to_topic_id) . '">', '</a>'); -	} -	else -	{ -		confirm_box(false, ($action == 'split_all') ? 'SPLIT_TOPIC_ALL' : 'SPLIT_TOPIC_BEYOND', $s_hidden_fields); -	} +		$redirect = request_var('redirect', "{$phpbb_root_path}viewtopic.$phpEx?f=$to_forum_id&t=$to_topic_id"); +		$redirect = reapply_sid($redirect); -	$redirect = request_var('redirect', "index.$phpEx"); -	$redirect = reapply_sid($redirect); - -	if (!$success_msg) -	{ -		return; +		meta_refresh(3, $redirect); +		trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link);  	}  	else  	{ -		meta_refresh(3, append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$to_forum_id&t=$to_topic_id")); -		trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link); +		confirm_box(false, ($action == 'split_all') ? 'SPLIT_TOPIC_ALL' : 'SPLIT_TOPIC_BEYOND', $s_hidden_fields);  	}  } @@ -600,14 +592,22 @@ function merge_posts($topic_id, $to_topic_id)  		return;  	} -	$topic_data = get_topic_data(array($to_topic_id), 'm_merge'); +	$sync_topics = array($topic_id, $to_topic_id); -	if (!sizeof($topic_data)) +	$topic_data = phpbb_get_topic_data($sync_topics, 'm_merge'); + +	if (!sizeof($topic_data) || empty($topic_data[$to_topic_id]))  	{  		$template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']);  		return;  	} +	$sync_forums = array(); +	foreach ($topic_data as $data) +	{ +		$sync_forums[$data['forum_id']] = $data['forum_id']; +	} +  	$topic_data = $topic_data[$to_topic_id];  	$post_id_list	= request_var('post_id_list', array(0)); @@ -619,7 +619,7 @@ function merge_posts($topic_id, $to_topic_id)  		return;  	} -	if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_merge'))) +	if (!phpbb_check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_merge')))  	{  		return;  	} @@ -642,7 +642,7 @@ function merge_posts($topic_id, $to_topic_id)  	{  		$to_forum_id = $topic_data['forum_id']; -		move_posts($post_id_list, $to_topic_id); +		move_posts($post_id_list, $to_topic_id, false);  		add_log('mod', $to_forum_id, $to_topic_id, 'LOG_MERGE', $topic_data['topic_title']);  		// Message and return links @@ -650,7 +650,7 @@ function merge_posts($topic_id, $to_topic_id)  		// Does the original topic still exist? If yes, link back to it  		$sql = 'SELECT forum_id -			FROM ' . TOPICS_TABLE . ' +			FROM ' . POSTS_TABLE . '  			WHERE topic_id = ' . $topic_id;  		$result = $db->sql_query_limit($sql, 1);  		$row = $db->sql_fetchrow($result); @@ -674,26 +674,22 @@ function merge_posts($topic_id, $to_topic_id)  			phpbb_update_rows_avoiding_duplicates($db, BOOKMARKS_TABLE, 'topic_id', array($topic_id), $to_topic_id);  		} +		// Re-sync the topics and forums because the auto-sync was deactivated in the call of move_posts() +		sync('topic_reported', 'topic_id', $sync_topics); +		sync('topic_attachment', 'topic_id', $sync_topics); +		sync('topic', 'topic_id', $sync_topics, true); +		sync('forum', 'forum_id', $sync_forums, true, true); +  		// Link to the new topic  		$return_link .= (($return_link) ? '<br /><br />' : '') . sprintf($user->lang['RETURN_NEW_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $to_forum_id . '&t=' . $to_topic_id) . '">', '</a>'); -	} -	else -	{ -		confirm_box(false, 'MERGE_POSTS', $s_hidden_fields); -	} - -	$redirect = request_var('redirect', "index.$phpEx"); -	$redirect = reapply_sid($redirect); +		$redirect = request_var('redirect', "{$phpbb_root_path}viewtopic.$phpEx?f=$to_forum_id&t=$to_topic_id"); +		$redirect = reapply_sid($redirect); -	if (!$success_msg) -	{ -		return; +		meta_refresh(3, $redirect); +		trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link);  	}  	else  	{ -		meta_refresh(3, append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$to_forum_id&t=$to_topic_id")); -		trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link); +		confirm_box(false, 'MERGE_POSTS', $s_hidden_fields);  	}  } - -?>
\ No newline at end of file diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php index 1016204ff8..fb47522644 100644 --- a/phpBB/includes/mcp/mcp_warn.php +++ b/phpBB/includes/mcp/mcp_warn.php @@ -1,10 +1,13 @@  <?php  /**  * -* @package mcp -* @version $Id$ -* @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file.  *  */ @@ -19,7 +22,6 @@ if (!defined('IN_PHPBB'))  /**  * mcp_warn  * Handling warning the users -* @package mcp  */  class mcp_warn  { @@ -97,9 +99,6 @@ class mcp_warn  				'U_NOTES'		=> append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $row['user_id']),  				'USERNAME_FULL'		=> get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), -				'USERNAME'			=> $row['username'], -				'USERNAME_COLOUR'	=> ($row['user_colour']) ? '#' . $row['user_colour'] : '', -				'U_USER'			=> append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $row['user_id']),  				'WARNING_TIME'	=> $user->format_date($row['user_last_warning']),  				'WARNINGS'		=> $row['user_warnings'], @@ -119,9 +118,6 @@ class mcp_warn  				'U_NOTES'		=> append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $row['user_id']),  				'USERNAME_FULL'		=> get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), -				'USERNAME'			=> $row['username'], -				'USERNAME_COLOUR'	=> ($row['user_colour']) ? '#' . $row['user_colour'] : '', -				'U_USER'			=> append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $row['user_id']),  				'WARNING_TIME'	=> $user->format_date($row['warning_time']),  				'WARNINGS'		=> $row['user_warnings'], @@ -135,10 +131,11 @@ class mcp_warn  	*/  	function mcp_warn_list_view($action)  	{ -		global $phpEx, $phpbb_root_path, $config; +		global $phpEx, $phpbb_root_path, $config, $phpbb_container;  		global $template, $db, $user, $auth;  		$user->add_lang('memberlist'); +		$pagination = $phpbb_container->get('pagination');  		$start	= request_var('start', 0);  		$st		= request_var('st', 0); @@ -167,15 +164,15 @@ class mcp_warn  				'U_NOTES'		=> append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $row['user_id']),  				'USERNAME_FULL'		=> get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), -				'USERNAME'			=> $row['username'], -				'USERNAME_COLOUR'	=> ($row['user_colour']) ? '#' . $row['user_colour'] : '', -				'U_USER'			=> append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $row['user_id']),  				'WARNING_TIME'	=> $user->format_date($row['user_last_warning']),  				'WARNINGS'		=> $row['user_warnings'],  			));  		} +		$base_url = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=warn&mode=list&st=$st&sk=$sk&sd=$sd"); +		$pagination->generate_template_pagination($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 +180,7 @@ 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), +			'TOTAL_USERS'		=> $user->lang('LIST_USERS', (int) $user_count),  		));  	} @@ -195,7 +190,7 @@ class mcp_warn  	function mcp_warn_post_view($action)  	{  		global $phpEx, $phpbb_root_path, $config; -		global $template, $db, $user, $auth; +		global $template, $db, $user, $auth, $phpbb_dispatcher;  		$post_id = request_var('p', 0);  		$forum_id = request_var('f', 0); @@ -252,7 +247,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); @@ -272,44 +267,82 @@ class mcp_warn  		{  			if (check_form_key('mcp_warn'))  			{ -				add_warning($user_row, $warning, $notify, $post_id); -				$msg = $user->lang['USER_WARNING_ADDED']; +				$s_mcp_warn_post = true; + +				/** +				* Event for before warning a user for a post. +				* +				* @event core.mcp_warn_post_before +				* @var array	user_row		The entire user row +				* @var string	warning			The warning message +				* @var bool		notify			If true, we notify the user for the warning +				* @var int		post_id			The post id for which the warning is added +				* @var bool		s_mcp_warn_post If true, we add the warning else we omit it +				* @since 3.1.0-b4 +				*/ +				$vars = array( +						'user_row', +						'warning', +						'notify', +						'post_id', +						's_mcp_warn_post', +				); +				extract($phpbb_dispatcher->trigger_event('core.mcp_warn_post_before', compact($vars))); + +				if ($s_mcp_warn_post) +				{ +					add_warning($user_row, $warning, $notify, $post_id); +					$message = $user->lang['USER_WARNING_ADDED']; + +					/** +					* Event for after warning a user for a post. +					* +					* @event core.mcp_warn_post_after +					* @var array	user_row	The entire user row +					* @var string	warning		The warning message +					* @var bool		notify		If true, the user was notified for the warning +					* @var int		post_id		The post id for which the warning is added +					* @var string	message		Message displayed to the moderator +					* @since 3.1.0-b4 +					*/ +					$vars = array( +							'user_row', +							'warning', +							'notify', +							'post_id', +							'message', +					); +					extract($phpbb_dispatcher->trigger_event('core.mcp_warn_post_after', compact($vars))); +				}  			}  			else  			{ -				$msg = $user->lang['FORM_INVALID']; +				$message = $user->lang['FORM_INVALID']; +			} + +			if (!empty($message)) +			{ +				$redirect = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=notes&mode=user_notes&u=$user_id"); +				meta_refresh(2, $redirect); +				trigger_error($message . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));  			} -			$redirect = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=notes&mode=user_notes&u=$user_id"); -			meta_refresh(2, $redirect); -			trigger_error($msg . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));  		}  		// OK, they didn't submit a warning so lets build the page for them to do so  		// 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('get_user_rank'))  		{  			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, @@ -337,7 +370,7 @@ class mcp_warn  	function mcp_warn_user_view($action)  	{  		global $phpEx, $phpbb_root_path, $config, $module; -		global $template, $db, $user, $auth; +		global $template, $db, $user, $auth, $phpbb_dispatcher;  		$user_id = request_var('u', 0);  		$username = request_var('username', '', true); @@ -375,7 +408,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); @@ -395,26 +428,70 @@ class mcp_warn  		{  			if (check_form_key('mcp_warn'))  			{ -				add_warning($user_row, $warning, $notify); -				$msg = $user->lang['USER_WARNING_ADDED']; +				$s_mcp_warn_user = true; + +				/** +				* Event for before warning a user from MCP. +				* +				* @event core.mcp_warn_user_before +				* @var array	user_row		The entire user row +				* @var string	warning			The warning message +				* @var bool		notify			If true, we notify the user for the warning +				* @var bool		s_mcp_warn_user If true, we add the warning else we omit it +				* @since 3.1.0-b4 +				*/ +				$vars = array( +						'user_row', +						'warning', +						'notify', +						's_mcp_warn_user', +				); +				extract($phpbb_dispatcher->trigger_event('core.mcp_warn_user_before', compact($vars))); + +				if ($s_mcp_warn_user) +				{ +					add_warning($user_row, $warning, $notify); +					$message = $user->lang['USER_WARNING_ADDED']; + +					/** +					* Event for after warning a user from MCP. +					* +					* @event core.mcp_warn_user_after +					* @var array	user_row	The entire user row +					* @var string	warning		The warning message +					* @var bool		notify		If true, the user was notified for the warning +					* @var string	message		Message displayed to the moderator +					* @since 3.1.0-b4 +					*/ +					$vars = array( +							'user_row', +							'warning', +							'notify', +							'message', +					); +					extract($phpbb_dispatcher->trigger_event('core.mcp_warn_user_after', compact($vars))); +				}  			}  			else  			{ -				$msg = $user->lang['FORM_INVALID']; +				$message = $user->lang['FORM_INVALID']; +			} + +			if (!empty($message)) +			{ +				$redirect = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=notes&mode=user_notes&u=$user_id"); +				meta_refresh(2, $redirect); +				trigger_error($message . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));  			} -			$redirect = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=notes&mode=user_notes&u=$user_id"); -			meta_refresh(2, $redirect); -			trigger_error($msg . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));  		}  		// Generate the appropriate user information for the user we are looking at -		if (!function_exists('get_user_avatar')) +		if (!function_exists('get_user_rank'))  		{  			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 +584,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 | 
