From 852eaf0da905c31a73bc312ad27bd6c9fc03101a Mon Sep 17 00:00:00 2001 From: James Atkinson Date: Sat, 24 Feb 2001 01:02:41 +0000 Subject: [PATCH] Forums can have moderators now.. git-svn-id: file:///svn/phpbb/trunk@39 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/functions/functions.php | 31 +++++++++++++ phpBB/index.php | 82 ++++++++++++++++++++--------------- 2 files changed, 79 insertions(+), 34 deletions(-) diff --git a/phpBB/functions/functions.php b/phpBB/functions/functions.php index 5d660f8db9..b9daefd91e 100644 --- a/phpBB/functions/functions.php +++ b/phpBB/functions/functions.php @@ -127,4 +127,35 @@ function make_jumpbox($db, $phpEx) return($boxstring); } +function get_moderators($db, $forum_id) +{ + $sql = "SELECT u.username, u.user_id FROM " . FORUM_MODS_TABLE ." f, " . USERS_TABLE . " u + WHERE f.forum_id = '$forum_id' AND u.user_id = f.user_id"; + if($result = $db->sql_query($sql)) + { + if($total_mods = $db->sql_numrows($result)) + { + $rowset = $db->sql_fetchrowset($result); + for($x = 0; $x < $total_mods; $x++) + { + $modArray[] = array("id" => $rowset[$x]["user_id"], + "name" => $rowset[$x]["username"]); + } + } + else + { + $modArray[] = array("id" => "-1", + "name" => "ERROR"); + } + + } + else + { + $modArray[] = array("id" => "-1", + "name" => "ERROR"); + } + + return($modArray); +} + ?> diff --git a/phpBB/index.php b/phpBB/index.php index b28f842603..a1c59c6211 100644 --- a/phpBB/index.php +++ b/phpBB/index.php @@ -69,40 +69,54 @@ if($total_categories) { if($forum_rows[$j]["cat_id"] == $category_rows[$i]["cat_id"]) { - $folder_image = ""; - $posts = $forum_rows[$j]["forum_posts"]; - $topics = $forum_rows[$j]["forum_topics"]; - if($forum_rows[$j]["username"] != "" && $forum_rows[$j]["post_time"] > 0){ - $last_post_user = $forum_rows[$j]["username"]; - $last_post_time = date($date_format, $forum_rows[$j]["post_time"]); - $last_post = $last_post_time." by ".$last_post_user; - } - else - { - $last_post = "No Posts"; - } - - $moderators = "theFinn"; - if($row_color == "#DDDDDD") - { - $row_color = "#CCCCCC"; - } - else - { - $row_color = "#DDDDDD"; - } - $template->set_var(array("FOLDER" => $folder_image, - "FORUM_NAME" => stripslashes($forum_rows[$j]["forum_name"]), - "FORUM_ID" => $forum_rows[$j]["forum_id"], - "FORUM_DESC" => stripslashes($forum_rows[$j]["forum_desc"]), - "ROW_COLOR" => $row_color, - "PHPEX" => $phpEx, - "POSTS" => $posts, - "TOPICS" => $topics, - "LAST_POST" => $last_post, - "MODERATORS" => $moderators)); - - $template->parse("forums", "forumrow", true); + $folder_image = ""; + $posts = $forum_rows[$j]["forum_posts"]; + $topics = $forum_rows[$j]["forum_topics"]; + if($forum_rows[$j]["username"] != "" && $forum_rows[$j]["post_time"] > 0){ + $last_post_user = $forum_rows[$j]["username"]; + $last_post_time = date($date_format, $forum_rows[$j]["post_time"]); + $last_post = $last_post_time." by ".$last_post_user; + } + 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(isset($moderators_links)) + { + $moderators_links .= ", "; + } + if(!($mods % 2) && $mods != 0) + { + $moderators_links .= "
"; + } + $moderators_links .= "".$moderators[$mods]["name"].""; + } + + if($row_color == "#DDDDDD") + { + $row_color = "#CCCCCC"; + } + else + { + $row_color = "#DDDDDD"; + } + $template->set_var(array("FOLDER" => $folder_image, + "FORUM_NAME" => stripslashes($forum_rows[$j]["forum_name"]), + "FORUM_ID" => $forum_rows[$j]["forum_id"], + "FORUM_DESC" => stripslashes($forum_rows[$j]["forum_desc"]), + "ROW_COLOR" => $row_color, + "PHPEX" => $phpEx, + "POSTS" => $posts, + "TOPICS" => $topics, + "LAST_POST" => $last_post, + "MODERATORS" => $moderators_links)); + + $template->parse("forums", "forumrow", true); } // if ... then } // for total forums $template->parse("cats", "forums", true);