169 lines
6.0 KiB
PHP
169 lines
6.0 KiB
PHP
<?php
|
|
|
|
$strLangue = 'fr';
|
|
$strPage = 'eve_acces.php';
|
|
$strAction = $_GET['p'] ?? 'kits';
|
|
|
|
require_once('php/inc_start_time.php');
|
|
require_once('php/inc_functions.php');
|
|
require_once('php/inc_fx_eve_acces_admin.php');
|
|
|
|
global $objDatabase;
|
|
|
|
if (empty($_SESSION['usa_id'])) {
|
|
header('Location: login.php');
|
|
exit;
|
|
}
|
|
|
|
$strFlash = '';
|
|
$strError = '';
|
|
$intRoleId = isset($_GET['id']) ? intval($_GET['id']) : 0;
|
|
|
|
if (isset($_GET['action'])) {
|
|
switch ($_GET['action']) {
|
|
case 'duplicate':
|
|
case 'toggle':
|
|
case 'delete':
|
|
if (!fxAdminCanEditEveAccesKits()) {
|
|
header('Location: eve_acces.php?p=kits&err=' . urlencode('Modification des kits réservée.'));
|
|
exit;
|
|
}
|
|
break;
|
|
}
|
|
switch ($_GET['action']) {
|
|
case 'duplicate':
|
|
if ($intRoleId <= 0) {
|
|
header('Location: eve_acces.php?p=kits');
|
|
exit;
|
|
}
|
|
$arrResult = fxEveAccesAdminDuplicateRole($intRoleId);
|
|
if ($arrResult['state'] === 'ok') {
|
|
header('Location: eve_acces.php?p=kit&id=' . intval($arrResult['role_id']) . '&saved=1');
|
|
} else {
|
|
header('Location: eve_acces.php?p=kits&err=' . urlencode($arrResult['message']));
|
|
}
|
|
exit;
|
|
|
|
case 'toggle':
|
|
if ($intRoleId <= 0) {
|
|
header('Location: eve_acces.php?p=kits');
|
|
exit;
|
|
}
|
|
$arrResult = fxEveAccesAdminToggleRoleActif($intRoleId);
|
|
$strQ = ($arrResult['state'] === 'ok') ? 'ok=' . urlencode($arrResult['message']) : 'err=' . urlencode($arrResult['message']);
|
|
header('Location: eve_acces.php?p=kits&' . $strQ);
|
|
exit;
|
|
|
|
case 'delete':
|
|
if ($intRoleId <= 0) {
|
|
header('Location: eve_acces.php?p=kits');
|
|
exit;
|
|
}
|
|
$arrResult = fxEveAccesAdminDeleteRole($intRoleId);
|
|
if ($arrResult['state'] === 'ok') {
|
|
header('Location: eve_acces.php?p=kits&ok=' . urlencode($arrResult['message']));
|
|
} else {
|
|
header('Location: eve_acces.php?p=kits&err=' . urlencode($arrResult['message']));
|
|
}
|
|
exit;
|
|
}
|
|
}
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && ($_POST['action'] ?? '') === 'save_kit') {
|
|
if (!fxAdminCanEditEveAccesKits()) {
|
|
header('Location: eve_acces.php?p=kits&err=' . urlencode('Modification des kits réservée.'));
|
|
exit;
|
|
}
|
|
$intRoleId = intval($_POST['role_id'] ?? 0);
|
|
$arrResult = fxEveAccesAdminSaveRole($_POST, $_POST['perm_keys'] ?? array());
|
|
if ($arrResult['state'] === 'ok') {
|
|
header('Location: eve_acces.php?p=kit&id=' . intval($arrResult['role_id']) . '&saved=1');
|
|
exit;
|
|
}
|
|
$strError = $arrResult['message'];
|
|
$strAction = 'kit';
|
|
}
|
|
|
|
if (isset($_GET['saved']) && $_GET['saved'] === '1') {
|
|
$strFlash = 'Kit enregistré.';
|
|
}
|
|
if (!empty($_GET['ok'])) {
|
|
$strFlash = (string)$_GET['ok'];
|
|
}
|
|
if (!empty($_GET['err'])) {
|
|
$strError = (string)$_GET['err'];
|
|
}
|
|
|
|
include('inc_header.php');
|
|
?>
|
|
<div class="container-fluid" id="main">
|
|
<div class="row">
|
|
<div class="col-md-9 col-lg-10 order-first order-md-last py-3">
|
|
<?php
|
|
require_once dirname(__FILE__) . '/../php/inc_fx_superadm_v2_ui.php';
|
|
|
|
switch ($strAction) {
|
|
case 'migrate':
|
|
$strV2Title = 'Accès promoteur — Migration legacy';
|
|
break;
|
|
case 'kit':
|
|
$strV2Title = 'Accès promoteur — Édition kit';
|
|
break;
|
|
case 'assignations':
|
|
$strV2Title = 'Accès promoteur — Assignations';
|
|
break;
|
|
case 'kits':
|
|
default:
|
|
$strV2Title = 'Accès promoteur — Kits d\'accès';
|
|
break;
|
|
}
|
|
|
|
fxSuperadmV2PanelOpen($strV2Title, array(
|
|
'zone_class' => 'superadm-content-v2-zone superadm-content-v2-zone--flush',
|
|
));
|
|
|
|
switch ($strAction) {
|
|
case 'migrate':
|
|
if ($strError !== '') {
|
|
echo '<div class="alert alert-danger">' . htmlspecialchars($strError, ENT_QUOTES, 'UTF-8') . '</div>';
|
|
}
|
|
fxEveAccesAdminRenderMigrationPage($strFlash);
|
|
break;
|
|
case 'kit':
|
|
if ($strFlash !== '' && $strError === '') {
|
|
echo '<div class="alert alert-success">' . htmlspecialchars($strFlash, ENT_QUOTES, 'UTF-8') . '</div>';
|
|
}
|
|
// MSIN-4401 — Nouveau kit réservé aux éditeurs ; lecture seule pour les autres.
|
|
if ($intRoleId <= 0 && !fxAdminCanEditEveAccesKits()) {
|
|
echo '<div class="alert alert-warning">Création de kit réservée. Vous pouvez consulter les kits existants.</div>';
|
|
fxEveAccesAdminRenderKitsList('');
|
|
break;
|
|
}
|
|
fxEveAccesAdminRenderKitForm($intRoleId, $strError);
|
|
break;
|
|
case 'assignations':
|
|
if ($intRoleId <= 0) {
|
|
header('Location: eve_acces.php?p=kits');
|
|
exit;
|
|
}
|
|
fxEveAccesAdminRenderKitAssignmentsPage($intRoleId, $strFlash);
|
|
break;
|
|
case 'kits':
|
|
default:
|
|
if ($strError !== '') {
|
|
$strFlash = '';
|
|
echo '<div class="alert alert-danger">' . htmlspecialchars($strError, ENT_QUOTES, 'UTF-8') . '</div>';
|
|
}
|
|
fxEveAccesAdminRenderKitsList($strFlash);
|
|
break;
|
|
}
|
|
|
|
fxSuperadmV2PanelClose();
|
|
?>
|
|
<p> </p>
|
|
</div>
|
|
<?php require_once('inc_droite.php'); ?>
|
|
</div>
|
|
</div>
|
|
<?php require_once('inc_footer.php'); ?>
|