diff options
Diffstat (limited to 'phpBB/includes/mcp')
| -rw-r--r-- | phpBB/includes/mcp/mcp_front.php | 37 | ||||
| -rw-r--r-- | phpBB/includes/mcp/mcp_main.php | 29 | ||||
| -rw-r--r-- | phpBB/includes/mcp/mcp_post.php | 60 | ||||
| -rw-r--r-- | phpBB/includes/mcp/mcp_queue.php | 2 | ||||
| -rw-r--r-- | phpBB/includes/mcp/mcp_reports.php | 59 | ||||
| -rw-r--r-- | phpBB/includes/mcp/mcp_topic.php | 12 | 
6 files changed, 175 insertions, 24 deletions
diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php index 500db55456..629b6fd275 100644 --- a/phpBB/includes/mcp/mcp_front.php +++ b/phpBB/includes/mcp/mcp_front.php @@ -41,10 +41,27 @@ function mcp_front_view($id, $mode, $action)  		if (!empty($forum_list))  		{ -			$sql = 'SELECT COUNT(post_id) AS total -				FROM ' . POSTS_TABLE . ' -				WHERE ' . $db->sql_in_set('forum_id', $forum_list) . ' -					AND ' . $db->sql_in_set('post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)); +			$sql_ary = array( +				'SELECT' => 'COUNT(post_id) AS total', +				'FROM' => array( +						POSTS_TABLE => 'p', +					), +				'WHERE' => $db->sql_in_set('p.forum_id', $forum_list) . ' +					AND ' . $db->sql_in_set('p.post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)) +			); + +			/** +			* Allow altering the query to get the number of unapproved posts +			* +			* @event core.mcp_front_queue_unapproved_total_before +			* @var	int		sql_ary						Query to get the total number of unapproved posts +			* @var	array	forum_list					List of forums to look for unapproved posts +			* @since 3.1.5-RC1 +			*/ +			$vars = array('sql_ary', 'forum_list'); +			extract($phpbb_dispatcher->trigger_event('core.mcp_front_queue_unapproved_total_before', compact($vars))); + +			$sql = $db->sql_build_query('SELECT', $sql_ary);  			$result = $db->sql_query($sql);  			$total = (int) $db->sql_fetchfield('total');  			$db->sql_freeresult($result); @@ -157,6 +174,18 @@ function mcp_front_view($id, $mode, $action)  					AND r.pm_id = 0  					AND r.report_closed = 0  					AND ' . $db->sql_in_set('p.forum_id', $forum_list); + +			/** +			* Alter sql query to count the number of reported posts +			* +			* @event core.mcp_front_reports_count_query_before +			* @var	int		sql				The query string used to get the number of reports that exist +			* @var	array	forum_list		List of forums that contain the posts +			* @since 3.1.5-RC1 +			*/ +			$vars = array('sql', 'forum_list'); +			extract($phpbb_dispatcher->trigger_event('core.mcp_front_reports_count_query_before', compact($vars))); +  			$result = $db->sql_query($sql);  			$total = (int) $db->sql_fetchfield('total');  			$db->sql_freeresult($result); diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index 1241b8bd0e..fc28968101 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -226,6 +226,31 @@ class mcp_main  			break;  			default: +				if ($quickmod) +				{ +					switch ($action) +					{ +						case 'lock': +						case 'unlock': +						case 'make_announce': +						case 'make_sticky': +						case 'make_global': +						case 'make_normal': +						case 'make_onindex': +						case 'move': +						case 'fork': +						case 'delete_topic': +							trigger_error('TOPIC_NOT_EXIST'); +						break; + +						case 'lock_post': +						case 'unlock_post': +						case 'delete_post': +							trigger_error('POST_NOT_EXIST'); +						break; +					} +				} +  				trigger_error('NO_MODE', E_USER_ERROR);  			break;  		} @@ -1119,7 +1144,7 @@ function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '',  function mcp_fork_topic($topic_ids)  {  	global $auth, $user, $db, $template, $config; -	global $phpEx, $phpbb_root_path; +	global $phpEx, $phpbb_root_path, $phpbb_dispatcher;  	if (!phpbb_check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_')))  	{ @@ -1197,7 +1222,7 @@ function mcp_fork_topic($topic_ids)  				}  				$error = false; -				$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user); +				$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher);  				$search_mode = 'post';  				if ($error) diff --git a/phpBB/includes/mcp/mcp_post.php b/phpBB/includes/mcp/mcp_post.php index 1687409198..7a93f73228 100644 --- a/phpBB/includes/mcp/mcp_post.php +++ b/phpBB/includes/mcp/mcp_post.php @@ -26,6 +26,7 @@ function mcp_post_details($id, $mode, $action)  {  	global $phpEx, $phpbb_root_path, $config;  	global $template, $db, $user, $auth, $cache; +	global $phpbb_dispatcher;  	$user->add_lang('posting'); @@ -106,6 +107,21 @@ function mcp_post_details($id, $mode, $action)  			}  		break; + +		default: + +			/** +			* This event allows you to handle custom post moderation options +			* +			* @event core.mcp_post_additional_options +			* @var	string	action		Post moderation action name +			* @var	array	post_info	Information on the affected post +			* @since 3.1.5-RC1 +			*/ +			$vars = array('action', 'post_info'); +			extract($phpbb_dispatcher->trigger_event('core.mcp_post_additional_options', compact($vars))); + +		break;  	}  	// Set some vars @@ -197,7 +213,7 @@ function mcp_post_details($id, $mode, $action)  		$l_deleted_by = '';  	} -	$template->assign_vars(array( +	$mcp_post_template_data = 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  		'U_APPROVE_ACTION'		=> append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&p=$post_id&f={$post_info['forum_id']}"), @@ -249,7 +265,32 @@ function mcp_post_details($id, $mode, $action)  		'U_LOOKUP_IP'			=> ($auth->acl_get('m_info', $post_info['forum_id'])) ? "$url&i=$id&mode=$mode&lookup={$post_info['poster_ip']}#ip" : '',  		'U_WHOIS'				=> ($auth->acl_get('m_info', $post_info['forum_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&mode=$mode&action=whois&p=$post_id&ip={$post_info['poster_ip']}") : '', -	)); +	); + +	$s_additional_opts = false; + +	/** +	* Event to add/modify MCP post template data +	* +	* @event core.mcp_post_template_data +	* @var	array	post_info					Array with the post information +	* @var	array	mcp_post_template_data		Array with the MCP post template data +	* @var	array	attachments					Array with the post attachments, if any +	* @var	bool	s_additional_opts			Must be set to true in extension if additional options are presented in MCP post panel +	* @since 3.1.5-RC1 +	*/ +	$vars = array( +		'post_info', +		'mcp_post_template_data', +		'attachments', +		's_additional_opts', +	); +	extract($phpbb_dispatcher->trigger_event('core.mcp_post_template_data', compact($vars))); + +	$template->assign_vars($mcp_post_template_data); +	$template->assign_var('S_MCP_POST_ADDITIONAL_OPTS', $s_additional_opts); + +	unset($mcp_post_template_data);  	// Get User Notes  	$log_data = array(); @@ -420,7 +461,7 @@ function mcp_post_details($id, $mode, $action)  */  function change_poster(&$post_info, $userdata)  { -	global $auth, $db, $config, $phpbb_root_path, $phpEx, $user; +	global $auth, $db, $config, $phpbb_root_path, $phpEx, $user, $phpbb_dispatcher;  	if (empty($userdata) || $userdata['user_id'] == $post_info['user_id'])  	{ @@ -497,7 +538,7 @@ function change_poster(&$post_info, $userdata)  	{  		// We do some additional checks in the module to ensure it can actually be utilised  		$error = false; -		$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user); +		$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher);  		if (!$error && method_exists($search, 'destroy_cache'))  		{ @@ -518,6 +559,17 @@ function change_poster(&$post_info, $userdata)  	$post_info = $post_info[$post_id]; +	/** +	* This event allows you to perform additional tasks after changing a post's poster +	* +	* @event core.mcp_change_poster_after +	* @var	array	userdata	Information on a post's new poster +	* @var	array	post_info	Information on the affected post +	* @since 3.1.6-RC1 +	*/ +	$vars = array('userdata', 'post_info'); +	extract($phpbb_dispatcher->trigger_event('core.mcp_change_poster_after', compact($vars))); +  	// 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);  } diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 82c3bc9ab0..5fde63ecb4 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -404,7 +404,7 @@ class mcp_queue  				$forum_options = '<option value="0"' . (($forum_id == 0) ? ' selected="selected"' : '') . '>' . $user->lang['ALL_FORUMS'] . '</option>';  				foreach ($forum_list_approve as $row)  				{ -					$forum_options .= '<option value="' . $row['forum_id'] . '"' . (($forum_id == $row['forum_id']) ? ' selected="selected"' : '') . '>' . str_repeat('   ', $row['padding']) . $row['forum_name'] . '</option>'; +					$forum_options .= '<option value="' . $row['forum_id'] . '"' . (($forum_id == $row['forum_id']) ? ' selected="selected"' : '') . '>' . str_repeat('   ', $row['padding']) . truncate_string($row['forum_name'], 30, 255, false, $user->lang['ELLIPSIS']) . '</option>';  				}  				$sort_days = $total = 0; diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index 804d48ea97..fa2fed842f 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -73,18 +73,66 @@ class mcp_reports  				// closed reports are accessed by report id  				$report_id = request_var('r', 0); +				$sql_ary = array( +					'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', -				$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") . ' +					'FROM'		=> array( +						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  						AND r.user_id = u.user_id -						AND r.pm_id = 0 -					ORDER BY report_closed ASC'; +						AND r.pm_id = 0', + +					'ORDER_BY'	=> 'report_closed ASC', +				); + +				/** +				* Allow changing the query to obtain the user-submitted report. +				* +				* @event core.mcp_reports_report_details_query_before +				* @var	array	sql_ary			The array in the format of the query builder with the query +				* @var	mixed	forum_id		The forum_id, the number in the f GET parameter +				* @var	int		post_id			The post_id of the report being viewed (if 0, it is meaningless) +				* @var	int		report_id		The report_id of the report being viewed +				* @since 3.1.5-RC1 +				*/ +				$vars = array( +					'sql_ary', +					'forum_id', +					'post_id', +					'report_id', +				); +				extract($phpbb_dispatcher->trigger_event('core.mcp_reports_report_details_query_before', compact($vars))); + +				$sql = $db->sql_build_query('SELECT', $sql_ary);  				$result = $db->sql_query_limit($sql, 1);  				$report = $db->sql_fetchrow($result);  				$db->sql_freeresult($result); +				/** +				* Allow changing the data obtained from the user-submitted report. +				* +				* @event core.mcp_reports_report_details_query_after +				* @var	array	sql_ary		The array in the format of the query builder with the query that had been executted +				* @var	mixed	forum_id	The forum_id, the number in the f GET parameter +				* @var	int		post_id		The post_id of the report being viewed (if 0, it is meaningless) +				* @var	int		report_id	The report_id of the report being viewed +				* @var	int		report		The query's resulting row. +				* @since 3.1.5-RC1 +				*/ +				$vars = array( +					'sql_ary', +					'forum_id', +					'post_id', +					'report_id', +					'report', +				); +				extract($phpbb_dispatcher->trigger_event('core.mcp_reports_report_details_query_after', compact($vars))); +  				if (!$report)  				{  					trigger_error('NO_REPORT'); @@ -489,6 +537,7 @@ function close_report($report_id_list, $mode, $action, $pm = false)  	{  		$post_id_list[] = $row[$id_column];  	} +	$db->sql_freeresult($result);  	$post_id_list = array_unique($post_id_list);  	if ($pm) diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index 3a456169d5..8347830d0f 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -147,21 +147,13 @@ function mcp_topic_view($id, $mode, $action)  	$result = $db->sql_query_limit($sql, $posts_per_page, $start);  	$rowset = $post_id_list = array(); -	$bbcode_bitfield = '';  	while ($row = $db->sql_fetchrow($result))  	{  		$rowset[] = $row;  		$post_id_list[] = $row['post_id']; -		$bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']);  	}  	$db->sql_freeresult($result); -	if ($bbcode_bitfield !== '') -	{ -		include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx); -		$bbcode = new bbcode(base64_encode($bbcode_bitfield)); -	} -  	$topic_tracking_info = array();  	// Get topic tracking info @@ -267,6 +259,8 @@ function mcp_topic_view($id, $mode, $action)  		* @var	int		current_row_number	Number of the post on this page  		* @var	array	post_row			Template block array of the current post  		* @var	array	row					Array with original post and user data +		* @var	array	topic_info			Array with topic data +		* @var	int		total				Total posts count  		* @since 3.1.4-RC1  		*/  		$vars = array( @@ -278,6 +272,8 @@ function mcp_topic_view($id, $mode, $action)  			'current_row_number',  			'post_row',  			'row', +			'topic_info', +			'total',  		);  		extract($phpbb_dispatcher->trigger_event('core.mcp_topic_review_modify_row', compact($vars)));  | 
