diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 06e901842d..9aa3cd8800 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -19,55 +19,6 @@ * ***************************************************************************/ -function get_db_stat($mode) -{ - global $db; - - switch( $mode ) - { - case 'usercount': - $sql = "SELECT COUNT(user_id) - 1 AS total - FROM " . USERS_TABLE; - break; - - case 'newestuser': - $sql = "SELECT user_id, username - FROM " . USERS_TABLE . " - WHERE user_id <> " . ANONYMOUS . " - ORDER BY user_id DESC - LIMIT 1"; - break; - - case 'postcount': - case 'topiccount': - $sql = "SELECT SUM(forum_topics) AS topic_total, SUM(forum_posts) AS post_total - FROM " . FORUMS_TABLE; - break; - } - - $result = $db->sql_query($sql); - - $row = $db->sql_fetchrow($result); - - switch ( $mode ) - { - case 'usercount': - return $row['total']; - break; - case 'newestuser': - return $row; - break; - case 'postcount': - return $row['post_total']; - break; - case 'topiccount': - return $row['topic_total']; - break; - } - - return false; -} - function sql_quote($msg) { return str_replace("'", "''", $msg); @@ -126,18 +77,22 @@ function get_forum_branch($forum_id, $type='all', $order='descending', $include_ // Obtain list of moderators of each forum // First users, then groups ... broken into two queries +// We could cache this ... certainly into a DB table. Would +// better allow the admin to decide which moderators are +// displayed(?) function get_moderators(&$forum_moderators, $forum_id = false) { - global $SID, $db, $phpEx; + global $SID, $db, $acl_options, $phpEx; - $forum_sql = ( $forum_id ) ? 'AND au.forum_id = ' . $forum_id : ''; + $forum_sql = ( $forum_id ) ? 'AND m.forum_id = ' . $forum_id : ''; $sql = "SELECT au.forum_id, u.user_id, u.username - FROM " . ACL_USERS_TABLE . " au, " . ACL_OPTIONS_TABLE . " ao, " . USERS_TABLE . " u - WHERE ao.auth_value = 'm_global' - $forum_sql - AND au.auth_option_id = ao.auth_option_id - AND u.user_id = au.user_id"; + FROM " . ACL_OPTIONS_TABLE . " o, " . ACL_USERS_TABLE . " au, " . USERS_TABLE . " u + WHERE au.auth_option_id = o.auth_option_id + AND au.user_id = u.user_id + AND o.auth_value = 'm_' + AND au.auth_allow_deny = 1 + $forum_sql"; $result = $db->sql_query($sql); while ( $row = $db->sql_fetchrow($result) ) @@ -145,12 +100,14 @@ function get_moderators(&$forum_moderators, $forum_id = false) $forum_moderators[$row['forum_id']][] = '' . $row['username'] . ''; } - $sql = "SELECT au.forum_id, g.group_id, g.group_name - FROM " . ACL_GROUPS_TABLE . " au, " . ACL_OPTIONS_TABLE . " ao, " . GROUPS_TABLE . " g - WHERE ao.auth_value = 'm_global' - $forum_sql - AND au.auth_option_id = ao.auth_option_id - AND g.group_id = au.group_id"; + $sql = "SELECT ag.forum_id, g.group_name, g.group_id + FROM " . ACL_OPTIONS_TABLE . " o, " . ACL_GROUPS_TABLE . " ag, " . GROUPS_TABLE . " g + WHERE ag.auth_option_id = o.auth_option_id + AND ag.group_id = g.group_id + AND o.auth_value = 'm_' + AND ag.auth_allow_deny = 1 + AND g.group_type <> " . GROUP_HIDDEN . " + $forum_sql"; $result = $db->sql_query($sql); while ( $row = $db->sql_fetchrow($result) ) @@ -611,8 +568,10 @@ function message_die($msg_code, $msg_text = '', $msg_title = '') case ERROR: $db->sql_close(); - echo '
' . $msg_text . '
Contact the site administrator to report this failure