From c1fc6dce16cf70a690bd02fd6bbb501527c6b7c4 Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Tue, 19 Nov 2002 18:55:23 +0000 Subject: [PATCH] Further layout faffing, nav links for viewtopic (code needs merging with viewforum/posting), moderators for viewtopic git-svn-id: file:///svn/phpbb/trunk@3063 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 57 +++++++++ phpBB/includes/page_header.php | 94 +++++++-------- phpBB/includes/page_tail.php | 2 +- phpBB/language/en/lang_main.php | 1 + phpBB/templates/subSilver/viewforum_body.html | 37 ++++-- .../subSilver/viewforum_subforum.html | 25 +++- phpBB/templates/subSilver/viewtopic_body.html | 14 ++- phpBB/viewtopic.php | 110 +++++++++++++----- 8 files changed, 244 insertions(+), 96 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index ccff70652e..5154681472 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -80,6 +80,63 @@ function get_forum_branch($forum_id, $type = 'all', $order = 'descending', $incl return $rows; } +// Create forum navigation links for given forum, create parent +// list if currently null, assign basic forum info to template +function generate_forum_nav(&$forum_data) +{ + global $db, $user, $template; + + // Get forum parents + $forum_parents = array(); + if ($forum_data['parent_id'] > 0) + { + if (empty($forum_data['forum_parents'])) + { + $sql = 'SELECT forum_id, forum_name + FROM ' . FORUMS_TABLE . ' + WHERE left_id < ' . $forum_data['left_id'] . ' + AND right_id > ' . $forum_data['right_id'] . ' + ORDER BY left_id ASC'; + + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) + { + $forum_parents[$row['forum_id']] = $row['forum_name']; + } + + $sql = 'UPDATE ' . FORUMS_TABLE . " + SET forum_parents = '" . sql_escape(serialize($forum_parents)) . "' + WHERE parent_id = " . $forum_data['parent_id']; + $db->sql_query($sql); + } + else + { + $forum_parents = unserialize($forum_data['forum_parents']); + } + } + + // Build navigation links + foreach ($forum_parents as $parent_forum_id => $parent_name) + { + $template->assign_block_vars('navlinks', array( + 'FORUM_NAME' => $parent_name, + 'U_VIEW_FORUM' => 'viewforum.' . $phpEx . $SID . '&f=' . $parent_forum_id + )); + } + $template->assign_block_vars('navlinks', array( + 'FORUM_NAME' => $forum_data['forum_name'], + 'U_VIEW_FORUM' => 'viewforum.' . $phpEx . $SID . '&f=' . $forum_id + )); + + $template->assign_vars(array( + 'FORUM_ID' => $forum_id, + 'FORUM_NAME' => $forum_data['forum_name'], + 'FORUM_DESC' => strip_tags($forum_data['forum_desc']) + )); + + return; +} + // Obtain list of moderators of each forum function get_moderators(&$forum_moderators, $forum_id = false) { diff --git a/phpBB/includes/page_header.php b/phpBB/includes/page_header.php index 3b19edad65..8805456cd4 100644 --- a/phpBB/includes/page_header.php +++ b/phpBB/includes/page_header.php @@ -19,7 +19,7 @@ * ***************************************************************************/ -if ( !defined('IN_PHPBB') ) +if (!defined('IN_PHPBB')) { die('Hacking attempt'); } @@ -27,28 +27,28 @@ if ( !defined('IN_PHPBB') ) define('HEADER_INC', TRUE); // gzip_compression -if ( $config['gzip_compress'] ) +if ($config['gzip_compress']) { - if ( extension_loaded('zlib') && strstr($HTTP_USER_AGENT,'compatible') && !headers_sent() ) + if (extension_loaded('zlib') && strstr($HTTP_USER_AGENT,'compatible') && !headers_sent()) { ob_start('ob_gzhandler'); } } // Generate logged in/logged out status -if ( $user->data['user_id'] ) +if ($user->data['user_id'] != ANONYMOUS) { $u_login_logout = 'login.'.$phpEx. $SID . '&logout=true'; - $l_login_logout = $user->lang['Logout'] . ' [ ' . $user->data['username'] . ' ]'; + $l_login_logout = $user->lang['LOGOUT'] . ' [ ' . $user->data['username'] . ' ]'; } else { $u_login_logout = 'login.'.$phpEx . $SID; - $l_login_logout = $user->lang['Login']; + $l_login_logout = $user->lang['LOGIN']; } // Last visit date/time -$s_last_visit = ( $user->data['user_id'] ) ? $user->format_date($user->data['session_last_visit']) : ''; +$s_last_visit = ($user->data['user_id']) ? $user->format_date($user->data['session_last_visit']) : ''; // Get users online list $userlist_ary = array(); @@ -63,33 +63,33 @@ $prev_user_id = 0; $prev_user_ip = ''; $reading_sql = ''; -if ( !empty($_GET['f']) || !empty($_GET['t']) ) +if (!empty($_GET['f']) || !empty($_GET['t'])) { - $reading_sql = "AND s.session_page LIKE '%" . ( ( !empty($_GET['t']) ) ? 't=' . intval($_GET['t']) : 'f=' . intval($_GET['f']) ) . "%'"; + $reading_sql = "AND s.session_page LIKE '%" . ((!empty($_GET['t'])) ? 't=' . intval($_GET['t']) : 'f=' . intval($_GET['f'])) . "%'"; } $sql = "SELECT u.username, u.user_id, u.user_allow_viewonline, u.user_colour, s.session_ip FROM " . USERS_TABLE . " u, " . SESSIONS_TABLE ." s - WHERE s.session_time >= ".( time() - 300 ) . " + WHERE s.session_time >= ".(time() - 300) . " $reading_sql AND u.user_id = s.session_user_id ORDER BY u.username ASC, s.session_ip ASC"; $result = $db->sql_query($sql, false); -while( $row = $db->sql_fetchrow($result) ) +while ($row = $db->sql_fetchrow($result)) { // User is logged in and therefor not a guest if ($row['user_id'] != ANONYMOUS) { // Skip multiple sessions for one user - if ( $row['user_id'] != $prev_user_id ) + if ($row['user_id'] != $prev_user_id) { - if ( $row['user_colour'] ) + if ($row['user_colour']) { $row['username'] = '' . $row['username'] . ''; } - if ( $row['user_allow_viewonline'] ) + if ($row['user_allow_viewonline']) { $user_online_link = '' . $row['username'] . ''; $logged_visible_online++; @@ -100,9 +100,9 @@ while( $row = $db->sql_fetchrow($result) ) $logged_hidden_online++; } - if ( $row['user_allow_viewonline'] || $auth->acl_get('a_') ) + if ($row['user_allow_viewonline'] || $auth->acl_get('a_')) { - $online_userlist .= ( $online_userlist != '' ) ? ', ' . $user_online_link : $user_online_link; + $online_userlist .= ($online_userlist != '') ? ', ' . $user_online_link : $user_online_link; } } @@ -111,7 +111,7 @@ while( $row = $db->sql_fetchrow($result) ) else { // Skip multiple sessions for one user - if ( $row['session_ip'] != $prev_session_ip ) + if ($row['session_ip'] != $prev_session_ip) { $guests_online++; } @@ -120,24 +120,24 @@ while( $row = $db->sql_fetchrow($result) ) $prev_session_ip = $row['session_ip']; } -if ( empty($online_userlist) ) +if (empty($online_userlist)) { $online_userlist = $user->lang['None']; } -if ( empty($_GET['f']) ) +if (empty($_GET['f'])) { $online_userlist = $user->lang['Registered_users'] . ' ' . $online_userlist; } else { - $l_online = ( $guests_online == 1 ) ? $user->lang['Browsing_forum_guest'] : $user->lang['Browsing_forum_guests']; + $l_online = ($guests_online == 1) ? $user->lang['Browsing_forum_guest'] : $user->lang['Browsing_forum_guests']; $online_userlist = sprintf($l_online, $online_userlist, $guests_online); } $total_online_users = $logged_visible_online + $logged_hidden_online + $guests_online; -if ( $total_online_users > $config['record_online_users']) +if ($total_online_users > $config['record_online_users']) { $config['record_online_users'] = $total_online_users; $config['record_online_date'] = time(); @@ -153,11 +153,11 @@ if ( $total_online_users > $config['record_online_users']) $db->sql_query($sql); } -if ( $total_online_users == 0 ) +if ($total_online_users == 0) { $l_t_user_s = $user->lang['Online_users_zero_total']; } -else if ( $total_online_users == 1 ) +else if ($total_online_users == 1) { $l_t_user_s = $user->lang['Online_user_total']; } @@ -166,11 +166,11 @@ else $l_t_user_s = $user->lang['Online_users_total']; } -if ( $logged_visible_online == 0 ) +if ($logged_visible_online == 0) { $l_r_user_s = $user->lang['Reg_users_zero_total']; } -else if ( $logged_visible_online == 1 ) +else if ($logged_visible_online == 1) { $l_r_user_s = $user->lang['Reg_user_total']; } @@ -179,11 +179,11 @@ else $l_r_user_s = $user->lang['Reg_users_total']; } -if ( $logged_hidden_online == 0 ) +if ($logged_hidden_online == 0) { $l_h_user_s = $user->lang['Hidden_users_zero_total']; } -else if ( $logged_hidden_online == 1 ) +else if ($logged_hidden_online == 1) { $l_h_user_s = $user->lang['Hidden_user_total']; } @@ -192,11 +192,11 @@ else $l_h_user_s = $user->lang['Hidden_users_total']; } -if ( $guests_online == 0 ) +if ($guests_online == 0) { $l_g_user_s = $user->lang['Guest_users_zero_total']; } -else if ( $guests_online == 1 ) +else if ($guests_online == 1) { $l_g_user_s = $user->lang['Guest_user_total']; } @@ -215,10 +215,10 @@ if ($user->data['user_id'] != ANONYMOUS) { if ($user->data['user_new_privmsg']) { - $l_message_new = ( $user->data['user_new_privmsg'] == 1 ) ? $user->lang['New_pm'] : $user->lang['New_pms']; + $l_message_new = ($user->data['user_new_privmsg'] == 1) ? $user->lang['New_pm'] : $user->lang['New_pms']; $l_privmsgs_text = sprintf($l_message_new, $user->data['user_new_privmsg']); - if ( $user->data['user_last_privmsg'] > $user->data['session_last_visit'] ) + if ($user->data['user_last_privmsg'] > $user->data['session_last_visit']) { $sql = "UPDATE " . USERS_TABLE . " SET user_last_privmsg = " . $user->data['session_last_visit'] . " @@ -238,9 +238,9 @@ if ($user->data['user_id'] != ANONYMOUS) $s_privmsg_new = 0; } - if ( $user->data['user_unread_privmsg'] ) + if ($user->data['user_unread_privmsg']) { - $l_message_unread = ( $user->data['user_unread_privmsg'] == 1 ) ? $user->lang['Unread_pm'] : $user->lang['Unread_pms']; + $l_message_unread = ($user->data['user_unread_privmsg'] == 1) ? $user->lang['Unread_pm'] : $user->lang['Unread_pms']; $l_privmsgs_text_unread = sprintf($l_message_unread, $user->data['user_unread_privmsg']); } else @@ -248,27 +248,21 @@ if ($user->data['user_id'] != ANONYMOUS) $l_privmsgs_text_unread = $user->lang['No_unread_pm']; } } -else -{ - $l_privmsgs_text = $user->lang['Login_check_pm']; - $l_privmsgs_text_unread = ''; - $s_privmsg_new = 0; -} // Generate HTML required for Mozilla Navigation bar $nav_links_html = ''; /* $nav_link_proto = '' . "\n"; -foreach ( $nav_links as $nav_item => $nav_array ) +foreach ($nav_links as $nav_item => $nav_array) { - if ( !empty($nav_array['url']) ) + if (!empty($nav_array['url'])) { $nav_links_html .= sprintf($nav_link_proto, $nav_item, $nav_array['url'], $nav_array['title']); } else { // We have a nested array, used for items like that can occur more than once. - foreach ( $nav_array as $key => $nested_array ) + foreach ($nav_array as $key => $nested_array) { $nav_links_html .= sprintf($nav_link_proto, $nav_item, $nested_array['url'], $nested_array['title']); } @@ -291,12 +285,7 @@ $template->assign_vars(array( 'PRIVATE_MESSAGE_NEW_FLAG' => $s_privmsg_new, 'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread, - 'L_USERNAME' => $user->lang['Username'], - 'L_PASSWORD' => $user->lang['Password'], 'L_LOGIN_LOGOUT' => $l_login_logout, - 'L_LOGIN' => $user->lang['Login'], - 'L_LOG_ME_IN' => $user->lang['Log_me_in'], - 'L_AUTO_LOGIN' => $user->lang['Log_me_in'], 'L_INDEX' => $user->lang['Forum_Index'], 'L_FAQ' => $user->lang['FAQ'], 'L_REGISTER' => $user->lang['Register'], @@ -305,10 +294,7 @@ $template->assign_vars(array( 'L_PRIVATEMSGS' => $user->lang['Private_Messages'], 'L_MEMBERLIST' => $user->lang['Memberlist'], 'L_USERGROUPS' => $user->lang['Usergroups'], - 'L_SEARCH_NEW' => $user->lang['Search_new'], - 'L_SEARCH_SELF' => $user->lang['Search_your_posts'], 'L_WHO_IS_ONLINE' => $user->lang['Who_is_Online'], - 'L_SEARCH_UNANSWERED' => $user->lang['Search_unanswered'], 'U_PRIVATEMSGS' => 'privmsg.'.$phpEx.$SID.'&folder=inbox', 'U_MEMBERLIST' => 'memberlist.'.$phpEx.$SID, @@ -327,15 +313,15 @@ $template->assign_vars(array( 'U_PRIVATEMSGS_POPUP' => 'privmsg.'.$phpEx.$SID.'&mode=newpm', 'U_SEARCH_UNANSWERED' => 'search.'.$phpEx.$SID.'&search_id=unanswered', - 'S_USER_LOGGED_IN' => ( $user->data['user_id'] ) ? true : false, - 'S_USER_PM_POPUP' => ( !empty($user->data['user_popup_pm']) ) ? true : false, + 'S_USER_LOGGED_IN' => ($user->data['user_id']) ? true : false, + 'S_USER_PM_POPUP' => (!empty($user->data['user_popup_pm'])) ? true : false, 'S_USER_BROWSER' => $user->data['session_browser'], 'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'], 'S_CONTENT_ENCODING' => $user->lang['ENCODING'], 'S_CONTENT_DIR_LEFT' => $user->lang['LEFT'], 'S_CONTENT_DIR_RIGHT' => $user->lang['RIGHT'], 'S_LOGIN_ACTION' => 'login.'.$phpEx.$SID, - 'S_TIMEZONE' => ( $user->data['user_dst'] ) ? sprintf($user->lang['All_times'], $user->lang[doubleval($config['board_timezone'])], $user->lang['tz']['dst']) : sprintf($user->lang['All_times'], $user->lang[doubleval($config['board_timezone'])], ''), + 'S_TIMEZONE' => ($user->data['user_dst']) ? sprintf($user->lang['All_times'], $user->lang[doubleval($config['board_timezone'])], $user->lang['tz']['dst']) : sprintf($user->lang['All_times'], $user->lang[doubleval($config['board_timezone'])], ''), 'T_STYLESHEET_DATA' => $user->theme['css_data'], 'T_STYLESHEET_LINK' => 'templates/' . $user->theme['css_external'], @@ -343,7 +329,7 @@ $template->assign_vars(array( 'NAV_LINKS' => $nav_links_html) ); -/*if ( $config['send_encoding'] ) +/*if ($config['send_encoding']) { header ('Content-type: text/html; charset: ' . $user->lang['ENCODING']); }*/ diff --git a/phpBB/includes/page_tail.php b/phpBB/includes/page_tail.php index 732640f09c..f2ff5f8cbf 100644 --- a/phpBB/includes/page_tail.php +++ b/phpBB/includes/page_tail.php @@ -47,7 +47,7 @@ if (defined('DEBUG')) $template->assign_vars(array( 'PHPBB_VERSION' => $config['version'], - 'ADMIN_LINK' => ($auth->acl_get('a_')) ? '' . $user->lang['Admin_panel'] . '

' : '', + 'ADMIN_LINK' => ($auth->acl_get('a_')) ? sprintf($user->lang['ACP'], '', '') . '

' : '', 'DEBUG_OUTPUT' => (defined('DEBUG')) ? $debug_output : '' )); diff --git a/phpBB/language/en/lang_main.php b/phpBB/language/en/lang_main.php index 762b22a5eb..d88b2ce280 100644 --- a/phpBB/language/en/lang_main.php +++ b/phpBB/language/en/lang_main.php @@ -207,6 +207,7 @@ $lang = array_merge($lang, array( 'Rules_delete_cannot' => 'You cannot delete your posts in this forum', 'Rules_vote_can' => 'You can vote in polls in this forum', 'Rules_vote_cannot' => 'You cannot vote in polls in this forum', + 'ACP' => '[ %sAdministration Control Panel%s ]', 'MCP' => '[ %sModerator Control Panel%s ]', 'No_topics_post_one' => 'There are no posts in this forum
Click on the Post New Topic link on this page to post one', 'Stop_watching_forum' => 'Stop watching this forum', diff --git a/phpBB/templates/subSilver/viewforum_body.html b/phpBB/templates/subSilver/viewforum_body.html index 68a635f89a..85d4f35ef2 100644 --- a/phpBB/templates/subSilver/viewforum_body.html +++ b/phpBB/templates/subSilver/viewforum_body.html @@ -2,12 +2,31 @@ - - + + + + + + +
{FORUM_NAME}
{L_MODERATORS}: {MODERATORS}

{LOGGED_IN_USER_LIST}
{MOD_CP}


{PAGINATION}
{FORUM_NAME}
{L_MODERATORS}: {MODERATORS}
{MOD_CP}
{LOGGED_IN_USER_LIST}{PAGINATION}
-
+ + + + + + +
+ + + + @@ -16,10 +35,12 @@ -> {navlinks.FORUM_NAME} - +
{POST_IMG}
+ + @@ -46,9 +67,9 @@ - - - + + +
{L_NO_TOPICS}
{L_DISPLAY_TOPICS}: {S_SELECT_SORT_DAYS} {L_SORT_BY} {S_SELECT_SORT_KEY} {S_SELECT_SORT_DIR} 
{L_DISPLAY_TOPICS}: {S_SELECT_SORT_DAYS} {L_SORT_BY} {S_SELECT_SORT_KEY} {S_SELECT_SORT_DIR} 
@@ -68,6 +89,7 @@
{S_WATCH_FORUM}
+ @@ -75,6 +97,7 @@
+
diff --git a/phpBB/templates/subSilver/viewforum_subforum.html b/phpBB/templates/subSilver/viewforum_subforum.html index 0acde8d353..0efd298888 100644 --- a/phpBB/templates/subSilver/viewforum_subforum.html +++ b/phpBB/templates/subSilver/viewforum_subforum.html @@ -13,11 +13,32 @@ - + -
{forumrow.FORUM_FOLDER_IMG}{forumrow.FORUM_NAME}
{forumrow.FORUM_DESC}
{L_MODERATORS}: {forumrow.MODERATORS}
{forumrow.L_SUBFORUM} {forumrow.SUBFORUMS}
{forumrow.FORUM_NAME}
{forumrow.FORUM_DESC}
{L_MODERATORS}: {forumrow.MODERATORS}

{forumrow.L_SUBFORUM} {forumrow.SUBFORUMS}
{forumrow.TOPICS} {forumrow.POSTS} {forumrow.LAST_POST}
\ No newline at end of file +
+ + + +
+ + + + + + + +
{POST_IMG}
+ + +
+ + diff --git a/phpBB/templates/subSilver/viewtopic_body.html b/phpBB/templates/subSilver/viewtopic_body.html index d2a1480868..83a081bf74 100644 --- a/phpBB/templates/subSilver/viewtopic_body.html +++ b/phpBB/templates/subSilver/viewtopic_body.html @@ -1,15 +1,19 @@ - +
- + + + + +
{TOPIC_TITLE}
{MOD_CP}

{TOPIC_TITLE}
{L_MODERATORS}: {MODERATORS}
{MOD_CP}
{PAGINATION}
- - + +
{POST_IMG}   {REPLY_IMG}   {L_INDEX} -> {FORUM_NAME}{POST_IMG}   {REPLY_IMG}
@@ -130,7 +134,7 @@ - + diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 678f4ffff9..84a5ecd398 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -44,32 +44,27 @@ if (isset($_GET['view']) && empty($post_id)) { if ($_GET['view'] == 'newest') { - if (!empty($_COOKIE[$config['cookie_name'] . '_sid']) || !empty($_GET['sid'])) + if ($user->session_id) { - $session_id = (!empty($_COOKIE[$config['cookie_name'] . '_sid'])) ? $_COOKIE[$config['cookie_name'] . '_sid'] : $_GET['sid']; + $sql = "SELECT p.post_id + FROM " . POSTS_TABLE . " p, " . SESSIONS_TABLE . " s, " . USERS_TABLE . " u + WHERE s.session_id = '$user->session_id' + AND u.user_id = s.session_user_id + AND p.topic_id = $topic_id + AND p.post_approved = 1 + AND p.post_time >= u.user_lastvisit + ORDER BY p.post_time ASC + LIMIT 1"; + $result = $db->sql_query($sql); - if ($session_id) + if (!($row = $db->sql_fetchrow($result))) { - $sql = "SELECT p.post_id - FROM " . POSTS_TABLE . " p, " . SESSIONS_TABLE . " s, " . USERS_TABLE . " u - WHERE s.session_id = '$session_id' - AND u.user_id = s.session_user_id - AND p.topic_id = $topic_id - AND p.post_approved = 1 - AND p.post_time >= u.user_lastvisit - ORDER BY p.post_time ASC - LIMIT 1"; - $result = $db->sql_query($sql); - - if (!($row = $db->sql_fetchrow($result))) - { - trigger_error('No_new_posts_last_visit'); - } - - $post_id = $row['post_id']; - $newest_post_id = $post_id; -// redirect("viewtopic.$phpEx$SID&p=$post_id#$post_id"); + trigger_error('No_new_posts_last_visit'); } + + $post_id = $row['post_id']; + $newest_post_id = $post_id; +// redirect("viewtopic.$phpEx$SID&p=$post_id#$post_id"); } // redirect("index.$phpEx"); @@ -131,13 +126,18 @@ if ($user->data['user_id'] != ANONYMOUS) } } + +// Look at this query ... perhaps a re-think? Perhaps store topic ids rather +// than last/first post ids and have a redirect at the top of this page +// for latest post, newest post for a given topic_id? + // This rather complex gaggle of code handles querying for topics but // also allows for direct linking to a post (and the calculation of which // page the post is on and the correct display of viewtopic) $join_sql_table = (!$post_id) ? '' : ', ' . POSTS_TABLE . ' p, ' . POSTS_TABLE . ' p2 '; $join_sql = (!$post_id) ? "t.topic_id = $topic_id" : "p.post_id = $post_id AND p.post_approved = " . TRUE . " AND t.topic_id = p.topic_id AND p2.topic_id = p.topic_id AND p2.post_approved = " . TRUE . " AND p2.post_id <= $post_id"; $extra_fields = (!$post_id) ? '' : ", COUNT(p2.post_id) AS prev_posts"; -$order_sql = (!$post_id) ? '' : "GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, f.forum_name, f.forum_status, f.forum_id, f.forum_style ORDER BY p.post_id ASC"; +$order_sql = (!$post_id) ? '' : "GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, f.forum_name, f.forum_desc, f.forum_parents, f.parent_id, f.left_id, f.right_id, f.forum_status, f.forum_id, f.forum_style ORDER BY p.post_id ASC"; if ($user->data['user_id'] != ANONYMOUS) { @@ -153,7 +153,7 @@ if ($user->data['user_id'] != ANONYMOUS) } } -$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.poll_start, t.poll_length, t.poll_title, f.forum_name, f.forum_status, f.forum_id, f.forum_style" . $extra_fields . " +$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.poll_start, t.poll_length, t.poll_title, f.forum_name, f.forum_desc, f.forum_parents, f.parent_id, f.left_id, f.right_id, f.forum_status, f.forum_id, f.forum_style" . $extra_fields . " FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f" . $join_sql_table . " WHERE $join_sql AND f.forum_id = t.forum_id @@ -165,6 +165,9 @@ if (!extract($db->sql_fetchrow($result))) trigger_error('Topic_post_not_exist'); } + + + // Configure style, language, etc. $user->setup(false, intval($forum_style)); $auth->acl($user->data, intval($forum_id)); @@ -184,6 +187,9 @@ if (!$auth->acl_gets('f_read', 'm_', 'a_', intval($forum_id))) } // End auth check + + + if (!empty($post_id)) { $start = floor(($prev_posts - 1) / $config['posts_per_page']) * $config['posts_per_page']; @@ -297,9 +303,7 @@ if ($user->data['user_id'] != ANONYMOUS) $rating = ''; } -// Was a highlight request part of the URI? Yes, this idea was -// taken from vB but we did already have a highlighter in place -// in search itself ... it's just been extended a bit! +// Was a highlight request part of the URI? $highlight_match = ''; if (isset($_GET['highlight'])) { @@ -361,15 +365,67 @@ if (count($orig_word)) $topic_title = preg_replace($orig_word, $replacement_word, $topic_title); } + + + +// Navigation links ... common to several scripts so we need +// to look at centralising this ... major issue is variable naming +// complicated particularly by viewtopic ... +if ($parent_id > 0) +{ + if (empty($forum_parents)) + { + $sql = 'SELECT forum_id, forum_name + FROM ' . FORUMS_TABLE . ' + WHERE left_id < ' . $left_id . ' + AND right_id > ' . $right_id . ' + ORDER BY left_id ASC'; + + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) + { + $forum_parents[$row['forum_id']] = $row['forum_name']; + } + + $sql = 'UPDATE ' . FORUMS_TABLE . " + SET forum_parents = '" . sql_escape(serialize($forum_parents)) . "' + WHERE parent_id = " . $parent_id; + $db->sql_query($sql); + } + else + { + $forum_parents = unserialize($forum_parents); + } +} + +// Build navigation links +foreach ($forum_parents as $parent_forum_id => $parent_name) +{ + $template->assign_block_vars('navlinks', array( + 'FORUM_NAME' => $parent_name, + 'U_VIEW_FORUM' => 'viewforum.' . $phpEx . $SID . '&f=' . $parent_forum_id + )); +} +$template->assign_block_vars('navlinks', array( + 'FORUM_NAME' => $forum_name, + 'U_VIEW_FORUM' => 'viewforum.' . $phpEx . $SID . '&f=' . $forum_id +)); + +// Moderators +$forum_moderators = array(); +get_moderators($forum_moderators, $forum_id); + // Send vars to template $template->assign_vars(array( 'FORUM_ID' => $forum_id, 'FORUM_NAME' => $forum_name, + 'FORUM_DESC' => strip_tags($forum_desc), 'TOPIC_ID' => $topic_id, 'TOPIC_TITLE' => $topic_title, 'PAGINATION' => $pagination, 'PAGE_NUMBER' => sprintf($user->lang['Page_of'], (floor($start / $config['posts_per_page']) + 1), ceil($topic_replies / $config['posts_per_page'])), 'MOD_CP' => ($auth->acl_gets('m_', 'a_', $forum_id)) ? sprintf($user->lang['MCP'], '', '') : '', + 'MODERATORS' => (sizeof($forum_moderators[$forum_id])) ? implode(', ', $forum_moderators[$forum_id]) : $user->lang['None'], 'POST_IMG' => $post_img, 'REPLY_IMG' => $reply_img,
{POST_IMG}   {REPLY_IMG}   {L_INDEX} -> {FORUM_NAME} {S_TIMEZONE}
{PAGINATION}