1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/includes/mcp/mcp_forum.php Wed Mar 07 16:41:10 2012 +0400
1.3 @@ -0,0 +1,447 @@
1.4 +<?php
1.5 +/**
1.6 +*
1.7 +* @package mcp
1.8 +* @version $Id$
1.9 +* @copyright (c) 2005 phpBB Group
1.10 +* @license http://opensource.org/licenses/gpl-license.php GNU Public License
1.11 +*
1.12 +*/
1.13 +
1.14 +/**
1.15 +* @ignore
1.16 +*/
1.17 +if (!defined('IN_PHPBB'))
1.18 +{
1.19 + exit;
1.20 +}
1.21 +
1.22 +/**
1.23 +* MCP Forum View
1.24 +*/
1.25 +function mcp_forum_view($id, $mode, $action, $forum_info)
1.26 +{
1.27 + global $template, $db, $user, $auth, $cache, $module;
1.28 + global $phpEx, $phpbb_root_path, $config;
1.29 +
1.30 + $user->add_lang(array('viewtopic', 'viewforum'));
1.31 +
1.32 + include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx);
1.33 +
1.34 + // merge_topic is the quickmod action, merge_topics is the mcp_forum action, and merge_select is the mcp_topic action
1.35 + $merge_select = ($action == 'merge_select' || $action == 'merge_topic' || $action == 'merge_topics') ? true : false;
1.36 +
1.37 + if ($merge_select)
1.38 + {
1.39 + // Fixes a "bug" that makes forum_view use the same ordering as topic_view
1.40 + unset($_POST['sk'], $_POST['sd'], $_REQUEST['sk'], $_REQUEST['sd']);
1.41 + }
1.42 +
1.43 + $forum_id = $forum_info['forum_id'];
1.44 + $start = request_var('start', 0);
1.45 + $topic_id_list = request_var('topic_id_list', array(0));
1.46 + $post_id_list = request_var('post_id_list', array(0));
1.47 + $source_topic_ids = array(request_var('t', 0));
1.48 + $to_topic_id = request_var('to_topic_id', 0);
1.49 +
1.50 + $url_extra = '';
1.51 + $url_extra .= ($forum_id) ? "&f=$forum_id" : '';
1.52 + $url_extra .= ($GLOBALS['topic_id']) ? '&t=' . $GLOBALS['topic_id'] : '';
1.53 + $url_extra .= ($GLOBALS['post_id']) ? '&p=' . $GLOBALS['post_id'] : '';
1.54 + $url_extra .= ($GLOBALS['user_id']) ? '&u=' . $GLOBALS['user_id'] : '';
1.55 +
1.56 + $url = append_sid("{$phpbb_root_path}mcp.$phpEx?$url_extra");
1.57 +
1.58 + // Resync Topics
1.59 + switch ($action)
1.60 + {
1.61 + case 'resync':
1.62 + $topic_ids = request_var('topic_id_list', array(0));
1.63 + mcp_resync_topics($topic_ids);
1.64 + break;
1.65 +
1.66 + case 'merge_topics':
1.67 + $source_topic_ids = $topic_id_list;
1.68 + case 'merge_topic':
1.69 + if ($to_topic_id)
1.70 + {
1.71 + merge_topics($forum_id, $source_topic_ids, $to_topic_id);
1.72 + }
1.73 + break;
1.74 + }
1.75 +
1.76 + $selected_ids = '';
1.77 + if (sizeof($post_id_list) && $action != 'merge_topics')
1.78 + {
1.79 + foreach ($post_id_list as $num => $post_id)
1.80 + {
1.81 + $selected_ids .= '&post_id_list[' . $num . ']=' . $post_id;
1.82 + }
1.83 + }
1.84 + else if (sizeof($topic_id_list) && $action == 'merge_topics')
1.85 + {
1.86 + foreach ($topic_id_list as $num => $topic_id)
1.87 + {
1.88 + $selected_ids .= '&topic_id_list[' . $num . ']=' . $topic_id;
1.89 + }
1.90 + }
1.91 +
1.92 + make_jumpbox($url . "&i=$id&action=$action&mode=$mode" . (($merge_select) ? $selected_ids : ''), $forum_id, false, 'm_', true);
1.93 +
1.94 + $topics_per_page = ($forum_info['forum_topics_per_page']) ? $forum_info['forum_topics_per_page'] : $config['topics_per_page'];
1.95 +
1.96 + $sort_days = $total = 0;
1.97 + $sort_key = $sort_dir = '';
1.98 + $sort_by_sql = $sort_order_sql = array();
1.99 + mcp_sorting('viewforum', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id);
1.100 +
1.101 + $forum_topics = ($total == -1) ? $forum_info['forum_topics'] : $total;
1.102 + $limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : '';
1.103 +
1.104 + $template->assign_vars(array(
1.105 + 'ACTION' => $action,
1.106 + 'FORUM_NAME' => $forum_info['forum_name'],
1.107 + 'FORUM_DESCRIPTION' => generate_text_for_display($forum_info['forum_desc'], $forum_info['forum_desc_uid'], $forum_info['forum_desc_bitfield'], $forum_info['forum_desc_options']),
1.108 +
1.109 + 'REPORTED_IMG' => $user->img('icon_topic_reported', 'TOPIC_REPORTED'),
1.110 + 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPIC_UNAPPROVED'),
1.111 + 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
1.112 + 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'),
1.113 +
1.114 + 'S_CAN_REPORT' => $auth->acl_get('m_report', $forum_id),
1.115 + 'S_CAN_DELETE' => $auth->acl_get('m_delete', $forum_id),
1.116 + 'S_CAN_MERGE' => $auth->acl_get('m_merge', $forum_id),
1.117 + 'S_CAN_MOVE' => $auth->acl_get('m_move', $forum_id),
1.118 + 'S_CAN_FORK' => $auth->acl_get('m_', $forum_id),
1.119 + 'S_CAN_LOCK' => $auth->acl_get('m_lock', $forum_id),
1.120 + 'S_CAN_SYNC' => $auth->acl_get('m_', $forum_id),
1.121 + 'S_CAN_APPROVE' => $auth->acl_get('m_approve', $forum_id),
1.122 + 'S_MERGE_SELECT' => ($merge_select) ? true : false,
1.123 + 'S_CAN_MAKE_NORMAL' => $auth->acl_gets('f_sticky', 'f_announce', $forum_id),
1.124 + 'S_CAN_MAKE_STICKY' => $auth->acl_get('f_sticky', $forum_id),
1.125 + 'S_CAN_MAKE_ANNOUNCE' => $auth->acl_get('f_announce', $forum_id),
1.126 +
1.127 + 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id),
1.128 + 'U_VIEW_FORUM_LOGS' => ($auth->acl_gets('a_', 'm_', $forum_id) && $module->loaded('logs')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=logs&mode=forum_logs&f=' . $forum_id) : '',
1.129 +
1.130 + 'S_MCP_ACTION' => $url . "&i=$id&forum_action=$action&mode=$mode&start=$start" . (($merge_select) ? $selected_ids : ''),
1.131 +
1.132 + 'PAGINATION' => generate_pagination($url . "&i=$id&action=$action&mode=$mode&sd=$sort_dir&sk=$sort_key&st=$sort_days" . (($merge_select) ? $selected_ids : ''), $forum_topics, $topics_per_page, $start),
1.133 + 'PAGE_NUMBER' => on_page($forum_topics, $topics_per_page, $start),
1.134 + 'TOTAL_TOPICS' => ($forum_topics == 1) ? $user->lang['VIEW_FORUM_TOPIC'] : sprintf($user->lang['VIEW_FORUM_TOPICS'], $forum_topics),
1.135 + ));
1.136 +
1.137 + // Grab icons
1.138 + $icons = $cache->obtain_icons();
1.139 +
1.140 + $topic_rows = array();
1.141 +
1.142 + if ($config['load_db_lastread'])
1.143 + {
1.144 + $read_tracking_join = ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id'] . ')';
1.145 + $read_tracking_select = ', tt.mark_time';
1.146 + }
1.147 + else
1.148 + {
1.149 + $read_tracking_join = $read_tracking_select = '';
1.150 + }
1.151 +
1.152 + $sql = "SELECT t.topic_id
1.153 + FROM " . TOPICS_TABLE . " t
1.154 + WHERE t.forum_id IN($forum_id, 0)
1.155 + " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1') . "
1.156 + $limit_time_sql
1.157 + ORDER BY t.topic_type DESC, $sort_order_sql";
1.158 + $result = $db->sql_query_limit($sql, $topics_per_page, $start);
1.159 +
1.160 + $topic_list = $topic_tracking_info = array();
1.161 +
1.162 + while ($row = $db->sql_fetchrow($result))
1.163 + {
1.164 + $topic_list[] = $row['topic_id'];
1.165 + }
1.166 + $db->sql_freeresult($result);
1.167 +
1.168 + $sql = "SELECT t.*$read_tracking_select
1.169 + FROM " . TOPICS_TABLE . " t $read_tracking_join
1.170 + WHERE " . $db->sql_in_set('t.topic_id', $topic_list, false, true);
1.171 +
1.172 + $result = $db->sql_query($sql);
1.173 + while ($row = $db->sql_fetchrow($result))
1.174 + {
1.175 + $topic_rows[$row['topic_id']] = $row;
1.176 + }
1.177 + $db->sql_freeresult($result);
1.178 +
1.179 + // If there is more than one page, but we have no topic list, then the start parameter is... erm... out of sync
1.180 + if (!sizeof($topic_list) && $forum_topics && $start > 0)
1.181 + {
1.182 + redirect($url . "&i=$id&action=$action&mode=$mode");
1.183 + }
1.184 +
1.185 + // Get topic tracking info
1.186 + if (sizeof($topic_list))
1.187 + {
1.188 + if ($config['load_db_lastread'])
1.189 + {
1.190 + $topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $topic_rows, array($forum_id => $forum_info['mark_time']), array());
1.191 + }
1.192 + else
1.193 + {
1.194 + $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list, array());
1.195 + }
1.196 + }
1.197 +
1.198 + foreach ($topic_list as $topic_id)
1.199 + {
1.200 + $topic_title = '';
1.201 +
1.202 + $row = &$topic_rows[$topic_id];
1.203 +
1.204 + $replies = ($auth->acl_get('m_approve', $forum_id)) ? $row['topic_replies_real'] : $row['topic_replies'];
1.205 +
1.206 + if ($row['topic_status'] == ITEM_MOVED)
1.207 + {
1.208 + $unread_topic = false;
1.209 + }
1.210 + else
1.211 + {
1.212 + $unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
1.213 + }
1.214 +
1.215 + // Get folder img, topic status/type related information
1.216 + $folder_img = $folder_alt = $topic_type = '';
1.217 + topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type);
1.218 +
1.219 + $topic_title = censor_text($row['topic_title']);
1.220 +
1.221 + $topic_unapproved = (!$row['topic_approved'] && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false;
1.222 + $posts_unapproved = ($row['topic_approved'] && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false;
1.223 + $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? $url . '&i=queue&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . '&t=' . $row['topic_id'] : '';
1.224 +
1.225 + $topic_row = array(
1.226 + 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
1.227 + 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt),
1.228 + 'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'),
1.229 + 'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '',
1.230 + 'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '',
1.231 + 'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '',
1.232 + 'UNAPPROVED_IMG' => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '',
1.233 +
1.234 + 'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
1.235 + 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
1.236 + 'TOPIC_AUTHOR_FULL' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
1.237 + 'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
1.238 +
1.239 + 'LAST_POST_AUTHOR' => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
1.240 + 'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
1.241 + 'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
1.242 + 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
1.243 +
1.244 + 'TOPIC_TYPE' => $topic_type,
1.245 + 'TOPIC_TITLE' => $topic_title,
1.246 + 'REPLIES' => ($auth->acl_get('m_approve', $row['forum_id'])) ? $row['topic_replies_real'] : $row['topic_replies'],
1.247 + 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']),
1.248 + 'FIRST_POST_TIME' => $user->format_date($row['topic_time']),
1.249 + 'LAST_POST_SUBJECT' => $row['topic_last_post_subject'],
1.250 + 'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']),
1.251 +
1.252 + 'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && empty($row['topic_moved_id']) && $auth->acl_get('m_report', $row['forum_id'])) ? true : false,
1.253 + 'S_TOPIC_UNAPPROVED' => $topic_unapproved,
1.254 + 'S_POSTS_UNAPPROVED' => $posts_unapproved,
1.255 + 'S_UNREAD_TOPIC' => $unread_topic,
1.256 + );
1.257 +
1.258 + if ($row['topic_status'] == ITEM_MOVED)
1.259 + {
1.260 + $topic_row = array_merge($topic_row, array(
1.261 + 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t={$row['topic_moved_id']}"),
1.262 + 'U_DELETE_TOPIC' => ($auth->acl_get('m_delete', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&f=$forum_id&topic_id_list[]={$row['topic_id']}&mode=forum_view&action=delete_topic") : '',
1.263 + 'S_MOVED_TOPIC' => true,
1.264 + 'TOPIC_ID' => $row['topic_moved_id'],
1.265 + ));
1.266 + }
1.267 + else
1.268 + {
1.269 + if ($action == 'merge_topic' || $action == 'merge_topics')
1.270 + {
1.271 + $u_select_topic = $url . "&i=$id&mode=forum_view&action=$action&to_topic_id=" . $row['topic_id'] . $selected_ids;
1.272 + }
1.273 + else
1.274 + {
1.275 + $u_select_topic = $url . "&i=$id&mode=topic_view&action=merge&to_topic_id=" . $row['topic_id'] . $selected_ids;
1.276 + }
1.277 + $topic_row = array_merge($topic_row, array(
1.278 + 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&f=$forum_id&t={$row['topic_id']}&mode=topic_view"),
1.279 +
1.280 + 'S_SELECT_TOPIC' => ($merge_select && !in_array($row['topic_id'], $source_topic_ids)) ? true : false,
1.281 + 'U_SELECT_TOPIC' => $u_select_topic,
1.282 + 'U_MCP_QUEUE' => $u_mcp_queue,
1.283 + 'U_MCP_REPORT' => ($auth->acl_get('m_report', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=topic_view&t=' . $row['topic_id'] . '&action=reports') : '',
1.284 + 'TOPIC_ID' => $row['topic_id'],
1.285 + 'S_TOPIC_CHECKED' => ($topic_id_list && in_array($row['topic_id'], $topic_id_list)) ? true : false,
1.286 + ));
1.287 + }
1.288 +
1.289 + $template->assign_block_vars('topicrow', $topic_row);
1.290 + }
1.291 + unset($topic_rows);
1.292 +}
1.293 +
1.294 +/**
1.295 +* Resync topics
1.296 +*/
1.297 +function mcp_resync_topics($topic_ids)
1.298 +{
1.299 + global $auth, $db, $template, $phpEx, $user, $phpbb_root_path;
1.300 +
1.301 + if (!sizeof($topic_ids))
1.302 + {
1.303 + trigger_error('NO_TOPIC_SELECTED');
1.304 + }
1.305 +
1.306 + if (!check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_')))
1.307 + {
1.308 + return;
1.309 + }
1.310 +
1.311 + // Sync everything and perform extra checks separately
1.312 + sync('topic_reported', 'topic_id', $topic_ids, false, true);
1.313 + sync('topic_attachment', 'topic_id', $topic_ids, false, true);
1.314 + sync('topic', 'topic_id', $topic_ids, true, false);
1.315 +
1.316 + $sql = 'SELECT topic_id, forum_id, topic_title
1.317 + FROM ' . TOPICS_TABLE . '
1.318 + WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
1.319 + $result = $db->sql_query($sql);
1.320 +
1.321 + // Log this action
1.322 + while ($row = $db->sql_fetchrow($result))
1.323 + {
1.324 + add_log('mod', $row['forum_id'], $row['topic_id'], 'LOG_TOPIC_RESYNC', $row['topic_title']);
1.325 + }
1.326 + $db->sql_freeresult($result);
1.327 +
1.328 + $msg = (sizeof($topic_ids) == 1) ? $user->lang['TOPIC_RESYNC_SUCCESS'] : $user->lang['TOPICS_RESYNC_SUCCESS'];
1.329 +
1.330 + $redirect = request_var('redirect', $user->data['session_page']);
1.331 +
1.332 + meta_refresh(3, $redirect);
1.333 + trigger_error($msg . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
1.334 +
1.335 + return;
1.336 +}
1.337 +
1.338 +/**
1.339 +* Merge selected topics into selected topic
1.340 +*/
1.341 +function merge_topics($forum_id, $topic_ids, $to_topic_id)
1.342 +{
1.343 + global $db, $template, $user, $phpEx, $phpbb_root_path, $auth;
1.344 +
1.345 + if (!sizeof($topic_ids))
1.346 + {
1.347 + $template->assign_var('MESSAGE', $user->lang['NO_TOPIC_SELECTED']);
1.348 + return;
1.349 + }
1.350 + if (!$to_topic_id)
1.351 + {
1.352 + $template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']);
1.353 + return;
1.354 + }
1.355 +
1.356 + $topic_data = get_topic_data(array($to_topic_id), 'm_merge');
1.357 +
1.358 + if (!sizeof($topic_data))
1.359 + {
1.360 + $template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']);
1.361 + return;
1.362 + }
1.363 +
1.364 + $topic_data = $topic_data[$to_topic_id];
1.365 +
1.366 + $post_id_list = request_var('post_id_list', array(0));
1.367 + $start = request_var('start', 0);
1.368 +
1.369 + if (!sizeof($post_id_list) && sizeof($topic_ids))
1.370 + {
1.371 + $sql = 'SELECT post_id
1.372 + FROM ' . POSTS_TABLE . '
1.373 + WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
1.374 + $result = $db->sql_query($sql);
1.375 +
1.376 + $post_id_list = array();
1.377 + while ($row = $db->sql_fetchrow($result))
1.378 + {
1.379 + $post_id_list[] = $row['post_id'];
1.380 + }
1.381 + $db->sql_freeresult($result);
1.382 + }
1.383 +
1.384 + if (!sizeof($post_id_list))
1.385 + {
1.386 + $template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']);
1.387 + return;
1.388 + }
1.389 +
1.390 + if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_merge')))
1.391 + {
1.392 + return;
1.393 + }
1.394 +
1.395 + $redirect = request_var('redirect', build_url(array('quickmod')));
1.396 +
1.397 + $s_hidden_fields = build_hidden_fields(array(
1.398 + 'i' => 'main',
1.399 + 'f' => $forum_id,
1.400 + 'post_id_list' => $post_id_list,
1.401 + 'to_topic_id' => $to_topic_id,
1.402 + 'mode' => 'forum_view',
1.403 + 'action' => 'merge_topics',
1.404 + 'start' => $start,
1.405 + 'redirect' => $redirect,
1.406 + 'topic_id_list' => $topic_ids)
1.407 + );
1.408 + $success_msg = $return_link = '';
1.409 +
1.410 + if (confirm_box(true))
1.411 + {
1.412 + $to_forum_id = $topic_data['forum_id'];
1.413 +
1.414 + move_posts($post_id_list, $to_topic_id);
1.415 + add_log('mod', $to_forum_id, $to_topic_id, 'LOG_MERGE', $topic_data['topic_title']);
1.416 +
1.417 + // Message and return links
1.418 + $success_msg = 'POSTS_MERGED_SUCCESS';
1.419 +
1.420 + // If the topic no longer exist, we will update the topic watch table.
1.421 + // To not let it error out on users watching both topics, we just return on an error...
1.422 + $db->sql_return_on_error(true);
1.423 + $db->sql_query('UPDATE ' . TOPICS_WATCH_TABLE . ' SET topic_id = ' . (int) $to_topic_id . ' WHERE ' . $db->sql_in_set('topic_id', $topic_ids));
1.424 + $db->sql_return_on_error(false);
1.425 +
1.426 + $db->sql_query('DELETE FROM ' . TOPICS_WATCH_TABLE . ' WHERE ' . $db->sql_in_set('topic_id', $topic_ids));
1.427 +
1.428 + // Link to the new topic
1.429 + $return_link .= (($return_link) ? '<br /><br />' : '') . sprintf($user->lang['RETURN_NEW_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $to_forum_id . '&t=' . $to_topic_id) . '">', '</a>');
1.430 + }
1.431 + else
1.432 + {
1.433 + confirm_box(false, 'MERGE_TOPICS', $s_hidden_fields);
1.434 + }
1.435 +
1.436 + $redirect = request_var('redirect', "index.$phpEx");
1.437 + $redirect = reapply_sid($redirect);
1.438 +
1.439 + if (!$success_msg)
1.440 + {
1.441 + return;
1.442 + }
1.443 + else
1.444 + {
1.445 + meta_refresh(3, append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$to_forum_id&t=$to_topic_id"));
1.446 + trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link);
1.447 + }
1.448 +}
1.449 +
1.450 +?>
1.451 \ No newline at end of file