$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php";
include_once($configPath);
$error = true;
if (isset($_SESSION["utente"]) && !empty($_GET["sezione"]) && !empty($_GET["codice_elemento"]) && $_SESSION["utente"]->permission($_GET["sezione"],$_GET["codice_elemento"])) {
$utenti = ente::getUtentiFromModulo($_GET["sezione"],$_SESSION["ente"]->codice);
$error = false;
?>
= __("Gli utenti di tipologia Amministratore sono automaticamente abilitati") ?>
if (!empty($utenti)) {
$bind = array();
$utenti = $_SESSION["ente"]->getUtentiFromEnte($utenti,(int) $_GET["ente"]);
if (!empty($utenti)) {
$check = $pdo->prepare("SELECT codice FROM r_permessi WHERE sezione = :sezione AND codice_elemento = :codice_elemento AND codice_gestore = :codice_gestore AND codice_utente = :codice_utente AND funzione = :funzione");
$check->bindValue(":sezione",$_GET["sezione"]);
$check->bindValue(":codice_gestore",$_SESSION["ente"]->codice);
$check->bindValue(":codice_elemento",$_GET["codice_elemento"]);
$functions = [["titolo"=>"Generale","descrizione"=>"Il permesso generale abilita l'utente a tutte le funzionalità compatibili con il suo profilo","value"=>0]];
$settings = $_SESSION["utente"]->settings[$_GET["sezione"]] ?? NULL;
if (!empty($settings["funzioni"])) {
$funct = $settings["funzioni"];
switch($funct["type"]) {
case "json":
$array = jsonToArray($config["jsonFolder"].$funct["path"]);
if (!empty($array)) {
foreach($array AS $value => $tmp) {
$functions[] = [
"titolo"=>$tmp["titolo"],
"descrizione"=>$tmp["descrizione"],
"value"=>$value,
"modulo_riferimento"=>$tmp["modulo_riferimento"]
];
}
}
break;
case "array":
$functions = array_merge($functions,$funct["value"]);
break;
case "script":
$functions = include_once "{$root}/{$funct["path"]}";
break;
}
}
$getSezione = $_GET["sezione"];
$getCodice_elemento = $_GET["codice_elemento"];
$showAll = true;
if ($_SESSION["utente"]->gerarchia > 10) {
$check->bindValue(":funzione","0");
$check->bindValue(":codice_utente",$_SESSION["utente"]->codice);
$check->execute();
$showAll = ($check->rowCount() > 0) ? true : false;
}
if (!$showAll) {
$tmp = $functions;
$functions = [];
$check->bindValue(":codice_utente",$_SESSION["utente"]->codice);
foreach($tmp AS $funzione) {
$check->bindValue(":funzione",$funzione["value"]);
$check->execute();
if ($check->rowCount() > 0) {
$functions[] = $funzione;
} else if ($funzione["value"] == "0") {
$opened = true;
}
}
}
$hidden = "";
if (count($functions) > 1) {
?>
foreach($functions AS $funzione) {
if (!isset($funzione["modulo_riferimento"]) || $funzione["modulo_riferimento"] == $getSezione) {
if ($funzione["value"] != "0" && !isset($opened)) {
$opened = true;
?>
}
?>
if ($funzione["value"] == "0") {
?>
}
}
}
?>
$hidden = "collapse";
}
}
}
}
if ($error) {
header('HTTP/1.0 403 Forbidden');
die();
}
?>