function CopyMultipleTopics() { global $board, $sourcedir, $user_info, $modSettings, $smcFunc; // Empty array? if (empty($_REQUEST['topics'])) { return; } // If copying multiple topics, we want them in the exact same order. $_REQUEST['topics'] = array_reverse($_REQUEST['topics']); $topics = array(); foreach ($_REQUEST['topics'] as $topic) { $topic = (int) $topic; if (!empty($topic)) { $topics[] = $topic; } } unset($topic); // Destination board empty or equal to 0? // Uses move_to because hijacking the move to dropdown if (empty($_REQUEST['move_to'])) { $_REQUEST['move_to'] = $board; } $_REQUEST['move_to'] = (int) $_REQUEST['move_to']; // Permission check! isAllowedTo('copy'); // Check Session checkSession(); // Destination board exists $request = $smcFunc['db_query']('', ' SELECT count_posts FROM {db_prefix}boards WHERE id_board = {int:move_to} LIMIT 1 ', array('move_to' => $_REQUEST['move_to'])); if ($smcFunc['db_num_rows']($request) == 0) { fatal_lang_error('no_board'); } list($count_posts) = $smcFunc['db_fetch_row']($request); $smcFunc['db_free_result']($request); // Strangely 0 = true, 1 = false $count_posts = empty($count_posts) ? 1 : 0; // Can the user see that board $request = $smcFunc['db_query']('', ' SELECT count(*) FROM {db_prefix}boards WHERE id_board = {int:move_to} AND {query_see_board} LIMIT 1 ', array('move_to' => $_REQUEST['move_to'])); if ($smcFunc['db_num_rows']($request) == 0) { fatal_lang_error('copytopic_notallowed'); } // Remember this for later. $_SESSION['copy_to_topic'] = $_REQUEST['move_to']; foreach ($topics as $topic) { // THE ACTUAL COPYING FUNCTION CopyTopics($topic, $_REQUEST['move_to'], $count_posts); // Log that they copied this topic. if (allowedTo('copy')) { logAction('copy', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_REQUEST['move_to'])); } } // Why not go back to the original board in case they want to keep moving? if (!isset($_REQUEST['goback'])) { redirectexit('board=' . $board . '.0'); } else { redirectexit(); } }
function CopyMultipleTopics() { global $board, $db_prefix, $sourcedir, $ID_MEMBER, $user_info, $modSettings; // Empty array? if (empty($_REQUEST['topics'])) { return; } // If copying multiple topics, we want them in the exact same order. $_REQUEST['topics'] = array_reverse($_REQUEST['topics']); $topics = array(); foreach ($_REQUEST['topics'] as $topic) { $topic = (int) $topic; if (!empty($topic)) { $topics[] = $topic; } } unset($topic); // Destination board empty or equal to 0? if (empty($_REQUEST['move_to'])) { $_REQUEST['move_to'] = $board; } $_REQUEST['move_to'] = (int) $_REQUEST['move_to']; // Permission check! isAllowedTo('copy'); // Check Session checkSession(); // Destination board exists $request = db_query("\n\t\tSELECT countPosts\n\t\tFROM {$db_prefix}boards\n\t\tWHERE ID_BOARD = {$_REQUEST['move_to']}\n\t\tLIMIT 1", __FILE__, __LINE__); if (mysql_num_rows($request) == 0) { fatal_lang_error('smf232'); } list($countPosts) = mysql_fetch_row($request); mysql_free_result($request); // Strangely 0 = true, 1 = false $countPosts = empty($countPosts) ? 1 : 0; // Can the user see that board $request = db_query("\n\t\tSELECT count(*)\n\t\tFROM {$db_prefix}boards\n\t\tWHERE ID_BOARD = {$_REQUEST['move_to']}\n\t\t\tAND {$user_info['query_see_board']}\n\t\tLIMIT 1", __FILE__, __LINE__); if (mysql_num_rows($request) == 0) { fatal_lang_error('copytopic_notallowed'); } // Remember this for later. $_SESSION['copy_to_topic'] = $_REQUEST['move_to']; foreach ($topics as $topic) { // THE ACTUAL COPYING FUNCTION CopyTopics($topic, $_REQUEST['move_to'], $countPosts); // Log that they copied this topic. if (allowedTo('copy')) { logAction('copy', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_REQUEST['move_to'])); } } // Why not go back to the original board in case they want to keep moving? if (!isset($_REQUEST['goback'])) { redirectexit('board=' . $board . '.0'); } else { redirectexit(); } }