diff --git a/phpBB/admin/admin_forums.php b/phpBB/admin/admin_forums.php
index 1f74bb0bf9..a15fb902c6 100644
--- a/phpBB/admin/admin_forums.php
+++ b/phpBB/admin/admin_forums.php
@@ -231,7 +231,7 @@ switch ($mode)
'prune_enable' => (!empty($_POST['prune_enable'])) ? 1 : 0,
'prune_days' => intval($_POST['prune_days']),
'prune_freq' => intval($_POST['prune_freq']),
- 'display_on_index' => (!empty($_POST['display_on_index'])) ? 0 : 1,
+ 'display_on_index' => (!isset($_POST['display_on_index']) || !empty($_POST['display_on_index'])) ? 1 : 0,
'post_count_inc' => (!empty($_POST['disable_post_count'])) ? 0 : 1
);
@@ -477,12 +477,21 @@ switch ($mode)
/>
0)
{
+ //
+ // if this forum is a subforum put the "display on index" checkbox
+ //
+ if ($parent_info = get_forum_info($parent_id))
+ {
+ if ($parent_info['parent_id'] > 0 || $parent_info['forum_status'] != ITEM_CATEGORY)
+ {
?>
-
- />
+
+ />
diff --git a/phpBB/db/mysql.php b/phpBB/db/mysql.php
index 5286b215ad..12ce33aed7 100644
--- a/phpBB/db/mysql.php
+++ b/phpBB/db/mysql.php
@@ -30,6 +30,8 @@ class sql_db
var $query_result;
var $return_on_error = false;
var $transaction = false;
+ var $sql_report = '';
+ var $sql_time = 0;
//
// Constructor
@@ -63,14 +65,14 @@ class sql_db
//
function sql_close()
{
- if ( !$this->db_connect_id )
+ if (!$this->db_connect_id)
{
return false;
}
- if ( count($this->open_queries) )
+ if (count($this->open_queries))
{
- foreach($this->open_queries as $query_id)
+ foreach ($this->open_queries as $query_id)
{
@mysql_free_result($query_id);
}
@@ -117,15 +119,60 @@ class sql_db
//
function sql_query($query = '', $transaction = false)
{
- if ( $query != '' )
+ if ($query != '')
{
$this->query_result = false;
$this->num_queries++;
- if ( !($this->query_result = @mysql_query($query, $this->db_connect_id)) )
+ if (!empty($_REQUEST['explain']))
+ {
+ global $starttime;
+ $curtime = explode(' ', microtime());
+ $curtime = $curtime[0] + $curtime[1] - $starttime;
+ }
+ if (!$this->query_result = @mysql_query($query, $this->db_connect_id))
{
$this->sql_error($query);
}
+ if (!empty($_REQUEST['explain']))
+ {
+ $endtime = explode(' ', microtime());
+ $endtime = $endtime[0] + $endtime[1] - $starttime;
+
+ $this->sql_report .= "Query:\t" . preg_replace('/[\s]*[\n\r\t]+[\n\r\s\t]*/', "\n\t", $query) . "\n\n";
+ if ($this->query_result)
+ {
+ $this->sql_report .= "Time before: $curtime\nTime after: $endtime\nElapsed time: " . ($endtime - $curtime) . " \n ";
+ }
+ else
+ {
+ $error = $this->sql_error();
+ $this->sql_report .= 'FAILED - MySQL Error ' . $error['code'] . ': ' . $error['message'] . '';
+ }
+ $this->sql_time += $endtime - $curtime;
+ if (preg_match('/^SELECT/', $query))
+ {
+ $html_table = FALSE;
+ if ($result = mysql_query("EXPLAIN $query", $this->db_connect_id))
+ {
+ while ($row = mysql_fetch_assoc($result))
+ {
+ if (!$html_table && count($row))
+ {
+ $html_table = TRUE;
+ $this->sql_report .= " \n";
+ $this->sql_report .= "\n" . implode(" \n", array_keys($row)) . " \n \n";
+ }
+ $this->sql_report .= "\n" . implode(" \n", array_values($row)) . " \n \n";
+ }
+ }
+ if ($html_table)
+ {
+ $this->sql_report .= '
';
+ }
+ }
+ $this->sql_report .= " \n";
+ }
$this->open_queries[] = $this->query_result;
}
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index aa7feba656..9b3d079e31 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -583,6 +583,29 @@ function on_page($num_items, $per_page, $start)
return sprintf($lang['Page_of'], floor( $start / $per_page ) + 1, max(ceil( $num_items / $per_page ), 1) );
}
+function format_subforums_list($subforums)
+{
+ if (empty($subforums))
+ {
+ return '';
+ }
+
+ global $phpEx, $SID;
+ foreach ($subforums as $row)
+ {
+ $alist[$row['forum_id']] = $row['forum_name'];
+ }
+ asort($alist);
+
+ $links = array();
+ foreach ($alist as $forum_id => $forum_name)
+ {
+ $links[] = '' . htmlspecialchars($forum_name) . ' ';
+ }
+
+ return implode(', ', $links);
+}
+
//
// Obtain list of naughty words and build preg style replacement arrays for use by the
// calling script, note that the vars are passed as references this just makes it easier
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index efab3f4550..bae5a9674c 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -1,6 +1,6 @@
#');
$html_entities_replace = array('&', '<', '>');
diff --git a/phpBB/includes/page_tail.php b/phpBB/includes/page_tail.php
index a4441ac38a..1c91e48399 100644
--- a/phpBB/includes/page_tail.php
+++ b/phpBB/includes/page_tail.php
@@ -19,21 +19,28 @@
*
***************************************************************************/
-if ( !defined('IN_PHPBB') )
-{
- die('Hacking attempt');
-}
+//
+// Close our DB connection.
+//
+$db->sql_close();
//
// Output page creation time
//
-if ( defined('DEBUG') )
+if (defined('DEBUG'))
{
- $mtime = microtime();
- $mtime = explode(' ', $mtime);
- $totaltime = ( $mtime[1] + $mtime[0] ) - $starttime;
+ $mtime = explode(' ', microtime());
+ $totaltime = $mtime[0] + $mtime[1] - $starttime;
- $debug_output = sprintf(' [ Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . ( ( $board_config['gzip_compress'] ) ? 'On' : 'Off' ) . ' | Load : ' . ( ( $session->load ) ? $session->load : 'N/A') . ' ]', $totaltime);
+ if (!empty($_REQUEST['explain']))
+ {
+ echo $db->sql_report;
+ echo "Page generated in $totaltime seconds with " . $db->num_queries . " queries,\nspending " . $db->sql_time . ' doing MySQL queries and ' . ($totaltime - $db->sql_time) . ' doing PHP things. ';
+
+ exit;
+ }
+
+ $debug_output = sprintf(' [ Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . ( ( $board_config['gzip_compress'] ) ? 'On' : 'Off' ) . ' | Load : ' . ( ( $session->load ) ? $session->load : 'N/A') . ' | Explain ]', $totaltime);
}
$template->assign_vars(array(
@@ -44,11 +51,5 @@ $template->assign_vars(array(
$template->display('body');
-//
-// Close our DB connection.
-//
-$db->sql_close();
-
exit;
-
?>
\ No newline at end of file
diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php
index 70d6053517..e8bb63e56b 100644
--- a/phpBB/includes/template.php
+++ b/phpBB/includes/template.php
@@ -171,9 +171,15 @@ class Template {
*/
function display($handle)
{
+ if (!empty($_REQUEST['explain']))
+ {
+ global $db;
+ echo $this->sql_report();
+ return TRUE;
+ }
$_str = '';
- if ( !($this->compile_load($_str, $handle, true)) )
+ if (!$this->compile_load($_str, $handle, true))
{
if ( !$this->loadfile($handle) )
{
diff --git a/phpBB/index.php b/phpBB/index.php
index f332bfb94c..80450d014a 100644
--- a/phpBB/index.php
+++ b/phpBB/index.php
@@ -24,12 +24,9 @@ $phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
-$viewcat = (!empty($HTTP_GET_VARS['c'])) ? intval($HTTP_GET_VARS['c']) : -1;
-$forum_id = (!empty($HTTP_GET_VARS['f'])) ? intval($HTTP_GET_VARS['f']) : 0;
-
-if (isset($HTTP_GET_VARS['mark']) || isset($HTTP_POST_VARS['mark']))
+if (isset($_GET['mark']) || isset($_POST['mark']))
{
- $mark_read = (isset($HTTP_POST_VARS['mark'])) ? $HTTP_POST_VARS['mark'] : $HTTP_GET_VARS['mark'];
+ $mark_read = (isset($_POST['mark'])) ? $_POST['mark'] : $_GET['mark'];
}
else
{
@@ -77,7 +74,6 @@ $mark_forums = (isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f'])) ?
//
// Set some stats, get posts count from forums data if we... hum... retrieve all forums data
//
-$total_posts = 0;
$total_users = $board_config['num_users'];
$newest_user = $board_config['newest_username'];
$newest_uid = $board_config['newest_user_id'];
@@ -98,182 +94,116 @@ else
$forum_moderators = array();
get_moderators($forum_moderators);
-$branch_root_id = 0;
+$cat_id = (!empty($_GET['c'])) ? intval($_GET['c']) : 0;
+$root_id = $branch_root_id = $cat_id;
$forum_rows = $subforums = array();
-$result = $db->sql_query('SELECT * FROM ' . FORUMS_TABLE . ' ORDER BY left_id');
+if ($cat_id == 0)
+{
+ $total_posts = 0;
+ switch (SQL_LAYER)
+ {
+ case 'oracle':
+ $sql = 'SELECT f.*, u.username
+ FROM ' . FORUMS_TABLE . ' f, ' . USERS_TABLE . 'u
+ WHERE f.forum_last_poster_id = u.user_id(+)
+ ORDER BY f.left_id';
+ break;
+
+ default:
+ $sql = 'SELECT f.*, u.username
+ FROM ' . FORUMS_TABLE . ' f
+ LEFT JOIN ' . USERS_TABLE . ' u ON f.forum_last_poster_id = u.user_id
+ ORDER BY f.left_id';
+ }
+}
+else
+{
+ if (!$acl->get_acl($cat_id, 'forum', 'list'))
+ {
+ //
+ // TODO: Deal with hidden categories
+ //
+ message_die(ERROR, $lang['Category_not_exist']);
+ }
+
+ $sql = 'SELECT SUM(forum_posts) AS total
+ FROM ' . FORUMS_TABLE . '
+ WHERE post_count_inc = 1
+ AND forum_status <> ' . ITEM_CATEGORY;
+
+ $result = $db->sql_query($sql);
+ $total_posts = $db->sql_fetchfield('total', 0, $result);
+
+ //
+ // TODO: change this to get both parents and children
+ //
+ $result = $db->sql_query('SELECT left_id, right_id, parent_id FROM ' . FORUMS_TABLE . ' WHERE forum_id = ' . $cat_id);
+ $catrow = $db->sql_fetchrow($result);
+
+ switch (SQL_LAYER)
+ {
+ case 'oracle':
+ $sql = 'SELECT f.*, u.username
+ FROM ' . FORUMS_TABLE . ' f, ' . USERS_TABLE . 'u
+ WHERE (f.left_id BETWEEN ' . $catrow['left_id'] . ' AND ' . $catrow['right_id'] . '
+ AND f.forum_last_poster_id = u.user_id(+)
+ ORDER BY left_id';
+ break;
+
+ default:
+ $sql = 'SELECT f.*, u.username
+ FROM ' . FORUMS_TABLE . ' f
+ LEFT JOIN ' . USERS_TABLE . ' u ON f.forum_last_poster_id = u.user_id
+ WHERE f.left_id BETWEEN ' . $catrow['left_id'] . ' AND ' . $catrow['right_id'] . '
+ ORDER BY f.left_id';
+ }
+}
+
+$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
- if ($row['parent_id'] == 0)
+ if (!$cat_id && $row['post_count_inc'])
+ {
+ $total_posts += $row['forum_posts'];
+ }
+
+ if ($row['forum_id'] == $cat_id)
{
$forum_rows[] = $row;
+ }
+ elseif ($row['parent_id'] == $cat_id)
+ {
+ //
+ // Root-level forum
+ //
+ $forum_rows[] = $row;
+ $parent_id = $row['forum_id'];
- if ($row['forum_status'] == ITEM_CATEGORY)
+ if (!$cat_id && $row['forum_status'] == ITEM_CATEGORY)
{
$branch_root_id = $row['forum_id'];
}
- else
- {
- $branch_root_id = 0;
- }
}
elseif ($row['parent_id'] == $branch_root_id)
{
+ //
+ // Forum directly under a category
+ //
$forum_rows[] = $row;
- $forum_root_id = $row['forum_id'];
+ $parent_id = $row['forum_id'];
}
elseif ($row['display_on_index'] && $row['forum_status'] != ITEM_CATEGORY)
{
if ($acl->get_acl($row['forum_id'], 'forum', 'list'))
{
- $subforums[$forum_root_id][] = $row;
+ $subforums[$parent_id][] = $row;
}
}
}
-function format_subforums_list($subforums)
-{
- if (empty($subforums))
- {
- return '';
- }
-
- global $phpEx, $SID;
- foreach ($subforums as $row)
- {
- $alist[$row['forum_id']] = $row['forum_name'];
- }
- asort($alist);
-
- $links = array();
- foreach ($alist as $forum_id => $forum_name)
- {
- $links[] = '' . htmlspecialchars($forum_name) . ' ';
- }
-
- return implode(', ', $links);
-}
-
-foreach ($forum_rows as $row)
-{
- extract($row);
- if ($parent_id == 0)
- {
- if ($forum_status == ITEM_CATEGORY)
- {
- $branch_root_id = $forum_id;
- $stored_cat = $row;
- continue;
- }
- else
- {
- $branch_root_id = 0;
- unset($stored_cat);
- }
- }
- elseif (!empty($stored_cat))
- {
- $template->assign_block_vars('forumrow', array(
- 'S_IS_CAT' => TRUE,
- 'CAT_ID' => $stored_cat['forum_id'],
- 'CAT_NAME' => $stored_cat['forum_name'],
- 'U_VIEWCAT' => 'index.' . $phpEx . $SID . '&c=' . $stored_cat['forum_id']
- ));
- unset($stored_cat);
- }
-
- if ($acl->get_acl($forum_id, 'forum', 'list'))
- {
- if ($forum_status == ITEM_LOCKED)
- {
- $folder_image = $theme['forum_locked'];
- $folder_alt = $lang['Forum_locked'];
- }
- else
- {
- $unread_topics = false;
- if ($userdata['user_id'] && $forum_last_post_time > $userdata['user_lastvisit'])
- {
- $unread_topics = true;
- if (isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']))
- {
- if ($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all'] > $forum_last_post_time)
- {
- $unread_topics = false;
- }
- }
-
- if (isset($mark_topics[$forum_id]) || isset($mark_forums[$forum_id]))
- {
- if ($mark_forums[$forum_id] > $userdata['user_lastvisit'] || !max($mark_topics[$forum_id]))
- {
- $unread_topics = false;
- }
- }
- }
-
- $folder_image = ($unread_topics) ? $theme['forum_new'] : $theme['forum'];
- $folder_alt = ($unread_topics) ? $lang['New_posts'] : $lang['No_new_posts'];
- }
-
- if ($forum_last_post_id)
- {
- $last_post = create_date($board_config['default_dateformat'], $forum_last_post_time, $board_config['board_timezone']) . ' ';
-
- $last_post .= ($user_id == ANONYMOUS) ? (($forum_last_poster_name != '') ? $forum_last_poster_name . ' ' : $lang['Guest'] . ' ') : '' . $username . ' ';
-
- $last_post .= '' . create_img($theme['goto_post_latest'], $lang['View_latest_post']) . ' ';
- }
- else
- {
- $last_post = $lang['No_Posts'];
- }
-
- if (!empty($forum_moderators[$forum_id]))
- {
- $l_moderators = (count($forum_moderators[$forum_id]) == 1) ? $lang['Moderator'] . ':' : $lang['Moderators'] . ':' ;
- $moderator_list = implode(', ', $forum_moderators[$forum_id]);
- }
- else
- {
- $l_moderators = ' ';
- $moderator_list = ' ';
- }
-
- if (isset($subforums[$forum_id]))
- {
- $subforums_list = format_subforums_list($subforums[$forum_id]);
- $l_subforums = ' ' . (count($subforums[$forum_id]) == 1) ? $lang['Subforum'] : $lang['Subforums'];
- }
- else
- {
- $subforums_list = '';
- $l_subforums = '';
- }
-
- $template->assign_block_vars('forumrow', array(
- 'S_IS_ROOTFORUM' => TRUE,
-
- 'FORUM_FOLDER_IMG' => create_img($folder_image, $folder_alt),
- 'FORUM_NAME' => $forum_name,
- 'FORUM_DESC' => $forum_desc,
-
- 'POSTS' => $forum_posts,
- 'TOPICS' => $forum_topics,
- 'LAST_POST' => $last_post,
- 'MODERATORS' => $moderator_list,
- 'SUBFORUMS' => $subforums_list,
-
- 'FORUM_IMG' => $forum_image,
-
- 'L_SUBFORUM' => $l_subforums,
- 'L_MODERATOR' => $l_moderators,
- 'L_FORUM_FOLDER_ALT' => $folder_alt,
-
- 'U_VIEWFORUM' => 'viewforum.' . $phpEx . $SID . '&f=' . $forum_id
- ));
- }
-}
+$root_id = ($cat_id) ? $catrow['parent_id'] : 0;
+include($phpbb_root_path . 'includes/forums_display.' . $phpEx);
if ($total_posts == 0)
{
@@ -289,31 +219,32 @@ else
}
$template->assign_vars(array(
- 'TOTAL_POSTS' => sprintf($l_total_post_s, $total_posts),
- 'TOTAL_USERS' => sprintf($l_total_user_s, $total_users),
- 'NEWEST_USER' => sprintf($lang['Newest_user'], '', $newest_user, ' '),
+ 'TOTAL_POSTS' => sprintf($l_total_post_s, $total_posts),
+ 'TOTAL_USERS' => sprintf($l_total_user_s, $total_users),
+ 'NEWEST_USER' => sprintf($lang['Newest_user'], '', $newest_user, ' '),
- 'FORUM_IMG' => create_img($theme['forum'], $lang['No_new_posts']),
- 'FORUM_NEW_IMG' => create_img($theme['forum_new'], $lang['New_posts']),
- 'FORUM_LOCKED_IMG' => create_img($theme['forum_locked'], $lang['No_new_posts_locked']),
+ 'FORUM_IMG' => create_img($theme['forum'], $lang['No_new_posts']),
+ 'FORUM_NEW_IMG' => create_img($theme['forum_new'], $lang['New_posts']),
+ 'FORUM_LOCKED_IMG' => create_img($theme['forum_locked'], $lang['No_new_posts_locked']),
- 'L_FORUM' => $lang['Forum'],
- 'L_TOPICS' => $lang['Topics'],
- 'L_REPLIES' => $lang['Replies'],
- 'L_VIEWS' => $lang['Views'],
- 'L_POSTS' => $lang['Posts'],
- 'L_LASTPOST' => $lang['Last_Post'],
- 'L_NO_NEW_POSTS' => $lang['No_new_posts'],
- 'L_NEW_POSTS' => $lang['New_posts'],
- 'L_NO_NEW_POSTS_LOCKED' => $lang['No_new_posts_locked'],
- 'L_NEW_POSTS_LOCKED' => $lang['New_posts_locked'],
- 'L_ONLINE_EXPLAIN' => $lang['Online_explain'],
+ 'L_FORUM' => $lang['Forum'],
+ 'L_TOPICS' => $lang['Topics'],
+ 'L_REPLIES' => $lang['Replies'],
+ 'L_VIEWS' => $lang['Views'],
+ 'L_POSTS' => $lang['Posts'],
+ 'L_LASTPOST' => $lang['Last_Post'],
+ 'L_MODERATORS' => $lang['Moderators'],
+ 'L_NO_NEW_POSTS' => $lang['No_new_posts'],
+ 'L_NEW_POSTS' => $lang['New_posts'],
+ 'L_NO_NEW_POSTS_LOCKED' => $lang['No_new_posts_locked'],
+ 'L_NEW_POSTS_LOCKED' => $lang['New_posts_locked'],
+ 'L_ONLINE_EXPLAIN' => $lang['Online_explain'],
- 'L_VIEW_MODERATORS' => $lang['View_moderators'],
- 'L_FORUM_LOCKED' => $lang['Forum_is_locked'],
- 'L_MARK_FORUMS_READ' => $lang['Mark_all_forums'],
- 'L_LEGEND' => $lang['Legend'],
- 'L_NO_FORUMS' => $lang['No_forums'],
+ 'L_VIEW_MODERATORS' => $lang['View_moderators'],
+ 'L_FORUM_LOCKED' => $lang['Forum_is_locked'],
+ 'L_MARK_FORUMS_READ' => $lang['Mark_all_forums'],
+ 'L_LEGEND' => $lang['Legend'],
+ 'L_NO_FORUMS' => $lang['No_forums'],
'U_MARK_READ' => "index.$phpEx$SID&mark=forums")
);
diff --git a/phpBB/install/schemas/mysql_basic.sql b/phpBB/install/schemas/mysql_basic.sql
index 88d5b2ce8c..34bb1cff45 100644
--- a/phpBB/install/schemas/mysql_basic.sql
+++ b/phpBB/install/schemas/mysql_basic.sql
@@ -85,7 +85,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_server', '');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_base_dn', '');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_uid', '');
-INSERT INTO phpbb_config (config_name, config_value) VALUES ('version', '2.1.0 [20020817]');
+INSERT INTO phpbb_config (config_name, config_value) VALUES ('version', '2.1.0 [20021003]');
# -- auth options
diff --git a/phpBB/language/lang_english/lang_main.php b/phpBB/language/lang_english/lang_main.php
index d842ed8432..908fd8e56b 100644
--- a/phpBB/language/lang_english/lang_main.php
+++ b/phpBB/language/lang_english/lang_main.php
@@ -37,8 +37,8 @@ $lang['DATE_FORMAT'] = 'd M Y'; // This should be changed to the default date f
// Common, these terms are used extensively on several pages
//
$lang['Forum'] = 'Forum';
-$lang['Subforum'] = 'Subforum: ';
-$lang['Subforums'] = 'Subforums: ';
+$lang['Subforum'] = 'Subforum';
+$lang['Subforums'] = 'Subforums';
$lang['Category'] = 'Category';
$lang['Topic'] = 'Topic';
$lang['Topics'] = 'Topics';
@@ -47,6 +47,7 @@ $lang['Views'] = 'Views';
$lang['Post'] = 'Post';
$lang['Posts'] = 'Posts';
$lang['Posted'] = 'Posted';
+$lang['Rating'] = 'Rating';
$lang['Username'] = 'Username';
$lang['Password'] = 'Password';
$lang['Email'] = 'Email';
@@ -221,6 +222,7 @@ $lang['Error_login'] = 'You have specified an incorrect or inactive username or
$lang['Index'] = 'Index';
$lang['No_Posts'] = 'No Posts';
$lang['No_forums'] = 'This board has no forums';
+$lang['Category_not_exist'] = 'The category you selected does not exist';
$lang['Private_Message'] = 'Private Message';
$lang['Private_Messages'] = 'Private Messages';
diff --git a/phpBB/templates/subSilver/index_body.html b/phpBB/templates/subSilver/index_body.html
index 818c50a58c..01faf2efb8 100644
--- a/phpBB/templates/subSilver/index_body.html
+++ b/phpBB/templates/subSilver/index_body.html
@@ -4,7 +4,11 @@
@@ -13,37 +17,63 @@
- {L_FORUM}
+ {L_FORUM}
{L_TOPICS}
{L_POSTS}
- {L_LASTPOST}
+ {L_LASTPOST}
+ {L_MODERATORS}
- {forumrow.CAT_NAME}
-
+ {forumrow.CAT_NAME}
+
-
- {forumrow.FORUM_FOLDER_IMG}
- {forumrow.FORUM_NAME} {forumrow.FORUM_DESC}
-
- {forumrow.L_MODERATOR} {forumrow.MODERATORS}
-
+
+ {forumrow.FORUM_FOLDER_IMG}
+ {forumrow.FORUM_NAME} {forumrow.FORUM_DESC}
- {forumrow.L_SUBFORUM} {forumrow.SUBFORUMS}
+ {forumrow.L_SUBFORUM} {forumrow.SUBFORUMS}
-
+
{forumrow.TOPICS}
{forumrow.POSTS}
{forumrow.LAST_POST}
+ {forumrow.MODERATORS}
+
+
+
+
+
+ {forumrow.FORUM_FOLDER_IMG}
+ {forumrow.FORUM_NAME} {forumrow.FORUM_DESC}
+
+ {forumrow.L_SUBFORUM} {forumrow.SUBFORUMS}
+
+
+ {forumrow.TOPICS}
+ {forumrow.POSTS}
+ {forumrow.LAST_POST}
+ {forumrow.MODERATORS}
+
+
+
+
+
+ {forumrow.FORUM_FOLDER_IMG}
+ {forumrow.FORUM_NAME} {forumrow.FORUM_DESC}
+
+ {forumrow.L_SUBFORUM} {forumrow.SUBFORUMS}
+
+
+
- {L_NO_FORUMS}
+ {L_NO_FORUMS}
diff --git a/phpBB/templates/subSilver/viewforum_body.html b/phpBB/templates/subSilver/viewforum_body.html
index 81c98ae8b7..cb7ac4b975 100644
--- a/phpBB/templates/subSilver/viewforum_body.html
+++ b/phpBB/templates/subSilver/viewforum_body.html
@@ -11,7 +11,11 @@
{POST_IMG}
- {L_INDEX} -> {FORUM_NAME}
+ {L_INDEX}
+
+ -> {navlinks.FORUM_NAME}
+
+
{L_MARK_TOPICS_READ}
@@ -21,9 +25,9 @@
{L_TOPICS}
{L_AUTHOR}
{L_REPLIES}
- {L_VIEWS}
+ {L_VIEWS}
{L_LASTPOST}
- Rating
+ {L_RATING}
@@ -49,7 +53,11 @@
{POST_IMG}
- {L_INDEX} -> {FORUM_NAME}
+ {L_INDEX}
+
+ -> {navlinks.FORUM_NAME}
+
+
{S_TIMEZONE} {PAGINATION}
diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php
index c48e008ceb..cd7defe107 100644
--- a/phpBB/viewforum.php
+++ b/phpBB/viewforum.php
@@ -63,19 +63,13 @@ $acl = new acl($userdata, $forum_id);
// Check if the user has actually sent a forum ID with his/her request
// If not give them a nice error page.
//
-if ( !empty($forum_id) )
-{
- $sql = "SELECT *
- FROM " . FORUMS_TABLE . "
- WHERE forum_id = $forum_id";
- $result = $db->sql_query($sql);
-}
-else
+if (empty($forum_id))
{
message_die(MESSAGE, 'Forum_not_exist');
}
-if ( !($forum_data = $db->sql_fetchrow($result)) )
+
+if (!$forum_branch = get_forum_branch($forum_id))
{
message_die(MESSAGE, 'Forum_not_exist');
}
@@ -89,7 +83,7 @@ $session->configure($userdata);
//
// Auth check
//
-if ( !$acl->get_acl($forum_id, 'forum', 'read') )
+if (!$acl->get_acl($forum_id, 'forum', 'read'))
{
if ( $userdata['user_id'] )
{
@@ -108,6 +102,67 @@ if ( !$acl->get_acl($forum_id, 'forum', 'read') )
// End of auth check
//
+$type = 'parent';
+$forum_rows = array();
+
+foreach ($forum_branch as $row)
+{
+ if ($type == 'parent')
+ {
+ if ($row['forum_status'] == ITEM_CATEGORY)
+ {
+ $link = 'index.' . $phpEx . $SID . '&c=' . $row['forum_id'];
+ }
+ else
+ {
+ $link = 'viewforum.' . $phpEx . $SID . '&f=' . $row['forum_id'];
+ }
+
+ $template->assign_block_vars('navlinks', array(
+ 'FORUM_NAME' => $row['forum_name'],
+ 'U_VIEW_FORUM' => $link
+ ));
+
+ if ($row['forum_id'] == $forum_id)
+ {
+ $branch_root_id = 0;
+ $forum_data = $row;
+ $type = 'child';
+ }
+ }
+ else
+ {
+ if ($row['parent_id'] == $forum_data['forum_id'])
+ {
+ //
+ // Root-level forum
+ //
+ $forum_rows[] = $row;
+ $parent_id = $row['forum_id'];
+
+ if ($row['forum_status'] == ITEM_CATEGORY)
+ {
+ $branch_root_id = $row['forum_id'];
+ }
+ }
+ elseif ($row['parent_id'] == $branch_root_id)
+ {
+ //
+ // Forum directly under a category
+ //
+ $forum_rows[] = $row;
+ $parent_id = $row['forum_id'];
+ }
+ elseif ($row['forum_status'] != ITEM_CATEGORY)
+ {
+ if ($acl->get_acl($row['forum_id'], 'forum', 'list'))
+ {
+ $subforums[$parent_id][] = $row;
+ }
+ }
+ }
+}
+
//
// Topic read tracking cookie info
//
@@ -236,14 +291,10 @@ $select_sort_dir = '';
$select_sort_dir .= ( $sort_dir == 'a' ) ? '' . $lang['Ascending'] . ' ' . $lang['Descending'] . ' ' : '' . $lang['Ascending'] . ' ' . $lang['Descending'] . ' ';
$select_sort_dir .= ' ';
-
-
-
$post_alt = ( $forum_data['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['Post_new_topic'];
$template->assign_vars(array(
'FORUM_ID' => $forum_id,
- 'FORUM_NAME' => $forum_data['forum_name'],
'POST_IMG' => ' ',
'PAGINATION' => generate_pagination("viewforum.$phpEx$SID&f=$forum_id&topicdays=$topic_days", $topics_count, $board_config['topics_per_page'], $start),
'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $topics_count / $board_config['topics_per_page'] )),
@@ -264,6 +315,7 @@ $template->assign_vars(array(
'L_VIEWS' => $lang['Views'],
'L_POSTS' => $lang['Posts'],
'L_LASTPOST' => $lang['Last_Post'],
+ 'L_RATING' => $lang['Rating'],
'L_VIEW_MODERATORS' => $lang['View_moderators'],
'L_DISPLAY_TOPICS' => $lang['Display_topics'],
'L_SORT_BY' => $lang['Sort_by'],
@@ -290,11 +342,24 @@ $template->assign_vars(array(
'S_FORUM_ACTION' => 'viewforum.' . $phpEx . $SID . '&f=' . $forum_id . "&start=$start",
'U_POST_NEW_TOPIC' => 'posting.' . $phpEx . $SID . '&mode=newtopic&f=' . $forum_id,
- 'U_VIEW_FORUM' => 'viewforum.' . $phpEx . $SID . '&f=' . $forum_id,
'U_VIEW_MODERATORS' => 'memberslist.' . $phpEx . $SID . '&mode=moderators&f=' . $forum_id,
'U_MARK_READ' => 'viewforum.' . $phpEx . $SID . '&f=' . $forum_id . '&mark=topics')
);
+//
+// Do we have subforums? if so, let's include this harmless file
+//
+if (count($forum_rows))
+{
+ $template->assign_vars(array(
+ 'S_HAS_SUBFORUM' => TRUE,
+ 'L_SUBFORUM' => (count($forum_rows) == 1) ? $lang['Subforum'] : $lang['Subforums']
+ ));
+
+ $root_id = $forum_id;
+ include($phpbb_root_path . 'includes/forums_display.' . $phpEx);
+}
+
//
// Grab all the basic data. If we're not on page 1 we also grab any
// announcements that may exist.
@@ -530,8 +595,8 @@ $nav_links['up'] = array(
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$template->set_filenames(array(
- 'body' => 'viewforum_body.html')
-);
+ 'body' => 'viewforum_body.html'
+));
make_jumpbox('viewforum.'.$phpEx);
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);