[ Index ]

PHP Cross Reference of phpBB-3.1.12-deutsch

title

Body

[close]

/includes/mcp/ -> mcp_forum.php (source)

   1  <?php
   2  /**
   3  *
   4  * This file is part of the phpBB Forum Software package.
   5  *
   6  * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7  * @license GNU General Public License, version 2 (GPL-2.0)
   8  *
   9  * For full copyright and license information, please see
  10  * the docs/CREDITS.txt file.
  11  *
  12  */
  13  
  14  /**
  15  * @ignore
  16  */
  17  if (!defined('IN_PHPBB'))
  18  {
  19      exit;
  20  }
  21  
  22  /**
  23  * MCP Forum View
  24  */
  25  function mcp_forum_view($id, $mode, $action, $forum_info)
  26  {
  27      global $template, $db, $user, $auth, $cache, $module;
  28      global $phpEx, $phpbb_root_path, $config;
  29      global $request, $phpbb_dispatcher, $phpbb_container;
  30  
  31      $user->add_lang(array('viewtopic', 'viewforum'));
  32  
  33      include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx);
  34  
  35      // merge_topic is the quickmod action, merge_topics is the mcp_forum action, and merge_select is the mcp_topic action
  36      $merge_select = ($action == 'merge_select' || $action == 'merge_topic' || $action == 'merge_topics') ? true : false;
  37  
  38      $forum_id            = $forum_info['forum_id'];
  39      $start                = request_var('start', 0);
  40      $topic_id_list        = request_var('topic_id_list', array(0));
  41      $post_id_list        = request_var('post_id_list', array(0));
  42      $source_topic_ids    = array(request_var('t', 0));
  43      $to_topic_id        = request_var('to_topic_id', 0);
  44  
  45      $url_extra = '';
  46      $url_extra .= ($forum_id) ? "&amp;f=$forum_id" : '';
  47      $url_extra .= ($GLOBALS['topic_id']) ? '&amp;t=' . $GLOBALS['topic_id'] : '';
  48      $url_extra .= ($GLOBALS['post_id']) ? '&amp;p=' . $GLOBALS['post_id'] : '';
  49      $url_extra .= ($GLOBALS['user_id']) ? '&amp;u=' . $GLOBALS['user_id'] : '';
  50  
  51      $url = append_sid("{$phpbb_root_path}mcp.$phpEx?$url_extra");
  52  
  53      // Resync Topics
  54      switch ($action)
  55      {
  56          case 'resync':
  57              $topic_ids = request_var('topic_id_list', array(0));
  58              mcp_resync_topics($topic_ids);
  59          break;
  60  
  61          case 'merge_topics':
  62              $source_topic_ids = $topic_id_list;
  63          case 'merge_topic':
  64              if ($to_topic_id)
  65              {
  66                  merge_topics($forum_id, $source_topic_ids, $to_topic_id);
  67              }
  68          break;
  69      }
  70  
  71      /**
  72      * Get some data in order to execute other actions.
  73      *
  74      * @event core.mcp_forum_view_before
  75      * @var    string    action                The action
  76      * @var    array    forum_info            Array with forum infos
  77      * @var    int        start                Start value
  78      * @var    array    topic_id_list        Array of topics ids
  79      * @var    array    post_id_list        Array of posts ids
  80      * @var    array    source_topic_ids    Array of source topics ids
  81      * @var    int        to_topic_id            Array of destination topics ids
  82      * @since 3.1.6-RC1
  83      */
  84      $vars = array(
  85          'action',
  86          'forum_info',
  87          'start',
  88          'topic_id_list',
  89          'post_id_list',
  90          'source_topic_ids',
  91          'to_topic_id',
  92      );
  93      extract($phpbb_dispatcher->trigger_event('core.mcp_forum_view_before', compact($vars)));
  94  
  95      $pagination = $phpbb_container->get('pagination');
  96  
  97      $selected_ids = '';
  98      if (sizeof($post_id_list) && $action != 'merge_topics')
  99      {
 100          foreach ($post_id_list as $num => $post_id)
 101          {
 102              $selected_ids .= '&amp;post_id_list[' . $num . ']=' . $post_id;
 103          }
 104      }
 105      else if (sizeof($topic_id_list) && $action == 'merge_topics')
 106      {
 107          foreach ($topic_id_list as $num => $topic_id)
 108          {
 109              $selected_ids .= '&amp;topic_id_list[' . $num . ']=' . $topic_id;
 110          }
 111      }
 112  
 113      make_jumpbox($url . "&amp;i=$id&amp;action=$action&amp;mode=$mode" . (($merge_select) ? $selected_ids : ''), $forum_id, false, 'm_', true);
 114  
 115      $topics_per_page = ($forum_info['forum_topics_per_page']) ? $forum_info['forum_topics_per_page'] : $config['topics_per_page'];
 116  
 117      $sort_days = $total = 0;
 118      $sort_key = $sort_dir = '';
 119      $sort_by_sql = $sort_order_sql = array();
 120      phpbb_mcp_sorting('viewforum', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id);
 121  
 122      $forum_topics = ($total == -1) ? $forum_info['forum_topics_approved'] : $total;
 123      $limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : '';
 124  
 125      $base_url = $url . "&amp;i=$id&amp;action=$action&amp;mode=$mode&amp;sd=$sort_dir&amp;sk=$sort_key&amp;st=$sort_days" . (($merge_select) ? $selected_ids : '');
 126      $pagination->generate_template_pagination($base_url, 'pagination', 'start', $forum_topics, $topics_per_page, $start);
 127  
 128      $template->assign_vars(array(
 129          'ACTION'                => $action,
 130          'FORUM_NAME'            => $forum_info['forum_name'],
 131          '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']),
 132  
 133          'REPORTED_IMG'            => $user->img('icon_topic_reported', 'TOPIC_REPORTED'),
 134          'UNAPPROVED_IMG'        => $user->img('icon_topic_unapproved', 'TOPIC_UNAPPROVED'),
 135          'LAST_POST_IMG'            => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
 136          'NEWEST_POST_IMG'        => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'),
 137  
 138          'S_CAN_REPORT'            => $auth->acl_get('m_report', $forum_id),
 139          'S_CAN_DELETE'            => $auth->acl_get('m_delete', $forum_id),
 140          'S_CAN_RESTORE'            => $auth->acl_get('m_approve', $forum_id),
 141          'S_CAN_MERGE'            => $auth->acl_get('m_merge', $forum_id),
 142          'S_CAN_MOVE'            => $auth->acl_get('m_move', $forum_id),
 143          'S_CAN_FORK'            => $auth->acl_get('m_', $forum_id),
 144          'S_CAN_LOCK'            => $auth->acl_get('m_lock', $forum_id),
 145          'S_CAN_SYNC'            => $auth->acl_get('m_', $forum_id),
 146          'S_CAN_APPROVE'            => $auth->acl_get('m_approve', $forum_id),
 147          'S_MERGE_SELECT'        => ($merge_select) ? true : false,
 148          'S_CAN_MAKE_NORMAL'        => $auth->acl_gets('f_sticky', 'f_announce', $forum_id),
 149          'S_CAN_MAKE_STICKY'        => $auth->acl_get('f_sticky', $forum_id),
 150          'S_CAN_MAKE_ANNOUNCE'    => $auth->acl_get('f_announce', $forum_id),
 151  
 152          'U_VIEW_FORUM'            => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id),
 153          'U_VIEW_FORUM_LOGS'        => ($auth->acl_gets('a_', 'm_', $forum_id) && $module->loaded('logs')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=logs&amp;mode=forum_logs&amp;f=' . $forum_id) : '',
 154  
 155          'S_MCP_ACTION'            => $url . "&amp;i=$id&amp;forum_action=$action&amp;mode=$mode&amp;start=$start" . (($merge_select) ? $selected_ids : ''),
 156  
 157          'TOTAL_TOPICS'            => $user->lang('VIEW_FORUM_TOPICS', (int) $forum_topics),
 158      ));
 159  
 160      // Grab icons
 161      $icons = $cache->obtain_icons();
 162  
 163      $topic_rows = array();
 164  
 165      if ($config['load_db_lastread'])
 166      {
 167          $read_tracking_join = ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id'] . ')';
 168          $read_tracking_select = ', tt.mark_time';
 169      }
 170      else
 171      {
 172          $read_tracking_join = $read_tracking_select = '';
 173      }
 174  
 175      $phpbb_content_visibility = $phpbb_container->get('content.visibility');
 176  
 177      $sql = 'SELECT t.topic_id
 178          FROM ' . TOPICS_TABLE . ' t
 179          WHERE t.forum_id = ' . $forum_id . '
 180              AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.') . "
 181              $limit_time_sql
 182          ORDER BY t.topic_type DESC, $sort_order_sql";
 183  
 184      /**
 185      * Modify SQL query before MCP forum view topic list is queried
 186      *
 187      * @event core.mcp_view_forum_modify_sql
 188      * @var    string    sql            SQL query for forum view topic list
 189      * @var    int    forum_id    ID of the forum
 190      * @var    string  limit_time_sql        SQL query part for limit time
 191      * @var    string  sort_order_sql        SQL query part for sort order
 192      * @var    int topics_per_page            Number of topics per page
 193      * @var    int start            Start value
 194      * @since 3.1.2-RC1
 195      */
 196      $vars = array('sql', 'forum_id', 'limit_time_sql', 'sort_order_sql', 'topics_per_page', 'start');
 197      extract($phpbb_dispatcher->trigger_event('core.mcp_view_forum_modify_sql', compact($vars)));
 198  
 199      $result = $db->sql_query_limit($sql, $topics_per_page, $start);
 200  
 201      $topic_list = $topic_tracking_info = array();
 202  
 203      while ($row = $db->sql_fetchrow($result))
 204      {
 205          $topic_list[] = $row['topic_id'];
 206      }
 207      $db->sql_freeresult($result);
 208  
 209      $sql = "SELECT t.*$read_tracking_select
 210          FROM " . TOPICS_TABLE . " t $read_tracking_join
 211          WHERE " . $db->sql_in_set('t.topic_id', $topic_list, false, true);
 212  
 213      $result = $db->sql_query($sql);
 214      while ($row = $db->sql_fetchrow($result))
 215      {
 216          $topic_rows[$row['topic_id']] = $row;
 217      }
 218      $db->sql_freeresult($result);
 219  
 220      // If there is more than one page, but we have no topic list, then the start parameter is... erm... out of sync
 221      if (!sizeof($topic_list) && $forum_topics && $start > 0)
 222      {
 223          redirect($url . "&amp;i=$id&amp;action=$action&amp;mode=$mode");
 224      }
 225  
 226      // Get topic tracking info
 227      if (sizeof($topic_list))
 228      {
 229          if ($config['load_db_lastread'])
 230          {
 231              $topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $topic_rows, array($forum_id => $forum_info['mark_time']));
 232          }
 233          else
 234          {
 235              $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list);
 236          }
 237      }
 238  
 239      foreach ($topic_list as $topic_id)
 240      {
 241          $topic_title = '';
 242  
 243          $row = &$topic_rows[$topic_id];
 244  
 245          $replies = $phpbb_content_visibility->get_count('topic_posts', $row, $forum_id) - 1;
 246  
 247          if ($row['topic_status'] == ITEM_MOVED)
 248          {
 249              $unread_topic = false;
 250          }
 251          else
 252          {
 253              $unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
 254          }
 255  
 256          // Get folder img, topic status/type related information
 257          $folder_img = $folder_alt = $topic_type = '';
 258          topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type);
 259  
 260          $topic_title = censor_text($row['topic_title']);
 261  
 262          $topic_unapproved = (($row['topic_visibility'] == ITEM_UNAPPROVED || $row['topic_visibility'] == ITEM_REAPPROVE)  && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false;
 263          $posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false;
 264          $topic_deleted = $row['topic_visibility'] == ITEM_DELETED;
 265          $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? $url . '&amp;i=queue&amp;mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . '&amp;t=' . $row['topic_id'] : '';
 266          $u_mcp_queue = (!$u_mcp_queue && $topic_deleted) ? $url . '&amp;i=queue&amp;mode=deleted_topics&amp;t=' . $topic_id : $u_mcp_queue;
 267  
 268          $topic_row = array(
 269              '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']) : '',
 270              'TOPIC_IMG_STYLE'        => $folder_img,
 271              'TOPIC_FOLDER_IMG'        => $user->img($folder_img, $folder_alt),
 272              'TOPIC_ICON_IMG'        => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '',
 273              'TOPIC_ICON_IMG_WIDTH'    => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '',
 274              'TOPIC_ICON_IMG_HEIGHT'    => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '',
 275              'UNAPPROVED_IMG'        => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '',
 276              'DELETED_IMG'            => ($topic_deleted) ? $user->img('icon_topic_deleted', 'TOPIC_DELETED') : '',
 277  
 278              'TOPIC_AUTHOR'                => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
 279              'TOPIC_AUTHOR_COLOUR'        => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
 280              'TOPIC_AUTHOR_FULL'            => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
 281              'U_TOPIC_AUTHOR'            => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
 282  
 283              'LAST_POST_AUTHOR'            => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
 284              'LAST_POST_AUTHOR_COLOUR'    => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
 285              'LAST_POST_AUTHOR_FULL'        => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
 286              'U_LAST_POST_AUTHOR'        => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
 287  
 288              'TOPIC_TYPE'        => $topic_type,
 289              'TOPIC_TITLE'        => $topic_title,
 290              'REPLIES'            => $phpbb_content_visibility->get_count('topic_posts', $row, $row['forum_id']) - 1,
 291              'LAST_POST_TIME'    => $user->format_date($row['topic_last_post_time']),
 292              'FIRST_POST_TIME'    => $user->format_date($row['topic_time']),
 293              'LAST_POST_SUBJECT'    => $row['topic_last_post_subject'],
 294              'LAST_VIEW_TIME'    => $user->format_date($row['topic_last_view_time']),
 295  
 296              'S_TOPIC_REPORTED'        => (!empty($row['topic_reported']) && empty($row['topic_moved_id']) && $auth->acl_get('m_report', $row['forum_id'])) ? true : false,
 297              'S_TOPIC_UNAPPROVED'    => $topic_unapproved,
 298              'S_POSTS_UNAPPROVED'    => $posts_unapproved,
 299              'S_TOPIC_DELETED'        => $topic_deleted,
 300              'S_UNREAD_TOPIC'        => $unread_topic,
 301          );
 302  
 303          if ($row['topic_status'] == ITEM_MOVED)
 304          {
 305              $topic_row = array_merge($topic_row, array(
 306                  'U_VIEW_TOPIC'        => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t={$row['topic_moved_id']}"),
 307                  'U_DELETE_TOPIC'    => ($auth->acl_get('m_delete', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&amp;f=$forum_id&amp;topic_id_list[]={$row['topic_id']}&amp;mode=forum_view&amp;action=delete_topic") : '',
 308                  'S_MOVED_TOPIC'        => true,
 309                  'TOPIC_ID'            => $row['topic_moved_id'],
 310              ));
 311          }
 312          else
 313          {
 314              if ($action == 'merge_topic' || $action == 'merge_topics')
 315              {
 316                  $u_select_topic = $url . "&amp;i=$id&amp;mode=forum_view&amp;action=$action&amp;to_topic_id=" . $row['topic_id'] . $selected_ids;
 317              }
 318              else
 319              {
 320                  $u_select_topic = $url . "&amp;i=$id&amp;mode=topic_view&amp;action=merge&amp;to_topic_id=" . $row['topic_id'] . $selected_ids;
 321              }
 322              $topic_row = array_merge($topic_row, array(
 323                  'U_VIEW_TOPIC'        => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&amp;f=$forum_id&amp;t={$row['topic_id']}&amp;mode=topic_view"),
 324  
 325                  'S_SELECT_TOPIC'    => ($merge_select && !in_array($row['topic_id'], $source_topic_ids)) ? true : false,
 326                  'U_SELECT_TOPIC'    => $u_select_topic,
 327                  'U_MCP_QUEUE'        => $u_mcp_queue,
 328                  'U_MCP_REPORT'        => ($auth->acl_get('m_report', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&amp;mode=topic_view&amp;t=' . $row['topic_id'] . '&amp;action=reports') : '',
 329                  'TOPIC_ID'            => $row['topic_id'],
 330                  'S_TOPIC_CHECKED'    => ($topic_id_list && in_array($row['topic_id'], $topic_id_list)) ? true : false,
 331              ));
 332          }
 333  
 334          /**
 335          * Modify the topic data before it is assigned to the template in MCP
 336          *
 337          * @event core.mcp_view_forum_modify_topicrow
 338          * @var    array    row            Array with topic data
 339          * @var    array    topic_row    Template array with topic data
 340          * @since 3.1.0-a1
 341          */
 342          $vars = array('row', 'topic_row');
 343          extract($phpbb_dispatcher->trigger_event('core.mcp_view_forum_modify_topicrow', compact($vars)));
 344  
 345          $template->assign_block_vars('topicrow', $topic_row);
 346      }
 347      unset($topic_rows);
 348  }
 349  
 350  /**
 351  * Resync topics
 352  */
 353  function mcp_resync_topics($topic_ids)
 354  {
 355      global $auth, $db, $template, $phpEx, $user, $phpbb_root_path;
 356  
 357      if (!sizeof($topic_ids))
 358      {
 359          trigger_error('NO_TOPIC_SELECTED');
 360      }
 361  
 362      if (!phpbb_check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_')))
 363      {
 364          return;
 365      }
 366  
 367      // Sync everything and perform extra checks separately
 368      sync('topic_reported', 'topic_id', $topic_ids, false, true);
 369      sync('topic_attachment', 'topic_id', $topic_ids, false, true);
 370      sync('topic', 'topic_id', $topic_ids, true, false);
 371  
 372      $sql = 'SELECT topic_id, forum_id, topic_title
 373          FROM ' . TOPICS_TABLE . '
 374          WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
 375      $result = $db->sql_query($sql);
 376  
 377      // Log this action
 378      while ($row = $db->sql_fetchrow($result))
 379      {
 380          add_log('mod', $row['forum_id'], $row['topic_id'], 'LOG_TOPIC_RESYNC', $row['topic_title']);
 381      }
 382      $db->sql_freeresult($result);
 383  
 384      $msg = (sizeof($topic_ids) == 1) ? $user->lang['TOPIC_RESYNC_SUCCESS'] : $user->lang['TOPICS_RESYNC_SUCCESS'];
 385  
 386      $redirect = request_var('redirect', $user->data['session_page']);
 387  
 388      meta_refresh(3, $redirect);
 389      trigger_error($msg . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
 390  
 391      return;
 392  }
 393  
 394  /**
 395  * Merge selected topics into selected topic
 396  */
 397  function merge_topics($forum_id, $topic_ids, $to_topic_id)
 398  {
 399      global $db, $template, $user, $phpEx, $phpbb_root_path, $auth, $phpbb_dispatcher;
 400  
 401      if (!sizeof($topic_ids))
 402      {
 403          $template->assign_var('MESSAGE', $user->lang['NO_TOPIC_SELECTED']);
 404          return;
 405      }
 406      if (!$to_topic_id)
 407      {
 408          $template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']);
 409          return;
 410      }
 411  
 412      $sync_topics = array_merge($topic_ids, array($to_topic_id));
 413  
 414      $all_topic_data = phpbb_get_topic_data($sync_topics, 'm_merge');
 415  
 416      if (!sizeof($all_topic_data) || empty($all_topic_data[$to_topic_id]))
 417      {
 418          $template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']);
 419          return;
 420      }
 421  
 422      $sync_forums = array();
 423      $topic_views = 0;
 424      foreach ($all_topic_data as $data)
 425      {
 426          $sync_forums[$data['forum_id']] = $data['forum_id'];
 427          $topic_views = max($topic_views, $data['topic_views']);
 428      }
 429  
 430      $to_topic_data = $all_topic_data[$to_topic_id];
 431  
 432      $post_id_list    = request_var('post_id_list', array(0));
 433      $start            = request_var('start', 0);
 434  
 435      if (!sizeof($post_id_list) && sizeof($topic_ids))
 436      {
 437          $sql = 'SELECT post_id
 438              FROM ' . POSTS_TABLE . '
 439              WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
 440          $result = $db->sql_query($sql);
 441  
 442          $post_id_list = array();
 443          while ($row = $db->sql_fetchrow($result))
 444          {
 445              $post_id_list[] = $row['post_id'];
 446          }
 447          $db->sql_freeresult($result);
 448      }
 449  
 450      if (!sizeof($post_id_list))
 451      {
 452          $template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']);
 453          return;
 454      }
 455  
 456      if (!phpbb_check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_merge')))
 457      {
 458          return;
 459      }
 460  
 461      $redirect = request_var('redirect', "{$phpbb_root_path}mcp.$phpEx?f=$forum_id&amp;i=main&amp;mode=forum_view");
 462  
 463      $s_hidden_fields = build_hidden_fields(array(
 464          'i'                => 'main',
 465          'f'                => $forum_id,
 466          'post_id_list'    => $post_id_list,
 467          'to_topic_id'    => $to_topic_id,
 468          'mode'            => 'forum_view',
 469          'action'        => 'merge_topics',
 470          'start'            => $start,
 471          'redirect'        => $redirect,
 472          'topic_id_list'    => $topic_ids)
 473      );
 474      $success_msg = $return_link = '';
 475  
 476      if (confirm_box(true))
 477      {
 478          $to_forum_id = $to_topic_data['forum_id'];
 479  
 480          move_posts($post_id_list, $to_topic_id, false);
 481          add_log('mod', $to_forum_id, $to_topic_id, 'LOG_MERGE', $to_topic_data['topic_title']);
 482  
 483          // Update topic views count
 484          $sql = 'UPDATE ' . TOPICS_TABLE . '
 485                  SET topic_views = ' . $topic_views . '
 486                  WHERE topic_id = ' . $to_topic_id;
 487          $db->sql_query($sql);
 488  
 489          // Message and return links
 490          $success_msg = 'POSTS_MERGED_SUCCESS';
 491  
 492          if (!function_exists('phpbb_update_rows_avoiding_duplicates_notify_status'))
 493          {
 494              include($phpbb_root_path . 'includes/functions_database_helper.' . $phpEx);
 495          }
 496  
 497          // Update the topic watch table.
 498          phpbb_update_rows_avoiding_duplicates_notify_status($db, TOPICS_WATCH_TABLE, 'topic_id', $topic_ids, $to_topic_id);
 499  
 500          // Update the bookmarks table.
 501          phpbb_update_rows_avoiding_duplicates($db, BOOKMARKS_TABLE, 'topic_id', $topic_ids, $to_topic_id);
 502  
 503          // Re-sync the topics and forums because the auto-sync was deactivated in the call of  move_posts()
 504          sync('topic_reported', 'topic_id', $sync_topics);
 505          sync('topic_attachment', 'topic_id', $sync_topics);
 506          sync('topic', 'topic_id', $sync_topics, true);
 507          sync('forum', 'forum_id', $sync_forums, true, true);
 508  
 509          // Link to the new topic
 510          $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 . '&amp;t=' . $to_topic_id) . '">', '</a>');
 511          $redirect = request_var('redirect', "{$phpbb_root_path}viewtopic.$phpEx?f=$to_forum_id&amp;t=$to_topic_id");
 512          $redirect = reapply_sid($redirect);
 513  
 514          /**
 515           * Perform additional actions after merging topics.
 516           *
 517           * @event core.mcp_forum_merge_topics_after
 518           * @var    array    all_topic_data            The data from all topics involved in the merge
 519           * @var    int        to_topic_id                The ID of the topic into which the rest are merged
 520           * @since 3.1.11-RC1
 521           */
 522          $vars = array(
 523              'all_topic_data',
 524              'to_topic_id',
 525          );
 526          extract($phpbb_dispatcher->trigger_event('core.mcp_forum_merge_topics_after', compact($vars)));
 527  
 528          meta_refresh(3, $redirect);
 529          trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link);
 530      }
 531      else
 532      {
 533          confirm_box(false, 'MERGE_TOPICS', $s_hidden_fields);
 534      }
 535  }


Generated: Thu Jan 11 00:25:41 2018 Cross-referenced by PHPXref 0.7.1