[ Index ]

PHP Cross Reference of phpBB-3.2.2-deutsch

title

Body

[close]

/ -> viewforum.php (source)

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


Generated: Thu Jan 11 23:14:31 2018 Cross-referenced by PHPXref 0.7.1