From 268d936f4673974e46d16d8ddd7edba1422aba9a Mon Sep 17 00:00:00 2001 From: Ludovic Arnaud Date: Thu, 3 Oct 2002 02:43:41 +0000 Subject: Subforums handling part 2, it almost works. Also added: the "Explain" link at the bottom page, can be removed easily before official release if necessary. git-svn-id: file:///svn/phpbb/trunk@2913 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/viewforum.php | 99 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 82 insertions(+), 17 deletions(-) (limited to 'phpBB/viewforum.php') 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 = ''; - - - $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' => '' . $post_alt . '', '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); -- cgit v1.2.1