Update jumpbox for subforum changes

git-svn-id: file:///svn/phpbb/trunk@3064 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2002-11-19 23:12:11 +00:00
parent c1fc6dce16
commit 8ae487932d
2 changed files with 41 additions and 66 deletions

View file

@ -184,20 +184,30 @@ function make_jumpbox($action, $forum_id = false)
{
global $auth, $template, $user, $db, $nav_links, $phpEx;
$boxstring = '<select name="f" onChange="if(this.options[this.selectedIndex].value != -1){ forms[\'jumpbox\'].submit() }"><option value="-1">' . $user->lang['Select_forum'] . '</option><option value="-1">&nbsp;</option>';
$boxstring = '<select name="f" onChange="if(this.options[this.selectedIndex].value != -1){ forms[\'jumpbox\'].submit() }"><option value="-1">' . $user->lang['Select_forum'] . '</option><option value="-1">-----------------</option>';
$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 .= '&nbsp; &nbsp;';
}
@ -208,53 +218,30 @@ 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)
{
$holding = '';
}
if ($row['parent_id'] == 0)
{
if ($row['forum_status'] == ITEM_CATEGORY)
{
$linefeed = TRUE;
$holding = '<option value="-1">&nbsp;</option>';
}
elseif (!empty($linefeed))
{
$linefeed = FALSE;
$boxstring .= '<option value="-1">&nbsp;</option>';
}
}
else
{
$linefeed = TRUE;
}
if ($row['forum_status'] == ITEM_CATEGORY)
{
$cat_right = max($cat_right, $row['right_id']);
$holding .= '<option value="c' . $row['forum_id'] . '"' . $selected . '>' . $padding . $row['forum_name'] . '</option><option value="-1">' . $padding . '----------------</option>';
$holding .= '<option value="' . $row['forum_id'] . '"' . $selected . '>' . $padding . '+ ' . $row['forum_name'] . '</option>';
}
else
{
$boxstring .= $holding . '<option value="' . $row['forum_id'] . '"' . $selected . '>' . $padding . $row['forum_name'] . '</option>';
$boxstring .= $holding . '<option value="' . $row['forum_id'] . '"' . $selected . '>' . $padding . '- ' . $row['forum_name'] . '</option>';
$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']
);
}
}
$db->sql_freeresult($result);
if (!$right)

View file

@ -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))