[ Index ]

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


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1