📄 acp_permissions.php
字号:
continue 2; } if ($all_groups && sizeof($items['group_ids'])) { $group_id = $items['group_ids']; continue 2; } $template->assign_vars(array( 'S_SELECT_USERGROUP' => ($victim == 'usergroup') ? true : false, 'S_SELECT_USERGROUP_VIEW' => ($victim == 'usergroup_view') ? true : false, 'S_DEFINED_USER_OPTIONS' => $items['user_ids_options'], 'S_DEFINED_GROUP_OPTIONS' => $items['group_ids_options'], 'S_ADD_GROUP_OPTIONS' => group_select_options(false, $items['group_ids']), 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=add_user&field=username'), 'UA_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=add_user&field=username', false)) ); break; } // The S_ALLOW_SELECT parameter below is a measure to lower memory usage. // If there are more than 5 forums selected the admin is not able to select all users/groups too. // We need to see if the number of forums can be increased or need to be decreased. $template->assign_vars(array( 'U_ACTION' => $this->u_action, 'ANONYMOUS_USER_ID' => ANONYMOUS, 'S_SELECT_VICTIM' => true, 'S_ALLOW_ALL_SELECT' => (sizeof($forum_id) > 5) ? false : true, 'S_CAN_SELECT_USER' => ($auth->acl_get('a_authusers')) ? true : false, 'S_CAN_SELECT_GROUP' => ($auth->acl_get('a_authgroups')) ? true : false, 'S_HIDDEN_FIELDS' => $s_hidden_fields) ); // Let the forum names being displayed if (sizeof($forum_id)) { $sql = 'SELECT forum_name FROM ' . FORUMS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_id) . ' ORDER BY forum_name ASC'; $result = $db->sql_query($sql); $forum_names = array(); while ($row = $db->sql_fetchrow($result)) { $forum_names[] = $row['forum_name']; } $db->sql_freeresult($result); $template->assign_vars(array( 'S_FORUM_NAMES' => (sizeof($forum_names)) ? true : false, 'FORUM_NAMES' => implode(', ', $forum_names)) ); } return; } // Do not allow forum_ids being set and no other setting defined (will bog down the server too much) if (sizeof($forum_id) && !sizeof($user_id) && !sizeof($group_id)) { trigger_error($user->lang['ONLY_FORUM_DEFINED'] . adm_back_link($this->u_action), E_USER_WARNING); } $template->assign_vars(array( 'S_PERMISSION_DROPDOWN' => (sizeof($this->permission_dropdown) > 1) ? $this->build_permission_dropdown($this->permission_dropdown, $permission_type) : false, 'L_PERMISSION_TYPE' => $user->lang['ACL_TYPE_' . strtoupper($permission_type)], 'U_ACTION' => $this->u_action, 'S_HIDDEN_FIELDS' => $s_hidden_fields) ); if (strpos($mode, 'setting_') === 0) { $template->assign_vars(array( 'S_SETTING_PERMISSIONS' => true) ); $hold_ary = $auth_admin->get_mask('set', (sizeof($user_id)) ? $user_id : false, (sizeof($group_id)) ? $group_id : false, (sizeof($forum_id)) ? $forum_id : false, $permission_type, $permission_scope, ACL_NO); $auth_admin->display_mask('set', $permission_type, $hold_ary, ((sizeof($user_id)) ? 'user' : 'group'), (($permission_scope == 'local') ? true : false)); } else { $template->assign_vars(array( 'S_VIEWING_PERMISSIONS' => true) ); $hold_ary = $auth_admin->get_mask('view', (sizeof($user_id)) ? $user_id : false, (sizeof($group_id)) ? $group_id : false, (sizeof($forum_id)) ? $forum_id : false, $permission_type, $permission_scope, ACL_NEVER); $auth_admin->display_mask('view', $permission_type, $hold_ary, ((sizeof($user_id)) ? 'user' : 'group'), (($permission_scope == 'local') ? true : false)); } } /** * Build +subforum options */ function build_subforum_options($forum_list) { global $user; $s_options = ''; $forum_list = array_merge($forum_list); foreach ($forum_list as $key => $row) { $s_options .= '<option value="' . $row['forum_id'] . '"' . $row['selected'] . '>' . $row['padding'] . $row['forum_name']; // We check if a branch is there... $branch_there = false; foreach (array_slice($forum_list, $key + 1) as $temp_row) { if ($temp_row['left_id'] > $row['left_id'] && $temp_row['left_id'] < $row['right_id']) { $branch_there = true; break; } continue; } if ($branch_there) { $s_options .= ' [' . $user->lang['PLUS_SUBFORUMS'] . ']'; } $s_options .= '</option>'; } return $s_options; } /** * Build dropdown field for changing permission types */ function build_permission_dropdown($options, $default_option) { global $user, $auth; $s_dropdown_options = ''; foreach ($options as $setting) { if (!$auth->acl_get('a_' . str_replace('_', '', $setting) . 'auth')) { continue; } $selected = ($setting == $default_option) ? ' selected="selected"' : ''; $s_dropdown_options .= '<option value="' . $setting . '"' . $selected . '>' . $user->lang['permission_type'][$setting] . '</option>'; } return $s_dropdown_options; } /** * Check if selected items exist. Remove not found ids and if empty return error. */ function check_existence($mode, &$ids) { global $db, $user; switch ($mode) { case 'user': $table = USERS_TABLE; $sql_id = 'user_id'; break; case 'group': $table = GROUPS_TABLE; $sql_id = 'group_id'; break; case 'forum': $table = FORUMS_TABLE; $sql_id = 'forum_id'; break; } $sql = "SELECT $sql_id FROM $table WHERE " . $db->sql_in_set($sql_id, $ids); $result = $db->sql_query($sql); $ids = array(); while ($row = $db->sql_fetchrow($result)) { $ids[] = $row[$sql_id]; } $db->sql_freeresult($result); if (!sizeof($ids)) { trigger_error($user->lang['SELECTED_' . strtoupper($mode) . '_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING); } } /** * Apply permissions */ function set_permissions($mode, $permission_type, &$auth_admin, &$user_id, &$group_id) { global $user, $auth; $psubmit = request_var('psubmit', array(0)); // User or group to be set? $ug_type = (sizeof($user_id)) ? 'user' : 'group'; // Check the permission setting again if (!$auth->acl_get('a_' . str_replace('_', '', $permission_type) . 'auth') || !$auth->acl_get('a_auth' . $ug_type . 's')) { trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); } $ug_id = $forum_id = 0; // We loop through the auth settings defined in our submit list($ug_id, ) = each($psubmit); list($forum_id, ) = each($psubmit[$ug_id]); $auth_settings = array_map('intval', $_POST['setting'][$ug_id][$forum_id]); // Do we have a role we want to set? $assigned_role = (isset($_POST['role'][$ug_id][$forum_id])) ? (int) $_POST['role'][$ug_id][$forum_id] : 0; // Do the admin want to set these permissions to other items too? $inherit = request_var('inherit', array(0)); $ug_id = array($ug_id); $forum_id = array($forum_id); if (sizeof($inherit)) { foreach ($inherit as $_ug_id => $forum_id_ary) { // Inherit users/groups? if (!in_array($_ug_id, $ug_id)) { $ug_id[] = $_ug_id; } // Inherit forums? $forum_id = array_merge($forum_id, array_keys($forum_id_ary)); } } $forum_id = array_unique($forum_id); // If the auth settings differ from the assigned role, then do not set a role... if ($assigned_role) { if (!$this->check_assigned_role($assigned_role, $auth_settings)) { $assigned_role = 0; } } // Update the permission set... $auth_admin->acl_set($ug_type, $forum_id, $ug_id, $auth_settings, $assigned_role); // Do we need to recache the moderator lists? if ($permission_type == 'm_') { cache_moderators(); } // Remove users who are now moderators or admins from everyones foes list if ($permission_type == 'm_' || $permission_type == 'a_') { update_foes(); } $this->log_action($mode, 'add', $permission_type, $ug_type, $ug_id, $forum_id); trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action)); } /** * Apply all permissions */ function set_all_permissions($mode, $permission_type, &$auth_admin, &$user_id, &$group_id) { global $user, $auth; // User or group to be set? $ug_type = (sizeof($user_id)) ? 'user' : 'group'; // Check the permission setting again if (!$auth->acl_get('a_' . str_replace('_', '', $permission_type) . 'auth') || !$auth->acl_get('a_auth' . $ug_type . 's')) { trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); } $auth_settings = (isset($_POST['setting'])) ? $_POST['setting'] : array(); $auth_roles = (isset($_POST['role'])) ? $_POST['role'] : array(); $ug_ids = $forum_ids = array(); // We need to go through the auth settings foreach ($auth_settings as $ug_id => $forum_auth_row) { $ug_id = (int) $ug_id; $ug_ids[] = $ug_id; foreach ($forum_auth_row as $forum_id => $auth_options) { $forum_id = (int) $forum_id; $forum_ids[] = $forum_id; // Check role... $assigned_role = (isset($auth_roles[$ug_id][$forum_id])) ? (int) $auth_roles[$ug_id][$forum_id] : 0; // If the auth settings differ from the assigned role, then do not set a role... if ($assigned_role) { if (!$this->check_assigned_role($assigned_role, $auth_options)) { $assigned_role = 0; } } // Update the permission set... $auth_admin->acl_set($ug_type, $forum_id, $ug_id, $auth_options, $assigned_role, false); } } $auth_admin->acl_clear_prefetch(); // Do we need to recache the moderator lists? if ($permission_type == 'm_') { cache_moderators(); } // Remove users who are now moderators or admins from everyones foes list if ($permission_type == 'm_' || $permission_type == 'a_') { update_foes(); } $this->log_action($mode, 'add', $permission_type, $ug_type, $ug_ids, $forum_ids); trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action)); } /** * Compare auth settings with auth settings from role * returns false if they differ, true if they are equal */ function check_assigned_role($role_id, &$auth_settings) { global $db; $sql = 'SELECT o.auth_option, r.auth_setting FROM ' . ACL_OPTIONS_TABLE . ' o, ' . ACL_ROLES_DATA_TABLE . ' r WHERE o.auth_option_id = r.auth_option_id AND r.role_id = ' . $role_id; $result = $db->sql_query($sql); $test_auth_settings = array(); while ($row = $db->sql_fetchrow($result)) { $test_auth_settings[$row['auth_option']] = $row['auth_setting']; } $db->sql_freeresult($result); // We need to add any ACL_NO setting from auth_settings to compare correctly foreach ($auth_settings as $option => $setting) { if ($setting == ACL_NO) { $test_auth_settings[$option] = $setting; } } if (sizeof(array_diff_assoc($auth_settings, $test_auth_settings))) { return false; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -