Files
assetmgt/maintenance.php
“VeLiTi” 24481279d5 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.
2026-01-19 15:29:16 +01:00

147 lines
5.2 KiB
PHP

<?php
defined(page_security_key) or exit;
$page = 'maintenance';
//Check if allowed
if (isAllowed($page,$_SESSION['authorization']['profile'],$_SESSION['authorization']['permission'],'R') === 0){
header('location: index.php');
exit;
}
//PAGE Security
$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');
if ($update_allowed === 1){
if (isset($_POST['geoupdate'])){
//GEOLOCATION UPDATE
geolocationUpdate($_SESSION['authorization']['userkey']);
}
if (isset($_POST['closeContract'])){
//GEOLOCATION UPDATE
closeContract();
}
if (isset($_POST['updatecartest'])){
//GEOLOCATION UPDATE
convertCartest();
}
if (isset($_POST['updateproductmeusurements'])){
$total_measurement = traintotalMeasurement();
$total_results = statisticalAnalyses($total_measurement);
storeMeasurementProduct($total_results, $_SESSION['authorization']['userkey']);
}
if (isset($_POST['updateequipmentmeusurements'])){
storeMeasurementEquipment('');
}
if (isset($_POST['generatefile'])){
generateLanguageFile($_POST['language'],$_SESSION['authorization']['userkey']);
}
if (isset($_POST['generateDealerInformation'])){
generateDealerInformation($_SESSION['authorization']['userkey']);
}
if (isset($_POST['generateCountriesFile'])){
generateCountriesFile($_SESSION['authorization']['userkey']);
}
}
// Handle success messages
if (isset($_GET['success_msg'])) {
if ($_GET['success_msg'] == 1) {
$success_msg = 'Settings updated successfully!';
}
}
//EMPTY VIEW
$view = '';
template_header('Maintenance', 'maintenance', 'manage');
if (isset($success_msg)){
$view .= ' <div class="msg error">
<i class="fas fa-check-circle"></i>
<p>'.$success_msg.'</p>
<i class="fas fa-times"></i>
</div>';
}
$view .='
<form action="" method="post">
<div class="content-title responsive-flex-wrap responsive-pad-bot-3">
<h2 class="responsive-width-100">Maintenance</h2>
</div>';
$view .= '<div class="tabs">
<a href="#" class="active">'.$general_actions .'</a>
</div>
';
if ($update_allowed === 1){
$view .= '<div class="content-block tab-content active">
<div class="form responsive-width-100">
<label for="service">Expired contract closure</label>
<input type="submit" name="closeContract" style="width: 15%;" value="closeContract" class="btn">
</div>
<div class="form responsive-width-100">
<label for="service">CarTestUpdate</label>
<input type="submit" name="updatecartest" style="width: 15%;" value="CarTestUpdate" class="btn">
</div>
<div class="form responsive-width-100">
<label for="service">GeoUpdate</label>
<input type="submit" name="geoupdate" style="width: 15%;" value="GeoUpdate" class="btn">
</div>
<div class="form responsive-width-100">
<label for="service">GenerateDealerInfo</label>
<input type="submit" name="generateDealerInformation" style="width: 15%;" value="DealerInfo" class="btn">
</div>
<div class="form responsive-width-100">
<label for="service">Generate Countries File</label>
<input type="submit" name="generateCountriesFile" style="width: 15%;" value="Countries" class="btn">
</div>
</div>
</div>';
}
$view .= '<div class="tabs">
<a href="#" class="">Learning</a>
</div>
';
if ($update_allowed === 1){
$view .= '<div class="content-block tab-content">
<div class="form responsive-width-100">
<label for="service">Train Products</label>
<input type="submit" name="updateproductmeusurements" style="width: 15%;" value="Train Products" class="btn">
</div>
<div class="form responsive-width-100">
<label for="service">Train Assets</label>
<input type="submit" name="updateequipmentmeusurements" style="width: 15%;" value="Train Assets" class="btn">
</div>
</div>';
}
$view .= '<div class="tabs">
<a href="#" class="">Translations</a>
</div>
';
if ($update_allowed === 1){
$view .= '<div class="content-block tab-content">
<div class="form responsive-width-100">
<label for="">'.$User_language.'</label>
<select id="language" name="language">';
$view .='<option value=""></option>';
foreach ($supportedLanguages as $language){
$view .='<option value="'.$language.'">'.$language.'</option>';
}
$view .=' </select>
<input type="submit" name="generatefile" style="width: 15%;" value="Generate language" class="btn">
</div>
</div>';
}
$view .= '</form>';
//Output
echo $view;
template_footer()
?>