/** * The actualiser to move a topic. * * @return tempcode The UI */ function _move_topic() { $topic_id = get_param_integer('id'); $to = post_param_integer('to'); $from = $GLOBALS['FORUM_DB']->query_value_null_ok('f_topics', 't_forum_id', array('id' => $topic_id)); require_code('ocf_topics_action'); require_code('ocf_topics_action2'); ocf_move_topics($from, $to, array($topic_id)); ocf_edit_topic($topic_id, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '', post_param('title')); return post_param_integer('redir_topic', 0) == 0 ? $this->redirect_to_forum('MOVE_TOPIC', $from) : $this->redirect_to('MOVE_TOPIC', $topic_id); }
/** * Delete a forum. * * @param AUTO_LINK The ID of the forum we are deleting. * @param AUTO_LINK The ID of the forum that topics will be moved to. * @param BINARY Whether to delete topics instead of moving them to the target forum. */ function ocf_delete_forum($forum_id, $target_forum_id, $delete_topics = 0) { if ($forum_id == db_get_first_id()) { warn_exit(do_lang_tempcode('CANNOT_DELETE_ROOT_FORUM')); } require_code('ocf_topics_action'); require_code('ocf_topics_action2'); if ($delete_topics == 0) { ocf_move_topics($forum_id, $target_forum_id); } else { $rows = $GLOBALS['FORUM_DB']->query_select('f_topics', array('id'), array('t_forum_id' => $forum_id)); foreach ($rows as $row) { ocf_delete_topic($row['id'], ''); } } $forum_info = $GLOBALS['FORUM_DB']->query_select('f_forums', array('*'), array('id' => $forum_id), '', 1); if (!array_key_exists(0, $forum_info)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } delete_lang($forum_info[0]['f_description'], $GLOBALS['FORUM_DB']); delete_lang($forum_info[0]['f_intro_question'], $GLOBALS['FORUM_DB']); $name = $GLOBALS['FORUM_DB']->query_value('f_forums', 'f_name', array('id' => $forum_id)); $GLOBALS['FORUM_DB']->query_update('f_multi_moderations', array('mm_move_to' => NULL), array('mm_move_to' => $forum_id)); $GLOBALS['FORUM_DB']->query_update('f_forums', array('f_parent_forum' => db_get_first_id()), array('f_parent_forum' => $forum_id)); $GLOBALS['FORUM_DB']->query_delete('f_forums', array('id' => $forum_id), '', 1); $GLOBALS['FORUM_DB']->query_delete('group_category_access', array('module_the_name' => 'forums', 'category_name' => strval($forum_id))); $GLOBALS['FORUM_DB']->query_delete('gsp', array('module_the_name' => 'forums', 'category_name' => strval($forum_id))); require_code('notifications'); delete_all_notifications_on('ocf_topic', 'forum:' . strval($forum_id)); $GLOBALS['FORUM_DB']->query_delete('f_forum_intro_member', array('i_forum_id' => $forum_id)); $GLOBALS['FORUM_DB']->query_delete('f_forum_intro_ip', array('i_forum_id' => $forum_id)); log_it('DELETE_FORUM', strval($forum_id), $name); }
/** * Perform a multi moderation. * * @param AUTO_LINK The ID of the multi moderation we are performing. * @param AUTO_LINK The ID of the topic we are performing the multi moderation on. * @param LONG_TEXT The reason for performing the multi moderation (may be blank). * @param LONG_TEXT The post text for a post to be added to the topic (blank: do not add a post). * @param BINARY Whether the post is marked emphasised. * @param BINARY Whether to skip showing the posters signature in the post. */ function ocf_perform_multi_moderation($id, $topic_id, $reason, $post_text = '', $is_emphasised = 1, $skip_sig = 0) { $topic_details = $GLOBALS['FORUM_DB']->query_select('f_topics', array('t_forum_id', 't_cache_first_title', 't_cache_first_post_id'), array('id' => $topic_id), '', 1); if (!array_key_exists(0, $topic_details)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $from = $topic_details[0]['t_forum_id']; if (!ocf_may_perform_multi_moderation($from)) { access_denied('I_ERROR'); } $mm = $GLOBALS['FORUM_DB']->query_select('f_multi_moderations', array('*'), array('id' => $id)); if (!array_key_exists(0, $mm)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } require_code('ocfiltering'); $idlist = ocfilter_to_idlist_using_db($mm[0]['mm_forum_multi_code'], 'id', 'f_forums', 'f_forums', 'f_parent_forum', 'f_parent_forum', 'id', true, true, $GLOBALS['FORUM_DB']); if (!in_array($from, $idlist)) { warn_exit(do_lang_tempcode('MM_APPLY_TWICE')); } $pin_state = $mm[0]['mm_pin_state']; $open_state = $mm[0]['mm_open_state']; $sink_state = $mm[0]['mm_sink_state']; $move_to = $mm[0]['mm_move_to']; $title_suffix = $mm[0]['mm_title_suffix']; //$post_text=$mm[0]['mm_post_text']; We'll allow user to specify the post_text, with this as a default $update_array = array(); if (!is_null($pin_state)) { $update_array['t_pinned'] = $pin_state; } if (!is_null($sink_state)) { $update_array['t_sunk'] = $sink_state; } if (!is_null($open_state)) { $update_array['t_is_open'] = $open_state; } if ($title_suffix != '') { $new_title = $topic_details[0]['t_cache_first_title'] . ' [' . $title_suffix . ']'; $update_array['t_cache_first_title'] = $new_title; $GLOBALS['FORUM_DB']->query_update('f_posts', array('p_title' => $new_title), array('id' => $topic_details[0]['t_cache_first_post_id']), '', 1); } if (count($update_array) != 0) { $GLOBALS['FORUM_DB']->query_update('f_topics', $update_array, array('id' => $topic_id), '', 1); } if (!is_null($move_to)) { require_code('ocf_topics_action'); require_code('ocf_topics_action2'); ocf_move_topics($from, $move_to, array($topic_id)); } if ($post_text != '') { require_code('ocf_posts_action'); require_code('ocf_posts_action2'); require_code('ocf_topics_action'); require_code('ocf_topics_action2'); ocf_make_post($topic_id, '', $post_text, $skip_sig, false, 1, $is_emphasised); $forum_id = is_null($move_to) ? $from : $move_to; handle_topic_ticket_reply($forum_id, $topic_id, $topic_details[0]['t_cache_first_title'], $post_text); } require_code('ocf_general_action2'); ocf_mod_log_it('PERFORM_MULTI_MODERATION', strval($id), strval($topic_id), $reason); }