- Updated authorization checks in product management, product attributes, configurations, software, and user management files to use 'permissions' for consistency. - Ensured that all relevant pages correctly check user permissions for read, update, delete, and create actions. - Adjusted session variable references to align with the new permissions structure across various modules.
189 lines
7.5 KiB
PHP
189 lines
7.5 KiB
PHP
<?php
|
|
defined(page_security_key) or exit;
|
|
|
|
if (debug && debug_id == $_SESSION['authorization']['id']){
|
|
ini_set('display_errors', '1');
|
|
ini_set('display_startup_errors', '1');
|
|
error_reporting(E_ALL);
|
|
}
|
|
|
|
include_once './assets/functions.php';
|
|
include_once './settings/settings_redirector.php';
|
|
|
|
//SET ORIGIN FOR NAVIGATION
|
|
$_SESSION['prev_origin_access_element'] = $_SERVER['REQUEST_URI'];
|
|
$page = 'access_element';
|
|
//Check if allowed
|
|
if (isAllowed($page,$_SESSION['authorization']['permissions'],$_SESSION['authorization']['permission'],'R') === 0){
|
|
header('location: index.php');
|
|
exit;
|
|
}
|
|
//PAGE Security
|
|
$page_manage = 'access_element_manage';
|
|
$update_allowed = isAllowed($page ,$_SESSION['authorization']['permissions'],$_SESSION['authorization']['permission'],'U');
|
|
$update_allowed_edit = isAllowed($page_manage ,$_SESSION['authorization']['permissions'],$_SESSION['authorization']['permission'],'U');
|
|
$delete_allowed = isAllowed($page_manage ,$_SESSION['authorization']['permissions'],$_SESSION['authorization']['permission'],'D');
|
|
$create_allowed = isAllowed($page_manage ,$_SESSION['authorization']['permissions'],$_SESSION['authorization']['permission'],'C');
|
|
|
|
//GET Details from URL
|
|
$GET_VALUES = urlGETdetails($_GET) ?? '';
|
|
|
|
//CALL TO API FOR General information
|
|
$api_url = '/v2/access_elements/'.$GET_VALUES;
|
|
$responses = ioServer($api_url,'');
|
|
//Decode Payload
|
|
if (!empty($responses)){$responses = json_decode($responses);}else{$responses = null;}
|
|
$responses = $responses[0];
|
|
|
|
$element_id = $responses->rowID;
|
|
|
|
//CALL TO API FOR Roles using this access element
|
|
$api_url = '/v2/role_access_permissions/access_id='.$element_id;
|
|
$role_permissions = ioServer($api_url,'');
|
|
//Decode Payload
|
|
if (!empty($role_permissions)){$role_permissions = json_decode($role_permissions);}else{$role_permissions = null;}
|
|
|
|
//------------------------------
|
|
//Variables
|
|
//------------------------------
|
|
$status_text = ($responses->is_active == 1) ? ($enabled ?? 'Active') : ($disabled ?? 'Inactive');
|
|
$status_class = ($responses->is_active == 1) ? 'id1' : 'id0';
|
|
|
|
// Handle success messages
|
|
if (isset($_GET['success_msg'])) {
|
|
if ($_GET['success_msg'] == 1) {
|
|
$success_msg = ($message_access_1 ?? 'Access element created successfully');
|
|
}
|
|
if ($_GET['success_msg'] == 2) {
|
|
$success_msg = ($message_access_2 ?? 'Access element updated successfully');
|
|
}
|
|
if ($_GET['success_msg'] == 3) {
|
|
$success_msg = ($message_access_3 ?? 'Access element deleted successfully');
|
|
}
|
|
}
|
|
|
|
template_header(($access_element_title ?? 'Access Element'), 'access_element', 'view');
|
|
$view = '
|
|
<div class="content-title responsive-flex-wrap responsive-pad-bot-3">
|
|
<h2 class="responsive-width-100">'.($view_access_h2 ?? 'Access Element').' - '.$responses->access_name.'</h2>
|
|
<a href="index.php?page='.$_SESSION['origin'].'&p='.$_SESSION['p'].$_SESSION['status'].$_SESSION['sort'].$_SESSION['search'].'" class="btn alt mar-right-2">←</a>
|
|
';
|
|
|
|
if ($update_allowed_edit === 1){
|
|
$view .= '<a href="index.php?page=access_element_manage&rowID='.$responses->rowID.'" class="btn">✏️</a>';
|
|
}
|
|
|
|
$view .= '</div>';
|
|
|
|
if (isset($success_msg)){
|
|
$view .= ' <div class="msg success">
|
|
<i class="fas fa-check-circle"></i>
|
|
<p>'.$success_msg.'</p>
|
|
<i class="fas fa-times"></i>
|
|
</div>';
|
|
}
|
|
|
|
$view .= '<div class="content-block-wrapper">';
|
|
|
|
// Access Element Information Block
|
|
$view .= ' <div class="content-block order-details">
|
|
<div class="block-header">
|
|
<i class="fa-solid fa-circle-info"></i>'.($view_access_information ?? 'Access Element Information').'
|
|
</div>
|
|
<div class="order-detail">
|
|
<h3>'.($general_status ?? 'Status').'</h3>
|
|
<p><span class="status '.$status_class.'">'.$status_text.'</span></p>
|
|
</div>
|
|
<div class="order-detail">
|
|
<h3>'.($access_element_name ?? 'Name').'</h3>
|
|
<p>'.$responses->access_name.'</p>
|
|
</div>
|
|
<div class="order-detail">
|
|
<h3>'.($access_element_path ?? 'Path').'</h3>
|
|
<p>'.$responses->access_path.'</p>
|
|
</div>
|
|
<div class="order-detail">
|
|
<h3>'.($access_element_group ?? 'Group').'</h3>
|
|
<p>'.($responses->access_group ?? '-').'</p>
|
|
</div>
|
|
<div class="order-detail">
|
|
<h3>'.($role_description ?? 'Description').'</h3>
|
|
<p>'.($responses->description ?? '-').'</p>
|
|
</div>
|
|
</div>
|
|
';
|
|
|
|
$view .= '</div>'; // Close content-block-wrapper
|
|
|
|
// Roles Using This Access Element
|
|
$view .= '<div class="content-block">
|
|
<div class="block-header">
|
|
<i class="fa-solid fa-user-shield fa-sm"></i>'.($view_access_roles ?? 'Roles Using This Element').'
|
|
</div>
|
|
<div class="table">
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>'.($role_name ?? 'Role Name').'</th>
|
|
<th>'.($permission_create ?? 'C').'</th>
|
|
<th>'.($permission_read ?? 'R').'</th>
|
|
<th>'.($permission_update ?? 'U').'</th>
|
|
<th>'.($permission_delete ?? 'D').'</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>';
|
|
|
|
if (!empty($role_permissions)){
|
|
foreach ($role_permissions as $role_perm){
|
|
$can_create = ($role_perm->can_create == 1) ? '<i class="fa-solid fa-check" style="color:green;"></i>' : '<i class="fa-solid fa-times" style="color:red;"></i>';
|
|
$can_read = ($role_perm->can_read == 1) ? '<i class="fa-solid fa-check" style="color:green;"></i>' : '<i class="fa-solid fa-times" style="color:red;"></i>';
|
|
$can_update = ($role_perm->can_update == 1) ? '<i class="fa-solid fa-check" style="color:green;"></i>' : '<i class="fa-solid fa-times" style="color:red;"></i>';
|
|
$can_delete = ($role_perm->can_delete == 1) ? '<i class="fa-solid fa-check" style="color:green;"></i>' : '<i class="fa-solid fa-times" style="color:red;"></i>';
|
|
|
|
$view .= '<tr onclick="window.location.href=\'index.php?page=user_role&rowID='.$role_perm->role_id.'\'" style="cursor: pointer;">
|
|
<td>'.$role_perm->role_name.'</td>
|
|
<td>'.$can_create.'</td>
|
|
<td>'.$can_read.'</td>
|
|
<td>'.$can_update.'</td>
|
|
<td>'.$can_delete.'</td>
|
|
</tr>';
|
|
}
|
|
} else {
|
|
$view .= '<tr>
|
|
<td colspan="5" style="text-align:center;">'.($no_roles_using ?? 'No roles are using this access element').'</td>
|
|
</tr>';
|
|
}
|
|
|
|
$view .= ' </tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
';
|
|
|
|
// Metadata Block
|
|
$view .= '<div class="content-block">
|
|
<div class="block-header">
|
|
<i class="fa-solid fa-bars fa-sm"></i>'.($tab3 ?? 'Details').'
|
|
</div>
|
|
<div class="table order-table">
|
|
<table>
|
|
<tr>
|
|
<td style="width:25%;">'.($general_created ?? 'Created').'</td>
|
|
<td>'.getRelativeTime($responses->created).'</td>
|
|
</tr>
|
|
<tr>
|
|
<td style="width:25%;">'.($general_updated ?? 'Updated').'</td>
|
|
<td>'.getRelativeTime($responses->updated).'</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
';
|
|
|
|
//OUTPUT
|
|
echo $view;
|
|
|
|
template_footer()
|
|
|
|
?>
|