Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

viewforum.php

Zuletzt modifiziert: 09.10.2024, 12:50 - Dateigröße: 38.10 KiB


0001  <?php
0002  /**
0003  *
0004  * This file is part of the phpBB Forum Software package.
0005  *
0006  * @copyright (c) phpBB Limited <https://www.phpbb.com>
0007  * @license GNU General Public License, version 2 (GPL-2.0)
0008  *
0009  * For full copyright and license information, please see
0010  * the docs/CREDITS.txt file.
0011  *
0012  */
0013   
0014  /**
0015  * @ignore
0016  */
0017  define('IN_PHPBB', true);
0018  $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
0019  $phpEx = substr(strrchr(__FILE__, '.'), 1);
0020  include($phpbb_root_path . 'common.' . $phpEx);
0021  include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
0022   
0023  // Start session
0024  $user->session_begin();
0025  $auth->acl($user->data);
0026   
0027  // Start initial var setup
0028  $forum_id    = $request->variable('f', 0);
0029  $mark_read    = $request->variable('mark', '');
0030  $start        = $request->variable('start', 0);
0031   
0032  $default_sort_days    = (!empty($user->data['user_topic_show_days'])) ? $user->data['user_topic_show_days'] : 0;
0033  $default_sort_key    = (!empty($user->data['user_topic_sortby_type'])) ? $user->data['user_topic_sortby_type'] : 't';
0034  $default_sort_dir    = (!empty($user->data['user_topic_sortby_dir'])) ? $user->data['user_topic_sortby_dir'] : 'd';
0035   
0036  $sort_days    = $request->variable('st', $default_sort_days);
0037  $sort_key    = $request->variable('sk', $default_sort_key);
0038  $sort_dir    = $request->variable('sd', $default_sort_dir);
0039   
0040  /* @var $pagination \phpbb\pagination */
0041  $pagination = $phpbb_container->get('pagination');
0042   
0043  // Check if the user has actually sent a forum ID with his/her request
0044  // If not give them a nice error page.
0045  if (!$forum_id)
0046  {
0047      trigger_error('NO_FORUM');
0048  }
0049   
0050  $sql_from = FORUMS_TABLE . ' f';
0051  $lastread_select = '';
0052   
0053  // Grab appropriate forum data
0054  if ($config['load_db_lastread'] && $user->data['is_registered'])
0055  {
0056      $sql_from .= ' LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $user->data['user_id'] . '
0057          AND ft.forum_id = f.forum_id)';
0058      $lastread_select .= ', ft.mark_time';
0059  }
0060   
0061  if ($user->data['is_registered'])
0062  {
0063      $sql_from .= ' LEFT JOIN ' . FORUMS_WATCH_TABLE . ' fw ON (fw.forum_id = f.forum_id AND fw.user_id = ' . $user->data['user_id'] . ')';
0064      $lastread_select .= ', fw.notify_status';
0065  }
0066   
0067  $sql = "SELECT f.* $lastread_select
0068      FROM $sql_from
0069      WHERE f.forum_id = $forum_id";
0070  $result = $db->sql_query($sql);
0071  $forum_data = $db->sql_fetchrow($result);
0072  $db->sql_freeresult($result);
0073   
0074  if (!$forum_data)
0075  {
0076      trigger_error('NO_FORUM');
0077  }
0078   
0079   
0080  // Configure style, language, etc.
0081  $user->setup('viewforum', $forum_data['forum_style']);
0082   
0083  // Redirect to login upon emailed notification links
0084  if (isset($_GET['e']) && !$user->data['is_registered'])
0085  {
0086      login_box('', $user->lang['LOGIN_NOTIFY_FORUM']);
0087  }
0088   
0089  // Permissions check
0090  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)))
0091  {
0092      if ($user->data['user_id'] != ANONYMOUS)
0093      {
0094          send_status_line(403, 'Forbidden');
0095          trigger_error('SORRY_AUTH_READ');
0096      }
0097   
0098      login_box('', $user->lang['LOGIN_VIEWFORUM']);
0099  }
0100   
0101  // Forum is passworded ... check whether access has been granted to this
0102  // user this session, if not show login box
0103  if ($forum_data['forum_password'])
0104  {
0105      login_forum_box($forum_data);
0106  }
0107   
0108  // Is this forum a link? ... User got here either because the
0109  // number of clicks is being tracked or they guessed the id
0110  if ($forum_data['forum_type'] == FORUM_LINK && $forum_data['forum_link'])
0111  {
0112      // Does it have click tracking enabled?
0113      if ($forum_data['forum_flags'] & FORUM_FLAG_LINK_TRACK)
0114      {
0115          $sql = 'UPDATE ' . FORUMS_TABLE . '
0116              SET forum_posts_approved = forum_posts_approved + 1
0117              WHERE forum_id = ' . $forum_id;
0118          $db->sql_query($sql);
0119      }
0120   
0121      // We redirect to the url. The third parameter indicates that external redirects are allowed.
0122      redirect($forum_data['forum_link'], false, true);
0123      return;
0124  }
0125   
0126  // Build navigation links
0127  generate_forum_nav($forum_data);
0128   
0129  // Forum Rules
0130  if ($auth->acl_get('f_read', $forum_id))
0131  {
0132      generate_forum_rules($forum_data);
0133  }
0134   
0135  // Do we have subforums?
0136  $active_forum_ary = $moderators = array();
0137   
0138  if ($forum_data['left_id'] != $forum_data['right_id'] - 1)
0139  {
0140      list($active_forum_ary, $moderators) = display_forums($forum_data, $config['load_moderators'], $config['load_moderators']);
0141  }
0142  else
0143  {
0144      $template->assign_var('S_HAS_SUBFORUM', false);
0145      if ($config['load_moderators'])
0146      {
0147          get_moderators($moderators, $forum_id);
0148      }
0149  }
0150   
0151  /* @var $phpbb_content_visibility \phpbb\content_visibility */
0152  $phpbb_content_visibility = $phpbb_container->get('content.visibility');
0153   
0154  // Dump out the page header and load viewforum template
0155  $topics_count = $phpbb_content_visibility->get_count('forum_topics', $forum_data, $forum_id);
0156  $start = $pagination->validate_start($start, $config['topics_per_page'], $topics_count);
0157   
0158  page_header($forum_data['forum_name'] . ($start ? ' - ' . $user->lang('PAGE_TITLE_NUMBER', $pagination->get_on_page($config['topics_per_page'], $start)) : ''), true, $forum_id);
0159   
0160  $template->set_filenames(array(
0161      'body' => 'viewforum_body.html')
0162  );
0163   
0164  make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"), $forum_id);
0165   
0166  $template->assign_vars(array(
0167      'U_VIEW_FORUM'            => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . (($start == 0) ? '' : "&amp;start=$start")),
0168  ));
0169   
0170  // Not postable forum or showing active topics?
0171  if (!($forum_data['forum_type'] == FORUM_POST || (($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) && $forum_data['forum_type'] == FORUM_CAT)))
0172  {
0173      page_footer();
0174  }
0175   
0176  // Ok, if someone has only list-access, we only display the forum list.
0177  // We also make this circumstance available to the template in case we want to display a notice. ;)
0178  if (!$auth->acl_get('f_read', $forum_id))
0179  {
0180      $template->assign_vars(array(
0181          'S_NO_READ_ACCESS'        => true,
0182      ));
0183   
0184      page_footer();
0185  }
0186   
0187  // Handle marking posts
0188  if ($mark_read == 'topics')
0189  {
0190      $token = $request->variable('hash', '');
0191      if (check_link_hash($token, 'global'))
0192      {
0193          markread('topics', array($forum_id), false, $request->variable('mark_time', 0));
0194      }
0195      $redirect_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id);
0196      meta_refresh(3, $redirect_url);
0197   
0198      if ($request->is_ajax())
0199      {
0200          // Tell the ajax script what language vars and URL need to be replaced
0201          $data = array(
0202              'NO_UNREAD_POSTS'    => $user->lang['NO_UNREAD_POSTS'],
0203              'UNREAD_POSTS'        => $user->lang['UNREAD_POSTS'],
0204              '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()) : '',
0205              'MESSAGE_TITLE'        => $user->lang['INFORMATION'],
0206              'MESSAGE_TEXT'        => $user->lang['TOPICS_MARKED']
0207          );
0208          $json_response = new \phpbb\json_response();
0209          $json_response->send($data);
0210      }
0211   
0212      trigger_error($user->lang['TOPICS_MARKED'] . '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect_url . '">', '</a>'));
0213  }
0214   
0215  // Is a forum specific topic count required?
0216  if ($forum_data['forum_topics_per_page'])
0217  {
0218      $config['topics_per_page'] = $forum_data['forum_topics_per_page'];
0219  }
0220   
0221  // Do the forum Prune thang - cron type job ...
0222  if (!$config['use_system_cron'])
0223  {
0224      /* @var $cron \phpbb\cron\manager */
0225      $cron = $phpbb_container->get('cron.manager');
0226   
0227      $task = $cron->find_task('cron.task.core.prune_forum');
0228      $task->set_forum_data($forum_data);
0229   
0230      if ($task->is_ready())
0231      {
0232          $url = $task->get_url();
0233          $template->assign_var('RUN_CRON_TASK', '<img src="' . $url . '" width="1" height="1" alt="cron" />');
0234      }
0235      else
0236      {
0237          // See if we should prune the shadow topics instead
0238          $task = $cron->find_task('cron.task.core.prune_shadow_topics');
0239          $task->set_forum_data($forum_data);
0240   
0241          if ($task->is_ready())
0242          {
0243              $url = $task->get_url();
0244              $template->assign_var('RUN_CRON_TASK', '<img src="' . $url . '" width="1" height="1" alt="cron" />');
0245          }
0246      }
0247  }
0248   
0249  // Forum rules and subscription info
0250  $s_watching_forum = array(
0251      'link'            => '',
0252      'link_toggle'    => '',
0253      'title'            => '',
0254      'title_toggle'    => '',
0255      'is_watching'    => false,
0256  );
0257   
0258  if ($config['allow_forum_notify'] && $forum_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_subscribe', $forum_id) || $user->data['user_id'] == ANONYMOUS))
0259  {
0260      $notify_status = (isset($forum_data['notify_status'])) ? $forum_data['notify_status'] : NULL;
0261      watch_topic_forum('forum', $s_watching_forum, $user->data['user_id'], $forum_id, 0, $notify_status, $start, $forum_data['forum_name']);
0262  }
0263   
0264  $s_forum_rules = '';
0265  gen_forum_auth_level('forum', $forum_id, $forum_data['forum_status']);
0266   
0267  // Topic ordering options
0268  $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']);
0269   
0270  $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']);
0271  $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');
0272   
0273  $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
0274  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);
0275   
0276  // Limit topics to certain time frame, obtain correct topic count
0277  if ($sort_days)
0278  {
0279      $min_post_time = time() - ($sort_days * 86400);
0280   
0281      $sql_array = array(
0282          'SELECT'    => 'COUNT(t.topic_id) AS num_topics',
0283          'FROM'        => array(
0284              TOPICS_TABLE    => 't',
0285          ),
0286          'WHERE'        => 't.forum_id = ' . $forum_id . '
0287              AND (t.topic_last_post_time >= ' . $min_post_time . '
0288                  OR t.topic_type = ' . POST_ANNOUNCE . '
0289                  OR t.topic_type = ' . POST_GLOBAL . ')
0290              AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.'),
0291      );
0292   
0293      /**
0294      * Modify the sort data SQL query for getting additional fields if needed
0295      *
0296      * @event core.viewforum_modify_sort_data_sql
0297      * @var int        forum_id        The forum_id whose topics are being listed
0298      * @var int        start            Variable containing start for pagination
0299      * @var int        sort_days        The oldest topic displayable in elapsed days
0300      * @var string    sort_key        The sorting by. It is one of the first character of (in low case):
0301      *                                Author, Post time, Replies, Subject, Views
0302      * @var string    sort_dir        Either "a" for ascending or "d" for descending
0303      * @var array    sql_array        The SQL array to get the data of all topics
0304      * @since 3.1.9-RC1
0305      */
0306      $vars = array(
0307          'forum_id',
0308          'start',
0309          'sort_days',
0310          'sort_key',
0311          'sort_dir',
0312          'sql_array',
0313      );
0314      extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_sort_data_sql', compact($vars)));
0315   
0316      $result = $db->sql_query($db->sql_build_query('SELECT', $sql_array));
0317      $topics_count = (int) $db->sql_fetchfield('num_topics');
0318      $db->sql_freeresult($result);
0319   
0320      if (isset($_POST['sort']))
0321      {
0322          $start = 0;
0323      }
0324      $sql_limit_time = "AND t.topic_last_post_time >= $min_post_time";
0325   
0326      // Make sure we have information about day selection ready
0327      $template->assign_var('S_SORT_DAYS', true);
0328  }
0329  else
0330  {
0331      $sql_limit_time = '';
0332  }
0333   
0334  // Basic pagewide vars
0335  $post_alt = ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->lang['FORUM_LOCKED'] : $user->lang['POST_NEW_TOPIC'];
0336   
0337  // Display active topics?
0338  $s_display_active = ($forum_data['forum_type'] == FORUM_CAT && ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS)) ? true : false;
0339   
0340  $s_search_hidden_fields = array('fid' => array($forum_id));
0341  if ($_SID)
0342  {
0343      $s_search_hidden_fields['sid'] = $_SID;
0344  }
0345   
0346  if (!empty($_EXTRA_URL))
0347  {
0348      foreach ($_EXTRA_URL as $url_param)
0349      {
0350          $url_param = explode('=', $url_param, 2);
0351          $s_search_hidden_fields[$url_param[0]] = $url_param[1];
0352      }
0353  }
0354   
0355  $template->assign_vars(array(
0356      'MODERATORS'    => (!empty($moderators[$forum_id])) ? implode($user->lang['COMMA_SEPARATOR'], $moderators[$forum_id]) : '',
0357   
0358      'POST_IMG'                    => ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', $post_alt) : $user->img('button_topic_new', $post_alt),
0359      'NEWEST_POST_IMG'            => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'),
0360      'LAST_POST_IMG'                => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
0361      'FOLDER_IMG'                => $user->img('topic_read', 'NO_UNREAD_POSTS'),
0362      'FOLDER_UNREAD_IMG'            => $user->img('topic_unread', 'UNREAD_POSTS'),
0363      'FOLDER_HOT_IMG'            => $user->img('topic_read_hot', 'NO_UNREAD_POSTS_HOT'),
0364      'FOLDER_HOT_UNREAD_IMG'        => $user->img('topic_unread_hot', 'UNREAD_POSTS_HOT'),
0365      'FOLDER_LOCKED_IMG'            => $user->img('topic_read_locked', 'NO_UNREAD_POSTS_LOCKED'),
0366      'FOLDER_LOCKED_UNREAD_IMG'    => $user->img('topic_unread_locked', 'UNREAD_POSTS_LOCKED'),
0367      'FOLDER_STICKY_IMG'            => $user->img('sticky_read', 'POST_STICKY'),
0368      'FOLDER_STICKY_UNREAD_IMG'    => $user->img('sticky_unread', 'POST_STICKY'),
0369      'FOLDER_ANNOUNCE_IMG'        => $user->img('announce_read', 'POST_ANNOUNCEMENT'),
0370      'FOLDER_ANNOUNCE_UNREAD_IMG'=> $user->img('announce_unread', 'POST_ANNOUNCEMENT'),
0371      'FOLDER_MOVED_IMG'            => $user->img('topic_moved', 'TOPIC_MOVED'),
0372      'REPORTED_IMG'                => $user->img('icon_topic_reported', 'TOPIC_REPORTED'),
0373      'UNAPPROVED_IMG'            => $user->img('icon_topic_unapproved', 'TOPIC_UNAPPROVED'),
0374      'DELETED_IMG'                => $user->img('icon_topic_deleted', 'TOPIC_DELETED'),
0375      'POLL_IMG'                    => $user->img('icon_topic_poll', 'TOPIC_POLL'),
0376      'GOTO_PAGE_IMG'                => $user->img('icon_post_target', 'GOTO_PAGE'),
0377   
0378      'L_NO_TOPICS'             => ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->lang['POST_FORUM_LOCKED'] : $user->lang['NO_TOPICS'],
0379   
0380      'S_DISPLAY_POST_INFO'    => ($forum_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false,
0381   
0382      'S_IS_POSTABLE'            => ($forum_data['forum_type'] == FORUM_POST) ? true : false,
0383      'S_USER_CAN_POST'        => ($auth->acl_get('f_post', $forum_id)) ? true : false,
0384      'S_DISPLAY_ACTIVE'        => $s_display_active,
0385      'S_SELECT_SORT_DIR'        => $s_sort_dir,
0386      'S_SELECT_SORT_KEY'        => $s_sort_key,
0387      'S_SELECT_SORT_DAYS'    => $s_limit_days,
0388      'S_TOPIC_ICONS'            => ($s_display_active && sizeof($active_forum_ary)) ? max($active_forum_ary['enable_icons']) : (($forum_data['enable_icons']) ? true : false),
0389      'U_WATCH_FORUM_LINK'    => $s_watching_forum['link'],
0390      'U_WATCH_FORUM_TOGGLE'    => $s_watching_forum['link_toggle'],
0391      'S_WATCH_FORUM_TITLE'    => $s_watching_forum['title'],
0392      'S_WATCH_FORUM_TOGGLE'    => $s_watching_forum['title_toggle'],
0393      'S_WATCHING_FORUM'        => $s_watching_forum['is_watching'],
0394      'S_FORUM_ACTION'        => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . (($start == 0) ? '' : "&amp;start=$start")),
0395      'S_DISPLAY_SEARCHBOX'    => ($auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search']) ? true : false,
0396      'S_SEARCHBOX_ACTION'    => append_sid("{$phpbb_root_path}search.$phpEx"),
0397      'S_SEARCH_LOCAL_HIDDEN_FIELDS'    => build_hidden_fields($s_search_hidden_fields),
0398      'S_SINGLE_MODERATOR'    => (!empty($moderators[$forum_id]) && sizeof($moderators[$forum_id]) > 1) ? false : true,
0399      'S_IS_LOCKED'            => ($forum_data['forum_status'] == ITEM_LOCKED) ? true : false,
0400      'S_VIEWFORUM'            => true,
0401   
0402      '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) : '',
0403      '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) : '',
0404      '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")),
0405      'U_CANONICAL'        => generate_board_url() . '/' . append_sid("viewforum.$phpEx", "f=$forum_id" . (($start) ? "&amp;start=$start" : ''), true, ''),
0406      '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()) : '',
0407  ));
0408   
0409  // Grab icons
0410  $icons = $cache->obtain_icons();
0411   
0412  // Grab all topic data
0413  $rowset = $announcement_list = $topic_list = $global_announce_forums = array();
0414   
0415  $sql_array = array(
0416      'SELECT'    => 't.*',
0417      'FROM'        => array(
0418          TOPICS_TABLE        => 't'
0419      ),
0420      'LEFT_JOIN'    => array(),
0421  );
0422   
0423  /**
0424  * Event to modify the SQL query before the topic data is retrieved
0425  *
0426  * It may also be used to override the above assigned template vars
0427  *
0428  * @event core.viewforum_get_topic_data
0429  * @var    array    forum_data            Array with forum data
0430  * @var    array    sql_array            The SQL array to get the data of all topics
0431  * @var    int        forum_id            The forum_id whose topics are being listed
0432  * @var    int        topics_count        The total number of topics for display
0433  * @var    int        sort_days            The oldest topic displayable in elapsed days
0434  * @var    string    sort_key            The sorting by. It is one of the first character of (in low case):
0435  *                                    Author, Post time, Replies, Subject, Views
0436  * @var    string    sort_dir            Either "a" for ascending or "d" for descending
0437  * @since 3.1.0-a1
0438  * @change 3.1.0-RC4 Added forum_data var
0439  * @change 3.1.4-RC1 Added forum_id, topics_count, sort_days, sort_key and sort_dir vars
0440  * @change 3.1.9-RC1 Fix types of properties
0441  */
0442  $vars = array(
0443      'forum_data',
0444      'sql_array',
0445      'forum_id',
0446      'topics_count',
0447      'sort_days',
0448      'sort_key',
0449      'sort_dir',
0450  );
0451  extract($phpbb_dispatcher->trigger_event('core.viewforum_get_topic_data', compact($vars)));
0452   
0453  $sql_approved = ' AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.');
0454   
0455  if ($user->data['is_registered'])
0456  {
0457      if ($config['load_db_track'])
0458      {
0459          $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']);
0460          $sql_array['SELECT'] .= ', tp.topic_posted';
0461      }
0462   
0463      if ($config['load_db_lastread'])
0464      {
0465          $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']);
0466          $sql_array['SELECT'] .= ', tt.mark_time';
0467   
0468          if ($s_display_active && sizeof($active_forum_ary))
0469          {
0470              $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']);
0471              $sql_array['SELECT'] .= ', ft.mark_time AS forum_mark_time';
0472          }
0473      }
0474  }
0475   
0476  if ($forum_data['forum_type'] == FORUM_POST)
0477  {
0478      // Get global announcement forums
0479      $g_forum_ary = $auth->acl_getf('f_read', true);
0480      $g_forum_ary = array_unique(array_keys($g_forum_ary));
0481   
0482      $sql_anounce_array['LEFT_JOIN'] = $sql_array['LEFT_JOIN'];
0483      $sql_anounce_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 'f.forum_id = t.forum_id');
0484      $sql_anounce_array['SELECT'] = $sql_array['SELECT'] . ', f.forum_name';
0485   
0486      // Obtain announcements ... removed sort ordering, sort by time in all cases
0487      $sql_ary = array(
0488          'SELECT'    => $sql_anounce_array['SELECT'],
0489          'FROM'        => $sql_array['FROM'],
0490          'LEFT_JOIN'    => $sql_anounce_array['LEFT_JOIN'],
0491   
0492          'WHERE'        => '(t.forum_id = ' . $forum_id . '
0493                  AND t.topic_type = ' . POST_ANNOUNCE . ') OR
0494              (' . $db->sql_in_set('t.forum_id', $g_forum_ary) . '
0495                  AND t.topic_type = ' . POST_GLOBAL . ')',
0496   
0497          'ORDER_BY'    => 't.topic_time DESC',
0498      );
0499   
0500      /**
0501      * Event to modify the SQL query before the announcement topic ids data is retrieved
0502      *
0503      * @event core.viewforum_get_announcement_topic_ids_data
0504      * @var    array    forum_data            Data about the forum
0505      * @var    array    g_forum_ary            Global announcement forums array
0506      * @var    array    sql_anounce_array    SQL announcement array
0507      * @var    array    sql_ary                SQL query array to get the announcement topic ids data
0508      * @var    int        forum_id            The forum ID
0509      *
0510      * @since 3.1.10-RC1
0511      */
0512      $vars = array(
0513          'forum_data',
0514          'g_forum_ary',
0515          'sql_anounce_array',
0516          'sql_ary',
0517          'forum_id',
0518      );
0519      extract($phpbb_dispatcher->trigger_event('core.viewforum_get_announcement_topic_ids_data', compact($vars)));
0520   
0521      $sql = $db->sql_build_query('SELECT', $sql_ary);
0522      $result = $db->sql_query($sql);
0523   
0524      while ($row = $db->sql_fetchrow($result))
0525      {
0526          if ($row['topic_visibility'] != ITEM_APPROVED && !$auth->acl_get('m_approve', $row['forum_id']))
0527          {
0528              // Do not display announcements that are waiting for approval or soft deleted.
0529              continue;
0530          }
0531   
0532          $rowset[$row['topic_id']] = $row;
0533          $announcement_list[] = $row['topic_id'];
0534   
0535          if ($forum_id != $row['forum_id'])
0536          {
0537              $topics_count++;
0538              $global_announce_forums[] = $row['forum_id'];
0539          }
0540      }
0541      $db->sql_freeresult($result);
0542  }
0543   
0544  $forum_tracking_info = array();
0545   
0546  if ($user->data['is_registered'] && $config['load_db_lastread'])
0547  {
0548      $forum_tracking_info[$forum_id] = $forum_data['mark_time'];
0549   
0550      if (!empty($global_announce_forums))
0551      {
0552          $sql = 'SELECT forum_id, mark_time
0553              FROM ' . FORUMS_TRACK_TABLE . '
0554              WHERE ' . $db->sql_in_set('forum_id', $global_announce_forums) . '
0555                  AND user_id = ' . $user->data['user_id'];
0556          $result = $db->sql_query($sql);
0557   
0558          while ($row = $db->sql_fetchrow($result))
0559          {
0560              $forum_tracking_info[$row['forum_id']] = $row['mark_time'];
0561          }
0562          $db->sql_freeresult($result);
0563      }
0564  }
0565   
0566  // If the user is trying to reach late pages, start searching from the end
0567  $store_reverse = false;
0568  $sql_limit = $config['topics_per_page'];
0569  if ($start > $topics_count / 2)
0570  {
0571      $store_reverse = true;
0572   
0573      // Select the sort order
0574      $direction = (($sort_dir == 'd') ? 'ASC' : 'DESC');
0575   
0576      $sql_limit = $pagination->reverse_limit($start, $sql_limit, $topics_count - sizeof($announcement_list));
0577      $sql_start = $pagination->reverse_start($start, $sql_limit, $topics_count - sizeof($announcement_list));
0578  }
0579  else
0580  {
0581      // Select the sort order
0582      $direction = (($sort_dir == 'd') ? 'DESC' : 'ASC');
0583      $sql_start = $start;
0584  }
0585   
0586  if (is_array($sort_by_sql[$sort_key]))
0587  {
0588      $sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction;
0589  }
0590  else
0591  {
0592      $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction;
0593  }
0594   
0595  if ($forum_data['forum_type'] == FORUM_POST || !sizeof($active_forum_ary))
0596  {
0597      $sql_where = 't.forum_id = ' . $forum_id;
0598  }
0599  else if (empty($active_forum_ary['exclude_forum_id']))
0600  {
0601      $sql_where = $db->sql_in_set('t.forum_id', $active_forum_ary['forum_id']);
0602  }
0603  else
0604  {
0605      $get_forum_ids = array_diff($active_forum_ary['forum_id'], $active_forum_ary['exclude_forum_id']);
0606      $sql_where = (sizeof($get_forum_ids)) ? $db->sql_in_set('t.forum_id', $get_forum_ids) : 't.forum_id = ' . $forum_id;
0607  }
0608   
0609  // Grab just the sorted topic ids
0610  $sql_ary = array(
0611      'SELECT'    => 't.topic_id',
0612      'FROM'        => array(
0613          TOPICS_TABLE => 't',
0614      ),
0615      'WHERE'        => "$sql_where
0616          AND t.topic_type IN (" . POST_NORMAL . ', ' . POST_STICKY . ")
0617          $sql_approved
0618          $sql_limit_time",
0619      'ORDER_BY'    => 't.topic_type ' . ((!$store_reverse) ? 'DESC' : 'ASC') . ', ' . $sql_sort_order,
0620  );
0621   
0622  /**
0623  * Event to modify the SQL query before the topic ids data is retrieved
0624  *
0625  * @event core.viewforum_get_topic_ids_data
0626  * @var    array    forum_data        Data about the forum
0627  * @var    array    sql_ary            SQL query array to get the topic ids data
0628  * @var    string    sql_approved    Topic visibility SQL string
0629  * @var    int        sql_limit        Number of records to select
0630  * @var    string    sql_limit_time    SQL string to limit topic_last_post_time data
0631  * @var    array    sql_sort_order    SQL sorting string
0632  * @var    int        sql_start        Offset point to start selection from
0633  * @var    string    sql_where        SQL WHERE clause string
0634  * @var    bool    store_reverse    Flag indicating if we select from the late pages
0635  *
0636  * @since 3.1.0-RC4
0637  *
0638  * @changed 3.1.3 Added forum_data
0639  */
0640  $vars = array(
0641      'forum_data',
0642      'sql_ary',
0643      'sql_approved',
0644      'sql_limit',
0645      'sql_limit_time',
0646      'sql_sort_order',
0647      'sql_start',
0648      'sql_where',
0649      'store_reverse',
0650  );
0651  extract($phpbb_dispatcher->trigger_event('core.viewforum_get_topic_ids_data', compact($vars)));
0652   
0653  $sql = $db->sql_build_query('SELECT', $sql_ary);
0654  $result = $db->sql_query_limit($sql, $sql_limit, $sql_start);
0655   
0656  while ($row = $db->sql_fetchrow($result))
0657  {
0658      $topic_list[] = (int) $row['topic_id'];
0659  }
0660  $db->sql_freeresult($result);
0661   
0662  // For storing shadow topics
0663  $shadow_topic_list = array();
0664   
0665  if (sizeof($topic_list))
0666  {
0667      // SQL array for obtaining topics/stickies
0668      $sql_array = array(
0669          'SELECT'        => $sql_array['SELECT'],
0670          'FROM'            => $sql_array['FROM'],
0671          'LEFT_JOIN'        => $sql_array['LEFT_JOIN'],
0672   
0673          'WHERE'            => $db->sql_in_set('t.topic_id', $topic_list),
0674      );
0675   
0676      // If store_reverse, then first obtain topics, then stickies, else the other way around...
0677      // Funnily enough you typically save one query if going from the last page to the middle (store_reverse) because
0678      // the number of stickies are not known
0679      $sql = $db->sql_build_query('SELECT', $sql_array);
0680      $result = $db->sql_query($sql);
0681   
0682      while ($row = $db->sql_fetchrow($result))
0683      {
0684          if ($row['topic_status'] == ITEM_MOVED)
0685          {
0686              $shadow_topic_list[$row['topic_moved_id']] = $row['topic_id'];
0687          }
0688   
0689          $rowset[$row['topic_id']] = $row;
0690      }
0691      $db->sql_freeresult($result);
0692  }
0693   
0694  // If we have some shadow topics, update the rowset to reflect their topic information
0695  if (sizeof($shadow_topic_list))
0696  {
0697      // SQL array for obtaining shadow topics
0698      $sql_array = array(
0699          'SELECT'    => 't.*',
0700          'FROM'        => array(
0701              TOPICS_TABLE        => 't'
0702          ),
0703          'WHERE'        => $db->sql_in_set('t.topic_id', array_keys($shadow_topic_list)),
0704      );
0705   
0706      /**
0707      * Event to modify the SQL query before the shadowtopic data is retrieved
0708      *
0709      * @event core.viewforum_get_shadowtopic_data
0710      * @var    array    sql_array        SQL array to get the data of any shadowtopics
0711      * @since 3.1.0-a1
0712      */
0713      $vars = array('sql_array');
0714      extract($phpbb_dispatcher->trigger_event('core.viewforum_get_shadowtopic_data', compact($vars)));
0715   
0716      $sql = $db->sql_build_query('SELECT', $sql_array);
0717      $result = $db->sql_query($sql);
0718   
0719      while ($row = $db->sql_fetchrow($result))
0720      {
0721          $orig_topic_id = $shadow_topic_list[$row['topic_id']];
0722   
0723          // If the shadow topic is already listed within the rowset (happens for active topics for example), then do not include it...
0724          if (isset($rowset[$row['topic_id']]))
0725          {
0726              // We need to remove any trace regarding this topic. :)
0727              unset($rowset[$orig_topic_id]);
0728              unset($topic_list[array_search($orig_topic_id, $topic_list)]);
0729              $topics_count--;
0730   
0731              continue;
0732          }
0733   
0734          // Do not include those topics the user has no permission to access
0735          if (!$auth->acl_get('f_read', $row['forum_id']))
0736          {
0737              // We need to remove any trace regarding this topic. :)
0738              unset($rowset[$orig_topic_id]);
0739              unset($topic_list[array_search($orig_topic_id, $topic_list)]);
0740              $topics_count--;
0741   
0742              continue;
0743          }
0744   
0745          // We want to retain some values
0746          $row = array_merge($row, array(
0747              'topic_moved_id'    => $rowset[$orig_topic_id]['topic_moved_id'],
0748              'topic_status'        => $rowset[$orig_topic_id]['topic_status'],
0749              'topic_type'        => $rowset[$orig_topic_id]['topic_type'],
0750              'topic_title'        => $rowset[$orig_topic_id]['topic_title'],
0751          ));
0752   
0753          // Shadow topics are never reported
0754          $row['topic_reported'] = 0;
0755   
0756          $rowset[$orig_topic_id] = $row;
0757      }
0758      $db->sql_freeresult($result);
0759  }
0760  unset($shadow_topic_list);
0761   
0762  // Ok, adjust topics count for active topics list
0763  if ($s_display_active)
0764  {
0765      $topics_count = 1;
0766  }
0767   
0768  // We need to remove the global announcements from the forums total topic count,
0769  // otherwise the number is different from the one on the forum list
0770  $total_topic_count = $topics_count - sizeof($announcement_list);
0771   
0772  $base_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : ''));
0773  $pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_topic_count, $config['topics_per_page'], $start);
0774   
0775  $template->assign_vars(array(
0776      'TOTAL_TOPICS'    => ($s_display_active) ? false : $user->lang('VIEW_FORUM_TOPICS', (int) $total_topic_count),
0777  ));
0778   
0779  $topic_list = ($store_reverse) ? array_merge($announcement_list, array_reverse($topic_list)) : array_merge($announcement_list, $topic_list);
0780  $topic_tracking_info = $tracking_topics = array();
0781   
0782  /**
0783  * Modify topics data before we display the viewforum page
0784  *
0785  * @event core.viewforum_modify_topics_data
0786  * @var    array    topic_list            Array with current viewforum page topic ids
0787  * @var    array    rowset                Array with topics data (in topic_id => topic_data format)
0788  * @var    int        total_topic_count    Forum's total topic count
0789  * @var    int        forum_id            Forum identifier
0790  * @since 3.1.0-b3
0791  * @changed 3.1.11-RC1 Added forum_id
0792  */
0793  $vars = array('topic_list', 'rowset', 'total_topic_count', 'forum_id');
0794  extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_topics_data', compact($vars)));
0795   
0796  // Okay, lets dump out the page ...
0797  if (sizeof($topic_list))
0798  {
0799      $mark_forum_read = true;
0800      $mark_time_forum = 0;
0801   
0802      // Generate topic forum list...
0803      $topic_forum_list = array();
0804      foreach ($rowset as $t_id => $row)
0805      {
0806          if (isset($forum_tracking_info[$row['forum_id']]))
0807          {
0808              $row['forum_mark_time'] = $forum_tracking_info[$row['forum_id']];
0809          }
0810   
0811          $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;
0812          $topic_forum_list[$row['forum_id']]['topics'][] = (int) $t_id;
0813      }
0814   
0815      if ($config['load_db_lastread'] && $user->data['is_registered'])
0816      {
0817          foreach ($topic_forum_list as $f_id => $topic_row)
0818          {
0819              $topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time']));
0820          }
0821      }
0822      else if ($config['load_anon_lastread'] || $user->data['is_registered'])
0823      {
0824          foreach ($topic_forum_list as $f_id => $topic_row)
0825          {
0826              $topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics']);
0827          }
0828      }
0829   
0830      unset($topic_forum_list);
0831   
0832      if (!$s_display_active)
0833      {
0834          if ($config['load_db_lastread'] && $user->data['is_registered'])
0835          {
0836              $mark_time_forum = (!empty($forum_data['mark_time'])) ? $forum_data['mark_time'] : $user->data['user_lastmark'];
0837          }
0838          else if ($config['load_anon_lastread'] || $user->data['is_registered'])
0839          {
0840              if (!$user->data['is_registered'])
0841              {
0842                  $user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0;
0843              }
0844              $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'];
0845          }
0846      }
0847   
0848      $s_type_switch = 0;
0849      foreach ($topic_list as $topic_id)
0850      {
0851          $row = &$rowset[$topic_id];
0852   
0853          $topic_forum_id = ($row['forum_id']) ? (int) $row['forum_id'] : $forum_id;
0854   
0855          // This will allow the style designer to output a different header
0856          // or even separate the list of announcements from sticky and normal topics
0857          $s_type_switch_test = ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) ? 1 : 0;
0858   
0859          // Replies
0860          $replies = $phpbb_content_visibility->get_count('topic_posts', $row, $topic_forum_id) - 1;
0861   
0862          if ($row['topic_status'] == ITEM_MOVED)
0863          {
0864              $topic_id = $row['topic_moved_id'];
0865              $unread_topic = false;
0866          }
0867          else
0868          {
0869              $unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
0870          }
0871   
0872          // Get folder img, topic status/type related information
0873          $folder_img = $folder_alt = $topic_type = '';
0874          topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type);
0875   
0876          // Generate all the URIs ...
0877          $view_topic_url_params = 'f=' . $row['forum_id'] . '&amp;t=' . $topic_id;
0878          $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params);
0879   
0880          $topic_unapproved = (($row['topic_visibility'] == ITEM_UNAPPROVED || $row['topic_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $row['forum_id']));
0881          $posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $auth->acl_get('m_approve', $row['forum_id']));
0882          $topic_deleted = $row['topic_visibility'] == ITEM_DELETED;
0883   
0884          $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) : '';
0885          $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;
0886   
0887          // Send vars to template
0888          $topic_row = array(
0889              'FORUM_ID'                    => $row['forum_id'],
0890              'TOPIC_ID'                    => $topic_id,
0891              'TOPIC_AUTHOR'                => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
0892              'TOPIC_AUTHOR_COLOUR'        => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
0893              'TOPIC_AUTHOR_FULL'            => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
0894              'FIRST_POST_TIME'            => $user->format_date($row['topic_time']),
0895              'LAST_POST_SUBJECT'            => censor_text($row['topic_last_post_subject']),
0896              'LAST_POST_TIME'            => $user->format_date($row['topic_last_post_time']),
0897              'LAST_VIEW_TIME'            => $user->format_date($row['topic_last_view_time']),
0898              'LAST_POST_AUTHOR'            => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
0899              'LAST_POST_AUTHOR_COLOUR'    => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
0900              'LAST_POST_AUTHOR_FULL'        => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
0901   
0902              'REPLIES'            => $replies,
0903              'VIEWS'                => $row['topic_views'],
0904              'TOPIC_TITLE'        => censor_text($row['topic_title']),
0905              'TOPIC_TYPE'        => $topic_type,
0906              'FORUM_NAME'        => (isset($row['forum_name'])) ? $row['forum_name'] : $forum_data['forum_name'],
0907   
0908              'TOPIC_IMG_STYLE'        => $folder_img,
0909              'TOPIC_FOLDER_IMG'        => $user->img($folder_img, $folder_alt),
0910              'TOPIC_FOLDER_IMG_ALT'    => $user->lang[$folder_alt],
0911   
0912              'TOPIC_ICON_IMG'        => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '',
0913              'TOPIC_ICON_IMG_WIDTH'    => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '',
0914              'TOPIC_ICON_IMG_HEIGHT'    => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '',
0915              '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']) : '',
0916              'UNAPPROVED_IMG'        => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '',
0917   
0918              'S_TOPIC_TYPE'            => $row['topic_type'],
0919              'S_USER_POSTED'            => (isset($row['topic_posted']) && $row['topic_posted']) ? true : false,
0920              'S_UNREAD_TOPIC'        => $unread_topic,
0921              'S_TOPIC_REPORTED'        => (!empty($row['topic_reported']) && $auth->acl_get('m_report', $row['forum_id'])) ? true : false,
0922              'S_TOPIC_UNAPPROVED'    => $topic_unapproved,
0923              'S_POSTS_UNAPPROVED'    => $posts_unapproved,
0924              'S_TOPIC_DELETED'        => $topic_deleted,
0925              'S_HAS_POLL'            => ($row['poll_start']) ? true : false,
0926              'S_POST_ANNOUNCE'        => ($row['topic_type'] == POST_ANNOUNCE) ? true : false,
0927              'S_POST_GLOBAL'            => ($row['topic_type'] == POST_GLOBAL) ? true : false,
0928              'S_POST_STICKY'            => ($row['topic_type'] == POST_STICKY) ? true : false,
0929              'S_TOPIC_LOCKED'        => ($row['topic_status'] == ITEM_LOCKED) ? true : false,
0930              'S_TOPIC_MOVED'            => ($row['topic_status'] == ITEM_MOVED) ? true : false,
0931   
0932              'U_NEWEST_POST'            => append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&amp;view=unread') . '#unread',
0933              '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'],
0934              'U_LAST_POST_AUTHOR'    => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
0935              'U_TOPIC_AUTHOR'        => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
0936              'U_VIEW_TOPIC'            => $view_topic_url,
0937              'U_VIEW_FORUM'            => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']),
0938              '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),
0939              'U_MCP_QUEUE'            => $u_mcp_queue,
0940   
0941              'S_TOPIC_TYPE_SWITCH'    => ($s_type_switch == $s_type_switch_test) ? -1 : $s_type_switch_test,
0942          );
0943   
0944          /**
0945          * Modify the topic data before it is assigned to the template
0946          *
0947          * @event core.viewforum_modify_topicrow
0948          * @var    array    row                    Array with topic data
0949          * @var    array    topic_row            Template array with topic data
0950          * @var    bool    s_type_switch        Flag indicating if the topic type is [global] announcement
0951          * @var    bool    s_type_switch_test    Flag indicating if the test topic type is [global] announcement
0952          * @since 3.1.0-a1
0953          *
0954          * @changed 3.1.10-RC1 Added s_type_switch, s_type_switch_test
0955          */
0956          $vars = array('row', 'topic_row', 's_type_switch', 's_type_switch_test');
0957          extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_topicrow', compact($vars)));
0958   
0959          $template->assign_block_vars('topicrow', $topic_row);
0960   
0961          $pagination->generate_template_pagination($view_topic_url, 'topicrow.pagination', 'start', $replies + 1, $config['posts_per_page'], 1, true, true);
0962   
0963          $s_type_switch = ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) ? 1 : 0;
0964   
0965          /**
0966          * Event after the topic data has been assigned to the template
0967          *
0968          * @event core.viewforum_topic_row_after
0969          * @var    array    row                Array with the topic data
0970          * @var    array    rowset            Array with topics data (in topic_id => topic_data format)
0971          * @var    bool    s_type_switch    Flag indicating if the topic type is [global] announcement
0972          * @var    int        topic_id        The topic ID
0973          * @var    array    topic_list        Array with current viewforum page topic ids
0974          * @var    array    topic_row        Template array with topic data
0975          * @since 3.1.3-RC1
0976          */
0977          $vars = array(
0978              'row',
0979              'rowset',
0980              's_type_switch',
0981              'topic_id',
0982              'topic_list',
0983              'topic_row',
0984          );
0985          extract($phpbb_dispatcher->trigger_event('core.viewforum_topic_row_after', compact($vars)));
0986   
0987          if ($unread_topic)
0988          {
0989              $mark_forum_read = false;
0990          }
0991   
0992          unset($rowset[$topic_id]);
0993      }
0994  }
0995   
0996  // This is rather a fudge but it's the best I can think of without requiring information
0997  // on all topics (as we do in 2.0.x). It looks for unread or new topics, if it doesn't find
0998  // any it updates the forum last read cookie. This requires that the user visit the forum
0999  // after reading a topic
1000  if ($forum_data['forum_type'] == FORUM_POST && sizeof($topic_list) && $mark_forum_read)
1001  {
1002      update_forum_tracking_info($forum_id, $forum_data['forum_last_post_time'], false, $mark_time_forum);
1003  }
1004   
1005  page_footer();
1006