+
+function get_panel_user_roles_list()
+{
+ GLOBAL $config;
+
+ /* Defaults */
+ $list = [
+ "Super-Admin" => get_panel_user_permission_list(), // SuperAdmin can do everything
+ "Read-Only" => [], // Read Only can do nothing
+ ];
+
+ if (isset($config["user_roles"]))
+ foreach($config['user_roles'] as $r => $role)
+ $list[$r] = $role;
+
+ return $list;
+}
+
+function generate_role_list($list)
+{
+ $list2 = get_panel_user_permission_list();
+ ?>
+ <h5>Roles List:</h5>
+ <div id="permlist">
+ <div class="container-xxl" style="max-width: 1430px;">
+ <div class="accordion" id="roles_accord">
+
+<?php foreach($list as $role => $slug) {?>
+ <div class="card">
+ <div class="card-header" id="<?php echo to_slug($role); ?>_heading">
+ <div class="btn-header-link btn-block text-left collapsed" type="button" data-toggle="collapse" data-target="#collapse_<?php echo to_slug($role); ?>" aria-expanded="true" aria-controls="collapse_<?php echo to_slug($role); ?>">
+ <?php echo $role ?>
+
+ </div>
+ </div>
+
+ <div id="collapse_<?php echo to_slug($role); ?>" class="collapse" aria-labelledby="<?php echo to_slug($role); ?>_heading" data-parent="#roles_accord">
+ <div id="results_rpc" class="card-body">
+ <form method="post">
+ <?php if ($role !== "Super-Admin" && $role !== "Read-Only") { ?>
+ <div class="container row mb-2">
+ <button id="update_role" name="update_role" value="<?php echo $role ?>" class="btn btn-primary ml-1 mr-2" >Update</button>
+ <button id="delete_role" name="del_role_name" value="<?php echo $role ?>" class="btn btn-danger"><i class="fa fa-trash fa-1" aria-hidden="true"></i></button>
+ </div>
+
+ <?php } ?>
+ <div id="<?php echo $role; ?>_input_area"><?php
+ foreach($list2 as $desc => $slug)
+ {
+ $attributes = "";
+ $attributes .= ($role == "Super-Admin" || $role == "Read-Only") ? "disabled " : "";
+
+ ?>
+ <div class="input-group">
+ <div class="input-group-prepend">
+ <div class="input-group-text">
+ <input <?php
+ $attributes .= (in_array($slug, $list[$role])) ? "checked" : "";
+ echo $attributes;
+ ?> name="permissions[]" value="<?php echo $slug; ?>" type="checkbox">
+ </div>
+ </div>
+ <input type="text" readonly class="form-control" value="<?php echo "$desc ($slug)"; ?>">
+ </div>
+
+ <?php
+ }
+ ?> </div>
+ </form>
+ </div>
+ </div>
+ </div>
+<?php }?>
+
+ </div></div><br>
+
+</div><?php
+
+}