diff options
author | Paul S. Owen <psotfx@users.sourceforge.net> | 2003-04-01 00:06:11 +0000 |
---|---|---|
committer | Paul S. Owen <psotfx@users.sourceforge.net> | 2003-04-01 00:06:11 +0000 |
commit | 5231006c03848f7e35ef53b0548a4ed5b5732a5e (patch) | |
tree | 1dda392cb8077f61261bc9e0ace9e6359d63376d /phpBB/adm | |
parent | 3257af80f0f510c11b4d7370bebf9c580a524d49 (diff) | |
download | forums-5231006c03848f7e35ef53b0548a4ed5b5732a5e.tar forums-5231006c03848f7e35ef53b0548a4ed5b5732a5e.tar.gz forums-5231006c03848f7e35ef53b0548a4ed5b5732a5e.tar.bz2 forums-5231006c03848f7e35ef53b0548a4ed5b5732a5e.tar.xz forums-5231006c03848f7e35ef53b0548a4ed5b5732a5e.zip |
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
Diffstat (limited to 'phpBB/adm')
-rw-r--r-- | phpBB/adm/admin_permissions.php | 302 |
1 files changed, 206 insertions, 96 deletions
diff --git a/phpBB/adm/admin_permissions.php b/phpBB/adm/admin_permissions.php index 1be21c51de..c6c60429b5 100644 --- a/phpBB/adm/admin_permissions.php +++ b/phpBB/adm/admin_permissions.php @@ -231,11 +231,11 @@ if ($mode == 'deps') // Generate header page_header($l_title); - $chg_acl_type = (isset($_POST['chg_type'])) ? htmlspecialchars($_POST['chg_type']) : ''; - $chg_acl_option_id = (isset($_POST['chg_option'])) ? intval($_POST['chg_option']) : ''; - $chg_acl_value = (isset($_POST['chg_value'])) ? intval($_POST['chg_value']) : ''; - $chg_forum_id = (isset($_POST['f'])) ? intval($_POST['f']) : 0; - $chg_acl_options = (isset($_POST['option'])) ? $_POST['option'] : ''; + $dep_quick_access = (isset($_POST['dep_quick_access'])) ? htmlspecialchars($_POST['dep_quick_access']) : ''; + $dep_type = (isset($_POST['dep_type'])) ? htmlspecialchars($_POST['dep_type']) : -1; + $dep_option = (isset($_POST['dep_option'])) ? $_POST['dep_option'] : array(); + $dep_value = (isset($_POST['dep_value'])) ? intval($_POST['dep_value']) : -1; + $dep_forum_id = (isset($_POST['f'])) ? $_POST['f'] : array(0); $acl_types = $auth_options = $value_options = $forum_options = ''; @@ -243,139 +243,247 @@ if ($mode == 'deps') 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': - $type_sql = 'a'; + $dep_type = 'a'; break; case 'supermod': case 'mod': - $type_sql = 'm'; + $dep_type = 'm'; break; } $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 . " - WHERE auth_value LIKE '" . $type_sql . "_%' + WHERE auth_value LIKE '" . $dep_type . "_%' $founder_sql"; $result = $db->sql_query($sql); 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); } - 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']); + + foreach ($values as $value => $option) { - $values = array(ACL_DENY => $user->lang['DENY'], ACL_ALLOW => $user->lang['ALLOW'], ACL_INHERIT => $user->lang['INHERIT']); + $value_options .= '<option value="' . $value . '"' . (($dep_value === $value) ? ' selected="selected"' : '') . '>' . $option . '</option>'; + } - foreach ($values as $value => $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 + FROM ' . ACL_DEPS_TABLE . " + WHERE dep_name ='$dep_quick_access'"; + $result = $db->sql_query($sql); + + $auth_values = array(); + if ($row = $db->sql_fetchrow($result)) + { + $auth_values = unserialize($row); + } + $db->sql_freeresult($result); } ?> -<h1><?php echo $l_title; ?></h1> - -<p><?php echo $l_title_explain; ?></p> +<script language="Javascript" type="text/javascript"> +<!-- -<form method="post" name="acl" action="<?php echo "admin_permissions.$phpEx$SID&mode=$mode"; ?>"><table class="bg" width="60%" cellspacing="1" cellpadding="4" border="0" align="center"> - <tr> - <th colspan="2"> </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> + var presets = new Array(); <?php - if ($auth_options != '') - { + echo $preset_js; ?> - <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 + function preset_obj(allow, deny, inherit) + { + this.allow = allow; + this.deny = deny; + this.inherit = inherit; } - if ($value_options != '') + 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 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 + <td align="right"><form method="post" name="deps" action="<?php echo "admin_permissions.$phpEx$SID&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'] . ' ->'; ?></option><?php - } + echo ($preset_options) ? '<option class="sep">' . $user->lang['USER_PRESETS'] . ' ->' . '</option>' . $preset_options : ''; + +?></select><table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0"> + <tr> + <th colspan="2"> </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 - if ($forum_options != '') + 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">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 + <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 ($_POST['type'] == 'mod') - { + if ($dep_type == 'mod') + { -?><option class="sep" value="-1">Affected forum</option><?php +?><option class="sep" value="-2">Affected forum</option><?php - } + } echo $forum_options; ?></select></td> - </tr> -</table> + </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 } - if (isset($_POST['f']) && strstr($_POST['field'], 'forum')) +?> + </table></form></td> + </tr> +<?php + + if (isset($_POST['setdep']) && $dep_option && $dep_value != -1) { ?> -<table class="bg" width="60%" cellspacing="1" cellpadding="4" border="0" align="center"> <tr> - <th> <?php echo $user->lang['OPTION']; ?> </th> - <th> <?php echo $user->lang['ALLOW']; ?> </th> - <th> <?php echo $user->lang['DENY']; ?> </th> - <th> <?php echo $user->lang['INHERIT']; ?> </th> - </tr> -<?php + <td align="right"><form method="post" name="acl" action="<?php echo "admin_permissions.$phpEx$SID&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'] . ' ->'; ?></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 - $sql = 'SELECT auth_dep - FROM ' . ACL_DEPS_TABLE . " - WHERE auth_value = $chg_acl_option - AND auth_allow = $chg_acl_value - AND forum_id = $chg_forum_id"; - $result = $db->sql_query($sql); + echo ($preset_options) ? '<option class="sep">' . $user->lang['USER_PRESETS'] . ' ->' . '</option>' . $preset_options : ''; - $auth_values = array(); - if ($row = $db->sql_fetchrow($result)) - { - $auth_values = unserialize($row); - } - $db->sql_freeresult($result); +?></select></td> + </tr> + <tr> + <td><table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0"> + <tr> + <th> <?php echo $user->lang['OPTION']; ?> </th> + <th width="50"> <?php echo $user->lang['YES']; ?> </th> + <th width="50"> <?php echo $user->lang['NO']; ?> </th> + <th width="50"> <?php echo $user->lang['UNSET']; ?> </th> + </tr> +<?php $founder_sql = ($user->data['user_founder']) ? ' AND founder_only <> 1' : ''; $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"' : ''; $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> - <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="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="option[<?php echo $row['auth_value']; ?>]" value="<?php echo ACL_INHERIT; ?>"<?php echo $inherit_type; ?> /></td> - </tr> + <tr> + <td class="<?php echo $row_class; ?>"><?php echo $l_can_cell; ?></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="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="aclopt[<?php echo $row['auth_value']; ?>]" value="<?php echo ACL_INHERIT; ?>"<?php echo $inherit_type; ?> /></td> + </tr> <?php } ?> - <tr> - <td class="cat" colspan="4" align="center"><input class="mainoption" type="submit" name="submit" value="<?php echo $user->lang['SUBMIT']; ?>" /></td> + <tr> + <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> <?php } ?> -</table><input type="hidden" name="field" value="" /></form> +</table> <?php @@ -707,15 +817,15 @@ else if (!empty($forum_id) || { switch (option) { - case 'all_allow': + case 'all_yes': if (elem.value == <?php echo ACL_ALLOW; ?>) elem.checked = true; break; - case 'all_deny': + case 'all_no': if (elem.value == <?php echo ACL_DENY; ?>) elem.checked = true; break; - case 'all_inherit': + case 'all_unset': if (elem.value == <?php echo ACL_INHERIT; ?>) elem.checked = true; break; @@ -750,7 +860,7 @@ else if (!empty($forum_id) || <form method="post" name="acl" action="<?php echo "admin_permissions.$phpEx$SID&mode=$mode"; ?>"><table cellspacing="2" cellpadding="0" border="0" align="center"> <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'] . ' ->'; ?></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'] . ' ->'; ?></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'] . ' ->' . '</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"> <tr> <th> <?php echo $user->lang['OPTION']; ?> </th> - <th> <?php echo $user->lang['ALLOW']; ?> </th> - <th> <?php echo $user->lang['DENY']; ?> </th> - <th> <?php echo $user->lang['INHERIT']; ?> </th> + <th width="50"> <?php echo $user->lang['YES']; ?> </th> + <th width="50"> <?php echo $user->lang['NO']; ?> </th> + <th width="50"> <?php echo $user->lang['UNSET']; ?> </th> </tr> <?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"' : ''; $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> - <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; ?> </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_INHERIT; ?>"<?php echo $inherit_type; ?> /></td> @@ -805,12 +915,12 @@ else if (!empty($forum_id) || { ?> <tr> - <th colspan="4"><?php echo $user->lang['INHERITANCE']; ?></th> + <th colspan="4"><?php echo $user->lang['ACL_SUBFORUMS']; ?></th> </tr> <tr> <td class="row1" colspan="4"><table width="100%" cellspacing="1" cellpadding="0" border="0"> <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> <?php foreach ($children as $row) |