diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 5154681472..250fe067f0 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -184,20 +184,30 @@ function make_jumpbox($action, $forum_id = false) { global $auth, $template, $user, $db, $nav_links, $phpEx; - $boxstring = ''; - $sql = 'SELECT forum_id, forum_name, forum_status, left_id, right_id + $sql = 'SELECT forum_id, forum_name, forum_postable, forum_status, left_id, right_id FROM ' . FORUMS_TABLE . ' ORDER BY left_id ASC'; $result = $db->sql_query($sql); - $right = 0; - $cat_right = 0; - $padding = ''; - $forum_list = ''; + $right = $cat_right = 0; + $padding = $forum_list = ''; while ($row = $db->sql_fetchrow($result)) { - if ($row['left_id'] < $right ) + if (!$row['forum_postable'] && ($row['left_id'] + 1 == $row['right_id'])) + { + // Non-postable forum with no subforums, don't display + continue; + } + + if (!$auth->acl_gets('f_list', 'm_', 'a_', intval($row['forum_id']))) + { + // if the user does not have permissions to list this forum skip + continue; + } + + if ($row['left_id'] < $right) { $padding .= '   '; } @@ -208,52 +218,29 @@ function make_jumpbox($action, $forum_id = false) $right = $row['right_id']; - $linefeed = FALSE; - if ($auth->acl_gets('f_list', 'm_', 'a_', $forum_id)) + $selected = ($row['forum_id'] == $forum_id) ? ' selected="selected"' : ''; + + if ($row['left_id'] > $cat_right) { - $selected = ($row['forum_id'] == $forum_id) ? ' selected="selected"' : ''; - - if ($row['left_id'] > $cat_right) - { - $holding = ''; - } - if ($row['parent_id'] == 0) - { - if ($row['forum_status'] == ITEM_CATEGORY) - { - $linefeed = TRUE; - $holding = ''; - } - elseif (!empty($linefeed)) - { - $linefeed = FALSE; - $boxstring .= ''; - } - } - else - { - $linefeed = TRUE; - } - - if ($row['forum_status'] == ITEM_CATEGORY) - { - $cat_right = max($cat_right, $row['right_id']); - - $holding .= ''; - } - else - { - $boxstring .= $holding . ''; - $holding = ''; - } - - // TODO: do not add empty categories to nav links - $nav_links['chapter forum'][$row['forum_id']] = array ( - 'url' => ($row['forum_status'] == ITEM_CATEGORY) ? "index.$phpEx$SIDc=" : "viewforum.$phpEx$SID&f=" . $row['forum_id'], - 'title' => $row['forum_name'] - ); + $holding = ''; } + if ($row['forum_status'] == ITEM_CATEGORY) + { + $cat_right = max($cat_right, $row['right_id']); + + $holding .= ''; + } + else + { + $boxstring .= $holding . ''; + $holding = ''; + } + + $nav_links['chapter forum'][$row['forum_id']] = array ( + 'url' => ($row['forum_status'] == ITEM_CATEGORY) ? "index.$phpEx$SIDc=" : "viewforum.$phpEx$SID&f=" . $row['forum_id'], + 'title' => $row['forum_name'] + ); } $db->sql_freeresult($result); diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 637ebfa17a..b6e10303f5 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -458,19 +458,10 @@ function config_cache_write($match, $data) // changed via admin_permissions. Changes of username // and group names must be carried through for the // moderators table -function cache_moderators($forum_id = false) +function cache_moderators() { global $db; - if (!empty($forum_id) && is_array($forum_id)) - { - $forum_sql = 'AND forum_id IN (' . implode(', ', $forum_id) . ')'; - } - else - { - $forum_sql = ($forum_id) ? 'AND forum_id = ' . $forum_id : ''; - } - // Clear table $db->sql_query('TRUNCATE ' . MODERATOR_TABLE); @@ -483,8 +474,7 @@ function cache_moderators($forum_id = false) WHERE o.auth_value = 'm_' AND a.auth_option_id = o.auth_option_id AND a.auth_allow_deny = 1 - AND u.user_id = a.user_id - $forum_sql"; + AND u.user_id = a.user_id"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) @@ -503,8 +493,7 @@ function cache_moderators($forum_id = false) AND a.auth_option_id = o.auth_option_id AND a.auth_allow_deny = 0 AND a.group_id = ug.group_id - AND ug.user_id IN ($user_id_sql) - $forum_sql"; + AND ug.user_id IN ($user_id_sql)"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) @@ -520,8 +509,7 @@ function cache_moderators($forum_id = false) AND a.auth_option_id = o.auth_option_id AND a.auth_allow_deny = 1 AND g.group_id = a.group_id - AND g.group_type NOT IN (" . GROUP_HIDDEN . ", " . GROUP_SPECIAL . ") - $forum_sql"; + AND g.group_type NOT IN (" . GROUP_HIDDEN . ", " . GROUP_SPECIAL . ")"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result))