diff options
Diffstat (limited to 'phpBB/viewtopic.php')
-rw-r--r-- | phpBB/viewtopic.php | 97 |
1 files changed, 91 insertions, 6 deletions
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index b6df14d42d..3fde5b5e03 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -987,6 +987,16 @@ $sql_ary = array( AND u.user_id = p.poster_id', ); +/** +* Event to modify the SQL query before the post and poster data is retrieved +* +* @event core.viewtopic_get_post_data +* @var array sql_ary The SQL array to get the data of posts and posters +* @since 3.1-A1 +*/ +$vars = array('sql_ary'); +extract($phpbb_dispatcher->trigger_event('core.viewtopic_get_post_data', compact($vars))); + $sql = $db->sql_build_query('SELECT', $sql_ary); $result = $db->sql_query($sql); @@ -1063,7 +1073,7 @@ while ($row = $db->sql_fetchrow($result)) { if ($poster_id == ANONYMOUS) { - $user_cache[$poster_id] = array( + $user_cache_data = array( 'joined' => '', 'posts' => '', 'from' => '', @@ -1098,6 +1108,20 @@ while ($row = $db->sql_fetchrow($result)) 'allow_pm' => 0, ); + /** + * Modify the guest user's data displayed with the posts + * + * @event core.viewtopic_cache_guest_data + * @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 + */ + $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']); } else @@ -1112,7 +1136,7 @@ while ($row = $db->sql_fetchrow($result)) $id_cache[] = $poster_id; - $user_cache[$poster_id] = array( + $user_cache_data = array( 'joined' => $user->format_date($row['user_regdate']), 'posts' => $row['user_posts'], 'warnings' => (isset($row['user_warnings'])) ? $row['user_warnings'] : 0, @@ -1150,6 +1174,20 @@ while ($row = $db->sql_fetchrow($result)) 'author_profile' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour']), ); + /** + * Modify the users' data displayed with their posts + * + * @event core.viewtopic_cache_user_data + * @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 + */ + $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']); if ((!empty($row['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_email')) @@ -1314,6 +1352,16 @@ if (sizeof($attach_list)) } } +$template->assign_vars(array( + 'S_HAS_ATTACHMENTS' => !empty($attachments), +)); + +$methods = phpbb_gen_download_links('topic_id', $topic_id, $phpbb_root_path, $phpEx); +foreach ($methods as $method) +{ + $template->assign_block_vars('dl_method', $method); +} + // Instantiate BBCode if need be if ($bbcode_bitfield !== '') { @@ -1493,7 +1541,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) ))); // - $postrow = array( + $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']), 'POST_AUTHOR_COLOUR' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_colour'] : get_username_string('colour', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_username'] : get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), @@ -1556,6 +1604,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'POSTER_ID' => $poster_id, '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_approved']) ? false : true, 'S_POST_REPORTED' => ($row['post_reported'] && $auth->acl_get('m_report', $forum_id)) ? true : false, 'S_DISPLAY_NOTICE' => $display_notice && $row['post_attachment'], @@ -1569,13 +1618,28 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'L_IGNORE_POST' => ($row['hide_post']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), '<a href="' . $viewtopic_url . "&p={$row['post_id']}&view=show#p{$row['post_id']}" . '">', '</a>') : '', ); + $user_poster_data = $user_cache[$poster_id]; + + /** + * Modify the posts template block + * + * @event core.viewtopic_modify_post_row + * @var array row Array with original post and user data + * @var array cp_row Custom profile field data of the poster + * @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 + */ + $vars = array('row', 'cp_row', 'user_poster_data', 'post_row'); + extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_post_row', compact($vars))); + if (isset($cp_row['row']) && sizeof($cp_row['row'])) { - $postrow = array_merge($postrow, $cp_row['row']); + $post_row = array_merge($post_row, $cp_row['row']); } // Dump vars into template - $template->assign_block_vars('postrow', $postrow); + $template->assign_block_vars('postrow', $post_row); if (!empty($cp_row['blockrow'])) { @@ -1594,6 +1658,12 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'DISPLAY_ATTACHMENT' => $attachment) ); } + + $methods = phpbb_gen_download_links('post_msg_id', $row['post_id'], $phpbb_root_path, $phpEx); + foreach ($methods as $method) + { + $template->assign_block_vars('postrow.dl_method', $method); + } } $prev_post_id = $row['post_id']; @@ -1729,8 +1799,23 @@ if (!request_var('t', 0) && !empty($topic_id)) $request->overwrite('t', $topic_id); } +$page_title = $topic_data['topic_title'] . ($start ? ' - ' . sprintf($user->lang['PAGE_TITLE_NUMBER'], floor($start / $config['posts_per_page']) + 1) : ''); + +/** +* 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 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 +*/ +$vars = array('page_title', 'topic_data', 'forum_id', 'start'); +extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_page_title', compact($vars))); + // Output the page -page_header($topic_data['topic_title'] . ($start ? ' - ' . sprintf($user->lang['PAGE_TITLE_NUMBER'], floor($start / $config['posts_per_page']) + 1) : ''), true, $forum_id); +page_header($page_title, true, $forum_id); $template->set_filenames(array( 'body' => ($view == 'print') ? 'viewtopic_print.html' : 'viewtopic_body.html') |