[ Index ]

PHP Cross Reference of phpBB-3.1.12-deutsch

title

Body

[close]

/ -> viewforum.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  define('IN_PHPBB', true);
  18  $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
  19  $phpEx = substr(strrchr(__FILE__, '.'), 1);
  20  include($phpbb_root_path . 'common.' . $phpEx);
  21  include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
  22  
  23  // Start session
  24  $user->session_begin();
  25  $auth->acl($user->data);
  26  
  27  // Start initial var setup
  28  $forum_id    = request_var('f', 0);
  29  $mark_read    = request_var('mark', '');
  30  $start        = request_var('start', 0);
  31  
  32  $default_sort_days    = (!empty($user->data['user_topic_show_days'])) ? $user->data['user_topic_show_days'] : 0;
  33  $default_sort_key    = (!empty($user->data['user_topic_sortby_type'])) ? $user->data['user_topic_sortby_type'] : 't';
  34  $default_sort_dir    = (!empty($user->data['user_topic_sortby_dir'])) ? $user->data['user_topic_sortby_dir'] : 'd';
  35  
  36  $sort_days    = request_var('st', $default_sort_days);
  37  $sort_key    = request_var('sk', $default_sort_key);
  38  $sort_dir    = request_var('sd', $default_sort_dir);
  39  
  40  $pagination = $phpbb_container->get('pagination');
  41  
  42  // Check if the user has actually sent a forum ID with his/her request
  43  // If not give them a nice error page.
  44  if (!$forum_id)
  45  {
  46      trigger_error('NO_FORUM');
  47  }
  48  
  49  $sql_from = FORUMS_TABLE . ' f';
  50  $lastread_select = '';
  51  
  52  // Grab appropriate forum data
  53  if ($config['load_db_lastread'] && $user->data['is_registered'])
  54  {
  55      $sql_from .= ' LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $user->data['user_id'] . '
  56          AND ft.forum_id = f.forum_id)';
  57      $lastread_select .= ', ft.mark_time';
  58  }
  59  
  60  if ($user->data['is_registered'])
  61  {
  62      $sql_from .= ' LEFT JOIN ' . FORUMS_WATCH_TABLE . ' fw ON (fw.forum_id = f.forum_id AND fw.user_id = ' . $user->data['user_id'] . ')';
  63      $lastread_select .= ', fw.notify_status';
  64  }
  65  
  66  $sql = "SELECT f.* $lastread_select
  67      FROM $sql_from
  68      WHERE f.forum_id = $forum_id";
  69  $result = $db->sql_query($sql);
  70  $forum_data = $db->sql_fetchrow($result);
  71  $db->sql_freeresult($result);
  72  
  73  if (!$forum_data)
  74  {
  75      trigger_error('NO_FORUM');
  76  }
  77  
  78  
  79  // Configure style, language, etc.
  80  $user->setup('viewforum', $forum_data['forum_style']);
  81  
  82  // Redirect to login upon emailed notification links
  83  if (isset($_GET['e']) && !$user->data['is_registered'])
  84  {
  85      login_box('', $user->lang['LOGIN_NOTIFY_FORUM']);
  86  }
  87  
  88  // Permissions check
  89  if (!$auth->acl_gets('f_list', 'f_read', $forum_id) || ($forum_data['forum_type'] == FORUM_LINK && $forum_data['forum_link'] && !$auth->acl_get('f_read', $forum_id)))
  90  {
  91      if ($user->data['user_id'] != ANONYMOUS)
  92      {
  93          trigger_error('SORRY_AUTH_READ');
  94      }
  95  
  96      login_box('', $user->lang['LOGIN_VIEWFORUM']);
  97  }
  98  
  99  // Forum is passworded ... check whether access has been granted to this
 100  // user this session, if not show login box
 101  if ($forum_data['forum_password'])
 102  {
 103      login_forum_box($forum_data);
 104  }
 105  
 106  // Is this forum a link? ... User got here either because the
 107  // number of clicks is being tracked or they guessed the id
 108  if ($forum_data['forum_type'] == FORUM_LINK && $forum_data['forum_link'])
 109  {
 110      // Does it have click tracking enabled?
 111      if ($forum_data['forum_flags'] & FORUM_FLAG_LINK_TRACK)
 112      {
 113          $sql = 'UPDATE ' . FORUMS_TABLE . '
 114              SET forum_posts_approved = forum_posts_approved + 1
 115              WHERE forum_id = ' . $forum_id;
 116          $db->sql_query($sql);
 117      }
 118  
 119      // We redirect to the url. The third parameter indicates that external redirects are allowed.
 120      redirect($forum_data['forum_link'], false, true);
 121      return;
 122  }
 123  
 124  // Build navigation links
 125  generate_forum_nav($forum_data);
 126  
 127  // Forum Rules
 128  if ($auth->acl_get('f_read', $forum_id))
 129  {
 130      generate_forum_rules($forum_data);
 131  }
 132  
 133  // Do we have subforums?
 134  $active_forum_ary = $moderators = array();
 135  
 136  if ($forum_data['left_id'] != $forum_data['right_id'] - 1)
 137  {
 138      list($active_forum_ary, $moderators) = display_forums($forum_data, $config['load_moderators'], $config['load_moderators']);
 139  }
 140  else
 141  {
 142      $template->assign_var('S_HAS_SUBFORUM', false);
 143      if ($config['load_moderators'])
 144      {
 145          get_moderators($moderators, $forum_id);
 146      }
 147  }
 148  
 149  // Is a forum specific topic count required?
 150  if ($forum_data['forum_topics_per_page'])
 151  {
 152      $config['topics_per_page'] = $forum_data['forum_topics_per_page'];
 153  }
 154  
 155  /* @var $phpbb_content_visibility \phpbb\content_visibility */
 156  $phpbb_content_visibility = $phpbb_container->get('content.visibility');
 157  
 158  // Dump out the page header and load viewforum template
 159  $topics_count = $phpbb_content_visibility->get_count('forum_topics', $forum_data, $forum_id);
 160  $start = $pagination->validate_start($start, $config['topics_per_page'], $topics_count);
 161  
 162  page_header($forum_data['forum_name'] . ($start ? ' - ' . $user->lang('PAGE_TITLE_NUMBER', $pagination->get_on_page($config['topics_per_page'], $start)) : ''), true, $forum_id);
 163  
 164  $template->set_filenames(array(
 165      'body' => 'viewforum_body.html')
 166  );
 167  
 168  make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"), $forum_id);
 169  
 170  $template->assign_vars(array(
 171      'U_VIEW_FORUM'            => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . (($start == 0) ? '' : "&amp;start=$start")),
 172  ));
 173  
 174  // Not postable forum or showing active topics?
 175  if (!($forum_data['forum_type'] == FORUM_POST || (($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) && $forum_data['forum_type'] == FORUM_CAT)))
 176  {
 177      page_footer();
 178  }
 179  
 180  // Ok, if someone has only list-access, we only display the forum list.
 181  // We also make this circumstance available to the template in case we want to display a notice. ;)
 182  if (!$auth->acl_get('f_read', $forum_id))
 183  {
 184      $template->assign_vars(array(
 185          'S_NO_READ_ACCESS'        => true,
 186      ));
 187  
 188      page_footer();
 189  }
 190  
 191  // Handle marking posts
 192  if ($mark_read == 'topics')
 193  {
 194      $token = request_var('hash', '');
 195      if (check_link_hash($token, 'global'))
 196      {
 197          markread('topics', array($forum_id), false, request_var('mark_time', 0));
 198      }
 199      $redirect_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id);
 200      meta_refresh(3, $redirect_url);
 201  
 202      if ($request->is_ajax())
 203      {
 204          // Tell the ajax script what language vars and URL need to be replaced
 205          $data = array(
 206              'NO_UNREAD_POSTS'    => $user->lang['NO_UNREAD_POSTS'],
 207              'UNREAD_POSTS'        => $user->lang['UNREAD_POSTS'],
 208              'U_MARK_TOPICS'        => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . "&f=$forum_id&mark=topics&mark_time=" . time()) : '',
 209              'MESSAGE_TITLE'        => $user->lang['INFORMATION'],
 210              'MESSAGE_TEXT'        => $user->lang['TOPICS_MARKED']
 211          );
 212          $json_response = new \phpbb\json_response();
 213          $json_response->send($data);
 214      }
 215  
 216      trigger_error($user->lang['TOPICS_MARKED'] . '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect_url . '">', '</a>'));
 217  }
 218  
 219  // Do the forum Prune thang - cron type job ...
 220  if (!$config['use_system_cron'])
 221  {
 222      $cron = $phpbb_container->get('cron.manager');
 223  
 224      $task = $cron->find_task('cron.task.core.prune_forum');
 225      $task->set_forum_data($forum_data);
 226  
 227      if ($task->is_ready())
 228      {
 229          $url = $task->get_url();
 230          $template->assign_var('RUN_CRON_TASK', '<img src="' . $url . '" width="1" height="1" alt="cron" />');
 231      }
 232      else
 233      {
 234          // See if we should prune the shadow topics instead
 235          $task = $cron->find_task('cron.task.core.prune_shadow_topics');
 236          $task->set_forum_data($forum_data);
 237  
 238          if ($task->is_ready())
 239          {
 240              $url = $task->get_url();
 241              $template->assign_var('RUN_CRON_TASK', '<img src="' . $url . '" width="1" height="1" alt="cron" />');
 242          }
 243      }
 244  }
 245  
 246  // Forum rules and subscription info
 247  $s_watching_forum = array(
 248      'link'            => '',
 249      'link_toggle'    => '',
 250      'title'            => '',
 251      'title_toggle'    => '',
 252      'is_watching'    => false,
 253  );
 254  
 255  if ($config['allow_forum_notify'] && $forum_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_subscribe', $forum_id) || $user->data['user_id'] == ANONYMOUS))
 256  {
 257      $notify_status = (isset($forum_data['notify_status'])) ? $forum_data['notify_status'] : NULL;
 258      watch_topic_forum('forum', $s_watching_forum, $user->data['user_id'], $forum_id, 0, $notify_status, $start, $forum_data['forum_name']);
 259  }
 260  
 261  $s_forum_rules = '';
 262  gen_forum_auth_level('forum', $forum_id, $forum_data['forum_status']);
 263  
 264  // Topic ordering options
 265  $limit_days = array(0 => $user->lang['ALL_TOPICS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
 266  
 267  $sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->lang['VIEWS']);
 268  $sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => array('t.topic_last_post_time', 't.topic_last_post_id'), 'r' => (($auth->acl_get('m_approve', $forum_id)) ? 't.topic_posts_approved + t.topic_posts_unapproved + t.topic_posts_softdeleted' : 't.topic_posts_approved'), 's' => 'LOWER(t.topic_title)', 'v' => 't.topic_views');
 269  
 270  $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
 271  gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param, $default_sort_days, $default_sort_key, $default_sort_dir);
 272  
 273  // Limit topics to certain time frame, obtain correct topic count
 274  if ($sort_days)
 275  {
 276      $min_post_time = time() - ($sort_days * 86400);
 277  
 278      $sql_array = array(
 279          'SELECT'    => 'COUNT(t.topic_id) AS num_topics',
 280          'FROM'        => array(
 281              TOPICS_TABLE    => 't',
 282          ),
 283          'WHERE'        => 't.forum_id = ' . $forum_id . '
 284              AND (t.topic_last_post_time >= ' . $min_post_time . '
 285                  OR t.topic_type = ' . POST_ANNOUNCE . '
 286                  OR t.topic_type = ' . POST_GLOBAL . ')
 287              AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.'),
 288      );
 289  
 290      /**
 291      * Modify the sort data SQL query for getting additional fields if needed
 292      *
 293      * @event core.viewforum_modify_sort_data_sql
 294      * @var int        forum_id        The forum_id whose topics are being listed
 295      * @var int        start            Variable containing start for pagination
 296      * @var int        sort_days        The oldest topic displayable in elapsed days
 297      * @var string    sort_key        The sorting by. It is one of the first character of (in low case):
 298      *                                Author, Post time, Replies, Subject, Views
 299      * @var string    sort_dir        Either "a" for ascending or "d" for descending
 300      * @var array    sql_array        The SQL array to get the data of all topics
 301      * @since 3.1.9-RC1
 302      */
 303      $vars = array(
 304          'forum_id',
 305          'start',
 306          'sort_days',
 307          'sort_key',
 308          'sort_dir',
 309          'sql_array',
 310      );
 311      extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_sort_data_sql', compact($vars)));
 312  
 313      $result = $db->sql_query($db->sql_build_query('SELECT', $sql_array));
 314      $topics_count = (int) $db->sql_fetchfield('num_topics');
 315      $db->sql_freeresult($result);
 316  
 317      if (isset($_POST['sort']))
 318      {
 319          $start = 0;
 320      }
 321      $sql_limit_time = "AND t.topic_last_post_time >= $min_post_time";
 322  
 323      // Make sure we have information about day selection ready
 324      $template->assign_var('S_SORT_DAYS', true);
 325  }
 326  else
 327  {
 328      $sql_limit_time = '';
 329  }
 330  
 331  // Basic pagewide vars
 332  $post_alt = ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->lang['FORUM_LOCKED'] : $user->lang['POST_NEW_TOPIC'];
 333  
 334  // Display active topics?
 335  $s_display_active = ($forum_data['forum_type'] == FORUM_CAT && ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS)) ? true : false;
 336  
 337  $s_search_hidden_fields = array('fid' => array($forum_id));
 338  if ($_SID)
 339  {
 340      $s_search_hidden_fields['sid'] = $_SID;
 341  }
 342  
 343  if (!empty($_EXTRA_URL))
 344  {
 345      foreach ($_EXTRA_URL as $url_param)
 346      {
 347          $url_param = explode('=', $url_param, 2);
 348          $s_search_hidden_fields[$url_param[0]] = $url_param[1];
 349      }
 350  }
 351  
 352  $template->assign_vars(array(
 353      'MODERATORS'    => (!empty($moderators[$forum_id])) ? implode($user->lang['COMMA_SEPARATOR'], $moderators[$forum_id]) : '',
 354  
 355      'POST_IMG'                    => ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', $post_alt) : $user->img('button_topic_new', $post_alt),
 356      'NEWEST_POST_IMG'            => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'),
 357      'LAST_POST_IMG'                => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
 358      'FOLDER_IMG'                => $user->img('topic_read', 'NO_UNREAD_POSTS'),
 359      'FOLDER_UNREAD_IMG'            => $user->img('topic_unread', 'UNREAD_POSTS'),
 360      'FOLDER_HOT_IMG'            => $user->img('topic_read_hot', 'NO_UNREAD_POSTS_HOT'),
 361      'FOLDER_HOT_UNREAD_IMG'        => $user->img('topic_unread_hot', 'UNREAD_POSTS_HOT'),
 362      'FOLDER_LOCKED_IMG'            => $user->img('topic_read_locked', 'NO_UNREAD_POSTS_LOCKED'),
 363      'FOLDER_LOCKED_UNREAD_IMG'    => $user->img('topic_unread_locked', 'UNREAD_POSTS_LOCKED'),
 364      'FOLDER_STICKY_IMG'            => $user->img('sticky_read', 'POST_STICKY'),
 365      'FOLDER_STICKY_UNREAD_IMG'    => $user->img('sticky_unread', 'POST_STICKY'),
 366      'FOLDER_ANNOUNCE_IMG'        => $user->img('announce_read', 'POST_ANNOUNCEMENT'),
 367      'FOLDER_ANNOUNCE_UNREAD_IMG'=> $user->img('announce_unread', 'POST_ANNOUNCEMENT'),
 368      'FOLDER_MOVED_IMG'            => $user->img('topic_moved', 'TOPIC_MOVED'),
 369      'REPORTED_IMG'                => $user->img('icon_topic_reported', 'TOPIC_REPORTED'),
 370      'UNAPPROVED_IMG'            => $user->img('icon_topic_unapproved', 'TOPIC_UNAPPROVED'),
 371      'DELETED_IMG'                => $user->img('icon_topic_deleted', 'TOPIC_DELETED'),
 372      'POLL_IMG'                    => $user->img('icon_topic_poll', 'TOPIC_POLL'),
 373      'GOTO_PAGE_IMG'                => $user->img('icon_post_target', 'GOTO_PAGE'),
 374  
 375      'L_NO_TOPICS'             => ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->lang['POST_FORUM_LOCKED'] : $user->lang['NO_TOPICS'],
 376  
 377      'S_DISPLAY_POST_INFO'    => ($forum_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false,
 378  
 379      'S_IS_POSTABLE'            => ($forum_data['forum_type'] == FORUM_POST) ? true : false,
 380      'S_USER_CAN_POST'        => ($auth->acl_get('f_post', $forum_id)) ? true : false,
 381      'S_DISPLAY_ACTIVE'        => $s_display_active,
 382      'S_SELECT_SORT_DIR'        => $s_sort_dir,
 383      'S_SELECT_SORT_KEY'        => $s_sort_key,
 384      'S_SELECT_SORT_DAYS'    => $s_limit_days,
 385      'S_TOPIC_ICONS'            => ($s_display_active && sizeof($active_forum_ary)) ? max($active_forum_ary['enable_icons']) : (($forum_data['enable_icons']) ? true : false),
 386      'U_WATCH_FORUM_LINK'    => $s_watching_forum['link'],
 387      'U_WATCH_FORUM_TOGGLE'    => $s_watching_forum['link_toggle'],
 388      'S_WATCH_FORUM_TITLE'    => $s_watching_forum['title'],
 389      'S_WATCH_FORUM_TOGGLE'    => $s_watching_forum['title_toggle'],
 390      'S_WATCHING_FORUM'        => $s_watching_forum['is_watching'],
 391      'S_FORUM_ACTION'        => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . (($start == 0) ? '' : "&amp;start=$start")),
 392      'S_DISPLAY_SEARCHBOX'    => ($auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search']) ? true : false,
 393      'S_SEARCHBOX_ACTION'    => append_sid("{$phpbb_root_path}search.$phpEx"),
 394      'S_SEARCH_LOCAL_HIDDEN_FIELDS'    => build_hidden_fields($s_search_hidden_fields),
 395      'S_SINGLE_MODERATOR'    => (!empty($moderators[$forum_id]) && sizeof($moderators[$forum_id]) > 1) ? false : true,
 396      'S_IS_LOCKED'            => ($forum_data['forum_status'] == ITEM_LOCKED) ? true : false,
 397      'S_VIEWFORUM'            => true,
 398  
 399      'U_MCP'                => ($auth->acl_get('m_', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&amp;i=main&amp;mode=forum_view", true, $user->session_id) : '',
 400      'U_POST_NEW_TOPIC'    => ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=post&amp;f=' . $forum_id) : '',
 401      'U_VIEW_FORUM'        => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : '') . (($start == 0) ? '' : "&amp;start=$start")),
 402      'U_CANONICAL'        => generate_board_url() . '/' . append_sid("viewforum.$phpEx", "f=$forum_id" . (($start) ? "&amp;start=$start" : ''), true, ''),
 403      'U_MARK_TOPICS'        => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . "&amp;f=$forum_id&amp;mark=topics&amp;mark_time=" . time()) : '',
 404  ));
 405  
 406  // Grab icons
 407  $icons = $cache->obtain_icons();
 408  
 409  // Grab all topic data
 410  $rowset = $announcement_list = $topic_list = $global_announce_forums = array();
 411  
 412  $sql_array = array(
 413      'SELECT'    => 't.*',
 414      'FROM'        => array(
 415          TOPICS_TABLE        => 't'
 416      ),
 417      'LEFT_JOIN'    => array(),
 418  );
 419  
 420  /**
 421  * Event to modify the SQL query before the topic data is retrieved
 422  *
 423  * It may also be used to override the above assigned template vars
 424  *
 425  * @event core.viewforum_get_topic_data
 426  * @var    array    forum_data            Array with forum data
 427  * @var    array    sql_array            The SQL array to get the data of all topics
 428  * @var    int        forum_id            The forum_id whose topics are being listed
 429  * @var    int        topics_count        The total number of topics for display
 430  * @var    int        sort_days            The oldest topic displayable in elapsed days
 431  * @var    string    sort_key            The sorting by. It is one of the first character of (in low case):
 432  *                                    Author, Post time, Replies, Subject, Views
 433  * @var    string    sort_dir            Either "a" for ascending or "d" for descending
 434  * @since 3.1.0-a1
 435  * @changed 3.1.0-RC4 Added forum_data var
 436  * @changed 3.1.4-RC1 Added forum_id, topics_count, sort_days, sort_key and sort_dir vars
 437  * @changed 3.1.9-RC1 Fix types of properties
 438  */
 439  $vars = array(
 440      'forum_data',
 441      'sql_array',
 442      'forum_id',
 443      'topics_count',
 444      'sort_days',
 445      'sort_key',
 446      'sort_dir',
 447  );
 448  extract($phpbb_dispatcher->trigger_event('core.viewforum_get_topic_data', compact($vars)));
 449  
 450  $sql_approved = ' AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.');
 451  
 452  if ($user->data['is_registered'])
 453  {
 454      if ($config['load_db_track'])
 455      {
 456          $sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_POSTED_TABLE => 'tp'), 'ON' => 'tp.topic_id = t.topic_id AND tp.user_id = ' . $user->data['user_id']);
 457          $sql_array['SELECT'] .= ', tp.topic_posted';
 458      }
 459  
 460      if ($config['load_db_lastread'])
 461      {
 462          $sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_TRACK_TABLE => 'tt'), 'ON' => 'tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id']);
 463          $sql_array['SELECT'] .= ', tt.mark_time';
 464  
 465          if ($s_display_active && sizeof($active_forum_ary))
 466          {
 467              $sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.forum_id = t.forum_id AND ft.user_id = ' . $user->data['user_id']);
 468              $sql_array['SELECT'] .= ', ft.mark_time AS forum_mark_time';
 469          }
 470      }
 471  }
 472  
 473  if ($forum_data['forum_type'] == FORUM_POST)
 474  {
 475      // Get global announcement forums
 476      $g_forum_ary = $auth->acl_getf('f_read', true);
 477      $g_forum_ary = array_unique(array_keys($g_forum_ary));
 478  
 479      $sql_anounce_array['LEFT_JOIN'] = $sql_array['LEFT_JOIN'];
 480      $sql_anounce_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 'f.forum_id = t.forum_id');
 481      $sql_anounce_array['SELECT'] = $sql_array['SELECT'] . ', f.forum_name';
 482  
 483      // Obtain announcements ... removed sort ordering, sort by time in all cases
 484      $sql_ary = array(
 485          'SELECT'    => $sql_anounce_array['SELECT'],
 486          'FROM'        => $sql_array['FROM'],
 487          'LEFT_JOIN'    => $sql_anounce_array['LEFT_JOIN'],
 488  
 489          'WHERE'        => '(t.forum_id = ' . $forum_id . '
 490                  AND t.topic_type = ' . POST_ANNOUNCE . ') OR
 491              (' . $db->sql_in_set('t.forum_id', $g_forum_ary) . '
 492                  AND t.topic_type = ' . POST_GLOBAL . ')',
 493  
 494          'ORDER_BY'    => 't.topic_time DESC',
 495      );
 496  
 497      /**
 498      * Event to modify the SQL query before the announcement topic ids data is retrieved
 499      *
 500      * @event core.viewforum_get_announcement_topic_ids_data
 501      * @var    array    forum_data            Data about the forum
 502      * @var    array    g_forum_ary            Global announcement forums array
 503      * @var    array    sql_anounce_array    SQL announcement array
 504      * @var    array    sql_ary                SQL query array to get the announcement topic ids data
 505      * @var    int        forum_id            The forum ID
 506      *
 507      * @since 3.1.10-RC1
 508      */
 509      $vars = array(
 510          'forum_data',
 511          'g_forum_ary',
 512          'sql_anounce_array',
 513          'sql_ary',
 514          'forum_id',
 515      );
 516      extract($phpbb_dispatcher->trigger_event('core.viewforum_get_announcement_topic_ids_data', compact($vars)));
 517  
 518      $sql = $db->sql_build_query('SELECT', $sql_ary);
 519      $result = $db->sql_query($sql);
 520  
 521      while ($row = $db->sql_fetchrow($result))
 522      {
 523          if ($row['topic_visibility'] != ITEM_APPROVED && !$auth->acl_get('m_approve', $row['forum_id']))
 524          {
 525              // Do not display announcements that are waiting for approval or soft deleted.
 526              continue;
 527          }
 528  
 529          $rowset[$row['topic_id']] = $row;
 530          $announcement_list[] = $row['topic_id'];
 531  
 532          if ($forum_id != $row['forum_id'])
 533          {
 534              $topics_count++;
 535              $global_announce_forums[] = $row['forum_id'];
 536          }
 537      }
 538      $db->sql_freeresult($result);
 539  }
 540  
 541  $forum_tracking_info = array();
 542  
 543  if ($user->data['is_registered'] && $config['load_db_lastread'])
 544  {
 545      $forum_tracking_info[$forum_id] = $forum_data['mark_time'];
 546  
 547      if (!empty($global_announce_forums))
 548      {
 549          $sql = 'SELECT forum_id, mark_time
 550              FROM ' . FORUMS_TRACK_TABLE . '
 551              WHERE ' . $db->sql_in_set('forum_id', $global_announce_forums) . '
 552                  AND user_id = ' . $user->data['user_id'];
 553          $result = $db->sql_query($sql);
 554  
 555          while ($row = $db->sql_fetchrow($result))
 556          {
 557              $forum_tracking_info[$row['forum_id']] = $row['mark_time'];
 558          }
 559          $db->sql_freeresult($result);
 560      }
 561  }
 562  
 563  // If the user is trying to reach late pages, start searching from the end
 564  $store_reverse = false;
 565  $sql_limit = $config['topics_per_page'];
 566  if ($start > $topics_count / 2)
 567  {
 568      $store_reverse = true;
 569  
 570      // Select the sort order
 571      $direction = (($sort_dir == 'd') ? 'ASC' : 'DESC');
 572  
 573      $sql_limit = $pagination->reverse_limit($start, $sql_limit, $topics_count - sizeof($announcement_list));
 574      $sql_start = $pagination->reverse_start($start, $sql_limit, $topics_count - sizeof($announcement_list));
 575  }
 576  else
 577  {
 578      // Select the sort order
 579      $direction = (($sort_dir == 'd') ? 'DESC' : 'ASC');
 580      $sql_start = $start;
 581  }
 582  
 583  if (is_array($sort_by_sql[$sort_key]))
 584  {
 585      $sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction;
 586  }
 587  else
 588  {
 589      $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction;
 590  }
 591  
 592  if ($forum_data['forum_type'] == FORUM_POST || !sizeof($active_forum_ary))
 593  {
 594      $sql_where = 't.forum_id = ' . $forum_id;
 595  }
 596  else if (empty($active_forum_ary['exclude_forum_id']))
 597  {
 598      $sql_where = $db->sql_in_set('t.forum_id', $active_forum_ary['forum_id']);
 599  }
 600  else
 601  {
 602      $get_forum_ids = array_diff($active_forum_ary['forum_id'], $active_forum_ary['exclude_forum_id']);
 603      $sql_where = (sizeof($get_forum_ids)) ? $db->sql_in_set('t.forum_id', $get_forum_ids) : 't.forum_id = ' . $forum_id;
 604  }
 605  
 606  // Grab just the sorted topic ids
 607  $sql_ary = array(
 608      'SELECT'    => 't.topic_id',
 609      'FROM'        => array(
 610          TOPICS_TABLE => 't',
 611      ),
 612      'WHERE'        => "$sql_where
 613          AND t.topic_type IN (" . POST_NORMAL . ', ' . POST_STICKY . ")
 614          $sql_approved
 615          $sql_limit_time",
 616      'ORDER_BY'    => 't.topic_type ' . ((!$store_reverse) ? 'DESC' : 'ASC') . ', ' . $sql_sort_order,
 617  );
 618  
 619  /**
 620  * Event to modify the SQL query before the topic ids data is retrieved
 621  *
 622  * @event core.viewforum_get_topic_ids_data
 623  * @var    array    forum_data        Data about the forum
 624  * @var    array    sql_ary            SQL query array to get the topic ids data
 625  * @var    string    sql_approved    Topic visibility SQL string
 626  * @var    int        sql_limit        Number of records to select
 627  * @var    string    sql_limit_time    SQL string to limit topic_last_post_time data
 628  * @var    array    sql_sort_order    SQL sorting string
 629  * @var    int        sql_start        Offset point to start selection from
 630  * @var    string    sql_where        SQL WHERE clause string
 631  * @var    bool    store_reverse    Flag indicating if we select from the late pages
 632  *
 633  * @since 3.1.0-RC4
 634  *
 635  * @changed 3.1.3 Added forum_data
 636  */
 637  $vars = array(
 638      'forum_data',
 639      'sql_ary',
 640      'sql_approved',
 641      'sql_limit',
 642      'sql_limit_time',
 643      'sql_sort_order',
 644      'sql_start',
 645      'sql_where',
 646      'store_reverse',
 647  );
 648  extract($phpbb_dispatcher->trigger_event('core.viewforum_get_topic_ids_data', compact($vars)));
 649  
 650  $sql = $db->sql_build_query('SELECT', $sql_ary);
 651  $result = $db->sql_query_limit($sql, $sql_limit, $sql_start);
 652  
 653  while ($row = $db->sql_fetchrow($result))
 654  {
 655      $topic_list[] = (int) $row['topic_id'];
 656  }
 657  $db->sql_freeresult($result);
 658  
 659  // For storing shadow topics
 660  $shadow_topic_list = array();
 661  
 662  if (sizeof($topic_list))
 663  {
 664      // SQL array for obtaining topics/stickies
 665      $sql_array = array(
 666          'SELECT'        => $sql_array['SELECT'],
 667          'FROM'            => $sql_array['FROM'],
 668          'LEFT_JOIN'        => $sql_array['LEFT_JOIN'],
 669  
 670          'WHERE'            => $db->sql_in_set('t.topic_id', $topic_list),
 671      );
 672  
 673      // If store_reverse, then first obtain topics, then stickies, else the other way around...
 674      // Funnily enough you typically save one query if going from the last page to the middle (store_reverse) because
 675      // the number of stickies are not known
 676      $sql = $db->sql_build_query('SELECT', $sql_array);
 677      $result = $db->sql_query($sql);
 678  
 679      while ($row = $db->sql_fetchrow($result))
 680      {
 681          if ($row['topic_status'] == ITEM_MOVED)
 682          {
 683              $shadow_topic_list[$row['topic_moved_id']] = $row['topic_id'];
 684          }
 685  
 686          $rowset[$row['topic_id']] = $row;
 687      }
 688      $db->sql_freeresult($result);
 689  }
 690  
 691  // If we have some shadow topics, update the rowset to reflect their topic information
 692  if (sizeof($shadow_topic_list))
 693  {
 694      // SQL array for obtaining shadow topics
 695      $sql_array = array(
 696          'SELECT'    => 't.*',
 697          'FROM'        => array(
 698              TOPICS_TABLE        => 't'
 699          ),
 700          'WHERE'        => $db->sql_in_set('t.topic_id', array_keys($shadow_topic_list)),
 701      );
 702  
 703      /**
 704      * Event to modify the SQL query before the shadowtopic data is retrieved
 705      *
 706      * @event core.viewforum_get_shadowtopic_data
 707      * @var    array    sql_array        SQL array to get the data of any shadowtopics
 708      * @since 3.1.0-a1
 709      */
 710      $vars = array('sql_array');
 711      extract($phpbb_dispatcher->trigger_event('core.viewforum_get_shadowtopic_data', compact($vars)));
 712  
 713      $sql = $db->sql_build_query('SELECT', $sql_array);
 714      $result = $db->sql_query($sql);
 715  
 716      while ($row = $db->sql_fetchrow($result))
 717      {
 718          $orig_topic_id = $shadow_topic_list[$row['topic_id']];
 719  
 720          // If the shadow topic is already listed within the rowset (happens for active topics for example), then do not include it...
 721          if (isset($rowset[$row['topic_id']]))
 722          {
 723              // We need to remove any trace regarding this topic. :)
 724              unset($rowset[$orig_topic_id]);
 725              unset($topic_list[array_search($orig_topic_id, $topic_list)]);
 726              $topics_count--;
 727  
 728              continue;
 729          }
 730  
 731          // Do not include those topics the user has no permission to access
 732          if (!$auth->acl_get('f_read', $row['forum_id']))
 733          {
 734              // We need to remove any trace regarding this topic. :)
 735              unset($rowset[$orig_topic_id]);
 736              unset($topic_list[array_search($orig_topic_id, $topic_list)]);
 737              $topics_count--;
 738  
 739              continue;
 740          }
 741  
 742          // We want to retain some values
 743          $row = array_merge($row, array(
 744              'topic_moved_id'    => $rowset[$orig_topic_id]['topic_moved_id'],
 745              'topic_status'        => $rowset[$orig_topic_id]['topic_status'],
 746              'topic_type'        => $rowset[$orig_topic_id]['topic_type'],
 747              'topic_title'        => $rowset[$orig_topic_id]['topic_title'],
 748          ));
 749  
 750          // Shadow topics are never reported
 751          $row['topic_reported'] = 0;
 752  
 753          $rowset[$orig_topic_id] = $row;
 754      }
 755      $db->sql_freeresult($result);
 756  }
 757  unset($shadow_topic_list);
 758  
 759  // Ok, adjust topics count for active topics list
 760  if ($s_display_active)
 761  {
 762      $topics_count = 1;
 763  }
 764  
 765  // We need to remove the global announcements from the forums total topic count,
 766  // otherwise the number is different from the one on the forum list
 767  $total_topic_count = $topics_count - sizeof($announcement_list);
 768  
 769  $base_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : ''));
 770  $pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_topic_count, $config['topics_per_page'], $start);
 771  
 772  $template->assign_vars(array(
 773      'TOTAL_TOPICS'    => ($s_display_active) ? false : $user->lang('VIEW_FORUM_TOPICS', (int) $total_topic_count),
 774  ));
 775  
 776  $topic_list = ($store_reverse) ? array_merge($announcement_list, array_reverse($topic_list)) : array_merge($announcement_list, $topic_list);
 777  $topic_tracking_info = $tracking_topics = array();
 778  
 779  /**
 780  * Modify topics data before we display the viewforum page
 781  *
 782  * @event core.viewforum_modify_topics_data
 783  * @var    array    topic_list            Array with current viewforum page topic ids
 784  * @var    array    rowset                Array with topics data (in topic_id => topic_data format)
 785  * @var    int        total_topic_count    Forum's total topic count
 786  * @var    int        forum_id            Forum identifier
 787  * @since 3.1.0-b3
 788  * @changed 3.1.11-RC1 Added forum_id
 789  */
 790  $vars = array('topic_list', 'rowset', 'total_topic_count', 'forum_id');
 791  extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_topics_data', compact($vars)));
 792  
 793  // Okay, lets dump out the page ...
 794  if (sizeof($topic_list))
 795  {
 796      $mark_forum_read = true;
 797      $mark_time_forum = 0;
 798  
 799      // Generate topic forum list...
 800      $topic_forum_list = array();
 801      foreach ($rowset as $t_id => $row)
 802      {
 803          if (isset($forum_tracking_info[$row['forum_id']]))
 804          {
 805              $row['forum_mark_time'] = $forum_tracking_info[$row['forum_id']];
 806          }
 807  
 808          $topic_forum_list[$row['forum_id']]['forum_mark_time'] = ($config['load_db_lastread'] && $user->data['is_registered'] && isset($row['forum_mark_time'])) ? $row['forum_mark_time'] : 0;
 809          $topic_forum_list[$row['forum_id']]['topics'][] = (int) $t_id;
 810      }
 811  
 812      if ($config['load_db_lastread'] && $user->data['is_registered'])
 813      {
 814          foreach ($topic_forum_list as $f_id => $topic_row)
 815          {
 816              $topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time']));
 817          }
 818      }
 819      else if ($config['load_anon_lastread'] || $user->data['is_registered'])
 820      {
 821          foreach ($topic_forum_list as $f_id => $topic_row)
 822          {
 823              $topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics']);
 824          }
 825      }
 826  
 827      unset($topic_forum_list);
 828  
 829      if (!$s_display_active)
 830      {
 831          if ($config['load_db_lastread'] && $user->data['is_registered'])
 832          {
 833              $mark_time_forum = (!empty($forum_data['mark_time'])) ? $forum_data['mark_time'] : $user->data['user_lastmark'];
 834          }
 835          else if ($config['load_anon_lastread'] || $user->data['is_registered'])
 836          {
 837              if (!$user->data['is_registered'])
 838              {
 839                  $user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0;
 840              }
 841              $mark_time_forum = (isset($tracking_topics['f'][$forum_id])) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark'];
 842          }
 843      }
 844  
 845      $s_type_switch = 0;
 846      foreach ($topic_list as $topic_id)
 847      {
 848          $row = &$rowset[$topic_id];
 849  
 850          $topic_forum_id = ($row['forum_id']) ? (int) $row['forum_id'] : $forum_id;
 851  
 852          // This will allow the style designer to output a different header
 853          // or even separate the list of announcements from sticky and normal topics
 854          $s_type_switch_test = ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) ? 1 : 0;
 855  
 856          // Replies
 857          $replies = $phpbb_content_visibility->get_count('topic_posts', $row, $topic_forum_id) - 1;
 858  
 859          if ($row['topic_status'] == ITEM_MOVED)
 860          {
 861              $topic_id = $row['topic_moved_id'];
 862              $unread_topic = false;
 863          }
 864          else
 865          {
 866              $unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
 867          }
 868  
 869          // Get folder img, topic status/type related information
 870          $folder_img = $folder_alt = $topic_type = '';
 871          topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type);
 872  
 873          // Generate all the URIs ...
 874          $view_topic_url_params = 'f=' . $row['forum_id'] . '&amp;t=' . $topic_id;
 875          $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params);
 876  
 877          $topic_unapproved = (($row['topic_visibility'] == ITEM_UNAPPROVED || $row['topic_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $row['forum_id']));
 878          $posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $auth->acl_get('m_approve', $row['forum_id']));
 879          $topic_deleted = $row['topic_visibility'] == ITEM_DELETED;
 880  
 881          $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&amp;t=$topic_id", true, $user->session_id) : '';
 882          $u_mcp_queue = (!$u_mcp_queue && $topic_deleted) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=deleted_topics&amp;t=' . $topic_id, true, $user->session_id) : $u_mcp_queue;
 883  
 884          // Send vars to template
 885          $topic_row = array(
 886              'FORUM_ID'                    => $row['forum_id'],
 887              'TOPIC_ID'                    => $topic_id,
 888              'TOPIC_AUTHOR'                => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
 889              'TOPIC_AUTHOR_COLOUR'        => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
 890              'TOPIC_AUTHOR_FULL'            => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
 891              'FIRST_POST_TIME'            => $user->format_date($row['topic_time']),
 892              'LAST_POST_SUBJECT'            => censor_text($row['topic_last_post_subject']),
 893              'LAST_POST_TIME'            => $user->format_date($row['topic_last_post_time']),
 894              'LAST_VIEW_TIME'            => $user->format_date($row['topic_last_view_time']),
 895              'LAST_POST_AUTHOR'            => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
 896              'LAST_POST_AUTHOR_COLOUR'    => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
 897              'LAST_POST_AUTHOR_FULL'        => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
 898  
 899              'REPLIES'            => $replies,
 900              'VIEWS'                => $row['topic_views'],
 901              'TOPIC_TITLE'        => censor_text($row['topic_title']),
 902              'TOPIC_TYPE'        => $topic_type,
 903              'FORUM_NAME'        => (isset($row['forum_name'])) ? $row['forum_name'] : $forum_data['forum_name'],
 904  
 905              'TOPIC_IMG_STYLE'        => $folder_img,
 906              'TOPIC_FOLDER_IMG'        => $user->img($folder_img, $folder_alt),
 907              'TOPIC_FOLDER_IMG_ALT'    => $user->lang[$folder_alt],
 908  
 909              'TOPIC_ICON_IMG'        => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '',
 910              'TOPIC_ICON_IMG_WIDTH'    => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '',
 911              'TOPIC_ICON_IMG_HEIGHT'    => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '',
 912              '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']) : '',
 913              'UNAPPROVED_IMG'        => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '',
 914  
 915              'S_TOPIC_TYPE'            => $row['topic_type'],
 916              'S_USER_POSTED'            => (isset($row['topic_posted']) && $row['topic_posted']) ? true : false,
 917              'S_UNREAD_TOPIC'        => $unread_topic,
 918              'S_TOPIC_REPORTED'        => (!empty($row['topic_reported']) && $auth->acl_get('m_report', $row['forum_id'])) ? true : false,
 919              'S_TOPIC_UNAPPROVED'    => $topic_unapproved,
 920              'S_POSTS_UNAPPROVED'    => $posts_unapproved,
 921              'S_TOPIC_DELETED'        => $topic_deleted,
 922              'S_HAS_POLL'            => ($row['poll_start']) ? true : false,
 923              'S_POST_ANNOUNCE'        => ($row['topic_type'] == POST_ANNOUNCE) ? true : false,
 924              'S_POST_GLOBAL'            => ($row['topic_type'] == POST_GLOBAL) ? true : false,
 925              'S_POST_STICKY'            => ($row['topic_type'] == POST_STICKY) ? true : false,
 926              'S_TOPIC_LOCKED'        => ($row['topic_status'] == ITEM_LOCKED) ? true : false,
 927              'S_TOPIC_MOVED'            => ($row['topic_status'] == ITEM_MOVED) ? true : false,
 928  
 929              'U_NEWEST_POST'            => append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&amp;view=unread') . '#unread',
 930              'U_LAST_POST'            => append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&amp;p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'],
 931              'U_LAST_POST_AUTHOR'    => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
 932              'U_TOPIC_AUTHOR'        => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
 933              'U_VIEW_TOPIC'            => $view_topic_url,
 934              'U_VIEW_FORUM'            => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']),
 935              'U_MCP_REPORT'            => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&amp;mode=reports&amp;f=' . $row['forum_id'] . '&amp;t=' . $topic_id, true, $user->session_id),
 936              'U_MCP_QUEUE'            => $u_mcp_queue,
 937  
 938              'S_TOPIC_TYPE_SWITCH'    => ($s_type_switch == $s_type_switch_test) ? -1 : $s_type_switch_test,
 939          );
 940  
 941          /**
 942          * Modify the topic data before it is assigned to the template
 943          *
 944          * @event core.viewforum_modify_topicrow
 945          * @var    array    row                    Array with topic data
 946          * @var    array    topic_row            Template array with topic data
 947          * @var    bool    s_type_switch        Flag indicating if the topic type is [global] announcement
 948          * @var    bool    s_type_switch_test    Flag indicating if the test topic type is [global] announcement
 949          * @since 3.1.0-a1
 950          *
 951          * @changed 3.1.10-RC1 Added s_type_switch, s_type_switch_test
 952          */
 953          $vars = array('row', 'topic_row', 's_type_switch', 's_type_switch_test');
 954          extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_topicrow', compact($vars)));
 955  
 956          $template->assign_block_vars('topicrow', $topic_row);
 957  
 958          $pagination->generate_template_pagination($view_topic_url, 'topicrow.pagination', 'start', $replies + 1, $config['posts_per_page'], 1, true, true);
 959  
 960          $s_type_switch = ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) ? 1 : 0;
 961  
 962          /**
 963          * Event after the topic data has been assigned to the template
 964          *
 965          * @event core.viewforum_topic_row_after
 966          * @var    array    row                Array with the topic data
 967          * @var    array    rowset            Array with topics data (in topic_id => topic_data format)
 968          * @var    bool    s_type_switch    Flag indicating if the topic type is [global] announcement
 969          * @var    int        topic_id        The topic ID
 970          * @var    array    topic_list        Array with current viewforum page topic ids
 971          * @var    array    topic_row        Template array with topic data
 972          * @since 3.1.3-RC1
 973          */
 974          $vars = array(
 975              'row',
 976              'rowset',
 977              's_type_switch',
 978              'topic_id',
 979              'topic_list',
 980              'topic_row',
 981          );
 982          extract($phpbb_dispatcher->trigger_event('core.viewforum_topic_row_after', compact($vars)));
 983  
 984          if ($unread_topic)
 985          {
 986              $mark_forum_read = false;
 987          }
 988  
 989          unset($rowset[$topic_id]);
 990      }
 991  }
 992  
 993  // This is rather a fudge but it's the best I can think of without requiring information
 994  // on all topics (as we do in 2.0.x). It looks for unread or new topics, if it doesn't find
 995  // any it updates the forum last read cookie. This requires that the user visit the forum
 996  // after reading a topic
 997  if ($forum_data['forum_type'] == FORUM_POST && sizeof($topic_list) && $mark_forum_read)
 998  {
 999      update_forum_tracking_info($forum_id, $forum_data['forum_last_post_time'], false, $mark_time_forum);
1000  }
1001  
1002  page_footer();


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