diff options
Diffstat (limited to 'phpBB/includes/mcp/mcp_main.php')
| -rw-r--r-- | phpBB/includes/mcp/mcp_main.php | 213 | 
1 files changed, 33 insertions, 180 deletions
| diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index ad10a52705..6c6c5a5532 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -333,131 +333,22 @@ function change_topic_type($action, $topic_ids)  	if (confirm_box(true))  	{ -		if ($new_topic_type != POST_GLOBAL) +		$sql = 'UPDATE ' . TOPICS_TABLE . " +			SET topic_type = $new_topic_type +			WHERE " . $db->sql_in_set('topic_id', $topic_ids); +		$db->sql_query($sql); + +		if (($new_topic_type == POST_GLOBAL) && sizeof($topic_ids))  		{ +			// Delete topic shadows for global announcements +			$sql = 'DELETE FROM ' . TOPICS_TABLE . ' +				WHERE ' . $db->sql_in_set('topic_moved_id', $topic_ids); +			$db->sql_query($sql); +  			$sql = 'UPDATE ' . TOPICS_TABLE . "  				SET topic_type = $new_topic_type -				WHERE " . $db->sql_in_set('topic_id', $topic_ids) . ' -					AND forum_id <> 0'; +					WHERE " . $db->sql_in_set('topic_id', $topic_ids);  			$db->sql_query($sql); - -			// Reset forum id if a global topic is within the array -			$to_forum_id = request_var('to_forum_id', 0); - -			if ($to_forum_id) -			{ -				$sql = 'UPDATE ' . TOPICS_TABLE . " -					SET topic_type = $new_topic_type, forum_id = $to_forum_id -					WHERE " . $db->sql_in_set('topic_id', $topic_ids) . ' -						AND forum_id = 0'; -				$db->sql_query($sql); - -				// Update forum_ids for all posts -				$sql = 'UPDATE ' . POSTS_TABLE . " -					SET forum_id = $to_forum_id -					WHERE " . $db->sql_in_set('topic_id', $topic_ids) . ' -						AND forum_id = 0'; -				$db->sql_query($sql); - -				// Do a little forum sync stuff -				$sql = 'SELECT SUM(t.topic_replies + t.topic_approved) as topic_posts, COUNT(t.topic_approved) as topics_authed -					FROM ' . TOPICS_TABLE . ' t -					WHERE ' . $db->sql_in_set('t.topic_id', $topic_ids); -				$result = $db->sql_query($sql); -				$row_data = $db->sql_fetchrow($result); -				$db->sql_freeresult($result); - -				$sync_sql = array(); - -				if ($row_data['topic_posts']) -				{ -					$sync_sql[$to_forum_id][]	= 'forum_posts = forum_posts + ' . (int) $row_data['topic_posts']; -				} - -				if ($row_data['topics_authed']) -				{ -					$sync_sql[$to_forum_id][]	= 'forum_topics = forum_topics + ' . (int) $row_data['topics_authed']; -				} - -				$sync_sql[$to_forum_id][]	= 'forum_topics_real = forum_topics_real + ' . (int) sizeof($topic_ids); - -				foreach ($sync_sql as $forum_id_key => $array) -				{ -					$sql = 'UPDATE ' . FORUMS_TABLE . ' -						SET ' . implode(', ', $array) . ' -						WHERE forum_id = ' . $forum_id_key; -					$db->sql_query($sql); -				} - -				sync('forum', 'forum_id', $to_forum_id); -			} -		} -		else -		{ -			// Get away with those topics already being a global announcement by re-calculating $topic_ids -			$sql = 'SELECT topic_id -				FROM ' . TOPICS_TABLE . ' -				WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . ' -					AND forum_id <> 0'; -			$result = $db->sql_query($sql); - -			$topic_ids = array(); -			while ($row = $db->sql_fetchrow($result)) -			{ -				$topic_ids[] = $row['topic_id']; -			} -			$db->sql_freeresult($result); - -			if (sizeof($topic_ids)) -			{ -				// Delete topic shadows for global announcements -				$sql = 'DELETE FROM ' . TOPICS_TABLE . ' -					WHERE ' . $db->sql_in_set('topic_moved_id', $topic_ids); -				$db->sql_query($sql); - -				$sql = 'UPDATE ' . TOPICS_TABLE . " -					SET topic_type = $new_topic_type, forum_id = 0 -						WHERE " . $db->sql_in_set('topic_id', $topic_ids); -				$db->sql_query($sql); - -				// Update forum_ids for all posts -				$sql = 'UPDATE ' . POSTS_TABLE . ' -					SET forum_id = 0 -					WHERE ' . $db->sql_in_set('topic_id', $topic_ids); -				$db->sql_query($sql); - -				// Do a little forum sync stuff -				$sql = 'SELECT SUM(t.topic_replies + t.topic_approved) as topic_posts, COUNT(t.topic_approved) as topics_authed -					FROM ' . TOPICS_TABLE . ' t -					WHERE ' . $db->sql_in_set('t.topic_id', $topic_ids); -				$result = $db->sql_query($sql); -				$row_data = $db->sql_fetchrow($result); -				$db->sql_freeresult($result); - -				$sync_sql = array(); - -				if ($row_data['topic_posts']) -				{ -					$sync_sql[$forum_id][]	= 'forum_posts = forum_posts - ' . (int) $row_data['topic_posts']; -				} - -				if ($row_data['topics_authed']) -				{ -					$sync_sql[$forum_id][]	= 'forum_topics = forum_topics - ' . (int) $row_data['topics_authed']; -				} - -				$sync_sql[$forum_id][]	= 'forum_topics_real = forum_topics_real - ' . (int) sizeof($topic_ids); - -				foreach ($sync_sql as $forum_id_key => $array) -				{ -					$sql = 'UPDATE ' . FORUMS_TABLE . ' -						SET ' . implode(', ', $array) . ' -						WHERE forum_id = ' . $forum_id_key; -					$db->sql_query($sql); -				} - -				sync('forum', 'forum_id', $forum_id); -			}  		}  		$success_msg = (sizeof($topic_ids) == 1) ? 'TOPIC_TYPE_CHANGED' : 'TOPICS_TYPE_CHANGED'; @@ -474,41 +365,7 @@ function change_topic_type($action, $topic_ids)  	}  	else  	{ -		// Global topic involved? -		$global_involved = false; - -		if ($new_topic_type != POST_GLOBAL) -		{ -			$sql = 'SELECT forum_id -				FROM ' . TOPICS_TABLE . ' -				WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . ' -					AND forum_id = 0'; -			$result = $db->sql_query($sql); -			$row = $db->sql_fetchrow($result); -			$db->sql_freeresult($result); - -			if ($row) -			{ -				$global_involved = true; -			} -		} - -		if ($global_involved) -		{ -			global $template; - -			$template->assign_vars(array( -				'S_FORUM_SELECT'		=> make_forum_select(request_var('f', $forum_id), false, false, true, true), -				'S_CAN_LEAVE_SHADOW'	=> false, -				'ADDITIONAL_MSG'		=> (sizeof($topic_ids) == 1) ? $user->lang['SELECT_FORUM_GLOBAL_ANNOUNCEMENT'] : $user->lang['SELECT_FORUM_GLOBAL_ANNOUNCEMENTS']) -			); - -			confirm_box(false, $l_new_type, build_hidden_fields($s_hidden_fields), 'mcp_move.html'); -		} -		else -		{ -			confirm_box(false, $l_new_type, build_hidden_fields($s_hidden_fields)); -		} +		confirm_box(false, $l_new_type, build_hidden_fields($s_hidden_fields));  	}  	$redirect = request_var('redirect', "index.$phpEx"); @@ -532,6 +389,7 @@ function mcp_move_topic($topic_ids)  {  	global $auth, $user, $db, $template;  	global $phpEx, $phpbb_root_path; +	global $request;  	// Here we limit the operation to one forum only  	$forum_id = check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_move'), true); @@ -585,8 +443,8 @@ function mcp_move_topic($topic_ids)  	if (!$to_forum_id || $additional_msg)  	{ -		unset($_POST['confirm']); -		unset($_REQUEST['confirm_key']); +		$request->overwrite('confirm', null, phpbb_request_interface::POST); +		$request->overwrite('confirm_key', null);  	}  	if (confirm_box(true)) @@ -627,16 +485,13 @@ function mcp_move_topic($topic_ids)  			$topic_posts_added += $topic_info['topic_replies']; -			if ($topic_info['topic_type'] != POST_GLOBAL) -			{ -				$topics_removed++; -				$topic_posts_removed += $topic_info['topic_replies']; +			$topics_removed++; +			$topic_posts_removed += $topic_info['topic_replies']; -				if ($topic_info['topic_approved']) -				{ -					$topics_authed_removed++; -					$topic_posts_removed++; -				} +			if ($topic_info['topic_approved']) +			{ +				$topics_authed_removed++; +				$topic_posts_removed++;  			}  		} @@ -659,6 +514,14 @@ function mcp_move_topic($topic_ids)  		// Move topics, but do not resync yet  		move_topics($topic_ids, $to_forum_id, false); +		if ($request->is_set_post('move_lock_topics') && $auth->acl_get('m_lock', $to_forum_id)) +		{ +			$sql = 'UPDATE ' . TOPICS_TABLE . ' +				SET topic_status = ' . ITEM_LOCKED . ' +				WHERE ' . $db->sql_in_set('topic_id', $topic_ids); +			$db->sql_query($sql); +		} +  		$forum_ids = array($to_forum_id);  		foreach ($topic_data as $topic_id => $row)  		{ @@ -666,15 +529,6 @@ function mcp_move_topic($topic_ids)  			$forum_ids[] = $row['forum_id'];  			add_log('mod', $to_forum_id, $topic_id, 'LOG_MOVE', $row['forum_name'], $forum_data['forum_name']); -			// If we have moved a global announcement, we need to correct the topic type -			if ($row['topic_type'] == POST_GLOBAL) -			{ -				$sql = 'UPDATE ' . TOPICS_TABLE . ' -					SET topic_type = ' . POST_ANNOUNCE . ' -					WHERE topic_id = ' . (int) $row['topic_id']; -				$db->sql_query($sql); -			} -  			// Leave a redirection if required and only if the topic is visible to users  			if ($leave_shadow && $row['topic_approved'] && $row['topic_type'] != POST_GLOBAL)  			{ @@ -756,6 +610,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)  		); @@ -1037,8 +892,8 @@ function mcp_fork_topic($topic_ids)  	if ($additional_msg)  	{ -		unset($_POST['confirm']); -		unset($_REQUEST['confirm_key']); +		$request->overwrite('confirm', null, phpbb_request_interface::POST); +		$request->overwrite('confirm_key', null);  	}  	if (confirm_box(true)) @@ -1314,5 +1169,3 @@ function mcp_fork_topic($topic_ids)  		trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link);  	}  } - -?>
\ No newline at end of file | 
