mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
viewcat now works also modified moderators construction, now faster
git-svn-id: file:///svn/phpbb/trunk@45 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
7ee5829185
commit
a797580600
1 changed files with 104 additions and 57 deletions
161
phpBB/index.php
161
phpBB/index.php
|
@ -31,6 +31,11 @@ $newest_user = $newest_userdata["username"];
|
||||||
$newest_uid = $newest_userdata["user_id"];
|
$newest_uid = $newest_userdata["user_id"];
|
||||||
$users_browsing = "4 Users";
|
$users_browsing = "4 Users";
|
||||||
|
|
||||||
|
if(empty($viewcat))
|
||||||
|
{
|
||||||
|
$viewcat = -1;
|
||||||
|
}
|
||||||
|
|
||||||
$pagetype = "index";
|
$pagetype = "index";
|
||||||
$page_title = "Forum Index";
|
$page_title = "Forum Index";
|
||||||
include('page_header.'.$phpEx);
|
include('page_header.'.$phpEx);
|
||||||
|
@ -38,10 +43,15 @@ include('page_header.'.$phpEx);
|
||||||
$template->set_block("body", "catrow", "cats");
|
$template->set_block("body", "catrow", "cats");
|
||||||
$template->set_block("catrow", "forumrow", "forums");
|
$template->set_block("catrow", "forumrow", "forums");
|
||||||
|
|
||||||
$sql = "SELECT c.* FROM ".CATEGORIES_TABLE." c, ".FORUMS_TABLE." f WHERE f.cat_id=c.cat_id GROUP BY c.cat_id ORDER BY c.cat_order";
|
$sql = "SELECT c.*
|
||||||
|
FROM ".CATEGORIES_TABLE." c, ".FORUMS_TABLE." f
|
||||||
|
WHERE f.cat_id=c.cat_id
|
||||||
|
GROUP BY c.cat_id
|
||||||
|
ORDER BY c.cat_order";
|
||||||
if(!$q_categories = $db->sql_query($sql))
|
if(!$q_categories = $db->sql_query($sql))
|
||||||
{
|
{
|
||||||
error_die($db, QUERY_ERROR);
|
$db_error = $db->sql_error();
|
||||||
|
error_die(QUERY_ERROR, $db_error["message"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$total_categories = $db->sql_numrows();
|
$total_categories = $db->sql_numrows();
|
||||||
|
@ -49,78 +59,115 @@ $total_categories = $db->sql_numrows();
|
||||||
if($total_categories)
|
if($total_categories)
|
||||||
{
|
{
|
||||||
$category_rows = $db->sql_fetchrowset($q_categories);
|
$category_rows = $db->sql_fetchrowset($q_categories);
|
||||||
$sql = "SELECT f.*, u.username, p.post_time FROM ".FORUMS_TABLE." f LEFT JOIN ".POSTS_TABLE." p ON p.post_id = f.forum_last_post_id LEFT JOIN ".USERS_TABLE." u ON u.user_id = p.poster_id ORDER BY f.forum_id";
|
|
||||||
|
$limit_forums = "";
|
||||||
|
if($viewcat != -1)
|
||||||
|
{
|
||||||
|
$limit_forums = " WHERE f.cat_id = $viewcat ";
|
||||||
|
}
|
||||||
|
$sql = "SELECT f.*, u.username, p.post_time
|
||||||
|
FROM ".FORUMS_TABLE." f
|
||||||
|
LEFT JOIN ".POSTS_TABLE." p ON p.post_id = f.forum_last_post_id
|
||||||
|
LEFT JOIN ".USERS_TABLE." u ON u.user_id = p.poster_id
|
||||||
|
$limit_forums
|
||||||
|
ORDER BY f.forum_id";
|
||||||
if(!$q_forums = $db->sql_query($sql))
|
if(!$q_forums = $db->sql_query($sql))
|
||||||
{
|
{
|
||||||
error_die($db, QUERY_ERROR);
|
error_die($db, QUERY_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$sql = "SELECT f.forum_id, u.username, u.user_id
|
||||||
|
FROM ".FORUMS_TABLE." f, ".USERS_TABLE." u, ".FORUM_MODS_TABLE." m
|
||||||
|
WHERE m.forum_id = f.forum_id
|
||||||
|
AND u.user_id = m.user_id
|
||||||
|
ORDER BY f.forum_id";
|
||||||
|
if(!$q_forum_mods = $db->sql_query($sql))
|
||||||
|
{
|
||||||
|
error_die($db, QUERY_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
$total_forums = $db->sql_numrows($q_forums);
|
$total_forums = $db->sql_numrows($q_forums);
|
||||||
$forum_rows = $db->sql_fetchrowset($q_forums);
|
$forum_rows = $db->sql_fetchrowset($q_forums);
|
||||||
|
$forum_mods_list = $db->sql_fetchrowset($q_forum_mods);
|
||||||
|
|
||||||
|
for($i = 0; $i < count($forum_mods_list); $i++)
|
||||||
|
{
|
||||||
|
$forum_mods[$forum_mods_list[$i]["forum_id"]]["username"][] = $forum_mods_list[$i]["username"];
|
||||||
|
$forum_mods[$forum_mods_list[$i]["forum_id"]]["user_id"][] = $forum_mods_list[$i]["user_id"];
|
||||||
|
}
|
||||||
|
|
||||||
for($i = 0; $i < $total_categories; $i++)
|
for($i = 0; $i < $total_categories; $i++)
|
||||||
{
|
{
|
||||||
$template->set_var(array("CAT_ID" => $category_rows[$i]["cat_id"],
|
$template->set_var(array("CAT_ID" => $category_rows[$i]["cat_id"],
|
||||||
"PHP_SELF" => $PHP_SELF,
|
"PHP_SELF" => $PHP_SELF,
|
||||||
"CAT_DESC" => stripslashes($category_rows[$i]["cat_title"])));
|
"CAT_DESC" => stripslashes($category_rows[$i]["cat_title"])));
|
||||||
$template->parse("cats", "catrow", true);
|
$template->parse("cats", "catrow", true);
|
||||||
|
|
||||||
|
$created_line = false;
|
||||||
for($j = 0; $j < $total_forums; $j++)
|
for($j = 0; $j < $total_forums; $j++)
|
||||||
{
|
{
|
||||||
if($forum_rows[$j]["cat_id"] == $category_rows[$i]["cat_id"])
|
if( ( $forum_rows[$j]["cat_id"] == $category_rows[$i]["cat_id"] && $viewcat == -1 ) ||
|
||||||
|
( $category_rows[$i]["cat_id"] == $viewcat) )
|
||||||
{
|
{
|
||||||
$folder_image = "<img src=\"images/folder.gif\">";
|
|
||||||
$posts = $forum_rows[$j]["forum_posts"];
|
$folder_image = "<img src=\"images/folder.gif\">";
|
||||||
$topics = $forum_rows[$j]["forum_topics"];
|
$posts = $forum_rows[$j]["forum_posts"];
|
||||||
if($forum_rows[$j]["username"] != "" && $forum_rows[$j]["post_time"] > 0){
|
$topics = $forum_rows[$j]["forum_topics"];
|
||||||
$last_post_user = $forum_rows[$j]["username"];
|
if($forum_rows[$j]["username"] != "" && $forum_rows[$j]["post_time"] > 0)
|
||||||
$last_post_time = date($date_format, $forum_rows[$j]["post_time"]);
|
{
|
||||||
$last_post = $last_post_time." by ".$last_post_user;
|
$last_post_user = $forum_rows[$j]["username"];
|
||||||
}
|
$last_post_time = date($date_format, $forum_rows[$j]["post_time"]);
|
||||||
else
|
$last_post = $last_post_time." by ".$last_post_user;
|
||||||
{
|
}
|
||||||
$last_post = "No Posts";
|
else
|
||||||
}
|
{
|
||||||
|
$last_post = "No Posts";
|
||||||
$moderators = get_moderators($db, $forum_rows[$j]["forum_id"]);
|
}
|
||||||
unset($moderators_links);
|
|
||||||
for($mods = 0; $mods < count($moderators); $mods++)
|
if($row_color == "#DDDDDD")
|
||||||
{
|
{
|
||||||
if(isset($moderators_links))
|
$row_color = "#CCCCCC";
|
||||||
{
|
}
|
||||||
$moderators_links .= ", ";
|
else
|
||||||
}
|
{
|
||||||
if(!($mods % 2) && $mods != 0)
|
$row_color = "#DDDDDD";
|
||||||
{
|
}
|
||||||
$moderators_links .= "<br>";
|
|
||||||
}
|
unset($moderators_links);
|
||||||
$moderators_links .= "<a href=\"profile.$phpEx?mode=viewprofile&user_id=".$moderators[$mods]["id"]."\">".$moderators[$mods]["name"]."</a>";
|
for($mods = 0; $mods < count($forum_mods[$forum_rows[$j]["forum_id"]]); $mods++)
|
||||||
}
|
{
|
||||||
|
if(isset($moderators_links))
|
||||||
if($row_color == "#DDDDDD")
|
{
|
||||||
{
|
$moderators_links .= ", ";
|
||||||
$row_color = "#CCCCCC";
|
}
|
||||||
}
|
if(!($mods % 2) && $mods != 0)
|
||||||
else
|
{
|
||||||
{
|
$moderators_links .= "<br>";
|
||||||
$row_color = "#DDDDDD";
|
}
|
||||||
}
|
$moderators_links .= "<a href=\"profile.$phpEx?mode=viewprofile&user_id=".$forum_mods[$forum_rows[$j]["forum_id"]]["user_id"][$mods]."\">".$forum_mods[$forum_rows[$j]["forum_id"]]["username"][$mods]."</a>";
|
||||||
$template->set_var(array("FOLDER" => $folder_image,
|
}
|
||||||
"FORUM_NAME" => stripslashes($forum_rows[$j]["forum_name"]),
|
|
||||||
"FORUM_ID" => $forum_rows[$j]["forum_id"],
|
$template->set_var(array("FOLDER" => $folder_image,
|
||||||
"FORUM_DESC" => stripslashes($forum_rows[$j]["forum_desc"]),
|
"FORUM_NAME" => stripslashes($forum_rows[$j]["forum_name"]),
|
||||||
"ROW_COLOR" => $row_color,
|
"FORUM_ID" => $forum_rows[$j]["forum_id"],
|
||||||
"PHPEX" => $phpEx,
|
"FORUM_DESC" => stripslashes($forum_rows[$j]["forum_desc"]),
|
||||||
"POSTS" => $posts,
|
"ROW_COLOR" => $row_color,
|
||||||
"TOPICS" => $topics,
|
"PHPEX" => $phpEx,
|
||||||
"LAST_POST" => $last_post,
|
"POSTS" => $forum_rows[$j]["forum_posts"],
|
||||||
"MODERATORS" => $moderators_links));
|
"TOPICS" => $forum_rows[$j]["forum_topics"],
|
||||||
|
"LAST_POST" => $last_post,
|
||||||
$template->parse("forums", "forumrow", true);
|
"MODERATORS" => $moderators_links));
|
||||||
} // if ... then
|
|
||||||
} // for total forums
|
$template->parse("forums", "forumrow", true);
|
||||||
$template->parse("cats", "forums", true);
|
|
||||||
$template->set_var("forums", "");
|
$created_line = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($created_line)
|
||||||
|
{
|
||||||
|
$template->parse("cats", "forums", true);
|
||||||
|
$template->set_var("forums", "");
|
||||||
|
}
|
||||||
|
|
||||||
} // for ... categories
|
} // for ... categories
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue