aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/viewforum.php
diff options
context:
space:
mode:
authorMaat <maat-pub@mageia.biz>2020-05-08 21:52:11 +0200
committerMaat <maat-pub@mageia.biz>2020-05-08 21:52:11 +0200
commit8ea437e30605e0f66b5220bf904a61d7c1d11ddd (patch)
treee0db2bb4a012d5b06a633160b19f62f4868ecd28 /phpBB/viewforum.php
parent36bc1870f21fac04736a1049c1d5b8e127d729f4 (diff)
parent2fdd46b36431ae0f58bb2e78e42553168db9a0ff (diff)
downloadforums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar
forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar.gz
forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar.bz2
forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar.xz
forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.zip
Merge remote-tracking branch 'upstream/prep-release-3.2.9'
Diffstat (limited to 'phpBB/viewforum.php')
-rw-r--r--phpBB/viewforum.php117
1 files changed, 87 insertions, 30 deletions
diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php
index 5c51975150..4691512cbd 100644
--- a/phpBB/viewforum.php
+++ b/phpBB/viewforum.php
@@ -25,18 +25,19 @@ $user->session_begin();
$auth->acl($user->data);
// Start initial var setup
-$forum_id = request_var('f', 0);
-$mark_read = request_var('mark', '');
-$start = request_var('start', 0);
+$forum_id = $request->variable('f', 0);
+$mark_read = $request->variable('mark', '');
+$start = $request->variable('start', 0);
$default_sort_days = (!empty($user->data['user_topic_show_days'])) ? $user->data['user_topic_show_days'] : 0;
$default_sort_key = (!empty($user->data['user_topic_sortby_type'])) ? $user->data['user_topic_sortby_type'] : 't';
$default_sort_dir = (!empty($user->data['user_topic_sortby_dir'])) ? $user->data['user_topic_sortby_dir'] : 'd';
-$sort_days = request_var('st', $default_sort_days);
-$sort_key = request_var('sk', $default_sort_key);
-$sort_dir = request_var('sd', $default_sort_dir);
+$sort_days = $request->variable('st', $default_sort_days);
+$sort_key = $request->variable('sk', $default_sort_key);
+$sort_dir = $request->variable('sd', $default_sort_dir);
+/* @var $pagination \phpbb\pagination */
$pagination = $phpbb_container->get('pagination');
// Check if the user has actually sent a forum ID with his/her request
@@ -86,10 +87,11 @@ if (isset($_GET['e']) && !$user->data['is_registered'])
}
// Permissions check
-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)))
+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)))
{
if ($user->data['user_id'] != ANONYMOUS)
{
+ send_status_line(403, 'Forbidden');
trigger_error('SORRY_AUTH_READ');
}
@@ -159,7 +161,22 @@ $phpbb_content_visibility = $phpbb_container->get('content.visibility');
$topics_count = $phpbb_content_visibility->get_count('forum_topics', $forum_data, $forum_id);
$start = $pagination->validate_start($start, $config['topics_per_page'], $topics_count);
-page_header($forum_data['forum_name'] . ($start ? ' - ' . $user->lang('PAGE_TITLE_NUMBER', $pagination->get_on_page($config['topics_per_page'], $start)) : ''), true, $forum_id);
+$page_title = $forum_data['forum_name'] . ($start ? ' - ' . $user->lang('PAGE_TITLE_NUMBER', $pagination->get_on_page($config['topics_per_page'], $start)) : '');
+
+/**
+* You can use this event to modify the page title of the viewforum page
+*
+* @event core.viewforum_modify_page_title
+* @var string page_title Title of the viewforum page
+* @var array forum_data Array with forum data
+* @var int forum_id The forum ID
+* @var int start Start offset used to calculate the page
+* @since 3.2.2-RC1
+*/
+$vars = array('page_title', 'forum_data', 'forum_id', 'start');
+extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_page_title', compact($vars)));
+
+page_header($page_title, true, $forum_id);
$template->set_filenames(array(
'body' => 'viewforum_body.html')
@@ -179,7 +196,7 @@ if (!($forum_data['forum_type'] == FORUM_POST || (($forum_data['forum_flags'] &
// Ok, if someone has only list-access, we only display the forum list.
// We also make this circumstance available to the template in case we want to display a notice. ;)
-if (!$auth->acl_get('f_read', $forum_id))
+if (!$auth->acl_gets('f_read', 'f_list_topics', $forum_id))
{
$template->assign_vars(array(
'S_NO_READ_ACCESS' => true,
@@ -191,10 +208,10 @@ if (!$auth->acl_get('f_read', $forum_id))
// Handle marking posts
if ($mark_read == 'topics')
{
- $token = request_var('hash', '');
+ $token = $request->variable('hash', '');
if (check_link_hash($token, 'global'))
{
- markread('topics', array($forum_id), false, request_var('mark_time', 0));
+ markread('topics', array($forum_id), false, $request->variable('mark_time', 0));
}
$redirect_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id);
meta_refresh(3, $redirect_url);
@@ -205,7 +222,7 @@ if ($mark_read == 'topics')
$data = array(
'NO_UNREAD_POSTS' => $user->lang['NO_UNREAD_POSTS'],
'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'],
- '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()) : '',
+ 'U_MARK_TOPICS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . "&f=$forum_id&mark=topics&mark_time=" . time(), false) : '',
'MESSAGE_TITLE' => $user->lang['INFORMATION'],
'MESSAGE_TEXT' => $user->lang['TOPICS_MARKED']
);
@@ -219,6 +236,7 @@ if ($mark_read == 'topics')
// Do the forum Prune thang - cron type job ...
if (!$config['use_system_cron'])
{
+ /* @var $cron \phpbb\cron\manager */
$cron = $phpbb_container->get('cron.manager');
$task = $cron->find_task('cron.task.core.prune_forum');
@@ -267,6 +285,20 @@ $limit_days = array(0 => $user->lang['ALL_TOPICS'], 1 => $user->lang['1_DAY'], 7
$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']);
$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');
+/**
+ * Modify the topic ordering if needed
+ *
+ * @event core.viewforum_modify_topic_ordering
+ * @var array sort_by_text Topic ordering options
+ * @var array sort_by_sql Topic orderings options SQL equivalent
+ * @since 3.2.5-RC1
+ */
+$vars = array(
+ 'sort_by_text',
+ 'sort_by_sql',
+);
+extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_topic_ordering', compact($vars)));
+
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
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);
@@ -382,7 +414,7 @@ $template->assign_vars(array(
'S_SELECT_SORT_DIR' => $s_sort_dir,
'S_SELECT_SORT_KEY' => $s_sort_key,
'S_SELECT_SORT_DAYS' => $s_limit_days,
- 'S_TOPIC_ICONS' => ($s_display_active && sizeof($active_forum_ary)) ? max($active_forum_ary['enable_icons']) : (($forum_data['enable_icons']) ? true : false),
+ 'S_TOPIC_ICONS' => ($s_display_active && count($active_forum_ary)) ? max($active_forum_ary['enable_icons']) : (($forum_data['enable_icons']) ? true : false),
'U_WATCH_FORUM_LINK' => $s_watching_forum['link'],
'U_WATCH_FORUM_TOGGLE' => $s_watching_forum['link_toggle'],
'S_WATCH_FORUM_TITLE' => $s_watching_forum['title'],
@@ -392,7 +424,7 @@ $template->assign_vars(array(
'S_DISPLAY_SEARCHBOX' => ($auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search']) ? true : false,
'S_SEARCHBOX_ACTION' => append_sid("{$phpbb_root_path}search.$phpEx"),
'S_SEARCH_LOCAL_HIDDEN_FIELDS' => build_hidden_fields($s_search_hidden_fields),
- 'S_SINGLE_MODERATOR' => (!empty($moderators[$forum_id]) && sizeof($moderators[$forum_id]) > 1) ? false : true,
+ 'S_SINGLE_MODERATOR' => (!empty($moderators[$forum_id]) && count($moderators[$forum_id]) > 1) ? false : true,
'S_IS_LOCKED' => ($forum_data['forum_status'] == ITEM_LOCKED) ? true : false,
'S_VIEWFORUM' => true,
@@ -462,7 +494,7 @@ if ($user->data['is_registered'])
$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']);
$sql_array['SELECT'] .= ', tt.mark_time';
- if ($s_display_active && sizeof($active_forum_ary))
+ if ($s_display_active && count($active_forum_ary))
{
$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']);
$sql_array['SELECT'] .= ', ft.mark_time AS forum_mark_time';
@@ -488,7 +520,7 @@ if ($forum_data['forum_type'] == FORUM_POST)
'WHERE' => '(t.forum_id = ' . $forum_id . '
AND t.topic_type = ' . POST_ANNOUNCE . ') OR
- (' . $db->sql_in_set('t.forum_id', $g_forum_ary) . '
+ (' . $db->sql_in_set('t.forum_id', $g_forum_ary, false, true) . '
AND t.topic_type = ' . POST_GLOBAL . ')',
'ORDER_BY' => 't.topic_time DESC',
@@ -520,7 +552,7 @@ if ($forum_data['forum_type'] == FORUM_POST)
while ($row = $db->sql_fetchrow($result))
{
- if ($row['topic_visibility'] != ITEM_APPROVED && !$auth->acl_get('m_approve', $row['forum_id']))
+ if (!$phpbb_content_visibility->is_visible('topic', $row['forum_id'], $row))
{
// Do not display announcements that are waiting for approval or soft deleted.
continue;
@@ -570,8 +602,8 @@ if ($start > $topics_count / 2)
// Select the sort order
$direction = (($sort_dir == 'd') ? 'ASC' : 'DESC');
- $sql_limit = $pagination->reverse_limit($start, $sql_limit, $topics_count - sizeof($announcement_list));
- $sql_start = $pagination->reverse_start($start, $sql_limit, $topics_count - sizeof($announcement_list));
+ $sql_limit = $pagination->reverse_limit($start, $sql_limit, $topics_count - count($announcement_list));
+ $sql_start = $pagination->reverse_start($start, $sql_limit, $topics_count - count($announcement_list));
}
else
{
@@ -580,6 +612,18 @@ else
$sql_start = $start;
}
+/**
+ * Modify the topics sort ordering if needed
+ *
+ * @event core.viewforum_modify_sort_direction
+ * @var string direction Topics sort order
+ * @since 3.2.5-RC1
+ */
+$vars = array(
+ 'direction',
+);
+extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_sort_direction', compact($vars)));
+
if (is_array($sort_by_sql[$sort_key]))
{
$sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction;
@@ -589,7 +633,7 @@ else
$sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction;
}
-if ($forum_data['forum_type'] == FORUM_POST || !sizeof($active_forum_ary))
+if ($forum_data['forum_type'] == FORUM_POST || !count($active_forum_ary))
{
$sql_where = 't.forum_id = ' . $forum_id;
}
@@ -600,7 +644,7 @@ else if (empty($active_forum_ary['exclude_forum_id']))
else
{
$get_forum_ids = array_diff($active_forum_ary['forum_id'], $active_forum_ary['exclude_forum_id']);
- $sql_where = (sizeof($get_forum_ids)) ? $db->sql_in_set('t.forum_id', $get_forum_ids) : 't.forum_id = ' . $forum_id;
+ $sql_where = (count($get_forum_ids)) ? $db->sql_in_set('t.forum_id', $get_forum_ids) : 't.forum_id = ' . $forum_id;
}
// Grab just the sorted topic ids
@@ -659,7 +703,7 @@ $db->sql_freeresult($result);
// For storing shadow topics
$shadow_topic_list = array();
-if (sizeof($topic_list))
+if (count($topic_list))
{
// SQL array for obtaining topics/stickies
$sql_array = array(
@@ -689,7 +733,7 @@ if (sizeof($topic_list))
}
// If we have some shadow topics, update the rowset to reflect their topic information
-if (sizeof($shadow_topic_list))
+if (count($shadow_topic_list))
{
// SQL array for obtaining shadow topics
$sql_array = array(
@@ -729,7 +773,7 @@ if (sizeof($shadow_topic_list))
}
// Do not include those topics the user has no permission to access
- if (!$auth->acl_get('f_read', $row['forum_id']))
+ if (!$auth->acl_gets('f_read', 'f_list_topics', $row['forum_id']))
{
// We need to remove any trace regarding this topic. :)
unset($rowset[$orig_topic_id]);
@@ -764,7 +808,7 @@ if ($s_display_active)
// We need to remove the global announcements from the forums total topic count,
// otherwise the number is different from the one on the forum list
-$total_topic_count = $topics_count - sizeof($announcement_list);
+$total_topic_count = $topics_count - count($announcement_list);
$base_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : ''));
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_topic_count, $config['topics_per_page'], $start);
@@ -791,7 +835,7 @@ $vars = array('topic_list', 'rowset', 'total_topic_count', 'forum_id');
extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_topics_data', compact($vars)));
// Okay, lets dump out the page ...
-if (sizeof($topic_list))
+if (count($topic_list))
{
$mark_forum_read = true;
$mark_time_forum = 0;
@@ -872,7 +916,7 @@ if (sizeof($topic_list))
// Generate all the URIs ...
$view_topic_url_params = 'f=' . $row['forum_id'] . '&amp;t=' . $topic_id;
- $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params);
+ $view_topic_url = $auth->acl_get('f_read', $forum_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params) : false;
$topic_unapproved = (($row['topic_visibility'] == ITEM_UNAPPROVED || $row['topic_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $row['forum_id']));
$posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $auth->acl_get('m_approve', $row['forum_id']));
@@ -889,9 +933,12 @@ if (sizeof($topic_list))
'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
'TOPIC_AUTHOR_FULL' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
'FIRST_POST_TIME' => $user->format_date($row['topic_time']),
+ 'FIRST_POST_TIME_RFC3339' => gmdate(DATE_RFC3339, $row['topic_time']),
'LAST_POST_SUBJECT' => censor_text($row['topic_last_post_subject']),
'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']),
+ 'LAST_POST_TIME_RFC3339' => gmdate(DATE_RFC3339, $row['topic_last_post_time']),
'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']),
+ 'LAST_VIEW_TIME_RFC3339' => gmdate(DATE_RFC3339, $row['topic_last_view_time']),
'LAST_POST_AUTHOR' => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
@@ -926,8 +973,8 @@ if (sizeof($topic_list))
'S_TOPIC_LOCKED' => ($row['topic_status'] == ITEM_LOCKED) ? true : false,
'S_TOPIC_MOVED' => ($row['topic_status'] == ITEM_MOVED) ? true : false,
- 'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&amp;view=unread') . '#unread',
- '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'],
+ '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,
+ '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,
'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
'U_VIEW_TOPIC' => $view_topic_url,
@@ -990,11 +1037,21 @@ if (sizeof($topic_list))
}
}
+/**
+* This event is to perform additional actions on viewforum page
+*
+* @event core.viewforum_generate_page_after
+* @var array forum_data Array with the forum data
+* @since 3.2.2-RC1
+*/
+$vars = array('forum_data');
+extract($phpbb_dispatcher->trigger_event('core.viewforum_generate_page_after', compact($vars)));
+
// This is rather a fudge but it's the best I can think of without requiring information
// on all topics (as we do in 2.0.x). It looks for unread or new topics, if it doesn't find
// any it updates the forum last read cookie. This requires that the user visit the forum
// after reading a topic
-if ($forum_data['forum_type'] == FORUM_POST && sizeof($topic_list) && $mark_forum_read)
+if ($forum_data['forum_type'] == FORUM_POST && count($topic_list) && $mark_forum_read)
{
update_forum_tracking_info($forum_id, $forum_data['forum_last_post_time'], false, $mark_time_forum);
}