From c66ba88f92a6beeb3b44cac36277e4cd33570cf8 Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Sun, 30 Mar 2003 14:27:42 +0000 Subject: [PATCH] Various changes ... it works again now :D git-svn-id: file:///svn/phpbb/trunk@3753 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/adm/admin_permissions.php | 353 +++++++++++++++++++++++--------- 1 file changed, 253 insertions(+), 100 deletions(-) diff --git a/phpBB/adm/admin_permissions.php b/phpBB/adm/admin_permissions.php index 0b0f3c2f05..1be21c51de 100644 --- a/phpBB/adm/admin_permissions.php +++ b/phpBB/adm/admin_permissions.php @@ -25,20 +25,21 @@ if (!empty($setmodules)) $module['FORUM']['PERMISSIONS'] = ($auth->acl_get('a_auth')) ? $filename . $SID . '&mode=forums' : ''; $module['FORUM']['MODERATORS'] = ($auth->acl_get('a_authmods')) ? $filename . $SID . '&mode=moderators' : ''; $module['FORUM']['SUPER_MODERATORS'] = ($auth->acl_get('a_authmods')) ? $filename . $SID . '&mode=supermoderators' : ''; - $module['GENERAL']['ADMINISTRATORS'] = ($auth->acl_get('a_authadmins')) ? $filename . $SID . '&mode=administrators' : ''; + $module['FORUM']['ADMINISTRATORS'] = ($auth->acl_get('a_authadmins')) ? $filename . $SID . '&mode=administrators' : ''; $module['USER']['PERMISSIONS'] = ($auth->acl_get('a_authusers')) ? $filename . $SID . '&mode=users' : ''; $module['GROUP']['PERMISSIONS'] = ($auth->acl_get('a_authgroups')) ? $filename . $SID . '&mode=groups' : ''; + $module['GENERAL']['DEPENDENCIES'] = ($auth->acl_get('a_authdeps')) ? $filename . $SID . '&mode=deps' : ''; return; } define('IN_PHPBB', 1); - // Include files $phpbb_root_path = '../'; require($phpbb_root_path . 'extension.inc'); require('pagestart.' . $phpEx); + // Define some vars $forum_id = 0; $forum_sql = ''; @@ -54,7 +55,6 @@ $group_id = (isset($_REQUEST['g'])) ? intval($_REQUEST['g']) : ''; $entries = (isset($_POST['entries'])) ? $_POST['entries'] : ''; - // Start program proper switch ($mode) { @@ -100,8 +100,14 @@ switch ($mode) $type_sql = 'u'; break; + case 'deps': + $l_title = $user->lang['DEPENDENCIES']; + $l_title_explain = $user->lang['DEPENDENCIES_EXPLAIN']; + $which_acl = 'a_authdeps'; + break; } + // Permission check if (!$auth->acl_get($which_acl)) { @@ -109,13 +115,11 @@ if (!$auth->acl_get($which_acl)) } - - // Call update or delete, both can take multiple user/group // ids. Additionally inheritance is handled (by the auth API) -switch ($_POST['runas']) -{ - case 'now': +//switch ($_POST['runas']) +//{ +// case 'now': if (isset($_POST['update'])) { $auth_admin = new auth_admin(); @@ -134,7 +138,7 @@ switch ($_POST['runas']) cache_moderators(); - trigger_error('Permissions updated successfully'); + trigger_error($user->lang['AUTH_UPDATED']); } else if (isset($_POST['delete'])) { @@ -167,7 +171,7 @@ switch ($_POST['runas']) cache_moderators(); - trigger_error('Permissions updated successfully'); + trigger_error($user->lang['AUTH_UPDATED']); } else if (isset($_POST['presetsave'])) { @@ -214,43 +218,222 @@ switch ($_POST['runas']) $db->sql_query($sql); } } - break; +// break; +//} - case 'evt': - if (isset($_POST['submit'])) + + + + + +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'] : ''; + + $acl_types = $auth_options = $value_options = $forum_options = ''; + + $types = array('admin' => $user->lang['ADMINISTRATORS'], 'supermod' => $user->lang['SUPER_MODERATORS'], 'mod' => $user->lang['MODERATORS']); + + foreach ($types as $value => $option) + { + $acl_types .= ''; + } + + if (isset($_POST['chg_type'])) + { + switch ($chg_acl_type) { - // user_ids are returned in user_id_ary, a simple array - $evt_code = "\$auth_admin = new auth_admin(); if (!empty(\$evt_inherit)){ array_push(\$evt_inherit, intval(\$evt_f)); } foreach (\$user_id_ary as \$id) { \$auth_admin->acl_set('user', \$evt_inherit, intval(\$id), \$evt_option); } cache_moderators();"; - - // event_code, type (user or group), id's (of users/groups), ... other data ... - event_create($evt_code, $_POST['type'], $_POST['entries'], array('mode' => $_POST['mode']), array('f' => $_POST['forum_id']), array('entries' => $_POST['entries']), array('inherit' => $_POST['inherit']), array('type' => $_POST['type']), array('option' => $_POST['option'])); + case 'admin': + $type_sql = 'a'; + break; + case 'supermod': + case 'mod': + $type_sql = 'm'; + break; } - // form submit page, ... associative data ... - event_define('admin_permissions', array('mode' => $mode), array('forum_id' => $forum_id), array('inherit' => $_POST['inherit']), array('entries' => $_POST['entries']), array('type' => $_POST['type']), array('option' => $_POST['option'])); - break; + $founder_sql = ($user->data['user_founder']) ? ' AND founder_only <> 1' : ''; + $sql = "SELECT auth_option_id, auth_value + FROM " . ACL_OPTIONS_TABLE . " + WHERE auth_value LIKE '" . $type_sql . "_%' + $founder_sql"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $auth_options .= ''; + } + $db->sql_freeresult($result); + } + + if (isset($_POST['chg_option']) && strstr($_POST['field'], 'options')) + { + $values = array(ACL_DENY => $user->lang['DENY'], ACL_ALLOW => $user->lang['ALLOW'], ACL_INHERIT => $user->lang['INHERIT']); + + foreach ($values as $value => $option) + { + $value_options .= ''; + } + } + + if (isset($_POST['chg_value']) && strstr($_POST['field'], 'values')) + { + $forum_options = make_forum_select(false, false, false); + } + +?> + +

+ +

+ +
"> + + + + + + + + + + + + + + + + + + + + + + +
 
Permission type:
Changing option:
To value:
Set option in:
+ + + + + + + + +sql_query($sql); + + $auth_values = array(); + if ($row = $db->sql_fetchrow($result)) + { + $auth_values = unserialize($row); + } + $db->sql_freeresult($result); + + $founder_sql = ($user->data['user_founder']) ? ' AND founder_only <> 1' : ''; + $sql = "SELECT auth_option_id, auth_value + FROM " . ACL_OPTIONS_TABLE . " + WHERE auth_value LIKE 'f_%' + AND auth_value <> 'f_' + $founder_sql"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $row_class = ($row_class == 'row1') ? 'row2' : 'row1'; + + $l_can_cell = (!empty($user->lang['acl_' . $row['auth_value']])) ? $user->lang['acl_' . $row['auth_value']] : ucfirst(preg_replace('#.*?_#', '', $row['auth_value'])); + + $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"' : ''; + +?> + + + + + + + + + + + +
 lang['OPTION']; ?>  lang['ALLOW']; ?>  lang['DENY']; ?>  lang['INHERIT']; ?> 
/> /> />
+ +sql_query($sql); - $forum_info = $db->sql_fetchrow($result); + if (!($forum_info = $db->sql_fetchrow($result))) + { + trigger_error($user->lang['NO_FORUM']); + } $db->sql_freeresult($result); $l_title .= ' : ' . $forum_info['forum_name'] . ''; @@ -272,7 +458,7 @@ if (!empty($forum_id) || !empty($group_id) || !empty($username) || if (!($row = $db->sql_fetchrow($result))) { - trigger_error($user->lang['No_such_user']); + trigger_error($user->lang['NO_USER']); } $db->sql_freeresult($result); @@ -288,7 +474,7 @@ if (!empty($forum_id) || !empty($group_id) || !empty($username) || if (!($row = $db->sql_fetchrow($result))) { - trigger_error($user->lang['No_such_group']); + trigger_error($user->lang['NO_GROUP']); } $db->sql_freeresult($result); @@ -296,9 +482,6 @@ if (!empty($forum_id) || !empty($group_id) || !empty($username) || $l_title .= ' : ' . $row['group_name'] . ''; } - - - // Generate header page_header($l_title); @@ -308,9 +491,6 @@ if (!empty($forum_id) || !empty($group_id) || !empty($username) || 1' : ''; - + $founder_sql = ($user->data['user_founder']) ? ' AND founder_only <> 1' : ''; $sql = "SELECT auth_option_id, auth_value FROM " . ACL_OPTIONS_TABLE . " WHERE auth_value LIKE '" . $type_sql . "_%' @@ -360,12 +533,9 @@ if (!empty($forum_id) || !empty($group_id) || !empty($username) || $where_sql = ''; foreach ($entries as $value) { - $where_sql .= (($where_sql != '') ? ', ' : '') . (($_POST['type'] == 'user' && !empty($_POST['new'])) ? '\'' . $value . '\'' : intval($value)); + $where_sql .= (($where_sql != '') ? ', ' : '') . (($_POST['type'] == 'user' && !empty($_POST['new'])) ? "'$value'" : intval($value)); } - - - $ug = '';; $ug_hidden = ''; $auth_values = array(); @@ -403,12 +573,11 @@ if (!empty($forum_id) || !empty($group_id) || !empty($username) || { $db->sql_freeresult($result); - $sql = ($_POST['type'] == 'group') ? "SELECT group_id AS id, group_name AS name, group_type FROM " . GROUPS_TABLE . " WHERE group_id IN ($where_sql) ORDER BY group_name ASC" : "SELECT user_id AS id, username AS name, user_founder FROM " . USERS_TABLE . " WHERE username IN ($where_sql) ORDER BY username, user_regdate ASC"; + $sql = ($_POST['type'] == 'group') ? "SELECT group_id AS id, group_name AS name, group_type FROM " . GROUPS_TABLE . " WHERE group_id IN ($where_sql) ORDER BY group_name ASC" : "SELECT user_id AS id, username AS name FROM " . USERS_TABLE . " WHERE username IN ($where_sql) ORDER BY username, user_regdate ASC"; $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) { - do { $ug_test = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang[$row['name']] : $row['name']; @@ -431,8 +600,7 @@ if (!empty($forum_id) || !empty($group_id) || !empty($username) || $preset_options = $preset_js = $preset_update_options = ''; $holding = array(); - // Do we have a parent forum? If so offer option - // to inherit from that + // Do we have a parent forum? If so offer option to inherit from that if ($forum_info['parent_id'] != 0) { switch ($_POST['type']) @@ -507,8 +675,6 @@ if (!empty($forum_id) || !empty($group_id) || !empty($username) || } unset($holding); - - ?>