aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/index.php
diff options
context:
space:
mode:
authorLudovic Arnaud <ludovic_arnaud@users.sourceforge.net>2002-10-03 02:43:41 +0000
committerLudovic Arnaud <ludovic_arnaud@users.sourceforge.net>2002-10-03 02:43:41 +0000
commit268d936f4673974e46d16d8ddd7edba1422aba9a (patch)
tree0e3ef51b37a4f4ebe10dd75af26cd2ba099e8790 /phpBB/index.php
parent1666e7d3e733bf81b460497ac334232258c343fa (diff)
downloadforums-268d936f4673974e46d16d8ddd7edba1422aba9a.tar
forums-268d936f4673974e46d16d8ddd7edba1422aba9a.tar.gz
forums-268d936f4673974e46d16d8ddd7edba1422aba9a.tar.bz2
forums-268d936f4673974e46d16d8ddd7edba1422aba9a.tar.xz
forums-268d936f4673974e46d16d8ddd7edba1422aba9a.zip
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
Diffstat (limited to 'phpBB/index.php')
-rw-r--r--phpBB/index.php287
1 files changed, 109 insertions, 178 deletions
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,183 +94,117 @@ 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');
-while ($row = $db->sql_fetchrow($result))
+if ($cat_id == 0)
{
- if ($row['parent_id'] == 0)
+ $total_posts = 0;
+ switch (SQL_LAYER)
{
- $forum_rows[] = $row;
-
- if ($row['forum_status'] == ITEM_CATEGORY)
- {
- $branch_root_id = $row['forum_id'];
- }
- else
- {
- $branch_root_id = 0;
- }
+ 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';
}
- elseif ($row['parent_id'] == $branch_root_id)
+}
+else
+{
+ if (!$acl->get_acl($cat_id, 'forum', 'list'))
{
- $forum_rows[] = $row;
- $forum_root_id = $row['forum_id'];
+ //
+ // TODO: Deal with hidden categories
+ //
+ message_die(ERROR, $lang['Category_not_exist']);
}
- elseif ($row['display_on_index'] && $row['forum_status'] != ITEM_CATEGORY)
+
+ $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)
{
- if ($acl->get_acl($row['forum_id'], 'forum', 'list'))
- {
- $subforums[$forum_root_id][] = $row;
- }
+ 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';
}
}
-function format_subforums_list($subforums)
+$result = $db->sql_query($sql);
+while ($row = $db->sql_fetchrow($result))
{
- if (empty($subforums))
+ if (!$cat_id && $row['post_count_inc'])
{
- return '';
+ $total_posts += $row['forum_posts'];
}
- global $phpEx, $SID;
- foreach ($subforums as $row)
+ if ($row['forum_id'] == $cat_id)
{
- $alist[$row['forum_id']] = $row['forum_name'];
+ $forum_rows[] = $row;
}
- asort($alist);
-
- $links = array();
- foreach ($alist as $forum_id => $forum_name)
+ elseif ($row['parent_id'] == $cat_id)
{
- $links[] = '<a href="viewforum.' . $phpEx . $SID . '&f=' . $forum_id . '">' . htmlspecialchars($forum_name) . '</a>';
- }
-
- return implode(', ', $links);
-}
+ //
+ // Root-level forum
+ //
+ $forum_rows[] = $row;
+ $parent_id = $row['forum_id'];
-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
+ if (!$cat_id && $row['forum_status'] == ITEM_CATEGORY)
{
- $branch_root_id = 0;
- unset($stored_cat);
+ $branch_root_id = $row['forum_id'];
}
}
- elseif (!empty($stored_cat))
+ elseif ($row['parent_id'] == $branch_root_id)
{
- $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 . '&amp;c=' . $stored_cat['forum_id']
- ));
- unset($stored_cat);
+ //
+ // Forum directly under a category
+ //
+ $forum_rows[] = $row;
+ $parent_id = $row['forum_id'];
}
-
- if ($acl->get_acl($forum_id, 'forum', 'list'))
+ elseif ($row['display_on_index'] && $row['forum_status'] != ITEM_CATEGORY)
{
- 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']) . '<br />';
-
- $last_post .= ($user_id == ANONYMOUS) ? (($forum_last_poster_name != '') ? $forum_last_poster_name . ' ' : $lang['Guest'] . ' ') : '<a href="profile.' . $phpEx . $SID . '&amp;mode=viewprofile&amp;u=' . $user_id . '">' . $username . '</a> ';
-
- $last_post .= '<a href="viewtopic.' . $phpEx . '$SID&amp;f=' . $forum_id . '&amp;p=' . $forum_last_post_id . '#' . $forum_last_post_id . '">' . create_img($theme['goto_post_latest'], $lang['View_latest_post']) . '</a>';
- }
- 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 = '&nbsp;';
- $moderator_list = '&nbsp;';
- }
-
- if (isset($subforums[$forum_id]))
- {
- $subforums_list = format_subforums_list($subforums[$forum_id]);
- $l_subforums = '<br />' . (count($subforums[$forum_id]) == 1) ? $lang['Subforum'] : $lang['Subforums'];
- }
- else
+ if ($acl->get_acl($row['forum_id'], 'forum', 'list'))
{
- $subforums_list = '';
- $l_subforums = '';
+ $subforums[$parent_id][] = $row;
}
-
- $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 . '&amp;f=' . $forum_id
- ));
}
}
+$root_id = ($cat_id) ? $catrow['parent_id'] : 0;
+include($phpbb_root_path . 'includes/forums_display.' . $phpEx);
+
if ($total_posts == 0)
{
$l_total_post_s = $lang['Posted_articles_zero_total'];
@@ -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'], '<a href="profile.' . $phpEx . $SID . '&amp;mode=viewprofile&amp;u=' . $newest_uid . '">', $newest_user, '</a>'),
-
- '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_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'],
+ 'TOTAL_POSTS' => sprintf($l_total_post_s, $total_posts),
+ 'TOTAL_USERS' => sprintf($l_total_user_s, $total_users),
+ 'NEWEST_USER' => sprintf($lang['Newest_user'], '<a href="profile.' . $phpEx . $SID . '&amp;mode=viewprofile&amp;u=' . $newest_uid . '">', $newest_user, '</a>'),
+
+ '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_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'],
'U_MARK_READ' => "index.$phpEx$SID&amp;mark=forums")
);