diff options
Diffstat (limited to 'phpBB/viewtopic.php')
-rw-r--r-- | phpBB/viewtopic.php | 116 |
1 files changed, 89 insertions, 27 deletions
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 5d7314635e..0691355563 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -16,6 +16,7 @@ $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(); @@ -266,7 +267,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) @@ -422,17 +423,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 @@ -864,6 +859,7 @@ if (!empty($topic_data['poll_start'])) $option_pct_txt = sprintf("%.1d%%", round($option_pct * 100)); $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; $template->assign_block_vars('poll_option', array( 'POLL_OPTION_ID' => $poll_option['poll_option_id'], @@ -874,6 +870,7 @@ if (!empty($topic_data['poll_start'])) '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, )); } @@ -1003,10 +1000,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); @@ -1032,7 +1039,7 @@ 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_attachments = true; } @@ -1079,7 +1086,7 @@ 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))); @@ -1135,7 +1142,7 @@ 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))); @@ -1157,6 +1164,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, @@ -1195,7 +1205,7 @@ 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))); @@ -1368,6 +1378,13 @@ if ($bbcode_bitfield !== '') $bbcode = new bbcode(base64_encode($bbcode_bitfield)); } +// 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']; + +// 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 = ''; @@ -1586,10 +1603,27 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) !$row['post_edit_locked'] ))); - $u_pm = ''; + // Can this user receive a Private Message? + $can_receive_pm = ( + // They must be a "normal" user + $user_cache[$poster_id]['user_type'] != USER_IGNORE && - if (($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_')))) + // 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_')) || $data['user_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&mode=compose&action=quotepost&p=' . $row['post_id']); } @@ -1654,7 +1688,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) '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, @@ -1682,15 +1716,29 @@ 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 - * @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 */ - $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_modify_post_row', compact($vars))); $i = $current_row_number; @@ -1772,14 +1820,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; @@ -1923,11 +1985,11 @@ $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 +* @since 3.1.0-a1 */ $vars = array('page_title', 'topic_data', 'forum_id', 'start'); extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_page_title', compact($vars))); |