[ Index ]

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


Generated: Sun Feb 19 19:47:08 2017 Cross-referenced by PHPXref 0.7.1