diff options
Diffstat (limited to 'phpBB/includes/mcp/mcp_main.php')
| -rw-r--r-- | phpBB/includes/mcp/mcp_main.php | 244 | 
1 files changed, 45 insertions, 199 deletions
diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index db7bc7c7ea..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"); @@ -628,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++;  			}  		} @@ -675,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)  			{ @@ -1058,37 +903,38 @@ function mcp_fork_topic($topic_ids)  		$total_posts = 0;  		$new_topic_id_list = array(); -		if ($topic_data['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)) +		foreach ($topic_data as $topic_id => $topic_row) +		{ +			if (!isset($search_type) && $topic_row['enable_indexing'])  			{ -				trigger_error('NO_SUCH_SEARCH_MODULE'); -			} +				// Select the search method and do some additional checks to ensure it can actually be utilised +				$search_type = basename($config['search_type']); -			if (!class_exists($search_type)) -			{ -				include("{$phpbb_root_path}includes/search/$search_type.$phpEx"); -			} +				if (!file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx)) +				{ +					trigger_error('NO_SUCH_SEARCH_MODULE'); +				} + +				if (!class_exists($search_type)) +				{ +					include("{$phpbb_root_path}includes/search/$search_type.$phpEx"); +				} -			$error = false; -			$search = new $search_type($error); -			$search_mode = 'post'; +				$error = false; +				$search = new $search_type($error); +				$search_mode = 'post'; -			if ($error) +				if ($error) +				{ +					trigger_error($error); +				} +			} +			else if (!isset($search_type) && !$topic_row['enable_indexing'])  			{ -				trigger_error($error); +				$search_type = false;  			} -		} -		else -		{ -			$search_type = false; -		} -		foreach ($topic_data as $topic_id => $topic_row) -		{  			$sql_ary = array(  				'forum_id'					=> (int) $to_forum_id,  				'icon_id'					=> (int) $topic_row['icon_id'], @@ -1197,9 +1043,9 @@ function mcp_fork_topic($topic_ids)  				// Copy whether the topic is dotted  				markread('post', $to_forum_id, $new_topic_id, 0, $row['poster_id']); -				if ($search_type) +				if (!empty($search_type))  				{ -					$search->index($search_mode, $sql_ary['post_id'], $sql_ary['post_text'], $sql_ary['post_subject'], $sql_ary['poster_id'], ($topic_row['topic_type'] == POST_GLOBAL) ? 0 : $to_forum_id); +					$search->index($search_mode, $new_post_id, $sql_ary['post_text'], $sql_ary['post_subject'], $sql_ary['poster_id'], ($topic_row['topic_type'] == POST_GLOBAL) ? 0 : $to_forum_id);  					$search_mode = 'reply'; // After one we index replies  				}  | 
