/** * Do the actual split. * is accessed with ?action=splittopics;sa=execute. * uses the main SplitTopics template. * supports three ways of splitting: * (1) only one message is split off. * (2) all messages after and including a given message are split off. * (3) select topics to split (redirects to action_splitSelectTopics()). * uses splitTopic function to do the actual splitting. */ public function action_splitExecute() { global $txt, $context, $topic; // Check the session to make sure they meant to do this. checkSession(); // Set the form options in to session $this->_set_session_values(); // Cant post an empty redirect topic if (!empty($_SESSION['messageRedirect']) && empty($_SESSION['reason'])) { $this->_unset_session_values(); fatal_lang_error('splittopic_no_reason', false); } // Redirect to the selector if they chose selective. if ($_POST['step2'] == 'selective') { if (!empty($_POST['at'])) { $_SESSION['split_selection'][$topic][] = (int) $_POST['at']; } return $this->action_splitSelectTopics(); } // We work with them topics. require_once SUBSDIR . '/Topic.subs.php'; require_once SUBSDIR . '/Boards.subs.php'; // Make sure they can see the board they are trying to move to // (and get whether posts count in the target board). // Before the actual split because of the fatal_lang_errors $boards = splitDestinationBoard($_SESSION['move_to_board']); $splitAt = (int) $_POST['at']; $messagesToBeSplit = array(); // Fetch the message IDs of the topic that are at or after the message. if ($_POST['step2'] == 'afterthis') { $messagesToBeSplit = messagesSince($topic, $splitAt, true); } elseif ($_POST['step2'] == 'onlythis') { $messagesToBeSplit[] = $splitAt; } else { $this->_unset_session_values(); fatal_lang_error('no_access', false); } $context['old_topic'] = $topic; $context['new_topic'] = splitTopic($topic, $messagesToBeSplit, $_SESSION['new_topic_subject']); $context['page_title'] = $txt['split_topic']; $context['sub_template'] = 'split_successful'; splitAttemptMove($boards, $context['new_topic']); // Create a link to this in the old topic. // @todo Does this make sense if the topic was unapproved before? We are not yet sure if the resulting topic is unapproved. if ($_SESSION['messageRedirect']) { postSplitRedirect($_SESSION['reason'], $_SESSION['new_topic_subject'], $boards['destination'], $context['new_topic']); } $this->_unset_session_values(); }
/** * Do the actual split. * is accessed with ?action=splittopics;sa=execute. * uses the main SplitTopics template. * supports three ways of splitting: * (1) only one message is split off. * (2) all messages after and including a given message are split off. * (3) select topics to split (redirects to action_splitSelectTopics()). * uses splitTopic function to do the actual splitting. */ public function action_splitExecute() { global $txt, $context, $topic; // Check the session to make sure they meant to do this. checkSession(); // Clean up the subject. if (isset($_POST['subname'])) { $this->_new_topic_subject = trim(Util::htmlspecialchars($_POST['subname'])); } if (empty($this->_new_topic_subject)) { $this->_new_topic_subject = $txt['new_topic']; } if (empty($_SESSION['move_to_board'])) { $context['move_to_board'] = !empty($_POST['move_to_board']) ? (int) $_POST['move_to_board'] : 0; $context['reason'] = !empty($_POST['reason']) ? trim(Util::htmlspecialchars($_POST['reason'], ENT_QUOTES)) : ''; } else { $context['move_to_board'] = (int) $_SESSION['move_to_board']; $context['reason'] = trim(Util::htmlspecialchars($_SESSION['reason'])); } $_SESSION['move_to_board'] = $context['move_to_board']; $_SESSION['reason'] = $context['reason']; // Redirect to the selector if they chose selective. if ($_POST['step2'] == 'selective') { return $this->action_splitSelectTopics(); } // We work with them topics. require_once SUBSDIR . '/Topic.subs.php'; require_once SUBSDIR . '/Boards.subs.php'; // Make sure they can see the board they are trying to move to (and get whether posts count in the target board). if (!empty($_POST['messageRedirect']) && empty($context['reason'])) { fatal_lang_error('splittopic_no_reason', false); } // Before the actual split because of the fatal_lang_errors $boards = splitDestinationBoard(); $splitAt = (int) $_POST['at']; $messagesToBeSplit = array(); // Fetch the message IDs of the topic that are at or after the message. if ($_POST['step2'] == 'afterthis') { $messagesToBeSplit = messagesSince($topic, $splitAt, true); } elseif ($_POST['step2'] == 'onlythis') { $messagesToBeSplit[] = $splitAt; } else { fatal_lang_error('no_access', false); } $context['old_topic'] = $topic; $context['new_topic'] = splitTopic($topic, $messagesToBeSplit, $this->_new_topic_subject); $context['page_title'] = $txt['split_topic']; $context['sub_template'] = 'split_successful'; splitAttemptMove($boards, $context['new_topic']); }