Verzeichnisstruktur phpBB-3.2.0
- Veröffentlicht
- 06.01.2017
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
mcp_forum.php
001 <?php
002 /**
003 *
004 * This file is part of the phpBB Forum Software package.
005 *
006 * @copyright (c) phpBB Limited <https://www.phpbb.com>
007 * @license GNU General Public License, version 2 (GPL-2.0)
008 *
009 * For full copyright and license information, please see
010 * the docs/CREDITS.txt file.
011 *
012 */
013
014 /**
015 * @ignore
016 */
017 if (!defined('IN_PHPBB'))
018 {
019 exit;
020 }
021
022 /**
023 * MCP Forum View
024 */
025 function mcp_forum_view($id, $mode, $action, $forum_info)
026 {
027 global $template, $db, $user, $auth, $cache, $module;
028 global $phpEx, $phpbb_root_path, $config;
029 global $request, $phpbb_dispatcher, $phpbb_container;
030
031 $user->add_lang(array('viewtopic', 'viewforum'));
032
033 include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx);
034
035 // merge_topic is the quickmod action, merge_topics is the mcp_forum action, and merge_select is the mcp_topic action
036 $merge_select = ($action == 'merge_select' || $action == 'merge_topic' || $action == 'merge_topics') ? true : false;
037
038 $forum_id = $forum_info['forum_id'];
039 $start = $request->variable('start', 0);
040 $topic_id_list = $request->variable('topic_id_list', array(0));
041 $post_id_list = $request->variable('post_id_list', array(0));
042 $source_topic_ids = array($request->variable('t', 0));
043 $to_topic_id = $request->variable('to_topic_id', 0);
044
045 $url_extra = '';
046 $url_extra .= ($forum_id) ? "&f=$forum_id" : '';
047 $url_extra .= ($GLOBALS['topic_id']) ? '&t=' . $GLOBALS['topic_id'] : '';
048 $url_extra .= ($GLOBALS['post_id']) ? '&p=' . $GLOBALS['post_id'] : '';
049 $url_extra .= ($GLOBALS['user_id']) ? '&u=' . $GLOBALS['user_id'] : '';
050
051 $url = append_sid("{$phpbb_root_path}mcp.$phpEx?$url_extra");
052
053 // Resync Topics
054 switch ($action)
055 {
056 case 'resync':
057 $topic_ids = $request->variable('topic_id_list', array(0));
058 mcp_resync_topics($topic_ids);
059 break;
060
061 case 'merge_topics':
062 $source_topic_ids = $topic_id_list;
063 case 'merge_topic':
064 if ($to_topic_id)
065 {
066 merge_topics($forum_id, $source_topic_ids, $to_topic_id);
067 }
068 break;
069 }
070
071 /**
072 * Get some data in order to execute other actions.
073 *
074 * @event core.mcp_forum_view_before
075 * @var string action The action
076 * @var array forum_info Array with forum infos
077 * @var int start Start value
078 * @var array topic_id_list Array of topics ids
079 * @var array post_id_list Array of posts ids
080 * @var array source_topic_ids Array of source topics ids
081 * @var int to_topic_id Array of destination topics ids
082 * @since 3.1.6-RC1
083 */
084 $vars = array(
085 'action',
086 'forum_info',
087 'start',
088 'topic_id_list',
089 'post_id_list',
090 'source_topic_ids',
091 'to_topic_id',
092 );
093 extract($phpbb_dispatcher->trigger_event('core.mcp_forum_view_before', compact($vars)));
094
095 /* @var $pagination \phpbb\pagination */
096 $pagination = $phpbb_container->get('pagination');
097
098 $selected_ids = '';
099 if (sizeof($post_id_list) && $action != 'merge_topics')
100 {
101 foreach ($post_id_list as $num => $post_id)
102 {
103 $selected_ids .= '&post_id_list[' . $num . ']=' . $post_id;
104 }
105 }
106 else if (sizeof($topic_id_list) && $action == 'merge_topics')
107 {
108 foreach ($topic_id_list as $num => $topic_id)
109 {
110 $selected_ids .= '&topic_id_list[' . $num . ']=' . $topic_id;
111 }
112 }
113
114 make_jumpbox($url . "&i=$id&action=$action&mode=$mode" . (($merge_select) ? $selected_ids : ''), $forum_id, false, 'm_', true);
115
116 $topics_per_page = ($forum_info['forum_topics_per_page']) ? $forum_info['forum_topics_per_page'] : $config['topics_per_page'];
117
118 $sort_days = $total = 0;
119 $sort_key = $sort_dir = '';
120 $sort_by_sql = $sort_order_sql = array();
121 phpbb_mcp_sorting('viewforum', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id);
122
123 $forum_topics = ($total == -1) ? $forum_info['forum_topics_approved'] : $total;
124 $limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : '';
125
126 $base_url = $url . "&i=$id&action=$action&mode=$mode&sd=$sort_dir&sk=$sort_key&st=$sort_days" . (($merge_select) ? $selected_ids : '');
127 $pagination->generate_template_pagination($base_url, 'pagination', 'start', $forum_topics, $topics_per_page, $start);
128
129 $template->assign_vars(array(
130 'ACTION' => $action,
131 'FORUM_NAME' => $forum_info['forum_name'],
132 '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']),
133
134 'REPORTED_IMG' => $user->img('icon_topic_reported', 'TOPIC_REPORTED'),
135 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPIC_UNAPPROVED'),
136 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
137 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'),
138
139 'S_CAN_REPORT' => $auth->acl_get('m_report', $forum_id),
140 'S_CAN_DELETE' => $auth->acl_get('m_delete', $forum_id),
141 'S_CAN_RESTORE' => $auth->acl_get('m_approve', $forum_id),
142 'S_CAN_MERGE' => $auth->acl_get('m_merge', $forum_id),
143 'S_CAN_MOVE' => $auth->acl_get('m_move', $forum_id),
144 'S_CAN_FORK' => $auth->acl_get('m_', $forum_id),
145 'S_CAN_LOCK' => $auth->acl_get('m_lock', $forum_id),
146 'S_CAN_SYNC' => $auth->acl_get('m_', $forum_id),
147 'S_CAN_APPROVE' => $auth->acl_get('m_approve', $forum_id),
148 'S_MERGE_SELECT' => ($merge_select) ? true : false,
149 'S_CAN_MAKE_NORMAL' => $auth->acl_gets('f_sticky', 'f_announce', 'f_announce_global', $forum_id),
150 'S_CAN_MAKE_STICKY' => $auth->acl_get('f_sticky', $forum_id),
151 'S_CAN_MAKE_ANNOUNCE' => $auth->acl_get('f_announce', $forum_id),
152 'S_CAN_MAKE_ANNOUNCE_GLOBAL' => $auth->acl_get('f_announce_global', $forum_id),
153
154 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id),
155 '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) : '',
156
157 'S_MCP_ACTION' => $url . "&i=$id&forum_action=$action&mode=$mode&start=$start" . (($merge_select) ? $selected_ids : ''),
158
159 'TOTAL_TOPICS' => $user->lang('VIEW_FORUM_TOPICS', (int) $forum_topics),
160 ));
161
162 // Grab icons
163 $icons = $cache->obtain_icons();
164
165 $topic_rows = array();
166
167 if ($config['load_db_lastread'])
168 {
169 $read_tracking_join = ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id'] . ')';
170 $read_tracking_select = ', tt.mark_time';
171 }
172 else
173 {
174 $read_tracking_join = $read_tracking_select = '';
175 }
176
177 /* @var $phpbb_content_visibility \phpbb\content_visibility */
178 $phpbb_content_visibility = $phpbb_container->get('content.visibility');
179
180 $sql = 'SELECT t.topic_id
181 FROM ' . TOPICS_TABLE . ' t
182 WHERE t.forum_id = ' . $forum_id . '
183 AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.') . "
184 $limit_time_sql
185 ORDER BY t.topic_type DESC, $sort_order_sql";
186
187 /**
188 * Modify SQL query before MCP forum view topic list is queried
189 *
190 * @event core.mcp_view_forum_modify_sql
191 * @var string sql SQL query for forum view topic list
192 * @var int forum_id ID of the forum
193 * @var string limit_time_sql SQL query part for limit time
194 * @var string sort_order_sql SQL query part for sort order
195 * @var int topics_per_page Number of topics per page
196 * @var int start Start value
197 * @since 3.1.2-RC1
198 */
199 $vars = array('sql', 'forum_id', 'limit_time_sql', 'sort_order_sql', 'topics_per_page', 'start');
200 extract($phpbb_dispatcher->trigger_event('core.mcp_view_forum_modify_sql', compact($vars)));
201
202 $result = $db->sql_query_limit($sql, $topics_per_page, $start);
203
204 $topic_list = $topic_tracking_info = array();
205
206 while ($row_ary = $db->sql_fetchrow($result))
207 {
208 $topic_list[] = $row_ary['topic_id'];
209 }
210 $db->sql_freeresult($result);
211
212 $sql = "SELECT t.*$read_tracking_select
213 FROM " . TOPICS_TABLE . " t $read_tracking_join
214 WHERE " . $db->sql_in_set('t.topic_id', $topic_list, false, true);
215
216 $result = $db->sql_query($sql);
217 while ($row_ary = $db->sql_fetchrow($result))
218 {
219 $topic_rows[$row_ary['topic_id']] = $row_ary;
220 }
221 $db->sql_freeresult($result);
222
223 // If there is more than one page, but we have no topic list, then the start parameter is... erm... out of sync
224 if (!sizeof($topic_list) && $forum_topics && $start > 0)
225 {
226 redirect($url . "&i=$id&action=$action&mode=$mode");
227 }
228
229 // Get topic tracking info
230 if (sizeof($topic_list))
231 {
232 if ($config['load_db_lastread'])
233 {
234 $topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $topic_rows, array($forum_id => $forum_info['mark_time']));
235 }
236 else
237 {
238 $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list);
239 }
240 }
241
242 foreach ($topic_list as $topic_id)
243 {
244 $row_ary = &$topic_rows[$topic_id];
245
246 $replies = $phpbb_content_visibility->get_count('topic_posts', $row_ary, $forum_id) - 1;
247
248 if ($row_ary['topic_status'] == ITEM_MOVED)
249 {
250 $unread_topic = false;
251 }
252 else
253 {
254 $unread_topic = (isset($topic_tracking_info[$topic_id]) && $row_ary['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
255 }
256
257 // Get folder img, topic status/type related information
258 $folder_img = $folder_alt = $topic_type = '';
259 topic_status($row_ary, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type);
260
261 $topic_title = censor_text($row_ary['topic_title']);
262
263 $topic_unapproved = (($row_ary['topic_visibility'] == ITEM_UNAPPROVED || $row_ary['topic_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $row_ary['forum_id'])) ? true : false;
264 $posts_unapproved = ($row_ary['topic_visibility'] == ITEM_APPROVED && $row_ary['topic_posts_unapproved'] && $auth->acl_get('m_approve', $row_ary['forum_id'])) ? true : false;
265 $topic_deleted = $row_ary['topic_visibility'] == ITEM_DELETED;
266 $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? $url . '&i=queue&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . '&t=' . $row_ary['topic_id'] : '';
267 $u_mcp_queue = (!$u_mcp_queue && $topic_deleted) ? $url . '&i=queue&mode=deleted_topics&t=' . $topic_id : $u_mcp_queue;
268
269 $topic_row = array(
270 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row_ary['forum_id']) && $row_ary['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
271 'TOPIC_IMG_STYLE' => $folder_img,
272 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt),
273 'TOPIC_ICON_IMG' => (!empty($icons[$row_ary['icon_id']])) ? $icons[$row_ary['icon_id']]['img'] : '',
274 'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row_ary['icon_id']])) ? $icons[$row_ary['icon_id']]['width'] : '',
275 'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row_ary['icon_id']])) ? $icons[$row_ary['icon_id']]['height'] : '',
276 'UNAPPROVED_IMG' => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '',
277 'DELETED_IMG' => ($topic_deleted) ? $user->img('icon_topic_deleted', 'TOPIC_DELETED') : '',
278
279 'TOPIC_AUTHOR' => get_username_string('username', $row_ary['topic_poster'], $row_ary['topic_first_poster_name'], $row_ary['topic_first_poster_colour']),
280 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row_ary['topic_poster'], $row_ary['topic_first_poster_name'], $row_ary['topic_first_poster_colour']),
281 'TOPIC_AUTHOR_FULL' => get_username_string('full', $row_ary['topic_poster'], $row_ary['topic_first_poster_name'], $row_ary['topic_first_poster_colour']),
282 'U_TOPIC_AUTHOR' => get_username_string('profile', $row_ary['topic_poster'], $row_ary['topic_first_poster_name'], $row_ary['topic_first_poster_colour']),
283
284 'LAST_POST_AUTHOR' => get_username_string('username', $row_ary['topic_last_poster_id'], $row_ary['topic_last_poster_name'], $row_ary['topic_last_poster_colour']),
285 'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row_ary['topic_last_poster_id'], $row_ary['topic_last_poster_name'], $row_ary['topic_last_poster_colour']),
286 'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row_ary['topic_last_poster_id'], $row_ary['topic_last_poster_name'], $row_ary['topic_last_poster_colour']),
287 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row_ary['topic_last_poster_id'], $row_ary['topic_last_poster_name'], $row_ary['topic_last_poster_colour']),
288
289 'TOPIC_TYPE' => $topic_type,
290 'TOPIC_TITLE' => $topic_title,
291 'REPLIES' => $phpbb_content_visibility->get_count('topic_posts', $row_ary, $row_ary['forum_id']) - 1,
292 'LAST_POST_TIME' => $user->format_date($row_ary['topic_last_post_time']),
293 'FIRST_POST_TIME' => $user->format_date($row_ary['topic_time']),
294 'LAST_POST_SUBJECT' => $row_ary['topic_last_post_subject'],
295 'LAST_VIEW_TIME' => $user->format_date($row_ary['topic_last_view_time']),
296
297 'S_TOPIC_REPORTED' => (!empty($row_ary['topic_reported']) && empty($row_ary['topic_moved_id']) && $auth->acl_get('m_report', $row_ary['forum_id'])) ? true : false,
298 'S_TOPIC_UNAPPROVED' => $topic_unapproved,
299 'S_POSTS_UNAPPROVED' => $posts_unapproved,
300 'S_TOPIC_DELETED' => $topic_deleted,
301 'S_UNREAD_TOPIC' => $unread_topic,
302 );
303
304 if ($row_ary['topic_status'] == ITEM_MOVED)
305 {
306 $topic_row = array_merge($topic_row, array(
307 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t={$row_ary['topic_moved_id']}"),
308 '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_ary['topic_id']}&mode=forum_view&action=delete_topic") : '',
309 'S_MOVED_TOPIC' => true,
310 'TOPIC_ID' => $row_ary['topic_moved_id'],
311 ));
312 }
313 else
314 {
315 if ($action == 'merge_topic' || $action == 'merge_topics')
316 {
317 $u_select_topic = $url . "&i=$id&mode=forum_view&action=$action&to_topic_id=" . $row_ary['topic_id'] . $selected_ids;
318 }
319 else
320 {
321 $u_select_topic = $url . "&i=$id&mode=topic_view&action=merge&to_topic_id=" . $row_ary['topic_id'] . $selected_ids;
322 }
323 $topic_row = array_merge($topic_row, array(
324 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&f=$forum_id&t={$row_ary['topic_id']}&mode=topic_view"),
325
326 'S_SELECT_TOPIC' => ($merge_select && !in_array($row_ary['topic_id'], $source_topic_ids)) ? true : false,
327 'U_SELECT_TOPIC' => $u_select_topic,
328 'U_MCP_QUEUE' => $u_mcp_queue,
329 'U_MCP_REPORT' => ($auth->acl_get('m_report', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=topic_view&t=' . $row_ary['topic_id'] . '&action=reports') : '',
330 'TOPIC_ID' => $row_ary['topic_id'],
331 'S_TOPIC_CHECKED' => ($topic_id_list && in_array($row_ary['topic_id'], $topic_id_list)) ? true : false,
332 ));
333 }
334
335 $row = $row_ary;
336 /**
337 * Modify the topic data before it is assigned to the template in MCP
338 *
339 * @event core.mcp_view_forum_modify_topicrow
340 * @var array row Array with topic data
341 * @var array topic_row Template array with topic data
342 * @since 3.1.0-a1
343 */
344 $vars = array('row', 'topic_row');
345 extract($phpbb_dispatcher->trigger_event('core.mcp_view_forum_modify_topicrow', compact($vars)));
346 $row_ary = $row;
347 unset($row);
348
349 $template->assign_block_vars('topicrow', $topic_row);
350 }
351 unset($topic_rows);
352 }
353
354 /**
355 * Resync topics
356 */
357 function mcp_resync_topics($topic_ids)
358 {
359 global $db, $user, $phpbb_log, $request;
360
361 if (!sizeof($topic_ids))
362 {
363 trigger_error('NO_TOPIC_SELECTED');
364 }
365
366 if (!phpbb_check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_')))
367 {
368 return;
369 }
370
371 // Sync everything and perform extra checks separately
372 sync('topic_reported', 'topic_id', $topic_ids, false, true);
373 sync('topic_attachment', 'topic_id', $topic_ids, false, true);
374 sync('topic', 'topic_id', $topic_ids, true, false);
375
376 $sql = 'SELECT topic_id, forum_id, topic_title
377 FROM ' . TOPICS_TABLE . '
378 WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
379 $result = $db->sql_query($sql);
380
381 // Log this action
382 while ($row = $db->sql_fetchrow($result))
383 {
384 $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_TOPIC_RESYNC', false, array(
385 'forum_id' => $row['forum_id'],
386 'topic_id' => $row['topic_id'],
387 $row['topic_title']
388 ));
389 }
390 $db->sql_freeresult($result);
391
392 $msg = (sizeof($topic_ids) == 1) ? $user->lang['TOPIC_RESYNC_SUCCESS'] : $user->lang['TOPICS_RESYNC_SUCCESS'];
393
394 $redirect = $request->variable('redirect', $user->data['session_page']);
395
396 meta_refresh(3, $redirect);
397 trigger_error($msg . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
398
399 return;
400 }
401
402 /**
403 * Merge selected topics into selected topic
404 */
405 function merge_topics($forum_id, $topic_ids, $to_topic_id)
406 {
407 global $db, $template, $user, $phpEx, $phpbb_root_path, $phpbb_log, $request, $phpbb_dispatcher;
408
409 if (!sizeof($topic_ids))
410 {
411 $template->assign_var('MESSAGE', $user->lang['NO_TOPIC_SELECTED']);
412 return;
413 }
414 if (!$to_topic_id)
415 {
416 $template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']);
417 return;
418 }
419
420 $sync_topics = array_merge($topic_ids, array($to_topic_id));
421
422 $all_topic_data = phpbb_get_topic_data($sync_topics, 'm_merge');
423
424 if (!sizeof($all_topic_data) || empty($all_topic_data[$to_topic_id]))
425 {
426 $template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']);
427 return;
428 }
429
430 $sync_forums = array();
431 $topic_views = 0;
432 foreach ($all_topic_data as $data)
433 {
434 $sync_forums[$data['forum_id']] = $data['forum_id'];
435 $topic_views = max($topic_views, $data['topic_views']);
436 }
437
438 $to_topic_data = $all_topic_data[$to_topic_id];
439
440 $post_id_list = $request->variable('post_id_list', array(0));
441 $start = $request->variable('start', 0);
442
443 if (!sizeof($post_id_list) && sizeof($topic_ids))
444 {
445 $sql = 'SELECT post_id
446 FROM ' . POSTS_TABLE . '
447 WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
448 $result = $db->sql_query($sql);
449
450 $post_id_list = array();
451 while ($row = $db->sql_fetchrow($result))
452 {
453 $post_id_list[] = $row['post_id'];
454 }
455 $db->sql_freeresult($result);
456 }
457
458 if (!sizeof($post_id_list))
459 {
460 $template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']);
461 return;
462 }
463
464 if (!phpbb_check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_merge')))
465 {
466 return;
467 }
468
469 $redirect = $request->variable('redirect', "{$phpbb_root_path}mcp.$phpEx?f=$forum_id&i=main&mode=forum_view");
470
471 $s_hidden_fields = build_hidden_fields(array(
472 'i' => 'main',
473 'f' => $forum_id,
474 'post_id_list' => $post_id_list,
475 'to_topic_id' => $to_topic_id,
476 'mode' => 'forum_view',
477 'action' => 'merge_topics',
478 'start' => $start,
479 'redirect' => $redirect,
480 'topic_id_list' => $topic_ids)
481 );
482 $return_link = '';
483
484 if (confirm_box(true))
485 {
486 $to_forum_id = $to_topic_data['forum_id'];
487
488 move_posts($post_id_list, $to_topic_id, false);
489
490 $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_MERGE', false, array(
491 'forum_id' => $to_forum_id,
492 'topic_id' => $to_topic_id,
493 $to_topic_data['topic_title']
494 ));
495
496 // Update topic views count
497 $sql = 'UPDATE ' . TOPICS_TABLE . '
498 SET topic_views = ' . $topic_views . '
499 WHERE topic_id = ' . $to_topic_id;
500 $db->sql_query($sql);
501
502 // Message and return links
503 $success_msg = 'POSTS_MERGED_SUCCESS';
504
505 if (!function_exists('phpbb_update_rows_avoiding_duplicates_notify_status'))
506 {
507 include($phpbb_root_path . 'includes/functions_database_helper.' . $phpEx);
508 }
509
510 // Update the topic watch table.
511 phpbb_update_rows_avoiding_duplicates_notify_status($db, TOPICS_WATCH_TABLE, 'topic_id', $topic_ids, $to_topic_id);
512
513 // Update the bookmarks table.
514 phpbb_update_rows_avoiding_duplicates($db, BOOKMARKS_TABLE, 'topic_id', $topic_ids, $to_topic_id);
515
516 // Re-sync the topics and forums because the auto-sync was deactivated in the call of move_posts()
517 sync('topic_reported', 'topic_id', $sync_topics);
518 sync('topic_attachment', 'topic_id', $sync_topics);
519 sync('topic', 'topic_id', $sync_topics, true);
520 sync('forum', 'forum_id', $sync_forums, true, true);
521
522 // Link to the new topic
523 $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>');
524 $redirect = $request->variable('redirect', "{$phpbb_root_path}viewtopic.$phpEx?f=$to_forum_id&t=$to_topic_id");
525 $redirect = reapply_sid($redirect);
526
527 /**
528 * Perform additional actions after merging topics.
529 *
530 * @event core.mcp_forum_merge_topics_after
531 * @var array all_topic_data The data from all topics involved in the merge
532 * @var int to_topic_id The ID of the topic into which the rest are merged
533 * @since 3.1.11-RC1
534 */
535 $vars = array(
536 'all_topic_data',
537 'to_topic_id',
538 );
539 extract($phpbb_dispatcher->trigger_event('core.mcp_forum_merge_topics_after', compact($vars)));
540
541 meta_refresh(3, $redirect);
542 trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link);
543 }
544 else
545 {
546 confirm_box(false, 'MERGE_TOPICS', $s_hidden_fields);
547 }
548 }
549