enorme push
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
<?php
|
||||
require_once('../src/User.php');
|
||||
|
||||
if (isset($_GET['id']) && !empty($_GET['id'])) {
|
||||
$id = strip_tags($_GET['id']);
|
||||
DeleteUser($id);
|
||||
header('Location: index.php');
|
||||
}
|
||||
BIN
tpCrudTwig/public/images/suisse.png
Normal file
BIN
tpCrudTwig/public/images/suisse.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.1 KiB |
@@ -1,6 +1,12 @@
|
||||
<?php
|
||||
|
||||
require_once('../src/User.php');
|
||||
require_once('../src/Twig.php');
|
||||
session_start();
|
||||
|
||||
$SERVER_ROOT = $_SERVER['DOCUMENT_ROOT'] . "/tpCrudTwig";
|
||||
|
||||
require_once($SERVER_ROOT . "/src/User.php");
|
||||
require_once($SERVER_ROOT . "/src/Twig.php");
|
||||
|
||||
renderTwig("users/index.twig", array("users" => GetUsers()));
|
||||
|
||||
$_SESSION['message'] = $_SESSION['error'] = "";
|
||||
|
||||
21
tpCrudTwig/public/roles/add.php
Normal file
21
tpCrudTwig/public/roles/add.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
$SERVER_ROOT = $_SERVER['DOCUMENT_ROOT'] . "/tpCrudTwig";
|
||||
|
||||
require_once($SERVER_ROOT . "/src/Role.php");
|
||||
require_once($SERVER_ROOT . "/src/Twig.php");
|
||||
|
||||
if (isset($_POST)) {
|
||||
if (
|
||||
isset($_POST['name']) && !empty($_POST['name'])
|
||||
) {
|
||||
$name = strip_tags($_POST['name']);
|
||||
AddRole($name);
|
||||
$_SESSION['message'] = "Rôle ajouté avec succès !";
|
||||
header('Location: /tpCrudTwig/public/roles/list.php');
|
||||
}
|
||||
}
|
||||
|
||||
renderTwig("roles/add.twig", array());
|
||||
14
tpCrudTwig/public/roles/delete.php
Normal file
14
tpCrudTwig/public/roles/delete.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
$SERVER_ROOT = $_SERVER['DOCUMENT_ROOT'] . "/tpCrudTwig";
|
||||
|
||||
require_once($SERVER_ROOT . "/src/Role.php");
|
||||
|
||||
if (isset($_GET['id']) && !empty($_GET['id'])) {
|
||||
$id = strip_tags($_GET['id']);
|
||||
DeleteRole($id);
|
||||
$_SESSION['message'] = "Rôle retiré avec succès !";
|
||||
header('Location: list.php');
|
||||
}
|
||||
0
tpCrudTwig/public/roles/details.php
Normal file
0
tpCrudTwig/public/roles/details.php
Normal file
32
tpCrudTwig/public/roles/edit.php
Normal file
32
tpCrudTwig/public/roles/edit.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
$SERVER_ROOT = $_SERVER['DOCUMENT_ROOT'] . "/tpCrudTwig";
|
||||
|
||||
require_once($SERVER_ROOT . "/src/Role.php");
|
||||
require_once($SERVER_ROOT . "/src/Twig.php");
|
||||
|
||||
if (isset($_POST)) {
|
||||
if (
|
||||
isset($_POST['id']) && !empty($_POST['id'])
|
||||
&& isset($_POST['name']) && !empty($_POST['name'])
|
||||
) {
|
||||
$id = strip_tags($_GET['id']);
|
||||
$name = strip_tags($_POST['name']);
|
||||
|
||||
$role = GetRole($id);
|
||||
$role->name = $name;
|
||||
|
||||
UpdateRole($role);
|
||||
|
||||
$_SESSION['message'] = "Rôle modifié avec succès !";
|
||||
header('Location: /tpCrudTwig/public/roles/list.php');
|
||||
}
|
||||
}
|
||||
if (isset($_GET['id']) && !empty($_GET['id'])) {
|
||||
$id = strip_tags($_GET['id']);
|
||||
$role = GetRole($id);
|
||||
}
|
||||
|
||||
renderTwig("roles/edit.twig", array("role" => $role));
|
||||
12
tpCrudTwig/public/roles/list.php
Normal file
12
tpCrudTwig/public/roles/list.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
$SERVER_ROOT = $_SERVER['DOCUMENT_ROOT'] . "/tpCrudTwig";
|
||||
|
||||
require_once($SERVER_ROOT . "/src/Role.php");
|
||||
require_once($SERVER_ROOT . "/src/Twig.php");
|
||||
|
||||
renderTwig("roles/index.twig", ["roles" => GetRoles()]);
|
||||
|
||||
$_SESSION['message'] = $_SESSION['error'] = "";
|
||||
@@ -1,7 +1,12 @@
|
||||
<?php
|
||||
|
||||
require_once('../src/User.php');
|
||||
require_once('../src/Twig.php');
|
||||
session_start();
|
||||
|
||||
$SERVER_ROOT = $_SERVER['DOCUMENT_ROOT'] . "/tpCrudTwig";
|
||||
|
||||
require_once($SERVER_ROOT . "/src/User.php");
|
||||
require_once($SERVER_ROOT . "/src/Role.php");
|
||||
require_once($SERVER_ROOT . "/src/Twig.php");
|
||||
|
||||
if (isset($_POST)) {
|
||||
if (
|
||||
@@ -18,10 +23,15 @@ if (isset($_POST)) {
|
||||
$role = strip_tags($_POST['role']);
|
||||
$firstname = strip_tags($_POST['firstname']);
|
||||
$description = strip_tags($_POST['description']);
|
||||
AddUser($login, $password, $lastname, $role, $firstname, $description);
|
||||
$_SESSION['message'] = "Utilisateur ajouté avec succès !";
|
||||
header('Location: index.php');
|
||||
if (GetRole((int) $role) == null) {
|
||||
$_SESSION['error'] = "Erreur lors de l'ajout de l'utilisateur";
|
||||
header('Location: /tpCrudTwig/public/index.php');
|
||||
} else {
|
||||
AddUser($login, $password, $lastname, $role, $firstname, $description);
|
||||
$_SESSION['message'] = "Utilisateur ajouté avec succès !";
|
||||
header('Location: /tpCrudTwig/public/index.php');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
renderTwig("users/add.twig", array());
|
||||
renderTwig("users/add.twig", ["roles" => GetRoles()]);
|
||||
14
tpCrudTwig/public/users/delete.php
Normal file
14
tpCrudTwig/public/users/delete.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
$SERVER_ROOT = $_SERVER['DOCUMENT_ROOT'] . "/tpCrudTwig";
|
||||
|
||||
require_once($SERVER_ROOT . "/src/User.php");
|
||||
|
||||
if (isset($_GET['id']) && !empty($_GET['id'])) {
|
||||
$id = strip_tags($_GET['id']);
|
||||
DeleteUser($id);
|
||||
$_SESSION['message'] = "Utilisateur supprimé avec succès !";
|
||||
header('Location: ../index.php');
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require_once('../src/User.php');
|
||||
require_once('../src/Twig.php');
|
||||
$SERVER_ROOT = $_SERVER['DOCUMENT_ROOT'] . "/tpCrudTwig";
|
||||
|
||||
require_once($SERVER_ROOT . "/src/User.php");
|
||||
require_once($SERVER_ROOT . "/src/Twig.php");
|
||||
|
||||
if (isset($_GET['id']) && !empty($_GET['id'])) {
|
||||
$id = strip_tags($_GET['id']);
|
||||
@@ -1,7 +1,11 @@
|
||||
<?php
|
||||
|
||||
require_once('../src/User.php');
|
||||
require_once('../src/Twig.php');
|
||||
session_start();
|
||||
|
||||
$SERVER_ROOT = $_SERVER['DOCUMENT_ROOT'] . "/tpCrudTwig";
|
||||
|
||||
require_once($SERVER_ROOT . "/src/User.php");
|
||||
require_once($SERVER_ROOT . "/src/Twig.php");
|
||||
|
||||
if (isset($_POST)) {
|
||||
if (
|
||||
@@ -14,19 +18,20 @@ if (isset($_POST)) {
|
||||
$login = strip_tags($_POST['login']);
|
||||
$description = strip_tags($_POST['description']);
|
||||
$role = strip_tags($_POST['role']);
|
||||
|
||||
|
||||
$user = GetUser($id);
|
||||
$user->login = $login;
|
||||
$user->description = $description;
|
||||
$user->role = $role;
|
||||
|
||||
$user->role = GetRole((int)$role);
|
||||
|
||||
UpdateUser($user);
|
||||
header('Location: index.php');
|
||||
$_SESSION['message'] = "Utilisateur modifié avec succès !";
|
||||
header('Location: /tpCrudTwig/public/index.php');
|
||||
}
|
||||
}
|
||||
if (isset($_GET['id']) && !empty($_GET['id'])) {
|
||||
$id = strip_tags($_GET['id']);
|
||||
$user = GetUser($id);
|
||||
}
|
||||
}
|
||||
|
||||
renderTwig("users/edit.twig", array("user" => $user));
|
||||
renderTwig("users/edit.twig", array("user" => $user, "roles" => GetRoles()));
|
||||
Reference in New Issue
Block a user