Just throwing this in ... dependencies still not complete ... the GUI and storage has caused me to do more "thinking" than I'd anticipated ... comments are welcome on what you see. Note also ALLOW/DENY/INHERIT have become YES/NO/UNSET

git-svn-id: file:///svn/phpbb/trunk@3772 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2003-04-01 00:06:11 +00:00
parent 3257af80f0
commit 5231006c03
6 changed files with 369 additions and 231 deletions

View file

@ -231,11 +231,11 @@ if ($mode == 'deps')
// Generate header // Generate header
page_header($l_title); page_header($l_title);
$chg_acl_type = (isset($_POST['chg_type'])) ? htmlspecialchars($_POST['chg_type']) : ''; $dep_quick_access = (isset($_POST['dep_quick_access'])) ? htmlspecialchars($_POST['dep_quick_access']) : '';
$chg_acl_option_id = (isset($_POST['chg_option'])) ? intval($_POST['chg_option']) : ''; $dep_type = (isset($_POST['dep_type'])) ? htmlspecialchars($_POST['dep_type']) : -1;
$chg_acl_value = (isset($_POST['chg_value'])) ? intval($_POST['chg_value']) : ''; $dep_option = (isset($_POST['dep_option'])) ? $_POST['dep_option'] : array();
$chg_forum_id = (isset($_POST['f'])) ? intval($_POST['f']) : 0; $dep_value = (isset($_POST['dep_value'])) ? intval($_POST['dep_value']) : -1;
$chg_acl_options = (isset($_POST['option'])) ? $_POST['option'] : ''; $dep_forum_id = (isset($_POST['f'])) ? $_POST['f'] : array(0);
$acl_types = $auth_options = $value_options = $forum_options = ''; $acl_types = $auth_options = $value_options = $forum_options = '';
@ -243,131 +243,82 @@ if ($mode == 'deps')
foreach ($types as $value => $option) foreach ($types as $value => $option)
{ {
$acl_types .= '<option value="' . $value . '"' . (($chg_acl_type == $value) ? ' selected="selected"' : '') . '>' . $option . '</option>'; $acl_types .= '<option value="' . $value . '"' . (($dep_type == $value) ? ' selected="selected"' : '') . '>' . $option . '</option>';
} }
if (isset($_POST['chg_type'])) if (!empty($dep_type))
{ {
switch ($chg_acl_type) switch ($dep_type)
{ {
case 'admin': case 'admin':
$type_sql = 'a'; $dep_type = 'a';
break; break;
case 'supermod': case 'supermod':
case 'mod': case 'mod':
$type_sql = 'm'; $dep_type = 'm';
break; break;
} }
$founder_sql = ($user->data['user_founder']) ? ' AND founder_only <> 1' : ''; $founder_sql = ($user->data['user_founder']) ? ' AND founder_only <> 1' : '';
$sql = "SELECT auth_option_id, auth_value $sql = "SELECT auth_value
FROM " . ACL_OPTIONS_TABLE . " FROM " . ACL_OPTIONS_TABLE . "
WHERE auth_value LIKE '" . $type_sql . "_%' WHERE auth_value LIKE '" . $dep_type . "_%'
$founder_sql"; $founder_sql";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = $db->sql_fetchrow($result))
{ {
$auth_options .= '<option value="' . $row['auth_option_id'] . '"' . (($chg_acl_option_id == $row['auth_option_id']) ? ' selected="selected"' : '') . '>' . ((!empty($user->lang['acl_' . $row['auth_value']])) ? $user->lang['acl_' . $row['auth_value']] : (($row['auth_value'] == $chg_type_sql . '_') ? 'Any option' : ucfirst(preg_replace('#.*?_#', '', $row['auth_value'])))) . '</option>'; $auth_options .= '<option value="' . $row['auth_value'] . '"' . ((in_array($row['auth_value'], $dep_option)) ? ' selected="selected"' : '') . '>' . ((!empty($user->lang['acl_' . $row['auth_value']])) ? $user->lang['acl_' . $row['auth_value']] : (($row['auth_value'] == $dep_type . '_') ? 'Any option' : ucfirst(preg_replace('#.*?_#', '', $row['auth_value'])))) . '</option>';
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
} }
if (isset($_POST['chg_option']) && strstr($_POST['field'], 'options')) $values = array(ACL_DENY => $user->lang['NO'], ACL_ALLOW => $user->lang['YES'], ACL_INHERIT => $user->lang['UNSET']);
{
$values = array(ACL_DENY => $user->lang['DENY'], ACL_ALLOW => $user->lang['ALLOW'], ACL_INHERIT => $user->lang['INHERIT']);
foreach ($values as $value => $option) foreach ($values as $value => $option)
{
$value_options .= '<option value="' . $value . '"' . (($dep_value === $value) ? ' selected="selected"' : '') . '>' . $option . '</option>';
}
$forum_options = make_forum_select($dep_forum_id, false, false);
// Look for custom presets
$sql = "SELECT preset_id, preset_name, preset_data
FROM " . ACL_PRESETS_TABLE . "
WHERE preset_type = '$type_sql'
ORDER BY preset_id ASC";
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
do
{ {
$value_options .= '<option value="' . $value . '"' . (($chg_acl_value == $value && strstr($_POST['field'], 'values')) ? ' selected="selected"' : '') . '>' . $option . '</option>'; $preset_update_options .= '<option value="' . $row['preset_id'] . '">' . $row['preset_name'] . '</option>';
$preset_options .= '<option value="preset_' . $row['preset_id'] . '">' . $row['preset_name'] . '</option>';
$preset_data = unserialize($row['preset_data']);
foreach ($preset_data as $preset_type => $preset_type_ary)
{
$holding[$preset_type] = '';
foreach ($preset_type_ary as $preset_option)
{
$holding[$preset_type] .= "$preset_option, ";
}
}
$preset_js .= "\tpresets['preset_" . $row['preset_id'] . "'] = new Array();" . "\n";
$preset_js .= "\tpresets['preset_" . $row['preset_id'] . "'] = new preset_obj('" . $holding['allow'] . "', '" . $holding['deny'] . "', '" . $holding['inherit'] . "');\n";
} }
while ($row = $db->sql_fetchrow($result));
} }
unset($holding);
if (isset($_POST['chg_value']) && strstr($_POST['field'], 'values')) if ($dep_quick_access)
{ {
$forum_options = make_forum_select(false, false, false); $sql = 'SELECT auth_deps
}
?>
<h1><?php echo $l_title; ?></h1>
<p><?php echo $l_title_explain; ?></p>
<form method="post" name="acl" action="<?php echo "admin_permissions.$phpEx$SID&amp;mode=$mode"; ?>"><table class="bg" width="60%" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th colspan="2">&nbsp;</th>
</tr>
<tr>
<td class="row1">Permission type: </td>
<td class="row2"><select name="chg_type" onchange="if(this.options[this.selectedIndex].value != -1){ this.form.field.value = 'type'; this.form.submit() }"><option value="-1">Choose type</option><?php echo $acl_types; ?></select></td>
</tr>
<?php
if ($auth_options != '')
{
?>
<tr>
<td class="row1">Changing option:</td>
<td class="row2"><select name="chg_option" onchange="if(this.options[this.selectedIndex].value != -1){ this.form.field.value = 'type, options'; this.form.submit() }"><option value="-1">Choose option</option><?php echo $auth_options; ?></select></td>
</tr>
<?php
}
if ($value_options != '')
{
?>
<tr>
<td class="row1">To value:</td>
<td class="row2"><select name="chg_value" onchange="if(this.options[this.selectedIndex].value != -1){ this.form.field.value = 'type, options, values';this.form.submit() }"><option>Choose value</option><?php echo $value_options; ?></select></td>
</tr>
<?php
}
if ($forum_options != '')
{
?>
<tr>
<td class="row1">Set option in: <br /><span class="gensmall"></span></td>
<td class="row2"><select name="f" onchange="if(this.options[this.selectedIndex].value != -1){ this.form.field.value = 'type, options, values, forum'; this.form.submit() }"><option class="sep" value="0">All forums</option><?php
if ($_POST['type'] == 'mod')
{
?><option class="sep" value="-1">Affected forum</option><?php
}
echo $forum_options; ?></select></td>
</tr>
</table>
<?php
}
if (isset($_POST['f']) && strstr($_POST['field'], 'forum'))
{
?>
<table class="bg" width="60%" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th>&nbsp;<?php echo $user->lang['OPTION']; ?>&nbsp;</th>
<th>&nbsp;<?php echo $user->lang['ALLOW']; ?>&nbsp;</th>
<th>&nbsp;<?php echo $user->lang['DENY']; ?>&nbsp;</th>
<th>&nbsp;<?php echo $user->lang['INHERIT']; ?>&nbsp;</th>
</tr>
<?php
$sql = 'SELECT auth_dep
FROM ' . ACL_DEPS_TABLE . " FROM ' . ACL_DEPS_TABLE . "
WHERE auth_value = $chg_acl_option WHERE dep_name ='$dep_quick_access'";
AND auth_allow = $chg_acl_value
AND forum_id = $chg_forum_id";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$auth_values = array(); $auth_values = array();
@ -376,6 +327,163 @@ if ($mode == 'deps')
$auth_values = unserialize($row); $auth_values = unserialize($row);
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
}
?>
<script language="Javascript" type="text/javascript">
<!--
var presets = new Array();
<?php
echo $preset_js;
?>
function preset_obj(allow, deny, inherit)
{
this.allow = allow;
this.deny = deny;
this.inherit = inherit;
}
function use_preset(option)
{
if (option)
{
document.acl.set.selectedIndex = 0;
var expr = new RegExp(/\d+/);
for (i = 0; i < document.acl.length; i++)
{
var elem = document.acl.elements[i];
if (elem.name.indexOf('aclopt') == 0)
{
switch (option)
{
case 'all_yes':
if (elem.value == <?php echo ACL_ALLOW; ?>)
elem.checked = true;
break;
case 'all_no':
if (elem.value == <?php echo ACL_DENY; ?>)
elem.checked = true;
break;
case 'all_unset':
if (elem.value == <?php echo ACL_INHERIT; ?>)
elem.checked = true;
break;
default:
option_name = elem.name.substr(7, elem.name.length - 8);
if (presets[option].allow.indexOf(option_name + ',') != -1 && elem.value == <?php echo ACL_ALLOW; ?>)
elem.checked = true;
else if (presets[option].deny.indexOf(option_name + ',') != -1 && elem.value == <?php echo ACL_DENY; ?>)
elem.checked = true;
else if (presets[option].inherit.indexOf(option_name + ',') != -1 && elem.value == <?php echo ACL_INHERIT; ?>)
elem.checked = true;
break;
}
}
}
}
}
//-->
</script>
<h1><?php echo $l_title; ?></h1>
<p><?php echo $l_title_explain; ?></p>
<table cellspacing="0" cellpadding="0" border="0" align="center">
<tr>
<td align="right"><form method="post" name="deps" action="<?php echo "admin_permissions.$phpEx$SID&amp;mode=$mode"; ?>"><?php echo $user->lang['QUICK ACCESS']; ?>: <select name="set" onchange="use_preset(this.options[this.selectedIndex].value);"><option class="sep"><?php echo $user->lang['SELECT'] . ' -&gt;'; ?></option><?php
echo ($preset_options) ? '<option class="sep">' . $user->lang['USER_PRESETS'] . ' -&gt;' . '</option>' . $preset_options : '';
?></select><table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0">
<tr>
<th colspan="2">&nbsp;</th>
</tr>
<tr>
<td class="row1" width="150">Permission type: </td>
<td class="row2"><select name="dep_type" onchange="if (this.options[this.selectedIndex].value != -1) this.form.submit();"><option value="-1"<?php
echo ($dep_type == -1) ? ' selected="selected"' : '';
?>>Choose type</option><?php echo $acl_types; ?></select></td>
</tr>
<?php
if ($dep_type != -1)
{
?>
<tr>
<td class="row1" width="150">Changing option:</td>
<td class="row2"><select name="dep_option[]" multiple="4"><?php echo $auth_options; ?></select></td>
</tr>
<tr>
<td class="row1" width="150">To value:</td>
<td class="row2"><select name="dep_value"><option value="-1"<?php
echo ($dep_value == -1) ? ' selected="selected"' : '';
?>>Choose value</option><?php echo $value_options; ?></select></td>
</tr>
<tr>
<td class="row1" width="150">Will set options in: <br /><span class="gensmall"></span></td>
<td class="row2"><select name="f[]" multiple="4"><option class="sep" value="0"<?php
echo ($dep_forum_id == 0) ? ' selected="selected"' : '';
?>>All current forums</option><?php
if ($dep_type == 'mod')
{
?><option class="sep" value="-2">Affected forum</option><?php
}
echo $forum_options; ?></select></td>
</tr>
<tr>
<td class="row1">Quick access name:</td>
<td class="row2"><input class="post" type="text" name="dep_name" value="" /></td>
</tr>
<tr>
<td class="cat" colspan="4" align="center"><input class="mainoption" type="submit" name="setdep" value="<?php echo $user->lang['SUBMIT']; ?>" /></td>
</tr>
<?php
}
?>
</table></form></td>
</tr>
<?php
if (isset($_POST['setdep']) && $dep_option && $dep_value != -1)
{
?>
<tr>
<td align="right"><form method="post" name="acl" action="<?php echo "admin_permissions.$phpEx$SID&amp;mode=$mode"; ?>"><?php echo $user->lang['PRESETS']; ?>: <select name="set" onchange="use_preset(this.options[this.selectedIndex].value);"><option class="sep"><?php echo $user->lang['SELECT'] . ' -&gt;'; ?></option><option value="all_yes"><?php echo $user->lang['ALL_YES']; ?></option><option value="all_no"><?php echo $user->lang['ALL_NO']; ?></option><option value="all_unset"><?php echo $user->lang['ALL_UNSET']; ?></option><?php
echo ($preset_options) ? '<option class="sep">' . $user->lang['USER_PRESETS'] . ' -&gt;' . '</option>' . $preset_options : '';
?></select></td>
</tr>
<tr>
<td><table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0">
<tr>
<th>&nbsp;<?php echo $user->lang['OPTION']; ?>&nbsp;</th>
<th width="50">&nbsp;<?php echo $user->lang['YES']; ?>&nbsp;</th>
<th width="50">&nbsp;<?php echo $user->lang['NO']; ?>&nbsp;</th>
<th width="50">&nbsp;<?php echo $user->lang['UNSET']; ?>&nbsp;</th>
</tr>
<?php
$founder_sql = ($user->data['user_founder']) ? ' AND founder_only <> 1' : ''; $founder_sql = ($user->data['user_founder']) ? ' AND founder_only <> 1' : '';
$sql = "SELECT auth_option_id, auth_value $sql = "SELECT auth_option_id, auth_value
@ -393,29 +501,31 @@ if ($mode == 'deps')
$allow_type = (isset($auth_values[$row['auth_value']]) && $auth_values[$row['auth_value']] == ACL_ALLOW) ? ' checked="checked"' : ''; $allow_type = (isset($auth_values[$row['auth_value']]) && $auth_values[$row['auth_value']] == ACL_ALLOW) ? ' checked="checked"' : '';
$deny_type = (isset($auth_values[$row['auth_value']]) && $auth_values[$row['auth_value']] == ACL_DENY) ? ' checked="checked"' : ''; $deny_type = (isset($auth_values[$row['auth_value']]) && $auth_values[$row['auth_value']] == ACL_DENY) ? ' checked="checked"' : '';
$inherit_type = (empty($auth_values[$row['auth_value']]) || $auth_values[$row['auth_value']] == ACL_INHERIT) ? ' checked="checked"' : ''; $inherit_type = (!isset($auth_values[$row['auth_value']]) || $auth_values[$row['auth_value']] == ACL_INHERIT) ? ' checked="checked"' : '';
?> ?>
<tr> <tr>
<td class="<?php echo $row_class; ?>"><?php echo $l_can_cell; ?></td> <td class="<?php echo $row_class; ?>"><?php echo $l_can_cell; ?></td>
<td class="<?php echo $row_class; ?>" align="center"><input type="radio" name="option[<?php echo $row['auth_value']; ?>]" value="<?php echo ACL_ALLOW; ?>"<?php echo $allow_type; ?> /></td> <td class="<?php echo $row_class; ?>" align="center"><input type="radio" name="aclopt[<?php echo $row['auth_value']; ?>]" value="<?php echo ACL_ALLOW; ?>"<?php echo $allow_type; ?> /></td>
<td class="<?php echo $row_class; ?>" align="center"><input type="radio" name="option[<?php echo $row['auth_value']; ?>]" value="<?php echo ACL_DENY; ?>"<?php echo $deny_type; ?> /></td> <td class="<?php echo $row_class; ?>" align="center"><input type="radio" name="aclopt[<?php echo $row['auth_value']; ?>]" value="<?php echo ACL_DENY; ?>"<?php echo $deny_type; ?> /></td>
<td class="<?php echo $row_class; ?>" align="center"><input type="radio" name="option[<?php echo $row['auth_value']; ?>]" value="<?php echo ACL_INHERIT; ?>"<?php echo $inherit_type; ?> /></td> <td class="<?php echo $row_class; ?>" align="center"><input type="radio" name="aclopt[<?php echo $row['auth_value']; ?>]" value="<?php echo ACL_INHERIT; ?>"<?php echo $inherit_type; ?> /></td>
</tr> </tr>
<?php <?php
} }
?> ?>
<tr> <tr>
<td class="cat" colspan="4" align="center"><input class="mainoption" type="submit" name="submit" value="<?php echo $user->lang['SUBMIT']; ?>" /></td> <td class="cat" colspan="4" align="center"><input class="mainoption" type="submit" name="submit" value="<?php echo $user->lang['SUBMIT']; ?>" /></td>
</tr>
</table></form></td>
</tr> </tr>
<?php <?php
} }
?> ?>
</table><input type="hidden" name="field" value="" /></form> </table>
<?php <?php
@ -707,15 +817,15 @@ else if (!empty($forum_id) ||
{ {
switch (option) switch (option)
{ {
case 'all_allow': case 'all_yes':
if (elem.value == <?php echo ACL_ALLOW; ?>) if (elem.value == <?php echo ACL_ALLOW; ?>)
elem.checked = true; elem.checked = true;
break; break;
case 'all_deny': case 'all_no':
if (elem.value == <?php echo ACL_DENY; ?>) if (elem.value == <?php echo ACL_DENY; ?>)
elem.checked = true; elem.checked = true;
break; break;
case 'all_inherit': case 'all_unset':
if (elem.value == <?php echo ACL_INHERIT; ?>) if (elem.value == <?php echo ACL_INHERIT; ?>)
elem.checked = true; elem.checked = true;
break; break;
@ -750,7 +860,7 @@ else if (!empty($forum_id) ||
<form method="post" name="acl" action="<?php echo "admin_permissions.$phpEx$SID&amp;mode=$mode"; ?>"><table cellspacing="2" cellpadding="0" border="0" align="center"> <form method="post" name="acl" action="<?php echo "admin_permissions.$phpEx$SID&amp;mode=$mode"; ?>"><table cellspacing="2" cellpadding="0" border="0" align="center">
<tr> <tr>
<td align="right"><?php echo $user->lang['PRESETS']; ?>: <select name="set" onchange="use_preset(this.options[this.selectedIndex].value);"><option class="sep"><?php echo $user->lang['SELECT'] . ' -&gt;'; ?></option><option value="all_allow"><?php echo $user->lang['ALL_ALLOW']; ?></option><option value="all_deny"><?php echo $user->lang['ALL_DENY']; ?></option><option value="all_inherit"><?php echo $user->lang['ALL_INHERIT']; ?></option><?php <td align="right"><?php echo $user->lang['PRESETS']; ?>: <select name="set" onchange="use_preset(this.options[this.selectedIndex].value);"><option class="sep"><?php echo $user->lang['SELECT'] . ' -&gt;'; ?></option><option value="all_yes"><?php echo $user->lang['ALL_YES']; ?></option><option value="all_no"><?php echo $user->lang['ALL_NO']; ?></option><option value="all_unset"><?php echo $user->lang['ALL_UNSET']; ?></option><?php
echo ($preset_options) ? '<option class="sep">' . $user->lang['USER_PRESETS'] . ' -&gt;' . '</option>' . $preset_options : ''; echo ($preset_options) ? '<option class="sep">' . $user->lang['USER_PRESETS'] . ' -&gt;' . '</option>' . $preset_options : '';
@ -760,9 +870,9 @@ else if (!empty($forum_id) ||
<td><table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0" align="center"> <td><table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0" align="center">
<tr> <tr>
<th>&nbsp;<?php echo $user->lang['OPTION']; ?>&nbsp;</th> <th>&nbsp;<?php echo $user->lang['OPTION']; ?>&nbsp;</th>
<th>&nbsp;<?php echo $user->lang['ALLOW']; ?>&nbsp;</th> <th width="50">&nbsp;<?php echo $user->lang['YES']; ?>&nbsp;</th>
<th>&nbsp;<?php echo $user->lang['DENY']; ?>&nbsp;</th> <th width="50">&nbsp;<?php echo $user->lang['NO']; ?>&nbsp;</th>
<th>&nbsp;<?php echo $user->lang['INHERIT']; ?>&nbsp;</th> <th width="50">&nbsp;<?php echo $user->lang['UNSET']; ?>&nbsp;</th>
</tr> </tr>
<?php <?php
@ -782,12 +892,12 @@ else if (!empty($forum_id) ||
{ {
$allow_type = (isset($auth_values[$auth_options[$i]['auth_value']]) && $auth_values[$auth_options[$i]['auth_value']] == ACL_ALLOW) ? ' checked="checked"' : ''; $allow_type = (isset($auth_values[$auth_options[$i]['auth_value']]) && $auth_values[$auth_options[$i]['auth_value']] == ACL_ALLOW) ? ' checked="checked"' : '';
$deny_type = (isset($auth_values[$auth_options[$i]['auth_value']]) && $auth_values[$auth_options[$i]['auth_value']] == ACL_DENY) ? ' checked="checked"' : ''; $deny_type = (isset($auth_values[$auth_options[$i]['auth_value']]) && $auth_values[$auth_options[$i]['auth_value']] == ACL_DENY) ? ' checked="checked"' : '';
$inherit_type = (empty($auth_values[$auth_options[$i]['auth_value']]) || $auth_values[$auth_options[$i]['auth_value']] == ACL_INHERIT) ? ' checked="checked"' : ''; $inherit_type = (!isset($auth_values[$auth_options[$i]['auth_value']]) || $auth_values[$auth_options[$i]['auth_value']] == ACL_INHERIT) ? ' checked="checked"' : '';
} }
?> ?>
<tr> <tr>
<td class="<?php echo $row_class; ?>"><?php echo $l_can_cell; ?></td> <td class="<?php echo $row_class; ?>" nowrap="nowrap"><?php echo $l_can_cell; ?>&nbsp;</td>
<td class="<?php echo $row_class; ?>" align="center"><input type="radio" name="option[<?php echo $auth_options[$i]['auth_value']; ?>]" value="<?php echo ACL_ALLOW; ?>"<?php echo $allow_type; ?> /></td> <td class="<?php echo $row_class; ?>" align="center"><input type="radio" name="option[<?php echo $auth_options[$i]['auth_value']; ?>]" value="<?php echo ACL_ALLOW; ?>"<?php echo $allow_type; ?> /></td>
<td class="<?php echo $row_class; ?>" align="center"><input type="radio" name="option[<?php echo $auth_options[$i]['auth_value']; ?>]" value="<?php echo ACL_DENY; ?>"<?php echo $deny_type; ?> /></td> <td class="<?php echo $row_class; ?>" align="center"><input type="radio" name="option[<?php echo $auth_options[$i]['auth_value']; ?>]" value="<?php echo ACL_DENY; ?>"<?php echo $deny_type; ?> /></td>
<td class="<?php echo $row_class; ?>" align="center"><input type="radio" name="option[<?php echo $auth_options[$i]['auth_value']; ?>]" value="<?php echo ACL_INHERIT; ?>"<?php echo $inherit_type; ?> /></td> <td class="<?php echo $row_class; ?>" align="center"><input type="radio" name="option[<?php echo $auth_options[$i]['auth_value']; ?>]" value="<?php echo ACL_INHERIT; ?>"<?php echo $inherit_type; ?> /></td>
@ -805,12 +915,12 @@ else if (!empty($forum_id) ||
{ {
?> ?>
<tr> <tr>
<th colspan="4"><?php echo $user->lang['INHERITANCE']; ?></th> <th colspan="4"><?php echo $user->lang['ACL_SUBFORUMS']; ?></th>
</tr> </tr>
<tr> <tr>
<td class="row1" colspan="4"><table width="100%" cellspacing="1" cellpadding="0" border="0"> <td class="row1" colspan="4"><table width="100%" cellspacing="1" cellpadding="0" border="0">
<tr> <tr>
<td colspan="4" height="16"><span class="gensmall"><?php echo $user->lang['INHERITANCE_EXPLAIN']; ?></span></td> <td class="gensmall" colspan="4" height="16" align="center"><?php echo $user->lang['ACL_SUBFORUMS_EXPLAIN']; ?></td>
</tr> </tr>
<?php <?php
foreach ($children as $row) foreach ($children as $row)

View file

@ -955,7 +955,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
die("Unable to show notice, \$user class hasn't been instantiated yet.<br />Error triggered in: " . $errfile .":". $errline); die("Unable to show notice, \$user class hasn't been instantiated yet.<br />Error triggered in: " . $errfile .":". $errline);
} }
if (empty($user->session_id)) if (empty($user->data))
{ {
$user->start(); $user->start();
} }
@ -996,6 +996,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
include($phpbb_root_path . 'includes/page_tail.' . $phpEx); include($phpbb_root_path . 'includes/page_tail.' . $phpEx);
} }
exit;
break; break;
} }
} }

View file

@ -20,7 +20,7 @@
***************************************************************************/ ***************************************************************************/
// Simple version of jumpbox, just lists authed forums // Simple version of jumpbox, just lists authed forums
function make_forum_select($forum_id = false, $ignore_forum = false, $add_select = true) function make_forum_select($forum_id = false, $ignore_forum = false, $add_select = false)
{ {
global $db, $user, $auth; global $db, $user, $auth;
@ -34,7 +34,7 @@ function make_forum_select($forum_id = false, $ignore_forum = false, $add_select
while ($row = $db->sql_fetchrow($result)) while ($row = $db->sql_fetchrow($result))
{ {
if (!$auth->acl_gets('f_list', 'm_', 'a_', $row['forum_id']) || $row['forum_id'] == $ignore_forum) if (!$auth->acl_get('f_list', $row['forum_id']) || $row['forum_id'] == $ignore_forum)
{ {
// if the user does not have permissions to list this forum skip // if the user does not have permissions to list this forum skip
continue; continue;
@ -51,7 +51,7 @@ function make_forum_select($forum_id = false, $ignore_forum = false, $add_select
$right = $row['right_id']; $right = $row['right_id'];
$selected = ($row['forum_id'] == $forum_id) ? ' selected="selected"' : ''; $selected = (is_array($forum_id)) ? ((in_array($row['forum_id'], $forum_id)) ? ' selected="selected"' : '') : (($row['forum_id'] == $forum_id) ? ' selected="selected"' : '');
if ($row['left_id'] > $cat_right) if ($row['left_id'] > $cat_right)
{ {
@ -1117,7 +1117,8 @@ function cache_moderators()
{ {
case 'mysql': case 'mysql':
case 'mysql4': case 'mysql4':
$sql = 'INSERT INTO ' . MODERATOR_TABLE . ' (forum_id, user_id, username, group_id, groupname) VALUES ' . implode(', ', preg_replace('#^(.*)$#', '(\1)', $m_sql)); $sql = 'INSERT INTO ' . MODERATOR_TABLE . ' (forum_id, user_id, username, group_id, groupname)
VALUES ' . implode(', ', preg_replace('#^(.*)$#', '(\1)', $m_sql));
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$db->sql_freeresult($result); $db->sql_freeresult($result);
break; break;
@ -1132,7 +1133,8 @@ function cache_moderators()
default: default:
foreach ($m_sql as $k => $sql) foreach ($m_sql as $k => $sql)
{ {
$result = $db->sql_query('INSERT INTO ' . MODERATOR_TABLE . " (forum_id, user_id, username, group_id, groupname) VALUES ($sql)"); $result = $db->sql_query('INSERT INTO ' . MODERATOR_TABLE . " (forum_id, user_id, username, group_id, groupname)
VALUES ($sql)");
$db->sql_freeresult($result); $db->sql_freeresult($result);
} }
} }
@ -1147,6 +1149,30 @@ class auth_admin extends auth
{ {
global $db; global $db;
// One or more forums
if (!is_array($forum_id))
{
$forum_id = array($forum_id);
}
// Obtain list of dependencies - WRONG
/* $sql = 'SELECT auth_value, forum_id, auth_allow, auth_dep
FROM ' . ACL_DEPS_TABLE . '
WHERE forum_id IN (' . implode(', ', $forum_id) . ')
AND auth_value IN (' . implode(', ', preg_replace('#^(.*?)$#', "'\\1'", $auth)) . ')';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$row = unserialize($row['auth_dep']);
foreach ($row as $auth_value => $allow)
{
$auth[$auth_value] = $allow;
}
unset($row);
}
$db->sql_freeresult($result);
*/
// Set any flags as required // Set any flags as required
foreach ($auth as $auth_value => $allow) foreach ($auth as $auth_value => $allow)
{ {
@ -1167,11 +1193,6 @@ class auth_admin extends auth
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
// One or more forums
if (!is_array($forum_id))
{
$forum_id = array($forum_id);
}
// NOTE THIS USED TO BE IN ($forum_id, 0) ... // NOTE THIS USED TO BE IN ($forum_id, 0) ...
$forum_sql = 'AND a.forum_id IN (' . implode(', ', $forum_id) . ')'; $forum_sql = 'AND a.forum_id IN (' . implode(', ', $forum_id) . ')';
@ -1366,12 +1387,12 @@ function add_log()
if ($mode == 'admin') if ($mode == 'admin')
{ {
$sql = 'INSERT INTO ' . LOG_ADMIN_TABLE . ' (user_id, log_ip, log_time, log_operation, log_data) $sql = 'INSERT INTO ' . LOG_ADMIN_TABLE . ' (user_id, log_ip, log_time, log_operation, log_data)
VALUES (' . $user->data['user_id'] . ", '$user->ip', " . time() . ", '$action', '$data')"; VALUES (' . $user->data['user_id'] . ", '$user->ip', " . time() . ", '$action', '$data')";
} }
else else
{ {
$sql = 'INSERT INTO ' . LOG_MOD_TABLE . ' (user_id, forum_id, topic_id, log_ip, log_time, log_operation, log_data) $sql = 'INSERT INTO ' . LOG_MOD_TABLE . ' (user_id, forum_id, topic_id, log_ip, log_time, log_operation, log_data)
VALUES (' . $user->data['user_id'] . ", $forum_id, $topic_id, '$user->ip', " . time() . ", '$action', '$data')"; VALUES (' . $user->data['user_id'] . ", $forum_id, $topic_id, '$user->ip', " . time() . ", '$action', '$data')";
} }
$db->sql_query($sql); $db->sql_query($sql);
@ -1402,7 +1423,7 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
do do
{ {
$log[$i]['id'] = $row['log_id']; $log[$i]['id'] = $row['log_id'];
$log[$i]['username'] = '<a href="admin_users.'.$phpEx . $SID . '&amp;u=' . $row['user_id'] . '">' . $row['username'] . '</a>'; $log[$i]['username'] = '<a href="admin_users.' . $phpEx . $SID . '&amp;u=' . $row['user_id'] . '">' . $row['username'] . '</a>';
$log[$i]['ip'] = $row['log_ip']; $log[$i]['ip'] = $row['log_ip'];
$log[$i]['time'] = $row['log_time']; $log[$i]['time'] = $row['log_time'];

View file

@ -184,7 +184,7 @@ INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('u_sendpm', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('u_viewonline', 1); INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('u_viewonline', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('u_viewprofile', 1); INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('u_viewprofile', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('u_chgavatar', 1); INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('u_chgavatar', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('u_chgcolor', 1); INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('u_chggrp', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('u_chgemail', 1); INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('u_chgemail', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('u_chgname', 1); INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('u_chgname', 1);
INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('u_chgpasswd', 1); INSERT INTO phpbb_auth_options (auth_value, is_global) VALUES ('u_chgpasswd', 1);

View file

@ -45,11 +45,14 @@ CREATE TABLE phpbb_attach_desc (
# Table structure for table `phpbb_auth_dependencies` # Table structure for table `phpbb_auth_dependencies`
# #
CREATE TABLE phpbb_auth_dependencies ( CREATE TABLE phpbb_auth_dependencies (
auth_value varchar(20) NOT NULL default '', dep_id tinyint(4) UNSIGNED NOT NULL auto_increment,
dep_name varchar(50) NOT NULL DEFAULT '',
auth_value text NOT NULL,
auth_allow tinyint(1) NOT NULL default '2', auth_allow tinyint(1) NOT NULL default '2',
forum_id int(11) NOT NULL default '0', forum_id text NOT NULL,
auth_deps text NOT NULL default '', auth_deps text NOT NULL,
PRIMARY KEY (auth_value) PRIMARY KEY (dep_id),
KEY dep_name (dep_name)
); );

View file

@ -199,7 +199,7 @@ $lang = array_merge($lang, array(
'Restore_Error_no_file' => 'No file was uploaded', 'Restore_Error_no_file' => 'No file was uploaded',
'ACL_EXPLAIN' => 'Permissions are based on an ALLOW / INHERIT / DENY system with all options being denied by default. The precedent is DENY &gt; ALLOW &gt; INHERIT for any combination of user or group settings. The INHERIT setting causes permissions granted elsewhere for the option being used in place of a specific ALLOW / DENY setting here.', 'ACL_EXPLAIN' => 'Permissions are based on a simple YES / NO system. Setting an option to NO for a user or usergroup overrides any other value assigned to it. If you do not wish to assign a value for an option for this user or group select UNSET. If values are assigned for this option elsewhere they will be used in preference, else NO is assumed.',
'PERMISSIONS_EXPLAIN' => 'Here you can alter which users and groups can access which forums. To assign moderators or define administrators please use the appropriate page (see left hand side menu).', 'PERMISSIONS_EXPLAIN' => 'Here you can alter which users and groups can access which forums. To assign moderators or define administrators please use the appropriate page (see left hand side menu).',
'MODERATORS' => 'Moderators', 'MODERATORS' => 'Moderators',
'MODERATORS_EXPLAIN' => 'Here you can assign users and groups as forum moderators. To assign users access to forums, to define super moderators or administrators please use the appropriate page (see left hand side menu).', 'MODERATORS_EXPLAIN' => 'Here you can assign users and groups as forum moderators. To assign users access to forums, to define super moderators or administrators please use the appropriate page (see left hand side menu).',
@ -225,108 +225,111 @@ $lang = array_merge($lang, array(
'REMOVE_SELECTED' => 'Remove selected', 'REMOVE_SELECTED' => 'Remove selected',
'SET_OPTIONS' => 'Set Options', 'SET_OPTIONS' => 'Set Options',
'OPTION' => 'Option', 'OPTION' => 'Option',
'ALLOW' => 'Allow', 'YES' => 'Yes',
'INHERIT' => 'Inherit', 'NO' => 'No',
'DENY' => 'Deny', 'UNSET' => 'Unset',
'PRESETS' => 'Presets', 'PRESETS' => 'Presets',
'ALL_ALLOW' => 'All Allow', 'ALL_YES' => 'All Yes',
'ALL_DENY' => 'All Deny', 'ALL_NO' => 'All No',
'ALL_INHERIT' => 'All Inherit', 'ALL_UNSET' => 'All Unset',
'USER_PRESETS' => 'User presets', 'USER_PRESETS' => 'User presets',
'INHERIT_PARENT'=> 'From Parent', 'FROM_PARENT' => 'From Parent',
'INHERITANCE' => 'Inheritance', 'ACL_SUBFORUMS' => 'Assign to sub-forums',
'INHERITANCE_EXPLAIN' => 'Select the subforums you want to inherit these permissions', 'ACL_SUBFORUMS_EXPLAIN' => 'Select the subforums (if any) you want to inherit these permissions',
'PRESETS_EXPLAIN' => 'To update or delete an existing preset select it from the list.', 'PRESETS_EXPLAIN' => 'To update or delete an existing preset select it from the list.',
'SELECT_PRESET' => 'Select preset', 'SELECT_PRESET' => 'Select preset',
'PRESET_NAME' => 'Preset name', 'PRESET_NAME' => 'Preset name',
'EMPTY' => 'Empty', 'EMPTY' => 'Empty',
'QUICK ACCESS' => 'Quick access',
'AUTH_UPDATED' => 'Permissions have been updated', 'AUTH_UPDATED' => 'Permissions have been updated',
'acl_a_server' => 'Alter Server/Email Settings', 'acl_a_server' => 'Can alter server and email settings',
'acl_a_defaults' => 'Alter Board Defaults', 'acl_a_defaults' => 'Can alter board defaults',
'acl_a_board' => 'Alter Board Settings', 'acl_a_board' => 'Can alter board settings',
'acl_a_cookies' => 'Alter Cookie Settings', 'acl_a_cookies' => 'Can alter cookie settings',
'acl_a_names' => 'Alter Disallowed Names', 'acl_a_names' => 'Can alter disallowed names',
'acl_a_words' => 'Alter Word Censors', 'acl_a_words' => 'Can alter word censors',
'acl_a_icons' => 'Alter Topic Icons/Emoticons', 'acl_a_icons' => 'Can alter topic icons and emoticons',
'acl_a_search' => 'Re-index Search Tables', 'acl_a_search' => 'Can re-index search tables',
'acl_a_prune' => 'Prune Forums', 'acl_a_prune' => 'Can prune forums',
'acl_a_bbcode' => 'Define BBCode Tags', 'acl_a_bbcode' => 'Can define BBCode tags',
'acl_a_attach' => 'Manage Attachments', 'acl_a_attach' => 'Can manage attachments',
'acl_a_events' => 'Manage User/Group Events', 'acl_a_ranks' => 'Can manage ranks',
'acl_a_ranks' => 'Manage Ranks', 'acl_a_user' => 'Can manage users',
'acl_a_user' => 'Manage Users', 'acl_a_userdel' => 'Can delete or prune users',
'acl_a_userdel' => 'Delete/Prune Users', 'acl_a_useradd' => 'Can add new users',
'acl_a_useradd' => 'Add New Users', 'acl_a_group' => 'Can manage groups',
'acl_a_group' => 'Manage Groups', 'acl_a_groupdel' => 'Can delete groups',
'acl_a_groupdel' => 'Delete Groups', 'acl_a_groupadd' => 'Can add new groups',
'acl_a_groupadd' => 'Add New Groups', 'acl_a_forum' => 'Can manage forums',
'acl_a_forum' => 'Manage Forums', 'acl_a_forumdel' => 'Can delete forums',
'acl_a_forumdel' => 'Delete Forums', 'acl_a_forumadd' => 'Can add new forums',
'acl_a_forumadd' => 'Add New Forums', 'acl_a_ban' => 'Can manage bans',
'acl_a_ban' => 'Manage Bans', 'acl_a_auth' => 'Can alter forum permissions',
'acl_a_auth' => 'Alter Forum Permissions', 'acl_a_authmods' => 'Can alter moderator permissions',
'acl_a_authmods' => 'Alter Moderator Permissions', 'acl_a_authadmins' => 'Can alter admin permissions',
'acl_a_authadmins' => 'Alter Admin Permissions', 'acl_a_authusers' => 'Can alter user permissions',
'acl_a_authusers' => 'Alter User Permissions', 'acl_a_authgroups' => 'Can alter group permissions',
'acl_a_authgroups' => 'Alter Group Permissions', 'acl_a_email' => 'Can send mass email',
'acl_a_email' => 'Mass Email', 'acl_a_styles' => 'Can manage styles',
'acl_a_styles' => 'Manage Styles', 'acl_a_backup' => 'Can backup database',
'acl_a_backup' => 'Backup Database', 'acl_a_restore' => 'Can restore database',
'acl_a_restore' => 'Restore Database', 'acl_a_clearlogs' => 'Can clear admin and mod logs',
'acl_a_clearlogs' => 'Clear Admin/Mod Logs', 'acl_a_events' => 'Can use event system',
'acl_a_events' => 'Use Event system', 'acl_a_cron' => 'Can use cron system',
'acl_a_cron' => 'Use Cron system', 'acl_a_authdeps' => 'Can set dependencies',
'acl_a_authdeps' => 'Set ACL Dependencies',
'acl_m_edit' => 'Edit posts', 'acl_m_edit' => 'Can edit posts',
'acl_m_delete' => 'Delete posts', 'acl_m_delete' => 'Can delete posts',
'acl_m_move' => 'Move posts', 'acl_m_move' => 'Can move topics',
'acl_m_lock' => 'Lock topics', 'acl_m_lock' => 'Can lock topics',
'acl_m_split' => 'Split topics', 'acl_m_split' => 'Can split topics',
'acl_m_merge' => 'Merge topics', 'acl_m_merge' => 'Can merge topics',
'acl_m_approve' => 'Approve posts', 'acl_m_approve' => 'Can approve posts',
'acl_m_unrate' => 'Un-rate topics', 'acl_m_unrate' => 'Can un-rate posts',
'acl_m_auth' => 'Set permissions', 'acl_m_auth' => 'Can set permissions',
'acl_m_ip' => 'View IP\'s', 'acl_m_ip' => 'Can view IP\'s',
'acl_f_list' => 'See forum', 'acl_f_list' => 'Can see forum',
'acl_f_read' => 'Read forum', 'acl_f_read' => 'Can read forum',
'acl_f_post' => 'Post in forum', 'acl_f_post' => 'Can post in forum',
'acl_f_reply' => 'Reply to posts', 'acl_f_reply' => 'Can reply to posts',
'acl_f_edit' => 'Edit own posts', 'acl_f_quote' => 'Can quote posts',
'acl_f_delete' => 'Delete own posts', 'acl_f_edit' => 'Can edit own posts',
'acl_f_poll' => 'Create polls', 'acl_f_delete' => 'Can delete own posts',
'acl_f_vote' => 'Vote in polls', 'acl_f_poll' => 'Can create polls',
'acl_f_announce' => 'Post announcements', 'acl_f_vote' => 'Can vote in polls',
'acl_f_sticky' => 'Post stickies', 'acl_f_announce' => 'Can post announcements',
'acl_f_attach' => 'Attach files', 'acl_f_sticky' => 'Can post stickies',
'acl_f_download' => 'Download files', 'acl_f_attach' => 'Can attach files',
'acl_f_html' => 'Post HTML', 'acl_f_download' => 'Can download files',
'acl_f_bbcode' => 'Post BBCode', 'acl_f_html' => 'Can post HTML',
'acl_f_smilies' => 'Post smilies', 'acl_f_bbcode' => 'Can post BBCode',
'acl_f_img' => 'Post images', 'acl_f_smilies' => 'Can post smilies',
'acl_f_flash' => 'Post Flash', 'acl_f_img' => 'Can post images',
'acl_f_sigs' => 'Use signatures', 'acl_f_flash' => 'Can post Flash',
'acl_f_search' => 'Search the forum', 'acl_f_sigs' => 'Can use signatures',
'acl_f_email' => 'Email topics', 'acl_f_search' => 'Can search the forum',
'acl_f_rate' => 'Rate topics', 'acl_f_email' => 'Can email topics',
'acl_f_print' => 'Print topics', 'acl_f_rate' => 'Can rate posts',
'acl_f_ignoreflood' => 'Ignore flood limit', 'acl_f_report' => 'Can report posts',
'acl_f_ignorequeue' => 'Ignore mod queue', 'acl_f_print' => 'Can print topics',
'acl_f_ignoreflood' => 'Can ignore flood limit',
'acl_f_postcount' => 'Increment post counter', 'acl_f_postcount' => 'Increment post counter',
'acl_f_moderate' => 'Posts are moderated',
'acl_u_viewonline' => 'View all online', 'acl_u_viewonline' => 'Can view all online',
'acl_u_viewprofile' => 'View profiles', 'acl_u_viewprofile' => 'Can view profiles',
'acl_u_sendemail' => 'Send emails', 'acl_u_sendemail' => 'Can send emails',
'acl_u_sendpm' => 'Send messages', 'acl_u_sendpm' => 'Can send messages',
'acl_u_readpm' => 'Read messages', 'acl_u_readpm' => 'Can read messages',
'acl_u_chgavatar' => 'Change avatar', 'acl_u_chgavatar' => 'Can change avatar',
'acl_u_chgcolor' => 'Change colour', 'acl_u_chgcolor' => 'Can change default group',
'acl_u_chgemail' => 'Change email address', 'acl_u_chgemail' => 'Can change email address',
'acl_u_chgname' => 'Change username', 'acl_u_chgname' => 'Can change username',
'acl_u_chgpasswd' => 'Change password', 'acl_u_chgpasswd' => 'Can change password',
'acl_u_search' => 'Search board', 'acl_u_search' => 'Can search board',
'Prune_users' => 'Prune Users', 'Prune_users' => 'Prune Users',