diff options
| author | javiexin <javiexin@gmail.com> | 2017-05-21 18:25:57 +0200 | 
|---|---|---|
| committer | javiexin <javiexin@gmail.com> | 2017-05-21 18:25:57 +0200 | 
| commit | 37c48a59c318c12547c371f0d0a8bc84f5206dcf (patch) | |
| tree | a45b111970e291ff871733cfe003a74e0631c441 /phpBB/includes/mcp/mcp_main.php | |
| parent | 60d6667eb4c5ad8a02d67dea62bc2d5b9553f958 (diff) | |
| parent | bd12504f6cf03b36821a5cea2bf77a419496dcdb (diff) | |
| download | forums-37c48a59c318c12547c371f0d0a8bc84f5206dcf.tar forums-37c48a59c318c12547c371f0d0a8bc84f5206dcf.tar.gz forums-37c48a59c318c12547c371f0d0a8bc84f5206dcf.tar.bz2 forums-37c48a59c318c12547c371f0d0a8bc84f5206dcf.tar.xz forums-37c48a59c318c12547c371f0d0a8bc84f5206dcf.zip  | |
Merge branch 'ticket/15068' of https://github.com/javiexin/phpbb into ticket/15068
Diffstat (limited to 'phpBB/includes/mcp/mcp_main.php')
| -rw-r--r-- | phpBB/includes/mcp/mcp_main.php | 156 | 
1 files changed, 114 insertions, 42 deletions
diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index b2441aed1b..971982e4fc 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -35,8 +35,8 @@ class mcp_main  	function main($id, $mode)  	{ -		global $auth, $db, $user, $template, $action; -		global $config, $phpbb_root_path, $phpEx, $request; +		global $auth, $user, $action; +		global $phpbb_root_path, $phpEx, $request;  		global $phpbb_dispatcher;  		$quickmod = ($mode == 'quickmod') ? true : false; @@ -45,7 +45,7 @@ class mcp_main  		{  			case 'lock':  			case 'unlock': -				$topic_ids = (!$quickmod) ? request_var('topic_id_list', array(0)) : array(request_var('t', 0)); +				$topic_ids = (!$quickmod) ? $request->variable('topic_id_list', array(0)) : array($request->variable('t', 0));  				if (!sizeof($topic_ids))  				{ @@ -58,7 +58,7 @@ class mcp_main  			case 'lock_post':  			case 'unlock_post': -				$post_ids = (!$quickmod) ? request_var('post_id_list', array(0)) : array(request_var('p', 0)); +				$post_ids = (!$quickmod) ? $request->variable('post_id_list', array(0)) : array($request->variable('p', 0));  				if (!sizeof($post_ids))  				{ @@ -73,7 +73,7 @@ class mcp_main  			case 'make_global':  			case 'make_normal': -				$topic_ids = (!$quickmod) ? request_var('topic_id_list', array(0)) : array(request_var('t', 0)); +				$topic_ids = (!$quickmod) ? $request->variable('topic_id_list', array(0)) : array($request->variable('t', 0));  				if (!sizeof($topic_ids))  				{ @@ -86,7 +86,7 @@ class mcp_main  			case 'move':  				$user->add_lang('viewtopic'); -				$topic_ids = (!$quickmod) ? request_var('topic_id_list', array(0)) : array(request_var('t', 0)); +				$topic_ids = (!$quickmod) ? $request->variable('topic_id_list', array(0)) : array($request->variable('t', 0));  				if (!sizeof($topic_ids))  				{ @@ -99,7 +99,7 @@ class mcp_main  			case 'fork':  				$user->add_lang('viewtopic'); -				$topic_ids = (!$quickmod) ? request_var('topic_id_list', array(0)) : array(request_var('t', 0)); +				$topic_ids = (!$quickmod) ? $request->variable('topic_id_list', array(0)) : array($request->variable('t', 0));  				if (!sizeof($topic_ids))  				{ @@ -164,7 +164,7 @@ class mcp_main  				* @var	string	action		Topic quick moderation action name  				* @var	bool	quickmod	Flag indicating whether MCP is in quick moderation mode  				* @since 3.1.0-a4 -				* @change 3.1.0-RC4 Added variables: action, quickmod +				* @changed 3.1.0-RC4 Added variables: action, quickmod  				*/  				$vars = array('action', 'quickmod');  				extract($phpbb_dispatcher->trigger_event('core.modify_quickmod_actions', compact($vars))); @@ -189,7 +189,7 @@ class mcp_main  				$user->add_lang('viewforum'); -				$forum_id = request_var('f', 0); +				$forum_id = $request->variable('f', 0);  				$forum_info = phpbb_get_forum_data($forum_id, 'm_', true); @@ -262,7 +262,7 @@ class mcp_main  */  function lock_unlock($action, $ids)  { -	global $auth, $user, $db, $phpEx, $phpbb_root_path, $request, $phpbb_dispatcher; +	global $user, $db, $request, $phpbb_log, $phpbb_dispatcher;  	if ($action == 'lock' || $action == 'unlock')  	{ @@ -298,7 +298,7 @@ function lock_unlock($action, $ids)  	}  	unset($orig_ids); -	$redirect = request_var('redirect', build_url(array('action', 'quickmod'))); +	$redirect = $request->variable('redirect', build_url(array('action', 'quickmod')));  	$redirect = reapply_sid($redirect);  	$s_hidden_fields = build_hidden_fields(array( @@ -306,7 +306,6 @@ function lock_unlock($action, $ids)  		'action'			=> $action,  		'redirect'			=> $redirect)  	); -	$success_msg = '';  	if (confirm_box(true))  	{ @@ -319,7 +318,12 @@ function lock_unlock($action, $ids)  		foreach ($data as $id => $row)  		{ -			add_log('mod', $row['forum_id'], $row['topic_id'], 'LOG_' . strtoupper($action), $row['topic_title']); +			$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_' . strtoupper($action), false, array( +				'forum_id' => $row['forum_id'], +				'topic_id' => $row['topic_id'], +				'post_id'  => isset($row['post_id']) ? $row['post_id'] : 0, +				$row['topic_title'] +			));  		}  		/** @@ -362,7 +366,7 @@ function lock_unlock($action, $ids)  */  function change_topic_type($action, $topic_ids)  { -	global $auth, $user, $db, $phpEx, $phpbb_root_path, $request; +	global $user, $db, $request, $phpbb_log;  	switch ($action)  	{ @@ -374,7 +378,7 @@ function change_topic_type($action, $topic_ids)  		case 'make_global':  			$new_topic_type = POST_GLOBAL; -			$check_acl = 'f_announce'; +			$check_acl = 'f_announce_global';  			$l_new_type = (sizeof($topic_ids) == 1) ? 'MCP_MAKE_GLOBAL' : 'MCP_MAKE_GLOBALS';  		break; @@ -398,7 +402,7 @@ function change_topic_type($action, $topic_ids)  		return;  	} -	$redirect = request_var('redirect', build_url(array('action', 'quickmod'))); +	$redirect = $request->variable('redirect', build_url(array('action', 'quickmod')));  	$redirect = reapply_sid($redirect);  	$s_hidden_fields = array( @@ -407,7 +411,6 @@ function change_topic_type($action, $topic_ids)  		'action'		=> $action,  		'redirect'		=> $redirect,  	); -	$success_msg = '';  	if (confirm_box(true))  	{ @@ -437,7 +440,11 @@ function change_topic_type($action, $topic_ids)  			foreach ($data as $topic_id => $row)  			{ -				add_log('mod', $forum_id, $topic_id, 'LOG_TOPIC_TYPE_CHANGED', $row['topic_title']); +				$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_TOPIC_TYPE_CHANGED', false, array( +					'forum_id' => $forum_id, +					'topic_id' => $topic_id, +					$row['topic_title'] +				));  			}  		} @@ -463,7 +470,7 @@ function change_topic_type($action, $topic_ids)  */  function mcp_move_topic($topic_ids)  { -	global $auth, $user, $db, $template, $phpbb_log, $request; +	global $auth, $user, $db, $template, $phpbb_log, $request, $phpbb_dispatcher;  	global $phpEx, $phpbb_root_path;  	// Here we limit the operation to one forum only @@ -474,8 +481,8 @@ function mcp_move_topic($topic_ids)  		return;  	} -	$to_forum_id = request_var('to_forum_id', 0); -	$redirect = request_var('redirect', build_url(array('action', 'quickmod'))); +	$to_forum_id = $request->variable('to_forum_id', 0); +	$redirect = $request->variable('redirect', build_url(array('action', 'quickmod')));  	$additional_msg = $success_msg = '';  	$s_hidden_fields = build_hidden_fields(array( @@ -625,6 +632,18 @@ function mcp_move_topic($topic_ids)  					'poll_last_vote'		=>	(int) $row['poll_last_vote']  				); +				/** +				* Perform actions before shadow topic is created. +				* +				* @event core.mcp_main_modify_shadow_sql +				* @var	array	shadow	SQL array to be used by $db->sql_build_array +				* @since 3.1.11-RC1 +				*/ +				$vars = array( +					'shadow', +				); +				extract($phpbb_dispatcher->trigger_event('core.mcp_main_modify_shadow_sql', compact($vars))); +  				$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 @@ -695,7 +714,7 @@ function mcp_move_topic($topic_ids)  		confirm_box(false, 'MOVE_TOPIC' . ((sizeof($topic_ids) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_move.html');  	} -	$redirect = request_var('redirect', "index.$phpEx"); +	$redirect = $request->variable('redirect', "index.$phpEx");  	$redirect = reapply_sid($redirect);  	if (!$success_msg) @@ -720,7 +739,7 @@ function mcp_move_topic($topic_ids)  */  function mcp_restore_topic($topic_ids)  { -	global $auth, $user, $db, $phpEx, $phpbb_root_path, $request, $phpbb_container; +	global $user, $phpEx, $phpbb_root_path, $request, $phpbb_container, $phpbb_log;  	if (!phpbb_check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_approve')))  	{ @@ -744,13 +763,19 @@ function mcp_restore_topic($topic_ids)  		$data = phpbb_get_topic_data($topic_ids); +		/* @var $phpbb_content_visibility \phpbb\content_visibility */  		$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']); +				$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_RESTORE_TOPIC', false, array( +					'forum_id' => $row['forum_id'], +					'topic_id' => $topic_id, +					$row['topic_title'], +					$row['topic_first_poster_name'] +				));  			}  		}  	} @@ -793,7 +818,7 @@ function mcp_restore_topic($topic_ids)  */  function mcp_delete_topic($topic_ids, $is_soft = false, $soft_delete_reason = '', $action = 'delete_topic')  { -	global $auth, $user, $db, $phpEx, $phpbb_root_path, $request, $phpbb_container; +	global $auth, $user, $db, $phpEx, $phpbb_root_path, $request, $phpbb_container, $phpbb_log;  	$check_permission = ($is_soft) ? 'm_softdelete' : 'm_delete';  	if (!phpbb_check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array($check_permission))) @@ -822,30 +847,47 @@ function mcp_delete_topic($topic_ids, $is_soft = false, $soft_delete_reason = ''  		{  			if ($row['topic_moved_id'])  			{ -				add_log('mod', $row['forum_id'], $topic_id, 'LOG_DELETE_SHADOW_TOPIC', $row['topic_title']); +				$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_DELETE_SHADOW_TOPIC', false, array( +					'forum_id' => $row['forum_id'], +					'topic_id' => $topic_id, +					$row['topic_title'] +				));  			}  			else  			{  				// Only soft delete non-shadow topics  				if ($is_soft)  				{ +					/* @var $phpbb_content_visibility \phpbb\content_visibility */  					$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); +						$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_SOFTDELETE_TOPIC', false, array( +							'forum_id' => $row['forum_id'], +							'topic_id' => $topic_id, +							$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); +					$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_DELETE_TOPIC', false, array( +						'forum_id' => $row['forum_id'], +						'topic_id' => $topic_id, +						$row['topic_title'], +						$row['topic_first_poster_name'], +						$soft_delete_reason +					));  				}  			}  		}  		if (!$is_soft)  		{ -			$return = delete_topics('topic_id', $topic_ids); +			delete_topics('topic_id', $topic_ids);  		}  	}  	else @@ -933,7 +975,7 @@ function mcp_delete_topic($topic_ids, $is_soft = false, $soft_delete_reason = ''  */  function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '', $action = 'delete_post')  { -	global $auth, $user, $db, $phpEx, $phpbb_root_path, $request, $phpbb_container; +	global $auth, $user, $db, $phpEx, $phpbb_root_path, $request, $phpbb_container, $phpbb_log;  	$check_permission = ($is_soft) ? 'm_softdelete' : 'm_delete';  	if (!phpbb_check_ids($post_ids, POSTS_TABLE, 'post_id', array($check_permission))) @@ -983,6 +1025,7 @@ function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '',  			$approve_log[] = array(  				'forum_id'		=> $post_data['forum_id'],  				'topic_id'		=> $post_data['topic_id'], +				'post_id'		=> $post_id,  				'post_subject'	=> $post_data['post_subject'],  				'poster_id'		=> $post_data['poster_id'],  				'post_username'	=> $post_data['post_username'], @@ -990,6 +1033,7 @@ function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '',  			);  		} +		/* @var $phpbb_content_visibility \phpbb\content_visibility */  		$phpbb_content_visibility = $phpbb_container->get('content.visibility');  		foreach ($topic_info as $topic_id => $topic_data)  		{ @@ -1004,7 +1048,14 @@ function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '',  		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); +			$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_SOFTDELETE_POST', false, array( +				'forum_id' => $row['forum_id'], +				'topic_id' => $row['topic_id'], +				'post_id'  => $row['post_id'], +				$row['post_subject'], +				$post_username, +				$soft_delete_reason +			));  		}  		$topic_id = $request->variable('t', 0); @@ -1047,7 +1098,14 @@ function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '',  		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, $soft_delete_reason); +			$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_DELETE_POST', false, array( +				'forum_id' => $row['forum_id'], +				'topic_id' => $row['topic_id'], +				'post_id'  => $row['post_id'], +				$row['post_subject'], +				$post_username, +				$soft_delete_reason +			));  		}  		// Now delete the posts, topics and forums are automatically resync'ed @@ -1162,16 +1220,16 @@ 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, $phpbb_dispatcher; +	global $phpEx, $phpbb_root_path, $phpbb_log, $request, $phpbb_dispatcher;  	if (!phpbb_check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_')))  	{  		return;  	} -	$to_forum_id = request_var('to_forum_id', 0); -	$forum_id = request_var('f', 0); -	$redirect = request_var('redirect', build_url(array('action', 'quickmod'))); +	$to_forum_id = $request->variable('to_forum_id', 0); +	$forum_id = $request->variable('f', 0); +	$redirect = $request->variable('redirect', build_url(array('action', 'quickmod')));  	$additional_msg = $success_msg = '';  	$counter = array(); @@ -1281,6 +1339,18 @@ function mcp_fork_topic($topic_ids)  				'poll_vote_change'			=> (int) $topic_row['poll_vote_change'],  			); +			/** +			* Perform actions before forked topic is created. +			* +			* @event core.mcp_main_modify_fork_sql +			* @var	array	sql_ary	SQL array to be used by $db->sql_build_array +			* @since 3.1.11-RC1 +			*/ +			$vars = array( +				'sql_ary', +			); +			extract($phpbb_dispatcher->trigger_event('core.mcp_main_modify_fork_sql', compact($vars))); +  			$db->sql_query('INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));  			$new_topic_id = $db->sql_nextid();  			$new_topic_id_list[$topic_id] = $new_topic_id; @@ -1301,8 +1371,6 @@ function mcp_fork_topic($topic_ids)  			if ($topic_row['poll_start'])  			{ -				$poll_rows = array(); -  				$sql = 'SELECT *  					FROM ' . POLL_OPTIONS_TABLE . "  					WHERE topic_id = $topic_id"; @@ -1515,12 +1583,16 @@ function mcp_fork_topic($topic_ids)  		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); +		$config->increment('num_topics', sizeof($new_topic_id_list), false); +		$config->increment('num_posts', $total_posts, false);  		foreach ($new_topic_id_list as $topic_id => $new_topic_id)  		{ -			add_log('mod', $to_forum_id, $new_topic_id, 'LOG_FORK', $topic_row['forum_name']); +			$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_FORK', false, array( +				'forum_id' => $to_forum_id, +				'topic_id' => $new_topic_id, +				$topic_row['forum_name'] +			));  		}  		$success_msg = (sizeof($topic_ids) == 1) ? 'TOPIC_FORKED_SUCCESS' : 'TOPICS_FORKED_SUCCESS'; @@ -1536,7 +1608,7 @@ function mcp_fork_topic($topic_ids)  		confirm_box(false, 'FORK_TOPIC' . ((sizeof($topic_ids) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_move.html');  	} -	$redirect = request_var('redirect', "index.$phpEx"); +	$redirect = $request->variable('redirect', "index.$phpEx");  	$redirect = reapply_sid($redirect);  	if (!$success_msg)  | 
