[ Index ]

PHP Cross Reference of phpBB-3.1.10-deutsch

title

Body

[close]

/ -> viewforum.php (source)

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


Generated: Sun Feb 19 19:52:41 2017 Cross-referenced by PHPXref 0.7.1