aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/viewtopic.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/viewtopic.php')
-rw-r--r--phpBB/viewtopic.php643
1 files changed, 482 insertions, 161 deletions
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index e02052a14d..87de7c79a4 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -1,9 +1,13 @@
<?php
/**
*
-* @package phpBB3
-* @copyright (c) 2005 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -16,40 +20,42 @@ $phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
+include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
// Initial var setup
-$forum_id = request_var('f', 0);
-$topic_id = request_var('t', 0);
-$post_id = request_var('p', 0);
-$voted_id = request_var('vote_id', array('' => 0));
+$forum_id = $request->variable('f', 0);
+$topic_id = $request->variable('t', 0);
+$post_id = $request->variable('p', 0);
+$voted_id = $request->variable('vote_id', array('' => 0));
$voted_id = (sizeof($voted_id) > 1) ? array_unique($voted_id) : $voted_id;
-$start = request_var('start', 0);
-$view = request_var('view', '');
+$start = $request->variable('start', 0);
+$view = $request->variable('view', '');
$default_sort_days = (!empty($user->data['user_post_show_days'])) ? $user->data['user_post_show_days'] : 0;
$default_sort_key = (!empty($user->data['user_post_sortby_type'])) ? $user->data['user_post_sortby_type'] : 't';
$default_sort_dir = (!empty($user->data['user_post_sortby_dir'])) ? $user->data['user_post_sortby_dir'] : 'a';
-$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);
-$update = request_var('update', false);
+$update = $request->variable('update', false);
+/* @var $pagination \phpbb\pagination */
$pagination = $phpbb_container->get('pagination');
$s_can_vote = false;
/**
* @todo normalize?
*/
-$hilit_words = request_var('hilit', '', true);
+$hilit_words = $request->variable('hilit', '', true);
// Do we have a topic or post id?
if (!$topic_id && !$post_id)
@@ -57,6 +63,7 @@ if (!$topic_id && !$post_id)
trigger_error('NO_TOPIC');
}
+/* @var $phpbb_content_visibility \phpbb\content_visibility */
$phpbb_content_visibility = $phpbb_container->get('content.visibility');
// Find topic id if user requested a newer or older topic
@@ -89,7 +96,7 @@ if ($view && !$post_id)
AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id) . "
AND post_time > $topic_last_read
AND forum_id = $forum_id
- ORDER BY post_time ASC";
+ ORDER BY post_time ASC, post_id ASC";
$result = $db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
@@ -141,7 +148,7 @@ if ($view && !$post_id)
AND topic_moved_id = 0
AND topic_last_post_time $sql_condition {$row['topic_last_post_time']}
AND " . $phpbb_content_visibility->get_visibility_sql('topic', $row['forum_id']) . "
- ORDER BY topic_last_post_time $sql_ordering";
+ ORDER BY topic_last_post_time $sql_ordering, topic_last_post_id $sql_ordering";
$result = $db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
@@ -266,7 +273,7 @@ if ($topic_data['topic_visibility'] != ITEM_APPROVED && !$auth->acl_get('m_appro
if ($post_id)
{
// are we where we are supposed to be?
- if ($topic_data['post_visibility'] == ITEM_UNAPPROVED && !$auth->acl_get('m_approve', $topic_data['forum_id']))
+ if (($topic_data['post_visibility'] == ITEM_UNAPPROVED || $topic_data['post_visibility'] == ITEM_REAPPROVE) && !$auth->acl_get('m_approve', $topic_data['forum_id']))
{
// If post_id was submitted, we try at least to display the topic as a last resort...
if ($topic_id)
@@ -331,8 +338,41 @@ if (($topic_data['topic_type'] == POST_STICKY || $topic_data['topic_type'] == PO
// Setup look and feel
$user->setup('viewtopic', $topic_data['forum_style']);
+$overrides_f_read_check = false;
+$overrides_forum_password_check = false;
+$topic_tracking_info = isset($topic_tracking_info) ? $topic_tracking_info : null;
+
+/**
+* Event to apply extra permissions and to override original phpBB's f_read permission and forum password check
+* on viewtopic access
+*
+* @event core.viewtopic_before_f_read_check
+* @var int forum_id The forum id from where the topic belongs
+* @var int topic_id The id of the topic the user tries to access
+* @var int post_id The id of the post the user tries to start viewing at.
+* It may be 0 for none given.
+* @var array topic_data All the information from the topic and forum tables for this topic
+* It includes posts information if post_id is not 0
+* @var bool overrides_f_read_check Set true to remove f_read check afterwards
+* @var bool overrides_forum_password_check Set true to remove forum_password check afterwards
+* @var array topic_tracking_info Information upon calling get_topic_tracking()
+* Set it to NULL to allow auto-filling later.
+* Set it to an array to override original data.
+* @since 3.1.3-RC1
+*/
+$vars = array(
+ 'forum_id',
+ 'topic_id',
+ 'post_id',
+ 'topic_data',
+ 'overrides_f_read_check',
+ 'overrides_forum_password_check',
+ 'topic_tracking_info',
+);
+extract($phpbb_dispatcher->trigger_event('core.viewtopic_before_f_read_check', compact($vars)));
+
// Start auth check
-if (!$auth->acl_get('f_read', $forum_id))
+if (!$overrides_f_read_check && !$auth->acl_get('f_read', $forum_id))
{
if ($user->data['user_id'] != ANONYMOUS)
{
@@ -344,7 +384,7 @@ if (!$auth->acl_get('f_read', $forum_id))
// Forum is passworded ... check whether access has been granted to this
// user this session, if not show login box
-if ($topic_data['forum_password'])
+if (!$overrides_forum_password_check && $topic_data['forum_password'])
{
login_forum_box($topic_data);
}
@@ -383,7 +423,7 @@ if (!isset($topic_tracking_info))
$limit_days = array(0 => $user->lang['ALL_POSTS'], 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']);
$sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']);
-$sort_by_sql = array('a' => array('u.username_clean', 'p.post_id'), 't' => 'p.post_time', 's' => array('p.post_subject', 'p.post_id'));
+$sort_by_sql = array('a' => array('u.username_clean', 'p.post_id'), 't' => array('p.post_time', 'p.post_id'), 's' => array('p.post_subject', 'p.post_id'));
$join_user_sql = array('a' => true, 't' => false, 's' => false);
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
@@ -422,17 +462,11 @@ else
$highlight_match = $highlight = '';
if ($hilit_words)
{
- foreach (explode(' ', trim($hilit_words)) as $word)
- {
- if (trim($word))
- {
- $word = str_replace('\*', '\w+?', preg_quote($word, '#'));
- $word = preg_replace('#(^|\s)\\\\w\*\?(\s|$)#', '$1\w+?$2', $word);
- $highlight_match .= (($highlight_match != '') ? '|' : '') . $word;
- }
- }
-
- $highlight = urlencode($hilit_words);
+ $highlight_match = phpbb_clean_search_string($hilit_words);
+ $highlight = urlencode($highlight_match);
+ $highlight_match = str_replace('\*', '\w+?', preg_quote($highlight_match, '#'));
+ $highlight_match = preg_replace('#(?<=^|\s)\\\\w\*\?(?=\s|$)#', '\w+?', $highlight_match);
+ $highlight_match = str_replace(' ', '|', $highlight_match);
}
// Make sure $start is set to the last page if it exceeds the amount
@@ -450,7 +484,7 @@ $s_watching_topic = array(
'is_watching' => false,
);
-if (($config['email_enable'] || $config['jab_enable']) && $config['allow_topic_notify'])
+if ($config['allow_topic_notify'])
{
$notify_status = (isset($topic_data['notify_status'])) ? $topic_data['notify_status'] : null;
watch_topic_forum('topic', $s_watching_topic, $user->data['user_id'], $forum_id, $topic_id, $notify_status, $start, $topic_data['topic_title']);
@@ -464,9 +498,9 @@ if (($config['email_enable'] || $config['jab_enable']) && $config['allow_topic_n
}
// Bookmarks
-if ($config['allow_bookmarks'] && $user->data['is_registered'] && request_var('bookmark', 0))
+if ($config['allow_bookmarks'] && $user->data['is_registered'] && $request->variable('bookmark', 0))
{
- if (check_link_hash(request_var('hash', ''), "topic_$topic_id"))
+ if (check_link_hash($request->variable('hash', ''), "topic_$topic_id"))
{
if (!$topic_data['bookmarked'])
{
@@ -524,11 +558,24 @@ gen_forum_auth_level('topic', $forum_id, $topic_data['forum_status']);
// Quick mod tools
$allow_change_type = ($auth->acl_get('m_', $forum_id) || ($user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'])) ? true : false;
+$s_quickmod_action = append_sid(
+ "{$phpbb_root_path}mcp.$phpEx",
+ array(
+ 'f' => $forum_id,
+ 't' => $topic_id,
+ 'start' => $start,
+ 'quickmod' => 1,
+ 'redirect' => urlencode(str_replace('&amp;', '&', $viewtopic_url)),
+ ),
+ true,
+ $user->session_id
+);
+
$quickmod_array = array(
// 'key' => array('LANG_KEY', $userHasPermissions),
- 'lock' => array('LOCK_TOPIC', ($topic_data['topic_status'] == ITEM_UNLOCKED) && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'] && $topic_data['topic_status'] == ITEM_UNLOCKED))),
- 'unlock' => array('UNLOCK_TOPIC', ($topic_data['topic_status'] != ITEM_UNLOCKED) && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'] && $topic_data['topic_status'] == ITEM_UNLOCKED))),
+ 'lock' => array('LOCK_TOPIC', ($topic_data['topic_status'] == ITEM_UNLOCKED) && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster']))),
+ 'unlock' => array('UNLOCK_TOPIC', ($topic_data['topic_status'] != ITEM_UNLOCKED) && ($auth->acl_get('m_lock', $forum_id))),
'delete_topic' => array('DELETE_TOPIC', ($auth->acl_get('m_delete', $forum_id) || (($topic_data['topic_visibility'] != ITEM_DELETED) && $auth->acl_get('m_softdelete', $forum_id)))),
'restore_topic' => array('RESTORE_TOPIC', (($topic_data['topic_visibility'] == ITEM_DELETED) && $auth->acl_get('m_approve', $forum_id))),
'move' => array('MOVE_TOPIC', $auth->acl_get('m_move', $forum_id) && $topic_data['topic_status'] != ITEM_MOVED),
@@ -536,18 +583,18 @@ $quickmod_array = array(
'merge' => array('MERGE_POSTS', $auth->acl_get('m_merge', $forum_id)),
'merge_topic' => array('MERGE_TOPIC', $auth->acl_get('m_merge', $forum_id)),
'fork' => array('FORK_TOPIC', $auth->acl_get('m_move', $forum_id)),
- 'make_normal' => array('MAKE_NORMAL', ($allow_change_type && $auth->acl_gets('f_sticky', 'f_announce', $forum_id) && $topic_data['topic_type'] != POST_NORMAL)),
+ 'make_normal' => array('MAKE_NORMAL', ($allow_change_type && $auth->acl_gets('f_sticky', 'f_announce', 'f_announce_global', $forum_id) && $topic_data['topic_type'] != POST_NORMAL)),
'make_sticky' => array('MAKE_STICKY', ($allow_change_type && $auth->acl_get('f_sticky', $forum_id) && $topic_data['topic_type'] != POST_STICKY)),
'make_announce' => array('MAKE_ANNOUNCE', ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_ANNOUNCE)),
- 'make_global' => array('MAKE_GLOBAL', ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_GLOBAL)),
+ 'make_global' => array('MAKE_GLOBAL', ($allow_change_type && $auth->acl_get('f_announce_global', $forum_id) && $topic_data['topic_type'] != POST_GLOBAL)),
'topic_logs' => array('VIEW_TOPIC_LOGS', $auth->acl_get('m_', $forum_id)),
);
-foreach($quickmod_array as $option => $qm_ary)
+foreach ($quickmod_array as $option => $qm_ary)
{
if (!empty($qm_ary[1]))
{
- phpbb_add_quickmod_option($option, $qm_ary[0]);
+ phpbb_add_quickmod_option($s_quickmod_action, $option, $qm_ary[0]);
}
}
@@ -590,6 +637,38 @@ if (!empty($_EXTRA_URL))
// If we've got a hightlight set pass it on to pagination.
$base_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : '') . (($highlight_match) ? "&amp;hilit=$highlight" : ''));
+
+/**
+* Event to modify data before template variables are being assigned
+*
+* @event core.viewtopic_assign_template_vars_before
+* @var string base_url URL to be passed to generate pagination
+* @var int forum_id Forum ID
+* @var int post_id Post ID
+* @var array quickmod_array Array with quick moderation options data
+* @var int start Pagination information
+* @var array topic_data Array with topic data
+* @var int topic_id Topic ID
+* @var array topic_tracking_info Array with topic tracking data
+* @var int total_posts Topic total posts count
+* @var string viewtopic_url URL to the topic page
+* @since 3.1.0-RC4
+* @change 3.1.2-RC1 Added viewtopic_url
+*/
+$vars = array(
+ 'base_url',
+ 'forum_id',
+ 'post_id',
+ 'quickmod_array',
+ 'start',
+ 'topic_data',
+ 'topic_id',
+ 'topic_tracking_info',
+ 'total_posts',
+ 'viewtopic_url',
+);
+extract($phpbb_dispatcher->trigger_event('core.viewtopic_assign_template_vars_before', compact($vars)));
+
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_posts, $config['posts_per_page'], $start);
// Send vars to template
@@ -620,11 +699,6 @@ $template->assign_vars(array(
'SEARCH_IMG' => $user->img('icon_user_search', 'SEARCH_USER_POSTS'),
'PM_IMG' => $user->img('icon_contact_pm', 'SEND_PRIVATE_MESSAGE'),
'EMAIL_IMG' => $user->img('icon_contact_email', 'SEND_EMAIL'),
- 'WWW_IMG' => $user->img('icon_contact_www', 'VISIT_WEBSITE'),
- 'ICQ_IMG' => $user->img('icon_contact_icq', 'ICQ'),
- 'AIM_IMG' => $user->img('icon_contact_aim', 'AIM'),
- 'MSN_IMG' => $user->img('icon_contact_msnm', 'MSNM'),
- 'YIM_IMG' => $user->img('icon_contact_yahoo', 'YIM'),
'JABBER_IMG' => $user->img('icon_contact_jabber', 'JABBER') ,
'REPORT_IMG' => $user->img('icon_post_report', 'REPORT_POST'),
'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED'),
@@ -637,9 +711,11 @@ $template->assign_vars(array(
'S_SELECT_SORT_DAYS' => $s_limit_days,
'S_SINGLE_MODERATOR' => (!empty($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id]) > 1) ? false : true,
'S_TOPIC_ACTION' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id" . (($start == 0) ? '' : "&amp;start=$start")),
- 'S_MOD_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&amp;t=$topic_id" . (($start == 0) ? '' : "&amp;start=$start") . "&amp;quickmod=1&amp;redirect=" . urlencode(str_replace('&amp;', '&', $viewtopic_url)), true, $user->session_id),
+ 'S_MOD_ACTION' => $s_quickmod_action,
+ 'L_RETURN_TO_FORUM' => $user->lang('RETURN_TO', $topic_data['forum_name']),
'S_VIEWTOPIC' => true,
+ 'S_UNREAD_VIEW' => $view == 'unread',
'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),
@@ -651,6 +727,7 @@ $template->assign_vars(array(
'U_TOPIC' => "{$server_path}viewtopic.$phpEx?f=$forum_id&amp;t=$topic_id",
'U_FORUM' => $server_path,
'U_VIEW_TOPIC' => $viewtopic_url,
+ 'U_CANONICAL' => generate_board_url() . '/' . append_sid("viewtopic.$phpEx", "t=$topic_id" . (($start) ? "&amp;start=$start" : ''), true, ''),
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id),
'U_VIEW_OLDER_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;view=previous"),
'U_VIEW_NEWER_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;view=next"),
@@ -729,6 +806,36 @@ if (!empty($topic_data['poll_start']))
($auth->acl_get('f_votechg', $forum_id) && $topic_data['poll_vote_change']))) ? true : false;
$s_display_results = (!$s_can_vote || ($s_can_vote && sizeof($cur_voted_id)) || $view == 'viewpoll') ? true : false;
+ /**
+ * Event to manipulate the poll data
+ *
+ * @event core.viewtopic_modify_poll_data
+ * @var array cur_voted_id Array with options' IDs current user has voted for
+ * @var int forum_id The topic's forum id
+ * @var array poll_info Array with the poll information
+ * @var bool s_can_vote Flag indicating if a user can vote
+ * @var bool s_display_results Flag indicating if results or poll options should be displayed
+ * @var int topic_id The id of the topic the user tries to access
+ * @var array topic_data All the information from the topic and forum tables for this topic
+ * @var string viewtopic_url URL to the topic page
+ * @var array vote_counts Array with the vote counts for every poll option
+ * @var array voted_id Array with updated options' IDs current user is voting for
+ * @since 3.1.5-RC1
+ */
+ $vars = array(
+ 'cur_voted_id',
+ 'forum_id',
+ 'poll_info',
+ 's_can_vote',
+ 's_display_results',
+ 'topic_id',
+ 'topic_data',
+ 'viewtopic_url',
+ 'vote_counts',
+ 'voted_id',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_poll_data', compact($vars)));
+
if ($update && $s_can_vote)
{
@@ -846,9 +953,11 @@ if (!empty($topic_data['poll_start']))
}
$poll_total = 0;
+ $poll_most = 0;
foreach ($poll_info as $poll_option)
{
$poll_total += $poll_option['poll_option_total'];
+ $poll_most = ($poll_option['poll_option_total'] >= $poll_most) ? $poll_option['poll_option_total'] : $poll_most;
}
$parse_flags = ($poll_info[0]['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES;
@@ -860,25 +969,31 @@ if (!empty($topic_data['poll_start']))
$topic_data['poll_title'] = generate_text_for_display($topic_data['poll_title'], $poll_info[0]['bbcode_uid'], $poll_info[0]['bbcode_bitfield'], $parse_flags, true);
+ $poll_template_data = $poll_options_template_data = array();
foreach ($poll_info as $poll_option)
{
$option_pct = ($poll_total > 0) ? $poll_option['poll_option_total'] / $poll_total : 0;
$option_pct_txt = sprintf("%.1d%%", round($option_pct * 100));
-
- $template->assign_block_vars('poll_option', array(
- 'POLL_OPTION_ID' => $poll_option['poll_option_id'],
- 'POLL_OPTION_CAPTION' => $poll_option['poll_option_text'],
- 'POLL_OPTION_RESULT' => $poll_option['poll_option_total'],
- 'POLL_OPTION_PERCENT' => $option_pct_txt,
- 'POLL_OPTION_PCT' => round($option_pct * 100),
- 'POLL_OPTION_WIDTH' => round($option_pct * 250),
- 'POLL_OPTION_VOTED' => (in_array($poll_option['poll_option_id'], $cur_voted_id)) ? true : false)
+ $option_pct_rel = ($poll_most > 0) ? $poll_option['poll_option_total'] / $poll_most : 0;
+ $option_pct_rel_txt = sprintf("%.1d%%", round($option_pct_rel * 100));
+ $option_most_votes = ($poll_option['poll_option_total'] > 0 && $poll_option['poll_option_total'] == $poll_most) ? true : false;
+
+ $poll_options_template_data[] = array(
+ 'POLL_OPTION_ID' => $poll_option['poll_option_id'],
+ 'POLL_OPTION_CAPTION' => $poll_option['poll_option_text'],
+ 'POLL_OPTION_RESULT' => $poll_option['poll_option_total'],
+ 'POLL_OPTION_PERCENT' => $option_pct_txt,
+ 'POLL_OPTION_PERCENT_REL' => $option_pct_rel_txt,
+ 'POLL_OPTION_PCT' => round($option_pct * 100),
+ 'POLL_OPTION_WIDTH' => round($option_pct * 250),
+ 'POLL_OPTION_VOTED' => (in_array($poll_option['poll_option_id'], $cur_voted_id)) ? true : false,
+ 'POLL_OPTION_MOST_VOTES' => $option_most_votes,
);
}
$poll_end = $topic_data['poll_length'] + $topic_data['poll_start'];
- $template->assign_vars(array(
+ $poll_template_data = array(
'POLL_QUESTION' => $topic_data['poll_title'],
'TOTAL_VOTES' => $poll_total,
'POLL_LEFT_CAP_IMG' => $user->img('poll_left'),
@@ -893,10 +1008,46 @@ if (!empty($topic_data['poll_start']))
'S_IS_MULTI_CHOICE' => ($topic_data['poll_max_options'] > 1) ? true : false,
'S_POLL_ACTION' => $viewtopic_url,
- 'U_VIEW_RESULTS' => $viewtopic_url . '&amp;view=viewpoll')
+ 'U_VIEW_RESULTS' => $viewtopic_url . '&amp;view=viewpoll',
);
- unset($poll_end, $poll_info, $voted_id);
+ /**
+ * Event to add/modify poll template data
+ *
+ * @event core.viewtopic_modify_poll_template_data
+ * @var array cur_voted_id Array with options' IDs current user has voted for
+ * @var int poll_end The poll end time
+ * @var array poll_info Array with the poll information
+ * @var array poll_options_template_data Array with the poll options template data
+ * @var array poll_template_data Array with the common poll template data
+ * @var int poll_total Total poll votes count
+ * @var int poll_most Mostly voted option votes count
+ * @var array topic_data All the information from the topic and forum tables for this topic
+ * @var string viewtopic_url URL to the topic page
+ * @var array vote_counts Array with the vote counts for every poll option
+ * @var array voted_id Array with updated options' IDs current user is voting for
+ * @since 3.1.5-RC1
+ */
+ $vars = array(
+ 'cur_voted_id',
+ 'poll_end',
+ 'poll_info',
+ 'poll_options_template_data',
+ 'poll_template_data',
+ 'poll_total',
+ 'poll_most',
+ 'topic_data',
+ 'viewtopic_url',
+ 'vote_counts',
+ 'voted_id',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_poll_template_data', compact($vars)));
+
+ $template->assign_block_vars_array('poll_option', $poll_options_template_data);
+
+ $template->assign_vars($poll_template_data);
+
+ unset($poll_end, $poll_info, $poll_options_template_data, $poll_template_data, $voted_id);
}
// If the user is trying to reach the second half of the topic, fetch it starting from the end
@@ -932,8 +1083,7 @@ else
// Container for user details, only process once
$post_list = $user_cache = $id_cache = $attachments = $attach_list = $rowset = $update_count = $post_edit_list = $post_delete_list = array();
-$has_attachments = $display_notice = false;
-$bbcode_bitfield = '';
+$has_unapproved_attachments = $has_approved_attachments = $display_notice = false;
$i = $i_total = 0;
// Go ahead and pull all data for this topic
@@ -1002,10 +1152,20 @@ $sql_ary = array(
* @var string sort_dir Direction the posts are sorted by
* @var int start Pagination information
* @var array sql_ary The SQL array to get the data of posts and posters
-* @since 3.1-A1
+* @since 3.1.0-a1
* @change 3.1.0-a2 Added vars forum_id, topic_id, topic_data, post_list, sort_days, sort_key, sort_dir, start
*/
-$vars = array('forum_id', 'topic_id', 'topic_data', 'post_list', 'sort_days', 'sort_key', 'sort_dir', 'start', 'sql_ary');
+$vars = array(
+ 'forum_id',
+ 'topic_id',
+ 'topic_data',
+ 'post_list',
+ 'sort_days',
+ 'sort_key',
+ 'sort_dir',
+ 'start',
+ 'sql_ary',
+);
extract($phpbb_dispatcher->trigger_event('core.viewtopic_get_post_data', compact($vars)));
$sql = $db->sql_build_query('SELECT', $sql_ary);
@@ -1031,9 +1191,13 @@ while ($row = $db->sql_fetchrow($result))
{
$attach_list[] = (int) $row['post_id'];
- if ($row['post_visibility'] == ITEM_UNAPPROVED)
+ if ($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE)
+ {
+ $has_unapproved_attachments = true;
+ }
+ else if ($row['post_visibility'] == ITEM_APPROVED)
{
- $has_attachments = true;
+ $has_approved_attachments = true;
}
}
@@ -1078,22 +1242,13 @@ while ($row = $db->sql_fetchrow($result))
* @event core.viewtopic_post_rowset_data
* @var array rowset_data Array with the rowset data for this post
* @var array row Array with original user and post data
- * @since 3.1-A1
+ * @since 3.1.0-a1
*/
$vars = array('rowset_data', 'row');
extract($phpbb_dispatcher->trigger_event('core.viewtopic_post_rowset_data', compact($vars)));
$rowset[$row['post_id']] = $rowset_data;
- // Define the global bbcode bitfield, will be used to load bbcodes
- $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']);
-
- // Is a signature attached? Are we going to display it?
- if ($row['enable_sig'] && $config['allow_sig'] && $user->optionget('viewsigs'))
- {
- $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['user_sig_bbcode_bitfield']);
- }
-
// Cache various user specific data ... so we don't have to recompute
// this each time the same user appears on this page
if (!isset($user_cache[$poster_id]))
@@ -1101,6 +1256,7 @@ while ($row = $db->sql_fetchrow($result))
if ($poster_id == ANONYMOUS)
{
$user_cache_data = array(
+ 'user_type' => USER_IGNORE,
'joined' => '',
'posts' => '',
@@ -1114,21 +1270,15 @@ while ($row = $db->sql_fetchrow($result))
'rank_image' => '',
'rank_image_src' => '',
'sig' => '',
- 'profile' => '',
'pm' => '',
'email' => '',
- 'www' => '',
- 'icq_status_img' => '',
- 'icq' => '',
- 'aim' => '',
- 'msn' => '',
- 'yim' => '',
'jabber' => '',
'search' => '',
'age' => '',
'username' => $row['username'],
'user_colour' => $row['user_colour'],
+ 'contact_user' => '',
'warnings' => 0,
'allow_pm' => 0,
@@ -1141,14 +1291,17 @@ while ($row = $db->sql_fetchrow($result))
* @var array user_cache_data Array with the user's data
* @var int poster_id Poster's user id
* @var array row Array with original user and post data
- * @since 3.1-A1
+ * @since 3.1.0-a1
*/
$vars = array('user_cache_data', 'poster_id', 'row');
extract($phpbb_dispatcher->trigger_event('core.viewtopic_cache_guest_data', compact($vars)));
$user_cache[$poster_id] = $user_cache_data;
- get_user_rank($row['user_rank'], false, $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);
+ $user_rank_data = phpbb_get_user_rank($row, false);
+ $user_cache[$poster_id]['rank_title'] = $user_rank_data['title'];
+ $user_cache[$poster_id]['rank_image'] = $user_rank_data['img'];
+ $user_cache[$poster_id]['rank_image_src'] = $user_rank_data['img_src'];
}
else
{
@@ -1163,6 +1316,9 @@ while ($row = $db->sql_fetchrow($result))
$id_cache[] = $poster_id;
$user_cache_data = array(
+ 'user_type' => $row['user_type'],
+ 'user_inactive_reason' => $row['user_inactive_reason'],
+
'joined' => $user->format_date($row['user_regdate']),
'posts' => $row['user_posts'],
'warnings' => (isset($row['user_warnings'])) ? $row['user_warnings'] : 0,
@@ -1183,15 +1339,11 @@ while ($row = $db->sql_fetchrow($result))
'username' => $row['username'],
'user_colour' => $row['user_colour'],
+ 'contact_user' => $user->lang('CONTACT_USER', get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['username'])),
'online' => false,
- 'profile' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=viewprofile&amp;u=$poster_id"),
- 'www' => $row['user_website'],
- 'aim' => ($row['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&amp;action=aim&amp;u=$poster_id") : '',
- 'msn' => ($row['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&amp;action=msnm&amp;u=$poster_id") : '',
- 'yim' => ($row['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($row['user_yim']) . '&amp;.src=pg' : '',
- 'jabber' => ($row['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&amp;action=jabber&amp;u=$poster_id") : '',
- 'search' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$poster_id&amp;sr=posts") : '',
+ 'jabber' => ($config['jab_enable'] && $row['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&amp;action=jabber&amp;u=$poster_id") : '',
+ 'search' => ($config['load_search'] && $auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$poster_id&amp;sr=posts") : '',
'author_full' => get_username_string('full', $poster_id, $row['username'], $row['user_colour']),
'author_colour' => get_username_string('colour', $poster_id, $row['username'], $row['user_colour']),
@@ -1206,14 +1358,17 @@ while ($row = $db->sql_fetchrow($result))
* @var array user_cache_data Array with the user's data
* @var int poster_id Poster's user id
* @var array row Array with original user and post data
- * @since 3.1-A1
+ * @since 3.1.0-a1
*/
$vars = array('user_cache_data', 'poster_id', 'row');
extract($phpbb_dispatcher->trigger_event('core.viewtopic_cache_user_data', compact($vars)));
$user_cache[$poster_id] = $user_cache_data;
- get_user_rank($row['user_rank'], $row['user_posts'], $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);
+ $user_rank_data = phpbb_get_user_rank($row, $row['user_posts']);
+ $user_cache[$poster_id]['rank_title'] = $user_rank_data['title'];
+ $user_cache[$poster_id]['rank_image'] = $user_rank_data['img'];
+ $user_cache[$poster_id]['rank_image_src'] = $user_rank_data['img_src'];
if ((!empty($row['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_email'))
{
@@ -1224,17 +1379,6 @@ while ($row = $db->sql_fetchrow($result))
$user_cache[$poster_id]['email'] = '';
}
- if (!empty($row['user_icq']))
- {
- $user_cache[$poster_id]['icq'] = 'http://www.icq.com/people/' . urlencode($row['user_icq']) . '/';
- $user_cache[$poster_id]['icq_status_img'] = '<img src="http://web.icq.com/whitepages/online?icq=' . $row['user_icq'] . '&amp;img=5" width="18" height="18" alt="" />';
- }
- else
- {
- $user_cache[$poster_id]['icq_status_img'] = '';
- $user_cache[$poster_id]['icq'] = '';
- }
-
if ($config['allow_birthdays'] && !empty($row['user_birthday']))
{
list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', $row['user_birthday']));
@@ -1262,10 +1406,11 @@ $db->sql_freeresult($result);
// Load custom profile fields
if ($config['load_cpf_viewtopic'])
{
+ /* @var $cp \phpbb\profilefields\manager */
$cp = $phpbb_container->get('profilefields.manager');
// Grab all profile fields from users in id cache for later use - similar to the poster cache
- $profile_fields_tmp = $cp->generate_profile_fields_template('grab', $id_cache);
+ $profile_fields_tmp = $cp->grab_profile_fields_data($id_cache);
// filter out fields not to be displayed on viewtopic. Yes, it's a hack, but this shouldn't break any MODs.
$profile_fields_cache = array();
@@ -1356,7 +1501,7 @@ if (sizeof($attach_list))
$db->sql_query($sql);
}
}
- else if ($has_attachments && !$topic_data['topic_attachment'])
+ else if ($has_approved_attachments && !$topic_data['topic_attachment'])
{
// Topic has approved attachments but its flag is wrong
$sql = 'UPDATE ' . TOPICS_TABLE . "
@@ -1366,6 +1511,11 @@ if (sizeof($attach_list))
$topic_data['topic_attachment'] = 1;
}
+ else if ($has_unapproved_attachments && !$topic_data['topic_attachment'])
+ {
+ // Topic has only unapproved attachments but we have the right to see and download them
+ $topic_data['topic_attachment'] = 1;
+ }
}
else
{
@@ -1373,30 +1523,61 @@ if (sizeof($attach_list))
}
}
-$methods = phpbb_gen_download_links('topic_id', $topic_id, $phpbb_root_path, $phpEx);
-foreach ($methods as $method)
-{
- $template->assign_block_vars('dl_method', $method);
-}
+// Get the list of users who can receive private messages
+$can_receive_pm_list = $auth->acl_get_list(array_keys($user_cache), 'u_readpm');
+$can_receive_pm_list = (empty($can_receive_pm_list) || !isset($can_receive_pm_list[0]['u_readpm'])) ? array() : $can_receive_pm_list[0]['u_readpm'];
-$template->assign_vars(array(
- 'S_HAS_ATTACHMENTS' => $topic_data['topic_attachment'],
- 'U_DOWNLOAD_ALL_ATTACHMENTS' => $methods[0]['LINK'],
-));
-
-// Instantiate BBCode if need be
-if ($bbcode_bitfield !== '')
-{
- $bbcode = new bbcode(base64_encode($bbcode_bitfield));
-}
+// Get the list of permanently banned users
+$permanently_banned_users = phpbb_get_banned_user_ids(array_keys($user_cache), false);
$i_total = sizeof($rowset) - 1;
$prev_post_id = '';
$template->assign_vars(array(
+ 'S_HAS_ATTACHMENTS' => $topic_data['topic_attachment'],
'S_NUM_POSTS' => sizeof($post_list))
);
+/**
+* Event to modify the post, poster and attachment data before assigning the posts
+*
+* @event core.viewtopic_modify_post_data
+* @var int forum_id Forum ID
+* @var int topic_id Topic ID
+* @var array topic_data Array with topic data
+* @var array post_list Array with post_ids we are going to display
+* @var array rowset Array with post_id => post data
+* @var array user_cache Array with prepared user data
+* @var int start Pagination information
+* @var int sort_days Display posts of previous x days
+* @var string sort_key Key the posts are sorted by
+* @var string sort_dir Direction the posts are sorted by
+* @var bool display_notice Shall we display a notice instead of attachments
+* @var bool has_approved_attachments Does the topic have approved attachments
+* @var array attachments List of attachments post_id => array of attachments
+* @var array permanently_banned_users List of permanently banned users
+* @var array can_receive_pm_list Array with posters that can receive pms
+* @since 3.1.0-RC3
+*/
+$vars = array(
+ 'forum_id',
+ 'topic_id',
+ 'topic_data',
+ 'post_list',
+ 'rowset',
+ 'user_cache',
+ 'sort_days',
+ 'sort_key',
+ 'sort_dir',
+ 'start',
+ 'permanently_banned_users',
+ 'can_receive_pm_list',
+ 'display_notice',
+ 'has_approved_attachments',
+ 'attachments',
+);
+extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_post_data', compact($vars)));
+
// Output the posts
$first_unread = $post_unread = false;
for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
@@ -1575,7 +1756,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
//
if ($config['load_cpf_viewtopic'])
{
- $cp_row = (isset($profile_fields_cache[$poster_id])) ? $cp->generate_profile_fields_template('show', false, $profile_fields_cache[$poster_id]) : array();
+ $cp_row = (isset($profile_fields_cache[$poster_id])) ? $cp->generate_profile_fields_template_data($profile_fields_cache[$poster_id]) : array();
}
$post_unread = (isset($topic_tracking_info[$topic_id]) && $row['post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
@@ -1586,22 +1767,102 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
$s_first_unread = $first_unread = true;
}
- $edit_allowed = ($user->data['is_registered'] && ($auth->acl_get('m_edit', $forum_id) || (
- $user->data['user_id'] == $poster_id &&
- $auth->acl_get('f_edit', $forum_id) &&
- !$row['post_edit_locked'] &&
- ($row['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time'])
- )));
+ $force_edit_allowed = $force_delete_allowed = false;
+
+ $s_cannot_edit = !$auth->acl_get('f_edit', $forum_id) || $user->data['user_id'] != $poster_id;
+ $s_cannot_edit_time = $config['edit_time'] && $row['post_time'] <= time() - ($config['edit_time'] * 60);
+ $s_cannot_edit_locked = $topic_data['topic_status'] == ITEM_LOCKED || $row['post_edit_locked'];
+
+ $s_cannot_delete = $user->data['user_id'] != $poster_id || (
+ !$auth->acl_get('f_delete', $forum_id) &&
+ (!$auth->acl_get('f_softdelete', $forum_id) || $row['post_visibility'] == ITEM_DELETED)
+ );
+ $s_cannot_delete_lastpost = $topic_data['topic_last_post_id'] != $row['post_id'];
+ $s_cannot_delete_time = $config['delete_time'] && $row['post_time'] <= time() - ($config['delete_time'] * 60);
+ // we do not want to allow removal of the last post if a moderator locked it!
+ $s_cannot_delete_locked = $topic_data['topic_status'] == ITEM_LOCKED || $row['post_edit_locked'];
- $delete_allowed = ($user->data['is_registered'] && (($auth->acl_get('m_delete', $forum_id) || ($auth->acl_get('m_softdelete', $forum_id) && $row['post_visibility'] != ITEM_DELETED)) || (
- $user->data['user_id'] == $poster_id &&
- ($auth->acl_get('f_delete', $forum_id) || ($auth->acl_get('f_softdelete', $forum_id) && $row['post_visibility'] != ITEM_DELETED)) &&
- $topic_data['topic_last_post_id'] == $row['post_id'] &&
- ($row['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time']) &&
- // we do not want to allow removal of the last post if a moderator locked it!
- !$row['post_edit_locked']
+ /**
+ * This event allows you to modify the conditions for the "can edit post" and "can delete post" checks
+ *
+ * @event core.viewtopic_modify_post_action_conditions
+ * @var array row Array with post data
+ * @var array topic_data Array with topic data
+ * @var bool force_edit_allowed Allow the user to edit the post (all permissions and conditions are ignored)
+ * @var bool s_cannot_edit User can not edit the post because it's not his
+ * @var bool s_cannot_edit_locked User can not edit the post because it's locked
+ * @var bool s_cannot_edit_time User can not edit the post because edit_time has passed
+ * @var bool force_delete_allowed Allow the user to delete the post (all permissions and conditions are ignored)
+ * @var bool s_cannot_delete User can not delete the post because it's not his
+ * @var bool s_cannot_delete_lastpost User can not delete the post because it's not the last post of the topic
+ * @var bool s_cannot_delete_locked User can not delete the post because it's locked
+ * @var bool s_cannot_delete_time User can not delete the post because edit_time has passed
+ * @since 3.1.0-b4
+ */
+ $vars = array(
+ 'row',
+ 'topic_data',
+ 'force_edit_allowed',
+ 's_cannot_edit',
+ 's_cannot_edit_locked',
+ 's_cannot_edit_time',
+ 'force_delete_allowed',
+ 's_cannot_delete',
+ 's_cannot_delete_lastpost',
+ 's_cannot_delete_locked',
+ 's_cannot_delete_time',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_post_action_conditions', compact($vars)));
+
+ $edit_allowed = $force_edit_allowed || ($user->data['is_registered'] && ($auth->acl_get('m_edit', $forum_id) || (
+ !$s_cannot_edit &&
+ !$s_cannot_edit_time &&
+ !$s_cannot_edit_locked
)));
+ $quote_allowed = $auth->acl_get('m_edit', $forum_id) || ($topic_data['topic_status'] != ITEM_LOCKED &&
+ ($user->data['user_id'] == ANONYMOUS || $auth->acl_get('f_reply', $forum_id))
+ );
+
+ // Only display the quote button if the post is quotable. Posts not approved are not quotable.
+ $quote_allowed = ($quote_allowed && $row['post_visibility'] == ITEM_APPROVED) ? true : false;
+
+ $delete_allowed = $force_delete_allowed || ($user->data['is_registered'] && (
+ ($auth->acl_get('m_delete', $forum_id) || ($auth->acl_get('m_softdelete', $forum_id) && $row['post_visibility'] != ITEM_DELETED)) ||
+ (!$s_cannot_delete && !$s_cannot_delete_lastpost && !$s_cannot_delete_time && !$s_cannot_delete_locked)
+ ));
+
+ $softdelete_allowed = ($auth->acl_get('m_softdelete', $forum_id) ||
+ ($auth->acl_get('f_softdelete', $forum_id) && $user->data['user_id'] == $poster_id)) && ($row['post_visibility'] != ITEM_DELETED);
+
+ $permanent_delete_allowed = ($auth->acl_get('m_delete', $forum_id) ||
+ ($auth->acl_get('f_delete', $forum_id) && $user->data['user_id'] == $poster_id));
+
+ // Can this user receive a Private Message?
+ $can_receive_pm = (
+ // They must be a "normal" user
+ $user_cache[$poster_id]['user_type'] != USER_IGNORE &&
+
+ // They must not be deactivated by the administrator
+ ($user_cache[$poster_id]['user_type'] != USER_INACTIVE || $user_cache[$poster_id]['user_inactive_reason'] != INACTIVE_MANUAL) &&
+
+ // They must be able to read PMs
+ in_array($poster_id, $can_receive_pm_list) &&
+
+ // They must not be permanently banned
+ !in_array($poster_id, $permanently_banned_users) &&
+
+ // They must allow users to contact via PM
+ (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || $user_cache[$poster_id]['allow_pm'])
+ );
+
+ $u_pm = '';
+
+ if ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && $can_receive_pm)
+ {
+ $u_pm = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;mode=compose&amp;action=quotepost&amp;p=' . $row['post_id']);
+ }
+
//
$post_row = array(
'POST_AUTHOR_FULL' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_full'] : get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
@@ -1615,8 +1876,9 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
'POSTER_JOINED' => $user_cache[$poster_id]['joined'],
'POSTER_POSTS' => $user_cache[$poster_id]['posts'],
'POSTER_AVATAR' => $user_cache[$poster_id]['avatar'],
- 'POSTER_WARNINGS' => $user_cache[$poster_id]['warnings'],
+ 'POSTER_WARNINGS' => $auth->acl_get('m_warn') ? $user_cache[$poster_id]['warnings'] : '',
'POSTER_AGE' => $user_cache[$poster_id]['age'],
+ 'CONTACT_USER' => $user_cache[$poster_id]['contact_user'],
'POST_DATE' => $user->format_date($row['post_time'], false, ($view == 'print') ? true : false),
'POST_SUBJECT' => $row['post_subject'],
@@ -1632,28 +1894,22 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
'POST_ICON_IMG' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['img'] : '',
'POST_ICON_IMG_WIDTH' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['width'] : '',
'POST_ICON_IMG_HEIGHT' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['height'] : '',
- 'ICQ_STATUS_IMG' => $user_cache[$poster_id]['icq_status_img'],
+ 'POST_ICON_IMG_ALT' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['alt'] : '',
'ONLINE_IMG' => ($poster_id == ANONYMOUS || !$config['load_onlinetrack']) ? '' : (($user_cache[$poster_id]['online']) ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')),
'S_ONLINE' => ($poster_id == ANONYMOUS || !$config['load_onlinetrack']) ? false : (($user_cache[$poster_id]['online']) ? true : false),
'U_EDIT' => ($edit_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=edit&amp;f=$forum_id&amp;p={$row['post_id']}") : '',
- 'U_QUOTE' => ($auth->acl_get('f_reply', $forum_id)) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=quote&amp;f=$forum_id&amp;p={$row['post_id']}") : '',
+ 'U_QUOTE' => ($quote_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=quote&amp;f=$forum_id&amp;p={$row['post_id']}") : '',
'U_INFO' => ($auth->acl_get('m_info', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&amp;mode=post_details&amp;f=$forum_id&amp;p=" . $row['post_id'], true, $user->session_id) : '',
- 'U_DELETE' => ($delete_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=delete&amp;f=$forum_id&amp;p={$row['post_id']}") : '',
+ 'U_DELETE' => ($delete_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=' . (($softdelete_allowed) ? 'soft_delete' : 'delete') . "&amp;f=$forum_id&amp;p={$row['post_id']}") : '',
- 'U_PROFILE' => $user_cache[$poster_id]['profile'],
'U_SEARCH' => $user_cache[$poster_id]['search'],
- 'U_PM' => ($poster_id != ANONYMOUS && $config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($user_cache[$poster_id]['allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;mode=compose&amp;action=quotepost&amp;p=' . $row['post_id']) : '',
+ 'U_PM' => $u_pm,
'U_EMAIL' => $user_cache[$poster_id]['email'],
- 'U_WWW' => $user_cache[$poster_id]['www'],
- 'U_ICQ' => $user_cache[$poster_id]['icq'],
- 'U_AIM' => $user_cache[$poster_id]['aim'],
- 'U_MSN' => $user_cache[$poster_id]['msn'],
- 'U_YIM' => $user_cache[$poster_id]['yim'],
'U_JABBER' => $user_cache[$poster_id]['jabber'],
'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&amp;p={$row['post_id']}&amp;f=$forum_id&amp;redirect=" . urlencode(str_replace('&amp;', '&', $viewtopic_url . '&amp;p=' . $row['post_id'] . '#p' . $row['post_id']))),
- 'U_REPORT' => ($auth->acl_get('f_report', $forum_id)) ? append_sid("{$phpbb_root_path}report.$phpEx", 'f=' . $forum_id . '&amp;p=' . $row['post_id']) : '',
+ 'U_REPORT' => ($auth->acl_get('f_report', $forum_id)) ? $phpbb_container->get('controller.helper')->route('phpbb_report_post_controller', array('id' => $row['post_id'])) : '',
'U_MCP_REPORT' => ($auth->acl_get('m_report', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&amp;mode=report_details&amp;f=' . $forum_id . '&amp;p=' . $row['post_id'], true, $user->session_id) : '',
'U_MCP_APPROVE' => ($auth->acl_get('m_approve', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=approve_details&amp;f=' . $forum_id . '&amp;p=' . $row['post_id'], true, $user->session_id) : '',
'U_MCP_RESTORE' => ($auth->acl_get('m_approve', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=' . (($topic_data['topic_visibility'] != ITEM_DELETED) ? 'deleted_posts' : 'deleted_topics') . '&amp;f=' . $forum_id . '&amp;p=' . $row['post_id'], true, $user->session_id) : '',
@@ -1666,10 +1922,12 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
'POST_ID' => $row['post_id'],
'POST_NUMBER' => $i + $start + 1,
'POSTER_ID' => $poster_id,
+ 'MINI_POST' => ($post_unread) ? $user->lang['UNREAD_POST'] : $user->lang['POST'],
+
'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false,
'S_MULTIPLE_ATTACHMENTS' => !empty($attachments[$row['post_id']]) && sizeof($attachments[$row['post_id']]) > 1,
- 'S_POST_UNAPPROVED' => ($row['post_visibility'] == ITEM_UNAPPROVED) ? true : false,
+ 'S_POST_UNAPPROVED' => ($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) ? true : false,
'S_POST_DELETED' => ($row['post_visibility'] == ITEM_DELETED) ? true : false,
'L_POST_DELETED_MESSAGE' => $l_deleted_message,
'S_POST_REPORTED' => ($row['post_reported'] && $auth->acl_get('m_report', $forum_id)) ? true : false,
@@ -1684,6 +1942,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
'L_IGNORE_POST' => ($row['foe']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username'])) : '',
'S_POST_HIDDEN' => $row['hide_post'],
'L_POST_DISPLAY' => ($row['hide_post']) ? $user->lang('POST_DISPLAY', '<a class="display_post" data-post-id="' . $row['post_id'] . '" href="' . $viewtopic_url . "&amp;p={$row['post_id']}&amp;view=show#p{$row['post_id']}" . '">', '</a>') : '',
+ 'S_DELETE_PERMANENT' => $permanent_delete_allowed,
);
$user_poster_data = $user_cache[$poster_id];
@@ -1697,15 +1956,32 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
* @var int start Start item of this page
* @var int current_row_number Number of the post on this page
* @var int end Number of posts on this page
+ * @var int total_posts Total posts count
+ * @var int poster_id Post author id
* @var array row Array with original post and user data
* @var array cp_row Custom profile field data of the poster
* @var array attachments List of attachments
* @var array user_poster_data Poster's data from user cache
* @var array post_row Template block array of the post
- * @since 3.1-A1
+ * @var array topic_data Array with topic data
+ * @since 3.1.0-a1
* @change 3.1.0-a3 Added vars start, current_row_number, end, attachments
+ * @change 3.1.0-b3 Added topic_data array, total_posts
+ * @change 3.1.0-RC3 Added poster_id
*/
- $vars = array('start', 'current_row_number', 'end', 'row', 'cp_row', 'attachments', 'user_poster_data', 'post_row');
+ $vars = array(
+ 'start',
+ 'current_row_number',
+ 'end',
+ 'total_posts',
+ 'poster_id',
+ 'row',
+ 'cp_row',
+ 'attachments',
+ 'user_poster_data',
+ 'post_row',
+ 'topic_data',
+ );
extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_post_row', compact($vars)));
$i = $current_row_number;
@@ -1718,11 +1994,46 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
// Dump vars into template
$template->assign_block_vars('postrow', $post_row);
+ $contact_fields = array(
+ array(
+ 'ID' => 'pm',
+ 'NAME' => $user->lang['SEND_PRIVATE_MESSAGE'],
+ 'U_CONTACT' => $u_pm,
+ ),
+ array(
+ 'ID' => 'email',
+ 'NAME' => $user->lang['SEND_EMAIL'],
+ 'U_CONTACT' => $user_cache[$poster_id]['email'],
+ ),
+ array(
+ 'ID' => 'jabber',
+ 'NAME' => $user->lang['JABBER'],
+ 'U_CONTACT' => $user_cache[$poster_id]['jabber'],
+ ),
+ );
+
+ foreach ($contact_fields as $field)
+ {
+ if ($field['U_CONTACT'])
+ {
+ $template->assign_block_vars('postrow.contact', $field);
+ }
+ }
+
if (!empty($cp_row['blockrow']))
{
foreach ($cp_row['blockrow'] as $field_data)
{
$template->assign_block_vars('postrow.custom_fields', $field_data);
+
+ if ($field_data['S_PROFILE_CONTACT'])
+ {
+ $template->assign_block_vars('postrow.contact', array(
+ 'ID' => $field_data['PROFILE_FIELD_IDENT'],
+ 'NAME' => $field_data['PROFILE_FIELD_NAME'],
+ 'U_CONTACT' => $field_data['PROFILE_FIELD_CONTACT'],
+ ));
+ }
}
}
@@ -1735,12 +2046,6 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
'DISPLAY_ATTACHMENT' => $attachment)
);
}
-
- $methods = phpbb_gen_download_links('post_id', $row['post_id'], $phpbb_root_path, $phpEx);
- foreach ($methods as $method)
- {
- $template->assign_block_vars('postrow.dl_method', $method);
- }
}
$current_row_number = $i;
@@ -1752,14 +2057,28 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
* @var int start Start item of this page
* @var int current_row_number Number of the post on this page
* @var int end Number of posts on this page
+ * @var int total_posts Total posts count
* @var array row Array with original post and user data
* @var array cp_row Custom profile field data of the poster
* @var array attachments List of attachments
* @var array user_poster_data Poster's data from user cache
* @var array post_row Template block array of the post
+ * @var array topic_data Array with topic data
* @since 3.1.0-a3
+ * @change 3.1.0-b3 Added topic_data array, total_posts
*/
- $vars = array('start', 'current_row_number', 'end', 'row', 'cp_row', 'attachments', 'user_poster_data', 'post_row');
+ $vars = array(
+ 'start',
+ 'current_row_number',
+ 'end',
+ 'total_posts',
+ 'row',
+ 'cp_row',
+ 'attachments',
+ 'user_poster_data',
+ 'post_row',
+ 'topic_data',
+ );
extract($phpbb_dispatcher->trigger_event('core.viewtopic_post_row_after', compact($vars)));
$i = $current_row_number;
@@ -1886,13 +2205,13 @@ if ($s_can_vote || $s_quick_reply)
// We overwrite $_REQUEST['f'] if there is no forum specified
// to be able to display the correct online list.
// One downside is that the user currently viewing this topic/post is not taken into account.
-if (!request_var('f', 0))
+if (!$request->variable('f', 0))
{
$request->overwrite('f', $forum_id);
}
// We need to do the same with the topic_id. See #53025.
-if (!request_var('t', 0) && !empty($topic_id))
+if (!$request->variable('t', 0) && !empty($topic_id))
{
$request->overwrite('t', $topic_id);
}
@@ -1903,13 +2222,15 @@ $page_title = $topic_data['topic_title'] . ($start ? ' - ' . sprintf($user->lang
* You can use this event to modify the page title of the viewtopic page
*
* @event core.viewtopic_modify_page_title
-* @var string page_title Title of the index page
+* @var string page_title Title of the viewtopic page
* @var array topic_data Array with topic data
* @var int forum_id Forum ID of the topic
* @var int start Start offset used to calculate the page
-* @since 3.1-A1
+* @var array post_list Array with post_ids we are going to display
+* @since 3.1.0-a1
+* @change 3.1.0-RC4 Added post_list var
*/
-$vars = array('page_title', 'topic_data', 'forum_id', 'start');
+$vars = array('page_title', 'topic_data', 'forum_id', 'start', 'post_list');
extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_page_title', compact($vars)));
// Output the page