Browse Source

! Did I mention how much I love consistency?

Signed-off-by: Michael Eshom <[email protected]>
Michael Eshom 10 years ago
parent
commit
00e3b0a5e8

+ 10 - 33
Sources/MoveTopic.php

@@ -30,7 +30,7 @@ if (!defined('SMF'))
  */
 function MoveTopic()
 {
-	global $txt, $board, $topic, $user_info, $context, $language, $scripturl, $settings, $smcFunc, $modSettings;
+	global $txt, $board, $topic, $user_info, $context, $language, $scripturl, $settings, $smcFunc, $modSettings, $sourcedir;
 
 	if (empty($topic))
 		fatal_lang_error('no_access', false);
@@ -79,41 +79,18 @@ function MoveTopic()
 
 	loadTemplate('MoveTopic');
 
-	// Get a list of boards this moderator can move to.
-	$request = $smcFunc['db_query']('order_by_board_order', '
-		SELECT b.id_board, b.name, b.child_level, c.name AS cat_name, c.id_cat
-		FROM {db_prefix}boards AS b
-			LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)
-		WHERE {query_see_board}
-			AND b.redirect = {string:blank_redirect}' . ($context['move_any'] ? '' : '
-			AND b.id_board IN ({array_int:boards})'),
-		array(
-			'blank_redirect' => '',
-			'current_board' => $board,
-			'boards' => $boards,
-		)
+	$options = array(
+		'not_redirection' => true,
 	);
-	$number_of_boards = $smcFunc['db_num_rows']($request);
-	while ($row = $smcFunc['db_fetch_assoc']($request))
-	{
-		if (!isset($context['categories'][$row['id_cat']]))
-			$context['categories'][$row['id_cat']] = array (
-				'name' => strip_tags($row['cat_name']),
-				'boards' => array(),
-			);
 
-		$context['categories'][$row['id_cat']]['boards'][] = array(
-			'id' => $row['id_board'],
-			'name' => strip_tags($row['name']),
-			'category' => strip_tags($row['cat_name']),
-			'child_level' => $row['child_level'],
-			'selected' => !empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] == $row['id_board'] && $row['id_board'] != $board,
-		);
-	}
-	$smcFunc['db_free_result']($request);
+	if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board)
+		$options['selected_board'] = $_SESSION['move_to_topic'];
+
+	if (!$context['move_any'])
+		$options['included_boards'] = $boards;
 
-	if (empty($context['categories']) || (!empty($number_of_boards) && $number_of_boards == 1))
-		fatal_lang_error('moveto_noboards', false);
+	require_once($sourcedir . '/Subs-MessageIndex.php');
+	$context['categories'] = getBoardList($options);
 
 	$context['page_title'] = $txt['move_topic'];
 

+ 13 - 29
Sources/SplitTopics.php

@@ -830,7 +830,7 @@ function MergeTopics()
  */
 function MergeIndex()
 {
-	global $txt, $board, $context, $smcFunc;
+	global $txt, $board, $context, $smcFunc, $sourcedir;
 	global $scripturl, $topic, $user_info, $modSettings;
 
 	if (!isset($_GET['from']))
@@ -898,40 +898,24 @@ function MergeIndex()
 	if (empty($merge_boards))
 		fatal_lang_error('cannot_merge_any', 'user');
 
-	// Get a list of boards they can navigate to to merge.
-	$request = $smcFunc['db_query']('order_by_board_order', '
-		SELECT b.id_board, b.name AS board_name, c.id_cat, c.name AS cat_name
-		FROM {db_prefix}boards AS b
-			LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)
-		WHERE {query_see_board}' . (!in_array(0, $merge_boards) ? '
-			AND b.id_board IN ({array_int:merge_boards})' : ''),
-		array(
-			'merge_boards' => $merge_boards,
-		)
-	);
-	$context['boards'] = array();
-	$context['num_boards'] = 0;
-	while ($row = $smcFunc['db_fetch_assoc']($request))
+	// No sense in loading this if you can only merge on this board
+	if (count($merge_boards) > 1 || in_array(0, $merge_boards))
 	{
-		if (!isset($context['merge_categories'][$row['id_cat']]))
-		{
-			$context['merge_categories'][$row['id_cat']] = array(
-				'id' => $row['id_cat'],
-				'name' => $row['cat_name'],
-				'boards' => array(),
-			);
-		}
+		require_once($sourcedir . '/Subs-MessageIndex.php');
 
-		$context['merge_categories'][$row['id_cat']]['boards'][$row['id_board']] = array(
-			'id' => $row['id_board'],
-			'name' => $row['board_name'],
+		// Set up a couple of options for our board list
+		$options = array(
+			'not_redirection' => true,
+			'selected_board' => $context['target_board'],
 		);
+	
+		// Only include these boards in the list (0 means you're an admin')
+		if (!in_array(0, $merge_boards))
+			$options['included_boards'] = $merge_boards;
 
-		$context['num_boards']++;
+		$context['merge_categories'] = getBoardList($options);
 	}
 
-	$smcFunc['db_free_result']($request);
-
 	// Get some topics to merge it with.
 	$request = $smcFunc['db_query']('', '
 		SELECT t.id_topic, m.subject, m.id_member, IFNULL(mem.real_name, m.poster_name) AS poster_name

+ 0 - 3
Sources/Subs-Db-postgresql.php

@@ -321,9 +321,6 @@ function smf_db_query($identifier, $db_string, $db_values = array(), $connection
 		'insert_log_search_results_subject' => array(
 			'~NOT RLIKE~' => '!~',
 		),
-		'messageindex_fetch_boards' => array(
-			'~(.)$~' => '$1 ORDER BY b.board_order',
-		),
 		'select_message_icons' => array(
 			'~(.)$~' => '$1 ORDER BY icon_order',
 		),

+ 0 - 3
Sources/Subs-Db-sqlite.php

@@ -317,9 +317,6 @@ function smf_db_query($identifier, $db_string, $db_values = array(), $connection
 		'boardindex_fetch_boards' => array(
 			'~(.)$~' => '$1 ORDER BY b.board_order',
 		),
-		'messageindex_fetch_boards' => array(
-			'~(.)$~' => '$1 ORDER BY b.board_order',
-		),
 		'order_by_board_order' => array(
 			'~(.)$~' => '$1 ORDER BY b.board_order',
 		),

+ 0 - 3
Sources/Subs-Db-sqlite3.php

@@ -357,9 +357,6 @@ function smf_db_query($identifier, $db_string, $db_values = array(), $connection
 		'boardindex_fetch_boards' => array(
 			'~(.)$~' => '$1 ORDER BY b.board_order',
 		),
-		'messageindex_fetch_boards' => array(
-			'~(.)$~' => '$1 ORDER BY b.board_order',
-		),
 		'order_by_board_order' => array(
 			'~(.)$~' => '$1 ORDER BY b.board_order',
 		),

+ 1 - 1
Sources/Subs-MessageIndex.php

@@ -54,7 +54,7 @@ function getBoardList($boardListOptions = array())
 		$where_parameters['blank_redirect'] = '';
 	}
 
-	$request = $smcFunc['db_query']('messageindex_fetch_boards', '
+	$request = $smcFunc['db_query']('order_by_board_order', '
 		SELECT c.name AS cat_name, c.id_cat, b.id_board, b.name AS board_name, b.child_level
 		FROM {db_prefix}boards AS b
 			LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)' . (empty($where) ? '' : '

+ 2 - 2
Themes/default/SplitTopics.template.php

@@ -276,7 +276,7 @@ function template_merge()
 							', $context['origin_subject'], '
 						</dd>';
 
-	if ($context['num_boards'] > 1)
+	if (isset($context['merge_categories']))
 	{
 			echo '
 						<dt>
@@ -294,7 +294,7 @@ function template_merge()
 				foreach ($cat['boards'] as $board)
 				{
 					echo '
-										<option value="', $board['id'], '"', $board['id'] == $context['target_board'] ? ' selected="selected"' : '', '>', $board['category'], ' - ', $board['name'], '</option>';
+										<option value="', $board['id'], '"', $board['selected'] ? ' selected="selected"' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '&nbsp;</option>';
 				}
 
 				echo '