[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * @package mcp 5 * @version $Id$ 6 * @copyright (c) 2005 phpBB Group 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License 8 * 9 */ 10 11 /** 12 * @ignore 13 */ 14 if (!defined('IN_PHPBB')) 15 { 16 exit; 17 } 18 19 /** 20 * View topic in MCP 21 */ 22 function mcp_topic_view($id, $mode, $action) 23 { 24 global $phpEx, $phpbb_root_path, $config; 25 global $template, $db, $user, $auth, $cache; 26 27 $url = append_sid("{$phpbb_root_path}mcp.$phpEx?" . extra_url()); 28 29 $user->add_lang('viewtopic'); 30 31 $topic_id = request_var('t', 0); 32 $topic_info = get_topic_data(array($topic_id), false, true); 33 34 if (!sizeof($topic_info)) 35 { 36 trigger_error('TOPIC_NOT_EXIST'); 37 } 38 39 $topic_info = $topic_info[$topic_id]; 40 41 // Set up some vars 42 $icon_id = request_var('icon', 0); 43 $subject = utf8_normalize_nfc(request_var('subject', '', true)); 44 $start = request_var('start', 0); 45 $sort_days_old = request_var('st_old', 0); 46 $forum_id = request_var('f', 0); 47 $to_topic_id = request_var('to_topic_id', 0); 48 $to_forum_id = request_var('to_forum_id', 0); 49 $sort = isset($_POST['sort']) ? true : false; 50 $submitted_id_list = request_var('post_ids', array(0)); 51 $checked_ids = $post_id_list = request_var('post_id_list', array(0)); 52 53 // Resync Topic? 54 if ($action == 'resync') 55 { 56 if (!function_exists('mcp_resync_topics')) 57 { 58 include($phpbb_root_path . 'includes/mcp/mcp_forum.' . $phpEx); 59 } 60 mcp_resync_topics(array($topic_id)); 61 } 62 63 // Split Topic? 64 if ($action == 'split_all' || $action == 'split_beyond') 65 { 66 if (!$sort) 67 { 68 split_topic($action, $topic_id, $to_forum_id, $subject); 69 } 70 $action = 'split'; 71 } 72 73 // Merge Posts? 74 if ($action == 'merge_posts') 75 { 76 if (!$sort) 77 { 78 merge_posts($topic_id, $to_topic_id); 79 } 80 $action = 'merge'; 81 } 82 83 if ($action == 'split' && !$subject) 84 { 85 $subject = $topic_info['topic_title']; 86 } 87 88 // Approve posts? 89 if ($action == 'approve' && $auth->acl_get('m_approve', $topic_info['forum_id'])) 90 { 91 include($phpbb_root_path . 'includes/mcp/mcp_queue.' . $phpEx); 92 include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); 93 include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); 94 95 if (!sizeof($post_id_list)) 96 { 97 trigger_error('NO_POST_SELECTED'); 98 } 99 100 if (!$sort) 101 { 102 approve_post($post_id_list, $id, $mode); 103 } 104 } 105 106 // Jumpbox, sort selects and that kind of things 107 make_jumpbox($url . "&i=$id&mode=forum_view", $topic_info['forum_id'], false, 'm_', true); 108 $where_sql = ($action == 'reports') ? 'WHERE post_reported = 1 AND ' : 'WHERE'; 109 110 $sort_days = $total = 0; 111 $sort_key = $sort_dir = ''; 112 $sort_by_sql = $sort_order_sql = array(); 113 mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $topic_info['forum_id'], $topic_id, $where_sql); 114 115 $limit_time_sql = ($sort_days) ? 'AND p.post_time >= ' . (time() - ($sort_days * 86400)) : ''; 116 117 if ($total == -1) 118 { 119 if ($auth->acl_get('m_approve', $topic_info['forum_id'])) 120 { 121 $total = $topic_info['topic_replies_real'] + 1; 122 } 123 else 124 { 125 $total = $topic_info['topic_replies'] + 1; 126 } 127 } 128 129 $posts_per_page = max(0, request_var('posts_per_page', intval($config['posts_per_page']))); 130 if ($posts_per_page == 0) 131 { 132 $posts_per_page = $total; 133 } 134 135 if ((!empty($sort_days_old) && $sort_days_old != $sort_days) || $total <= $posts_per_page) 136 { 137 $start = 0; 138 } 139 140 // Make sure $start is set to the last page if it exceeds the amount 141 if ($start < 0 || $start >= $total) 142 { 143 $start = ($start < 0) ? 0 : floor(($total - 1) / $posts_per_page) * $posts_per_page; 144 } 145 146 $sql = 'SELECT u.username, u.username_clean, u.user_colour, p.* 147 FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u 148 WHERE ' . (($action == 'reports') ? 'p.post_reported = 1 AND ' : '') . ' 149 p.topic_id = ' . $topic_id . ' ' . 150 ((!$auth->acl_get('m_approve', $topic_info['forum_id'])) ? ' AND p.post_approved = 1 ' : '') . ' 151 AND p.poster_id = u.user_id ' . 152 $limit_time_sql . ' 153 ORDER BY ' . $sort_order_sql; 154 $result = $db->sql_query_limit($sql, $posts_per_page, $start); 155 156 $rowset = $post_id_list = array(); 157 $bbcode_bitfield = ''; 158 while ($row = $db->sql_fetchrow($result)) 159 { 160 $rowset[] = $row; 161 $post_id_list[] = $row['post_id']; 162 $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']); 163 } 164 $db->sql_freeresult($result); 165 166 if ($bbcode_bitfield !== '') 167 { 168 include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx); 169 $bbcode = new bbcode(base64_encode($bbcode_bitfield)); 170 } 171 172 $topic_tracking_info = array(); 173 174 // Get topic tracking info 175 if ($config['load_db_lastread']) 176 { 177 $tmp_topic_data = array($topic_id => $topic_info); 178 $topic_tracking_info = get_topic_tracking($topic_info['forum_id'], $topic_id, $tmp_topic_data, array($topic_info['forum_id'] => $topic_info['forum_mark_time'])); 179 unset($tmp_topic_data); 180 } 181 else 182 { 183 $topic_tracking_info = get_complete_topic_tracking($topic_info['forum_id'], $topic_id); 184 } 185 186 $has_unapproved_posts = false; 187 188 // Grab extensions 189 $extensions = $attachments = array(); 190 if ($topic_info['topic_attachment'] && sizeof($post_id_list)) 191 { 192 $extensions = $cache->obtain_attach_extensions($topic_info['forum_id']); 193 194 // Get attachments... 195 if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $topic_info['forum_id'])) 196 { 197 $sql = 'SELECT * 198 FROM ' . ATTACHMENTS_TABLE . ' 199 WHERE ' . $db->sql_in_set('post_msg_id', $post_id_list) . ' 200 AND in_message = 0 201 ORDER BY filetime DESC, post_msg_id ASC'; 202 $result = $db->sql_query($sql); 203 204 while ($row = $db->sql_fetchrow($result)) 205 { 206 $attachments[$row['post_msg_id']][] = $row; 207 } 208 $db->sql_freeresult($result); 209 } 210 } 211 212 foreach ($rowset as $i => $row) 213 { 214 $message = $row['post_text']; 215 $post_subject = ($row['post_subject'] != '') ? $row['post_subject'] : $topic_info['topic_title']; 216 217 if ($row['bbcode_bitfield']) 218 { 219 $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']); 220 } 221 222 $message = bbcode_nl2br($message); 223 $message = smiley_text($message); 224 225 if (!empty($attachments[$row['post_id']])) 226 { 227 $update_count = array(); 228 parse_attachments($topic_info['forum_id'], $message, $attachments[$row['post_id']], $update_count); 229 } 230 231 if (!$row['post_approved']) 232 { 233 $has_unapproved_posts = true; 234 } 235 236 $post_unread = (isset($topic_tracking_info[$topic_id]) && $row['post_time'] > $topic_tracking_info[$topic_id]) ? true : false; 237 238 $template->assign_block_vars('postrow', array( 239 'POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 240 'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 241 'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 242 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 243 244 'POST_DATE' => $user->format_date($row['post_time']), 245 'POST_SUBJECT' => $post_subject, 246 'MESSAGE' => $message, 247 'POST_ID' => $row['post_id'], 248 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $topic_id) . '">', '</a>'), 249 250 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), 251 252 'S_POST_REPORTED' => ($row['post_reported'] && $auth->acl_get('m_report', $topic_info['forum_id'])), 253 'S_POST_UNAPPROVED' => (!$row['post_approved'] && $auth->acl_get('m_approve', $topic_info['forum_id'])), 254 'S_CHECKED' => (($submitted_id_list && !in_array(intval($row['post_id']), $submitted_id_list)) || in_array(intval($row['post_id']), $checked_ids)) ? true : false, 255 'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false, 256 257 'U_POST_DETAILS' => "$url&i=$id&p={$row['post_id']}&mode=post_details" . (($forum_id) ? "&f=$forum_id" : ''), 258 'U_MCP_APPROVE' => ($auth->acl_get('m_approve', $topic_info['forum_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $topic_info['forum_id'] . '&p=' . $row['post_id']) : '', 259 'U_MCP_REPORT' => ($auth->acl_get('m_report', $topic_info['forum_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $topic_info['forum_id'] . '&p=' . $row['post_id']) : '') 260 ); 261 262 // Display not already displayed Attachments for this post, we already parsed them. ;) 263 if (!empty($attachments[$row['post_id']])) 264 { 265 foreach ($attachments[$row['post_id']] as $attachment) 266 { 267 $template->assign_block_vars('postrow.attachment', array( 268 'DISPLAY_ATTACHMENT' => $attachment) 269 ); 270 } 271 } 272 273 unset($rowset[$i]); 274 } 275 276 // Display topic icons for split topic 277 $s_topic_icons = false; 278 279 if ($auth->acl_gets('m_split', 'm_merge', (int) $topic_info['forum_id'])) 280 { 281 include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); 282 $s_topic_icons = posting_gen_topic_icons('', $icon_id); 283 284 // Has the user selected a topic for merge? 285 if ($to_topic_id) 286 { 287 $to_topic_info = get_topic_data(array($to_topic_id), 'm_merge'); 288 289 if (!sizeof($to_topic_info)) 290 { 291 $to_topic_id = 0; 292 } 293 else 294 { 295 $to_topic_info = $to_topic_info[$to_topic_id]; 296 297 if (!$to_topic_info['enable_icons'] || $auth->acl_get('!f_icons', $topic_info['forum_id'])) 298 { 299 $s_topic_icons = false; 300 } 301 } 302 } 303 } 304 305 $s_hidden_fields = build_hidden_fields(array( 306 'st_old' => $sort_days, 307 'post_ids' => $post_id_list, 308 )); 309 310 $template->assign_vars(array( 311 'TOPIC_TITLE' => $topic_info['topic_title'], 312 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $topic_info['forum_id'] . '&t=' . $topic_info['topic_id']), 313 314 'TO_TOPIC_ID' => $to_topic_id, 315 'TO_TOPIC_INFO' => ($to_topic_id) ? sprintf($user->lang['YOU_SELECTED_TOPIC'], $to_topic_id, '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $to_topic_info['forum_id'] . '&t=' . $to_topic_id) . '">' . $to_topic_info['topic_title'] . '</a>') : '', 316 317 'SPLIT_SUBJECT' => $subject, 318 'POSTS_PER_PAGE' => $posts_per_page, 319 'ACTION' => $action, 320 321 'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED'), 322 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'), 323 'INFO_IMG' => $user->img('icon_post_info', 'VIEW_INFO'), 324 325 'S_MCP_ACTION' => "$url&i=$id&mode=$mode&action=$action&start=$start", 326 'S_FORUM_SELECT' => ($to_forum_id) ? make_forum_select($to_forum_id, false, false, true, true, true) : make_forum_select($topic_info['forum_id'], false, false, true, true, true), 327 'S_CAN_SPLIT' => ($auth->acl_get('m_split', $topic_info['forum_id'])) ? true : false, 328 'S_CAN_MERGE' => ($auth->acl_get('m_merge', $topic_info['forum_id'])) ? true : false, 329 'S_CAN_DELETE' => ($auth->acl_get('m_delete', $topic_info['forum_id'])) ? true : false, 330 'S_CAN_APPROVE' => ($has_unapproved_posts && $auth->acl_get('m_approve', $topic_info['forum_id'])) ? true : false, 331 'S_CAN_LOCK' => ($auth->acl_get('m_lock', $topic_info['forum_id'])) ? true : false, 332 'S_CAN_REPORT' => ($auth->acl_get('m_report', $topic_info['forum_id'])) ? true : false, 333 'S_CAN_SYNC' => $auth->acl_get('m_', $topic_info['forum_id']), 334 'S_REPORT_VIEW' => ($action == 'reports') ? true : false, 335 'S_MERGE_VIEW' => ($action == 'merge') ? true : false, 336 'S_SPLIT_VIEW' => ($action == 'split') ? true : false, 337 338 'S_HIDDEN_FIELDS' => $s_hidden_fields, 339 340 'S_SHOW_TOPIC_ICONS' => $s_topic_icons, 341 'S_TOPIC_ICON' => $icon_id, 342 343 'U_SELECT_TOPIC' => "$url&i=$id&mode=forum_view&action=merge_select" . (($forum_id) ? "&f=$forum_id" : ''), 344 345 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$topic_info['forum_id']}&t={$topic_info['topic_id']}&start=$start") . '">', '</a>'), 346 'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", "f={$topic_info['forum_id']}&start=$start") . '">', '</a>'), 347 348 'PAGE_NUMBER' => on_page($total, $posts_per_page, $start), 349 'PAGINATION' => (!$posts_per_page) ? '' : generate_pagination(append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&t={$topic_info['topic_id']}&mode=$mode&action=$action&to_topic_id=$to_topic_id&posts_per_page=$posts_per_page&st=$sort_days&sk=$sort_key&sd=$sort_dir"), $total, $posts_per_page, $start), 350 'TOTAL_POSTS' => ($total == 1) ? $user->lang['VIEW_TOPIC_POST'] : sprintf($user->lang['VIEW_TOPIC_POSTS'], $total), 351 )); 352 } 353 354 /** 355 * Split topic 356 */ 357 function split_topic($action, $topic_id, $to_forum_id, $subject) 358 { 359 global $db, $template, $user, $phpEx, $phpbb_root_path, $auth, $config; 360 361 $post_id_list = request_var('post_id_list', array(0)); 362 $forum_id = request_var('forum_id', 0); 363 $start = request_var('start', 0); 364 365 if (!sizeof($post_id_list)) 366 { 367 $template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']); 368 return; 369 } 370 371 if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_split'))) 372 { 373 return; 374 } 375 376 $post_id = $post_id_list[0]; 377 $post_info = get_post_data(array($post_id)); 378 379 if (!sizeof($post_info)) 380 { 381 $template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']); 382 return; 383 } 384 385 $post_info = $post_info[$post_id]; 386 $subject = trim($subject); 387 388 // Make some tests 389 if (!$subject) 390 { 391 $template->assign_var('MESSAGE', $user->lang['EMPTY_SUBJECT']); 392 return; 393 } 394 395 if ($to_forum_id <= 0) 396 { 397 $template->assign_var('MESSAGE', $user->lang['NO_DESTINATION_FORUM']); 398 return; 399 } 400 401 $forum_info = get_forum_data(array($to_forum_id), 'f_post'); 402 403 if (!sizeof($forum_info)) 404 { 405 $template->assign_var('MESSAGE', $user->lang['USER_CANNOT_POST']); 406 return; 407 } 408 409 $forum_info = $forum_info[$to_forum_id]; 410 411 if ($forum_info['forum_type'] != FORUM_POST) 412 { 413 $template->assign_var('MESSAGE', $user->lang['FORUM_NOT_POSTABLE']); 414 return; 415 } 416 417 $redirect = request_var('redirect', build_url(array('quickmod'))); 418 419 $s_hidden_fields = build_hidden_fields(array( 420 'i' => 'main', 421 'post_id_list' => $post_id_list, 422 'f' => $forum_id, 423 'mode' => 'topic_view', 424 'start' => $start, 425 'action' => $action, 426 't' => $topic_id, 427 'redirect' => $redirect, 428 'subject' => $subject, 429 'to_forum_id' => $to_forum_id, 430 'icon' => request_var('icon', 0)) 431 ); 432 $success_msg = $return_link = ''; 433 434 if (confirm_box(true)) 435 { 436 if ($action == 'split_beyond') 437 { 438 $sort_days = $total = 0; 439 $sort_key = $sort_dir = ''; 440 $sort_by_sql = $sort_order_sql = array(); 441 mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id); 442 443 $limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : ''; 444 445 if ($sort_order_sql[0] == 'u') 446 { 447 $sql = 'SELECT p.post_id, p.forum_id, p.post_approved 448 FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u 449 WHERE p.topic_id = $topic_id 450 AND p.poster_id = u.user_id 451 $limit_time_sql 452 ORDER BY $sort_order_sql"; 453 } 454 else 455 { 456 $sql = 'SELECT p.post_id, p.forum_id, p.post_approved 457 FROM ' . POSTS_TABLE . " p 458 WHERE p.topic_id = $topic_id 459 $limit_time_sql 460 ORDER BY $sort_order_sql"; 461 } 462 $result = $db->sql_query_limit($sql, 0, $start); 463 464 $store = false; 465 $post_id_list = array(); 466 while ($row = $db->sql_fetchrow($result)) 467 { 468 // If split from selected post (split_beyond), we split the unapproved items too. 469 if (!$row['post_approved'] && !$auth->acl_get('m_approve', $row['forum_id'])) 470 { 471 // continue; 472 } 473 474 // Start to store post_ids as soon as we see the first post that was selected 475 if ($row['post_id'] == $post_id) 476 { 477 $store = true; 478 } 479 480 if ($store) 481 { 482 $post_id_list[] = $row['post_id']; 483 } 484 } 485 $db->sql_freeresult($result); 486 } 487 488 if (!sizeof($post_id_list)) 489 { 490 trigger_error('NO_POST_SELECTED'); 491 } 492 493 $icon_id = request_var('icon', 0); 494 495 $sql_ary = array( 496 'forum_id' => $to_forum_id, 497 'topic_title' => $subject, 498 'icon_id' => $icon_id, 499 'topic_approved'=> 1 500 ); 501 502 $sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); 503 $db->sql_query($sql); 504 505 $to_topic_id = $db->sql_nextid(); 506 move_posts($post_id_list, $to_topic_id); 507 508 $topic_info = get_topic_data(array($topic_id)); 509 $topic_info = $topic_info[$topic_id]; 510 511 add_log('mod', $to_forum_id, $to_topic_id, 'LOG_SPLIT_DESTINATION', $subject); 512 add_log('mod', $forum_id, $topic_id, 'LOG_SPLIT_SOURCE', $topic_info['topic_title']); 513 514 // Change topic title of first post 515 $sql = 'UPDATE ' . POSTS_TABLE . " 516 SET post_subject = '" . $db->sql_escape($subject) . "' 517 WHERE post_id = {$post_id_list[0]}"; 518 $db->sql_query($sql); 519 520 // Copy topic subscriptions to new topic 521 $sql = 'SELECT user_id, notify_status 522 FROM ' . TOPICS_WATCH_TABLE . ' 523 WHERE topic_id = ' . $topic_id; 524 $result = $db->sql_query($sql); 525 526 $sql_ary = array(); 527 while ($row = $db->sql_fetchrow($result)) 528 { 529 $sql_ary[] = array( 530 'topic_id' => (int) $to_topic_id, 531 'user_id' => (int) $row['user_id'], 532 'notify_status' => (int) $row['notify_status'], 533 ); 534 } 535 $db->sql_freeresult($result); 536 537 if (sizeof($sql_ary)) 538 { 539 $db->sql_multi_insert(TOPICS_WATCH_TABLE, $sql_ary); 540 } 541 542 // Copy bookmarks to new topic 543 $sql = 'SELECT user_id 544 FROM ' . BOOKMARKS_TABLE . ' 545 WHERE topic_id = ' . $topic_id; 546 $result = $db->sql_query($sql); 547 548 $sql_ary = array(); 549 while ($row = $db->sql_fetchrow($result)) 550 { 551 $sql_ary[] = array( 552 'topic_id' => (int) $to_topic_id, 553 'user_id' => (int) $row['user_id'], 554 ); 555 } 556 $db->sql_freeresult($result); 557 558 if (sizeof($sql_ary)) 559 { 560 $db->sql_multi_insert(BOOKMARKS_TABLE, $sql_ary); 561 } 562 563 $success_msg = 'TOPIC_SPLIT_SUCCESS'; 564 565 // Update forum statistics 566 set_config_count('num_topics', 1, true); 567 568 // Link back to both topics 569 $return_link = sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']) . '">', '</a>') . '<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>'); 570 } 571 else 572 { 573 confirm_box(false, ($action == 'split_all') ? 'SPLIT_TOPIC_ALL' : 'SPLIT_TOPIC_BEYOND', $s_hidden_fields); 574 } 575 576 $redirect = request_var('redirect', "index.$phpEx"); 577 $redirect = reapply_sid($redirect); 578 579 if (!$success_msg) 580 { 581 return; 582 } 583 else 584 { 585 meta_refresh(3, append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$to_forum_id&t=$to_topic_id")); 586 trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link); 587 } 588 } 589 590 /** 591 * Merge selected posts into selected topic 592 */ 593 function merge_posts($topic_id, $to_topic_id) 594 { 595 global $db, $template, $user, $phpEx, $phpbb_root_path, $auth; 596 597 if (!$to_topic_id) 598 { 599 $template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']); 600 return; 601 } 602 603 $topic_data = get_topic_data(array($to_topic_id), 'm_merge'); 604 605 if (!sizeof($topic_data)) 606 { 607 $template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']); 608 return; 609 } 610 611 $topic_data = $topic_data[$to_topic_id]; 612 613 $post_id_list = request_var('post_id_list', array(0)); 614 $start = request_var('start', 0); 615 616 if (!sizeof($post_id_list)) 617 { 618 $template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']); 619 return; 620 } 621 622 if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_merge'))) 623 { 624 return; 625 } 626 627 $redirect = request_var('redirect', build_url(array('quickmod'))); 628 629 $s_hidden_fields = build_hidden_fields(array( 630 'i' => 'main', 631 'post_id_list' => $post_id_list, 632 'to_topic_id' => $to_topic_id, 633 'mode' => 'topic_view', 634 'action' => 'merge_posts', 635 'start' => $start, 636 'redirect' => $redirect, 637 't' => $topic_id) 638 ); 639 $success_msg = $return_link = ''; 640 641 if (confirm_box(true)) 642 { 643 $to_forum_id = $topic_data['forum_id']; 644 645 move_posts($post_id_list, $to_topic_id); 646 add_log('mod', $to_forum_id, $to_topic_id, 'LOG_MERGE', $topic_data['topic_title']); 647 648 // Message and return links 649 $success_msg = 'POSTS_MERGED_SUCCESS'; 650 651 // Does the original topic still exist? If yes, link back to it 652 $sql = 'SELECT forum_id 653 FROM ' . TOPICS_TABLE . ' 654 WHERE topic_id = ' . $topic_id; 655 $result = $db->sql_query_limit($sql, 1); 656 $row = $db->sql_fetchrow($result); 657 $db->sql_freeresult($result); 658 659 if ($row) 660 { 661 $return_link .= sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $topic_id) . '">', '</a>'); 662 } 663 else 664 { 665 if (!function_exists('phpbb_update_rows_avoiding_duplicates_notify_status')) 666 { 667 include($phpbb_root_path . 'includes/functions_database_helper.' . $phpEx); 668 } 669 670 // If the topic no longer exist, we will update the topic watch table. 671 phpbb_update_rows_avoiding_duplicates_notify_status($db, TOPICS_WATCH_TABLE, 'topic_id', array($topic_id), $to_topic_id); 672 673 // If the topic no longer exist, we will update the bookmarks table. 674 phpbb_update_rows_avoiding_duplicates($db, BOOKMARKS_TABLE, 'topic_id', array($topic_id), $to_topic_id); 675 } 676 677 // Link to the new topic 678 $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>'); 679 } 680 else 681 { 682 confirm_box(false, 'MERGE_POSTS', $s_hidden_fields); 683 } 684 685 $redirect = request_var('redirect', "index.$phpEx"); 686 $redirect = reapply_sid($redirect); 687 688 if (!$success_msg) 689 { 690 return; 691 } 692 else 693 { 694 meta_refresh(3, append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$to_forum_id&t=$to_topic_id")); 695 trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link); 696 } 697 } 698 699 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Oct 2 15:03:47 2013 | Cross-referenced by PHPXref 0.7.1 |