-
Notifications
You must be signed in to change notification settings - Fork 0
/
permisos.php
52 lines (42 loc) · 2.09 KB
/
permisos.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
require_once "/usr/local/lib/php/vendor/autoload.php";
include("bd.php");
$loader = new \Twig\Loader\FilesystemLoader('templates');
$twig = new \Twig\Environment($loader);
session_start();
$conexion = new BDGestion();
$identificado = false;
if(isset($_SESSION['identificado'])) {
$identificado = true;
}
if($identificado) {
$usuario = $conexion->cargarUsuario($_SESSION['nameUsuario']);
}
if($_SERVER['REQUEST_METHOD'] === 'GET') {
if($usuario['super'] == 1) {
if(isset($_GET['idUser']) && ctype_digit($_GET['idUser']) && isset($_GET['moderator']) && is_string($_GET['moderator']) && ($_GET['moderator'] == true || $_GET['moderator'] == false)) {
$opcion = (htmlspecialchars($_GET['moderator']) == 'false') ? 0 : 1;
$rol = 'moderador';
$conexion->cambiarPermisos($_GET['idUser'], $opcion, $rol);
header("Location: permisos.php");
}
if(isset($_GET['idUser']) && ctype_digit($_GET['idUser']) && isset($_GET['gestor']) && is_string($_GET['gestor']) && ($_GET['gestor'] == true || $_GET['gestor'] == false)) {
$opcion = (htmlspecialchars($_GET['gestor']) == 'false') ? 0 : 1;
$rol = 'gestor';
$conexion->cambiarPermisos($_GET['idUser'], $opcion, $rol);
header("Location: permisos.php");
}
if(isset($_GET['idUser']) && ctype_digit($_GET['idUser']) && isset($_GET['super']) && is_string($_GET['super']) && ($_GET['super'] == true || $_GET['super'] == false)) {
$opcion = (htmlspecialchars($_GET['super']) == 'false') ? 0 : 1;
$rol = 'super';
$conexion->cambiarPermisos($_GET['idUser'], $opcion, $rol);
header("Location: permisos.php");
}
}
}
$usuarios = array();
if($usuario['super'] == 1) {
$usuarios = $conexion->getAllUsuarios();
}
echo $twig->render('permisos.html', ['identificado' => $identificado, 'usuario' => $usuario, 'usuarios' => $usuarios]);
?>