X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-webpanel.git/blobdiff_plain/4b48b46f55bb6a03a29d0d0db04b3076c1eaae8f..579020f8c67f7bdfd9d530a25b701af6ee53c412:/settings/user-role-edit.php diff --git a/settings/user-role-edit.php b/settings/user-role-edit.php index 0f39a25..88e0092 100644 --- a/settings/user-role-edit.php +++ b/settings/user-role-edit.php @@ -1,19 +1,150 @@ Access denied"; + die(); +} $permissions = get_panel_user_permission_list(); $list = get_panel_user_roles_list(); + +/** + * Add a new role + */ +$errors = []; +$success = []; + + + +if (isset($_POST['add_role_name']) && $role_name = $_POST['add_role_name']) +{ + foreach ($list as $name => $u) // don't add it if it already exists + { + if (!strcmp(to_slug($name),to_slug($role_name))) + { + $errors[] = "Cannot create role \"$role_name\": A role with that name already exists."; + break; + } + } + if (empty($errors)) // so far so good + { + $msg = "Added user role \"$role_name\""; + $permissions = []; + if (isset($_POST['use_dup_role']) && $dup = $_POST['dup_role']) // if they're duplicating a role + { + $permissions = $list[$dup]; + $msg .= ", a duplicate of \"$dup\""; + } + $clean_perms = []; + foreach($permissions as $k => $v) + $clean_perms[] = $v; + + $config['user_roles'][$role_name] = $clean_perms; + write_config('user_roles'); + $success[] = $msg; + $list = get_panel_user_roles_list(); // refresh + + } +} + + +elseif (isset($_POST['del_role_name']) && $role_name = $_POST['del_role_name']) +{ + $found = 0; + foreach ($list as $name => $u) // don't add it if it already exists + { + if (!strcmp(to_slug($name),to_slug($role_name))) + { + $found = 1; + break; + } + } + if ($found) // so far so good + { + unset($config['user_roles'][$role_name]); + write_config('user_roles'); + $success[] = "Successfully deleted role \"$role_name\""; + $list = get_panel_user_roles_list(); // refresh + } + else + $errors[] = "Could not delete role \"$role_name\": Role does not exist."; +} + +elseif (isset($_POST['update_role']) && $role_name = $_POST['update_role']) +{ + $found = 0; + foreach ($list as $name => $u) // don't add it if it already exists + { + if (!strcmp(to_slug($name),to_slug($role_name))) + { + $found = 1; + break; + } + } + if (!$found) // so far so good + { + $errors[] = "Could not update role \"$role_name\": Role does not exist."; + } + else + { + $config['user_roles'][$role_name] = $_POST['permissions']; + write_config('user_roles'); + $success[] = "Successfully updated role \"$role_name\""; + $list = get_panel_user_roles_list(); // refresh + } +} ?> -

User Role Editor

-Here, you can easily edit user roles to ensure that your team has the appropriate access and permissions they need.
-Some roles are built-in and cannot be deleted or modified.

-Click a role name to view role permissions.

+
+ +
+

User Role Editor

+ + Roles are user categories where each has it's own set of permissions.
+ Here, you can easily add and edit User Roles to ensure that your team has the appropriate access and permissions they need.
+ Once you've created a role, you can assign it to a user on your panel, and they will have the permissions assigned to their role.

+
Some roles are built-in and cannot be deleted or modified, specifically "Super Admin" and "Read Only"


+ Click a role name to view role permissions. +
+
+
+
+
Create New Role
+
You must create a new role before you can add permissions to it.
+
+
+ New Role Name +
+ + +
+
+
+
+ Duplicate Role +
+
+ +
+
+ +
+ + +
+
+
-
-

- -

-
-
-
Creating a new role:
-
-
- Role name -
- -
- -
-
-
Note: You must create a new role before you can add permissions to it.
-
-
+ + +