diff options
author | Ludovic Arnaud <ludovic_arnaud@users.sourceforge.net> | 2002-10-03 19:44:58 +0000 |
---|---|---|
committer | Ludovic Arnaud <ludovic_arnaud@users.sourceforge.net> | 2002-10-03 19:44:58 +0000 |
commit | 743460bd80067eac830d4f830492f109e8ea76eb (patch) | |
tree | 390a6a0acf2dd78ad22724d07d5697b918c15daf | |
parent | 4c8253171260124bedabc69bedd74e82a921627e (diff) | |
download | forums-743460bd80067eac830d4f830492f109e8ea76eb.tar forums-743460bd80067eac830d4f830492f109e8ea76eb.tar.gz forums-743460bd80067eac830d4f830492f109e8ea76eb.tar.bz2 forums-743460bd80067eac830d4f830492f109e8ea76eb.tar.xz forums-743460bd80067eac830d4f830492f109e8ea76eb.zip |
Subforums part 3: "the one that actually works"
git-svn-id: file:///svn/phpbb/trunk@2916 89ea8834-ac86-4346-8a33-228a782c2dd0
-rw-r--r-- | phpBB/index.php | 89 | ||||
-rw-r--r-- | phpBB/templates/subSilver/viewforum_body.html | 5 | ||||
-rw-r--r-- | phpBB/templates/subSilver/viewforum_subforum.html | 2 |
3 files changed, 64 insertions, 32 deletions
diff --git a/phpBB/index.php b/phpBB/index.php index 80450d014a..b2dc88fcb7 100644 --- a/phpBB/index.php +++ b/phpBB/index.php @@ -96,10 +96,11 @@ get_moderators($forum_moderators); $cat_id = (!empty($_GET['c'])) ? intval($_GET['c']) : 0; $root_id = $branch_root_id = $cat_id; -$forum_rows = $subforums = array(); +$forum_rows = $subforums = $parent_forums = array(); if ($cat_id == 0) { + $is_child = TRUE; $total_posts = 0; switch (SQL_LAYER) { @@ -119,6 +120,8 @@ if ($cat_id == 0) } else { + $is_child = FALSE; + if (!$acl->get_acl($cat_id, 'forum', 'list')) { // @@ -127,17 +130,16 @@ else message_die(ERROR, $lang['Category_not_exist']); } + // + // NOTE: make sure that categories post count is set to 0 + // $sql = 'SELECT SUM(forum_posts) AS total FROM ' . FORUMS_TABLE . ' - WHERE post_count_inc = 1 - AND forum_status <> ' . ITEM_CATEGORY; + WHERE post_count_inc = 1'; $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); @@ -147,6 +149,7 @@ else $sql = 'SELECT f.*, u.username FROM ' . FORUMS_TABLE . ' f, ' . USERS_TABLE . 'u WHERE (f.left_id BETWEEN ' . $catrow['left_id'] . ' AND ' . $catrow['right_id'] . ' + OR ' . $catrow['left_id'] . ' BETWEEN f.left_id AND f.right_id) AND f.forum_last_poster_id = u.user_id(+) ORDER BY left_id'; break; @@ -156,6 +159,7 @@ else 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'] . ' + OR ' . $catrow['left_id'] . ' BETWEEN f.left_id AND f.right_id ORDER BY f.left_id'; } } @@ -170,34 +174,46 @@ while ($row = $db->sql_fetchrow($result)) if ($row['forum_id'] == $cat_id) { + $parent_forums[] = $row; $forum_rows[] = $row; + $is_child = TRUE; } - elseif ($row['parent_id'] == $cat_id) - { - // - // Root-level forum - // - $forum_rows[] = $row; - $parent_id = $row['forum_id']; - - if (!$cat_id && $row['forum_status'] == ITEM_CATEGORY) - { - $branch_root_id = $row['forum_id']; - } - } - elseif ($row['parent_id'] == $branch_root_id) + elseif (!$is_child) { - // - // Forum directly under a category - // - $forum_rows[] = $row; - $parent_id = $row['forum_id']; + $parent_forums[] = $row; } - elseif ($row['display_on_index'] && $row['forum_status'] != ITEM_CATEGORY) + else { - if ($acl->get_acl($row['forum_id'], 'forum', 'list')) + if ($row['parent_id'] == $cat_id) + { + // + // Root-level forum + // + $forum_rows[] = $row; + $parent_id = $row['forum_id']; + + if (!$cat_id && $row['forum_status'] == ITEM_CATEGORY) + { + $branch_root_id = $row['forum_id']; + } + } + elseif ($row['parent_id'] == $branch_root_id) { - $subforums[$parent_id][] = $row; + // + // Forum directly under a category + // + $forum_rows[] = $row; + $parent_id = $row['forum_id']; + } + elseif ($row['display_on_index'] && $row['forum_status'] != ITEM_CATEGORY) + { + // + // Subforum, store it for direct linking + // + if ($acl->get_acl($row['forum_id'], 'forum', 'list')) + { + $subforums[$parent_id][] = $row; + } } } } @@ -249,6 +265,23 @@ $template->assign_vars(array( 'U_MARK_READ' => "index.$phpEx$SID&mark=forums") ); +foreach ($parent_forums as $row) +{ + 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 + )); +} + // // Start output of page // diff --git a/phpBB/templates/subSilver/viewforum_body.html b/phpBB/templates/subSilver/viewforum_body.html index cb7ac4b975..616f7b993e 100644 --- a/phpBB/templates/subSilver/viewforum_body.html +++ b/phpBB/templates/subSilver/viewforum_body.html @@ -4,7 +4,7 @@ <!-- INCLUDE viewforum_subforum.html --> <!-- ENDIF --> -<form method="post" action="{S_FORUM_ACTION}"><table width="100%" cellspacing="2" cellpadding="2" border="0" align="center"> +<table width="100%" cellspacing="2" cellpadding="2" border="0" align="center"> <tr> <td colspan="2" align="left" valign="bottom"><a class="maintitle" href="{U_VIEW_FORUM}">{FORUM_NAME}</a><br /><span class="gensmall"> [ <a href="{U_VIEW_MODERATORS}">{L_VIEW_MODERATORS}</a> ]<br /><br /><b>{LOGGED_IN_USER_LIST}</b></span></td> <td align="right" valign="bottom" nowrap="nowrap"><span class="gensmall"><b>{PAGINATION}</b></span></td> @@ -46,7 +46,7 @@ </tr> <!-- END topicrow --> <tr> - <td class="catBottom" colspan="8" height="28" align="center" valign="middle"><span class="genmed">{L_DISPLAY_TOPICS}: {S_SELECT_SORT_DAYS} {L_SORT_BY} {S_SELECT_SORT_KEY} {S_SELECT_SORT_DIR} <input type="submit" class="liteoption" value="{L_GO}" name="sort" /></span></td> + <form method="post" action="{S_FORUM_ACTION}"><td class="catBottom" colspan="8" height="28" align="center" valign="middle"><span class="genmed">{L_DISPLAY_TOPICS}: {S_SELECT_SORT_DAYS} {L_SORT_BY} {S_SELECT_SORT_KEY} {S_SELECT_SORT_DIR} <input type="submit" class="liteoption" value="{L_GO}" name="sort" /></span></td></form> </tr> </table> @@ -67,7 +67,6 @@ <td colspan="3"><span class="gensmall">{S_WATCH_FORUM}</span></td> </tr> </table> -</form> <table width="100%" cellspacing="0" cellpadding="0" border="0"> <tr> diff --git a/phpBB/templates/subSilver/viewforum_subforum.html b/phpBB/templates/subSilver/viewforum_subforum.html index e47df6f5af..5b6bae8770 100644 --- a/phpBB/templates/subSilver/viewforum_subforum.html +++ b/phpBB/templates/subSilver/viewforum_subforum.html @@ -1,5 +1,5 @@ <table class="forumline" width="100%" cellspacing="1" cellpadding="2" border="0"> - <tr> + <tr> <th class="thCornerL" colspan="3" height="25" nowrap="nowrap"> {L_SUBFORUM} </th> <th class="thTop" width="50" nowrap="nowrap"> {L_TOPICS} </th> <th class="thTop" width="50" nowrap="nowrap"> {L_POSTS} </th> |