Refactor user session handling and permissions management

- Updated session variables to use 'authorization' array instead of 'username' for user identification across multiple files.
- Introduced a new function `getUserPermissions` to consolidate user permissions retrieval based on assigned roles.
- Modified API calls to use the new authorization structure and updated endpoints to v2.
- Enhanced language support by adding 'PL' to the list of supported languages.
- Cleaned up redundant code and improved session management during user login and registration processes.
- Added a new API endpoint for fetching user permissions based on user ID.
This commit is contained in:
“VeLiTi”
2026-01-19 15:29:16 +01:00
parent 782050c3ca
commit 24481279d5
99 changed files with 683 additions and 539 deletions

View File

@@ -3,16 +3,16 @@ defined(page_security_key) or exit;
$page = 'translation_manage';
//Check if allowed
if (isAllowed($page,$_SESSION['profile'],$_SESSION['permission'],'R') === 0){
if (isAllowed($page,$_SESSION['authorization']['profile'],$_SESSION['authorization']['permission'],'R') === 0){
header('location: index.php');
exit;
}
//PAGE Security
$update_allowed = isAllowed($page ,$_SESSION['profile'],$_SESSION['permission'],'U');
$delete_allowed = isAllowed($page ,$_SESSION['profile'],$_SESSION['permission'],'D');
$create_allowed = isAllowed($page ,$_SESSION['profile'],$_SESSION['permission'],'C');
$update_allowed = isAllowed($page ,$_SESSION['authorization']['profile'],$_SESSION['authorization']['permission'],'U');
$delete_allowed = isAllowed($page ,$_SESSION['authorization']['profile'],$_SESSION['authorization']['permission'],'D');
$create_allowed = isAllowed($page ,$_SESSION['authorization']['profile'],$_SESSION['authorization']['permission'],'C');
// Default input product values
$text_variable = [
@@ -66,8 +66,8 @@ if (isset($_GET['rowID'])) {
if ($responses === 'NOK'){
} else {
if ($_SESSION['permission'] == 4){
generateLanguageFile($_POST['language_key'],$_SESSION['userkey']);
if ($_SESSION['authorization']['permission'] == 4){
generateLanguageFile($_POST['language_key'],$_SESSION['authorization']['userkey']);
}
header('Location: index.php?page=translation_manage&rowID='.$_GET['rowID'].'');
exit;
@@ -99,8 +99,8 @@ if (isset($_GET['rowID'])) {
if ($NOK_error == 0){
//NO errors generatelanguagefile
if ($_SESSION['permission'] == 4){
generateLanguageFile($attr_language,$_SESSION['userkey']);
if ($_SESSION['authorization']['permission'] == 4){
generateLanguageFile($attr_language,$_SESSION['authorization']['userkey']);
}
}