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
|
<?php
|
||||||
|
|
||||||
require_once('../src/User.php');
|
session_start();
|
||||||
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");
|
||||||
|
|
||||||
renderTwig("users/index.twig", array("users" => GetUsers()));
|
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
|
<?php
|
||||||
|
|
||||||
require_once('../src/User.php');
|
session_start();
|
||||||
require_once('../src/Twig.php');
|
|
||||||
|
$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 (isset($_POST)) {
|
||||||
if (
|
if (
|
||||||
@@ -18,10 +23,15 @@ if (isset($_POST)) {
|
|||||||
$role = strip_tags($_POST['role']);
|
$role = strip_tags($_POST['role']);
|
||||||
$firstname = strip_tags($_POST['firstname']);
|
$firstname = strip_tags($_POST['firstname']);
|
||||||
$description = strip_tags($_POST['description']);
|
$description = strip_tags($_POST['description']);
|
||||||
AddUser($login, $password, $lastname, $role, $firstname, $description);
|
if (GetRole((int) $role) == null) {
|
||||||
$_SESSION['message'] = "Utilisateur ajouté avec succès !";
|
$_SESSION['error'] = "Erreur lors de l'ajout de l'utilisateur";
|
||||||
header('Location: index.php');
|
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
|
<?php
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require_once('../src/User.php');
|
$SERVER_ROOT = $_SERVER['DOCUMENT_ROOT'] . "/tpCrudTwig";
|
||||||
require_once('../src/Twig.php');
|
|
||||||
|
require_once($SERVER_ROOT . "/src/User.php");
|
||||||
|
require_once($SERVER_ROOT . "/src/Twig.php");
|
||||||
|
|
||||||
if (isset($_GET['id']) && !empty($_GET['id'])) {
|
if (isset($_GET['id']) && !empty($_GET['id'])) {
|
||||||
$id = strip_tags($_GET['id']);
|
$id = strip_tags($_GET['id']);
|
||||||
@@ -1,7 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once('../src/User.php');
|
session_start();
|
||||||
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($_POST)) {
|
if (isset($_POST)) {
|
||||||
if (
|
if (
|
||||||
@@ -14,19 +18,20 @@ if (isset($_POST)) {
|
|||||||
$login = strip_tags($_POST['login']);
|
$login = strip_tags($_POST['login']);
|
||||||
$description = strip_tags($_POST['description']);
|
$description = strip_tags($_POST['description']);
|
||||||
$role = strip_tags($_POST['role']);
|
$role = strip_tags($_POST['role']);
|
||||||
|
|
||||||
$user = GetUser($id);
|
$user = GetUser($id);
|
||||||
$user->login = $login;
|
$user->login = $login;
|
||||||
$user->description = $description;
|
$user->description = $description;
|
||||||
$user->role = $role;
|
$user->role = GetRole((int)$role);
|
||||||
|
|
||||||
UpdateUser($user);
|
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'])) {
|
if (isset($_GET['id']) && !empty($_GET['id'])) {
|
||||||
$id = strip_tags($_GET['id']);
|
$id = strip_tags($_GET['id']);
|
||||||
$user = GetUser($id);
|
$user = GetUser($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderTwig("users/edit.twig", array("user" => $user));
|
renderTwig("users/edit.twig", array("user" => $user, "roles" => GetRoles()));
|
||||||
@@ -28,7 +28,7 @@ function AddRole(string $name): void
|
|||||||
CloseDataBase();
|
CloseDataBase();
|
||||||
}
|
}
|
||||||
|
|
||||||
function GetRole(int $id): Role
|
function GetRole(int $id)
|
||||||
{
|
{
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ function GetRoles(): array
|
|||||||
$roles = array();
|
$roles = array();
|
||||||
|
|
||||||
foreach ($result as $role) {
|
foreach ($result as $role) {
|
||||||
array_push($roles, new User($role));
|
array_push($roles, new Role($role));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $roles;
|
return $roles;
|
||||||
@@ -78,9 +78,23 @@ function UpdateRole(Role $role): void
|
|||||||
|
|
||||||
$sql = "UPDATE `roles` SET `name`=:name WHERE `id`=:id;";
|
$sql = "UPDATE `roles` SET `name`=:name WHERE `id`=:id;";
|
||||||
$query = $db->prepare($sql);
|
$query = $db->prepare($sql);
|
||||||
$query->bindValue(':login', $role->name, PDO::PARAM_STR);
|
$query->bindValue(':name', $role->name, PDO::PARAM_STR);
|
||||||
$query->bindValue(':id', $role->id, PDO::PARAM_INT);
|
$query->bindValue(':id', $role->id, PDO::PARAM_INT);
|
||||||
$query->execute();
|
$query->execute();
|
||||||
|
|
||||||
CloseDataBase();
|
CloseDataBase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function DeleteRole(int $id)
|
||||||
|
{
|
||||||
|
global $db;
|
||||||
|
|
||||||
|
ConnectDataBase();
|
||||||
|
|
||||||
|
$sql = "DELETE FROM `roles` WHERE `id`=:id;";
|
||||||
|
$query = $db->prepare($sql);
|
||||||
|
$query->bindValue(':id', $id, PDO::PARAM_INT);
|
||||||
|
$query->execute();
|
||||||
|
|
||||||
|
CloseDataBase();
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,15 +1,25 @@
|
|||||||
<?php
|
<?php
|
||||||
/* inclure l'autoloader */
|
|
||||||
require_once('../vendor/autoload.php');
|
|
||||||
|
|
||||||
function renderTwig(string $file, $donnees) {
|
$SERVER_ROOT = $_SERVER['DOCUMENT_ROOT'] . "/tpCrudTwig";
|
||||||
|
|
||||||
|
require_once($SERVER_ROOT . '/vendor/autoload.php');
|
||||||
|
|
||||||
|
function renderTwig(string $file, $donnees)
|
||||||
|
{
|
||||||
|
global $SERVER_ROOT;
|
||||||
/* templates chargés à partir du système de fichiers (répertoire vue) */
|
/* templates chargés à partir du système de fichiers (répertoire vue) */
|
||||||
$loader = new Twig\Loader\FilesystemLoader('../templates');
|
$loader = new Twig\Loader\FilesystemLoader($SERVER_ROOT . "/templates");
|
||||||
/* options : prod = cache dans le répertoire cache, dev = pas de cache */
|
/* options : prod = cache dans le répertoire cache, dev = pas de cache */
|
||||||
$options_prod = array('cache' => 'cache', 'autoescape' => true);
|
$options_prod = array('cache' => 'cache', 'autoescape' => true);
|
||||||
$options_dev = array('cache' => false, 'autoescape' => true);
|
$options_dev = array('cache' => false, 'autoescape' => true);
|
||||||
/* stocker la configuration */
|
/* stocker la configuration */
|
||||||
$twig = new Twig\Environment($loader);
|
$twig = new Twig\Environment($loader);
|
||||||
|
|
||||||
|
$message = isset($_SESSION['message']) ? $_SESSION['message'] : "";
|
||||||
|
$error = isset($_SESSION['error']) ? $_SESSION['error'] : "";
|
||||||
|
|
||||||
|
$donnees["message"] = $message;
|
||||||
|
$donnees["error"] = $error;
|
||||||
/* charger+compiler le template, exécuter, envoyer le résultat au navigateur */
|
/* charger+compiler le template, exécuter, envoyer le résultat au navigateur */
|
||||||
echo $twig->render($file, $donnees);
|
echo $twig->render($file, $donnees);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once('DataBase.php');
|
require_once('DataBase.php');
|
||||||
|
require_once('Role.php');
|
||||||
|
|
||||||
class User {
|
class User
|
||||||
|
{
|
||||||
public int $id;
|
public int $id;
|
||||||
public string $login;
|
public string $login;
|
||||||
public string $password;
|
public string $password;
|
||||||
public string $firstname;
|
public string $firstname;
|
||||||
public string $lastname;
|
public string $lastname;
|
||||||
public string $description;
|
public string $description;
|
||||||
public int $role;
|
public Role $role;
|
||||||
public bool $enabled;
|
public bool $enabled;
|
||||||
|
|
||||||
function __construct(array $table)
|
function __construct(array $table)
|
||||||
@@ -20,12 +22,12 @@ class User {
|
|||||||
$this->firstname = $table['firstname'];
|
$this->firstname = $table['firstname'];
|
||||||
$this->lastname = $table['lastname'];
|
$this->lastname = $table['lastname'];
|
||||||
$this->description = $table['description'];
|
$this->description = $table['description'];
|
||||||
$this->role = $table['role'];
|
$this->role = GetRole((int) $table['role']);
|
||||||
$this->enabled = $table['enabled'];
|
$this->enabled = $table['enabled'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function GetUsers() : array
|
function GetUsers(): array
|
||||||
{
|
{
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
@@ -47,7 +49,7 @@ function GetUsers() : array
|
|||||||
return $users;
|
return $users;
|
||||||
}
|
}
|
||||||
|
|
||||||
function GetUser(int $id) : User
|
function GetUser(int $id): User
|
||||||
{
|
{
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
@@ -95,7 +97,7 @@ function UpdateUser(User $user)
|
|||||||
$query = $db->prepare($sql);
|
$query = $db->prepare($sql);
|
||||||
$query->bindValue(':login', $user->login, PDO::PARAM_STR);
|
$query->bindValue(':login', $user->login, PDO::PARAM_STR);
|
||||||
$query->bindValue(':description', $user->description, PDO::PARAM_STR);
|
$query->bindValue(':description', $user->description, PDO::PARAM_STR);
|
||||||
$query->bindValue(':role', $user->role, PDO::PARAM_INT);
|
$query->bindValue(':role', $user->role->id, PDO::PARAM_INT);
|
||||||
$query->bindValue(':id', $user->id, PDO::PARAM_INT);
|
$query->bindValue(':id', $user->id, PDO::PARAM_INT);
|
||||||
$query->execute();
|
$query->execute();
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
|
||||||
|
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
||||||
|
<title>{% block title %}{% endblock %}</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||||
|
<a class="navbar-brand" href="/tpCrudTwig/public/index.php">TP Crud
|
||||||
|
<img src="/tpCrudTwig/public/images/suisse.png" alt="suisse" width="30" height="30"
|
||||||
|
class="d-inline-block align-text-top">
|
||||||
|
</a>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavAltMarkup"
|
||||||
|
aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
|
||||||
|
<div class="navbar-nav">
|
||||||
|
<li class="nav-item dropdown">
|
||||||
|
<a class="nav-link dropdown-toggle active" href="#" role="button" data-bs-toggle="dropdown"
|
||||||
|
aria-expanded="false">
|
||||||
|
Utilisateurs
|
||||||
|
</a>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li><a class="dropdown-item" href="/tpCrudTwig/public/index.php">Liste des utilisateurs</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<hr class="dropdown-divider">
|
||||||
|
</li>
|
||||||
|
<li><a class="dropdown-item" href="/tpCrudTwig/public/users/add.php">Ajouter un
|
||||||
|
utilisateur</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="nav-item dropdown">
|
||||||
|
<a class="nav-link dropdown-toggle active" href="#" role="button" data-bs-toggle="dropdown"
|
||||||
|
aria-expanded="false">
|
||||||
|
Roles
|
||||||
|
</a>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li><a class="dropdown-item" href="/tpCrudTwig/public/roles/list.php">Liste des rôles</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<hr class="dropdown-divider">
|
||||||
|
</li>
|
||||||
|
<li><a class="dropdown-item" href="/tpCrudTwig/public/roles/add.php">Ajouter un rôle</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="container text-center bg-light p-2">
|
||||||
|
{% block content %}
|
||||||
|
{% endblock %}
|
||||||
|
{% if message is not empty %}
|
||||||
|
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||||
|
{{ message }}
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% if error is not empty %}
|
||||||
|
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||||
|
{{ error }}
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<footer class="footer fixed-bottom text-center m-1 bg-dark-subtle">
|
||||||
|
{% block footer %}
|
||||||
|
© Copyright {{ "now"|date('Y') }} de Simon Pribylski.
|
||||||
|
{% endblock %}
|
||||||
|
</footer>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
|
||||||
|
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
|
||||||
|
crossorigin="anonymous"></script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
16
tpCrudTwig/templates/roles/add.twig
Normal file
16
tpCrudTwig/templates/roles/add.twig
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{% extends "base.twig" %}
|
||||||
|
|
||||||
|
{% block title %}Ajouter rôle{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<h1>Ajouter un rôle</h1>
|
||||||
|
<form class="form-group" role="search" method="post">
|
||||||
|
<label for="name">Nom du rôle</label>
|
||||||
|
<input type="text" class="form-control" name="name" id="name">
|
||||||
|
<input type="submit" class="btn btn-success" name="Ajouter" />
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
17
tpCrudTwig/templates/roles/edit.twig
Normal file
17
tpCrudTwig/templates/roles/edit.twig
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{% extends "base.twig" %}
|
||||||
|
|
||||||
|
{% block title %}Modification du rôle{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<h1>Modifier un rôle</h1>
|
||||||
|
<form method="post">
|
||||||
|
<label for="name">Nom</label>
|
||||||
|
<input type="text" class="form-control" name="name" id="name" value="{{ role.name }}">
|
||||||
|
<input type="submit" class="btn btn-success" name="Enregistrer" value="Enregistrer" />
|
||||||
|
<input type="hidden" name="id" value="{{ role.id }}">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
36
tpCrudTwig/templates/roles/index.twig
Normal file
36
tpCrudTwig/templates/roles/index.twig
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
{% extends "base.twig" %}
|
||||||
|
|
||||||
|
{% block title %}Liste des rôles{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<h1 class="">Liste des rôles</h1>
|
||||||
|
<table class="table table-striped table-bordered table-condensed">
|
||||||
|
<thead>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Nom</th>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{# afficher les roles #}
|
||||||
|
{% for role in roles %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ role.id }}</td>
|
||||||
|
<td>{{ role.name }}</td>
|
||||||
|
<td>
|
||||||
|
<button type="button" class="btn btn-info"
|
||||||
|
onclick="window.location.href='details.php?id={{ role.id }}'">Voir</button>
|
||||||
|
<button type="button" class="btn btn-warning"
|
||||||
|
onclick="window.location.href='edit.php?id={{ role.id }}'">Modifier</button>
|
||||||
|
<button type="button" class="btn btn-danger"
|
||||||
|
onclick="window.location.href='delete.php?id={{ role.id }}'">Supprimer</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<button type="button" class="btn btn-success mb-2" onclick="window.location.href='add.php'">Ajouter</button>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@@ -1,33 +1,35 @@
|
|||||||
<!DOCTYPE html>
|
{% extends "base.twig" %}
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
{% block title %}Ajouter utilisateur{% endblock %}
|
||||||
<meta charset="UTF-8">
|
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
|
||||||
{# <link rel="stylesheet" href="style/style.css"/> #}
|
|
||||||
{# <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script> #}
|
|
||||||
<title>Ajouter utilisateur</title>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div class="container text-center bg-light">
|
|
||||||
<h1>Ajouter un utilisateur</h1>
|
|
||||||
<form class="form-group" role="search" method="post">
|
|
||||||
<label for="login">Utilisateur</label>
|
|
||||||
<input type="text" class="form-control" name="login" id="login">
|
|
||||||
<label for="password">Mot de passe</label>
|
|
||||||
<input type="password" class="form-control" name="password" id="password" />
|
|
||||||
<label for="firstname">Prénom</label>
|
|
||||||
<input type="text" class="form-control" name="firstname" id="firstname">
|
|
||||||
<label for="lastname">Nom de famille</label>
|
|
||||||
<input type="text" class="form-control" name="lastname" id="lastname" />
|
|
||||||
<label for="role">Role</label>
|
|
||||||
<input type="number" class="form-control" name="role" id="role">
|
|
||||||
<label for="description">Description</label>
|
|
||||||
<textarea name="description" class="form-control"></textarea>
|
|
||||||
<input type="submit" class="btn btn-success" name="Enregistrer" value="Enregistrer"/>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<h1>Ajouter un utilisateur</h1>
|
||||||
|
<form class="form-group" role="search" method="post">
|
||||||
|
<label for="login">Utilisateur</label>
|
||||||
|
<input type="text" class="form-control" name="login" id="login">
|
||||||
|
<label for="password">Mot de passe</label>
|
||||||
|
<input type="password" class="form-control" name="password" id="password" />
|
||||||
|
<label for="firstname">Prénom</label>
|
||||||
|
<input type="text" class="form-control" name="firstname" id="firstname">
|
||||||
|
<label for="lastname">Nom de famille</label>
|
||||||
|
<input type="text" class="form-control" name="lastname" id="lastname" />
|
||||||
|
|
||||||
|
|
||||||
|
<label for="role">Role</label>
|
||||||
|
<select class="form-control" name="role" id="role-select">
|
||||||
|
|
||||||
|
{% for role in roles %}
|
||||||
|
<option value="{{ role.id }}">{{ role.name }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<label for="description">Description</label>
|
||||||
|
<textarea name="description" class="form-control"></textarea>
|
||||||
|
<input type="submit" class="btn btn-success" name="Ajouter" />
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@@ -1,29 +1,24 @@
|
|||||||
<!DOCTYPE html>
|
{% extends "base.twig" %}
|
||||||
<html lang="fr">
|
|
||||||
|
|
||||||
<head>
|
{% block title %}Détails de l'utilisateur{% endblock %}
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>Détails de l'utilisateur</title>
|
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
|
||||||
{# <link rel="stylesheet" href="style/style.css" /> #}
|
|
||||||
{# <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script> #}
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div class="container text-center bg-light">
|
|
||||||
<h1>Détails pour l’utilisateur {{ user.login }}</h1>
|
|
||||||
<div class="container bg-white w-25 border my-2">
|
|
||||||
<p>ID : {{ user.id }}</p>
|
|
||||||
<p>Login : {{ user.login }}</p>
|
|
||||||
<p>FirstName : {{ user.firstname }}</p>
|
|
||||||
<p>LastName : {{ user.lastname }}</p>
|
|
||||||
<p>Role : {{ user.role }}</p>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<button type="button" class="btn btn-warning" onclick="window.location.href='edit.php?id={{ user.id }}'">Modifier</button>
|
|
||||||
<button type="button" class="btn btn-danger" onclick="window.location.href='delete.php?id={{ user.id }}'">Supprimer</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<h1>Détails pour l’utilisateur {{ user.login }}</h1>
|
||||||
|
<div class="container bg-white w-25 border my-2">
|
||||||
|
<p>ID : {{ user.id }}</p>
|
||||||
|
<p>Login : {{ user.login }}</p>
|
||||||
|
<p>FirstName : {{ user.firstname }}</p>
|
||||||
|
<p>LastName : {{ user.lastname }}</p>
|
||||||
|
<p>Role : {{ user.role.name }}</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<button type="button" class="btn btn-warning"
|
||||||
|
onclick="window.location.href='edit.php?id={{ user.id }}'">Modifier</button>
|
||||||
|
<button type="button" class="btn btn-danger"
|
||||||
|
onclick="window.location.href='delete.php?id={{ user.id }}'">Supprimer</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@@ -1,30 +1,28 @@
|
|||||||
<!DOCTYPE html>
|
{% extends "base.twig" %}
|
||||||
<html lang="fr">
|
|
||||||
|
|
||||||
<head>
|
{% block title %}Modification de l'utilisateur{% endblock %}
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Modification de l'utilisateur</title>
|
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
|
||||||
{# <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script> #}
|
|
||||||
{# <link rel="stylesheet"
|
|
||||||
href="style/style.css"> #}
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div class="container text-center bg-light">
|
|
||||||
<h1>Modifier un utilisateur</h1>
|
|
||||||
<form method="post">
|
|
||||||
<label for="login">Login</label>
|
|
||||||
<input type="text" class="form-control" name="login" id="login" value="{{ user.login }}">
|
|
||||||
<label for="description">Description</label>
|
|
||||||
<input type="text" class="form-control" name="description" id="description" value="{{ user.description }}">
|
|
||||||
<label for="role">Role</label>
|
|
||||||
<input type="number" class="form-control" name="role" id="role" value="{{ user.role }}">
|
|
||||||
<input type="submit" class="btn btn-success" name="Enregistrer" value="Enregistrer"/>
|
|
||||||
<input type="hidden" name="id" value="{{ user.id }}">
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<h1>Modifier un utilisateur</h1>
|
||||||
|
<form method="post">
|
||||||
|
<label for="login">Login</label>
|
||||||
|
<input type="text" class="form-control" name="login" id="login" value="{{ user.login }}">
|
||||||
|
<label for="description">Description</label>
|
||||||
|
<input type="text" class="form-control" name="description" id="description" value="{{ user.description }}">
|
||||||
|
<label for="role">Role</label>
|
||||||
|
<select class="form-control" name="role" id="role-select">
|
||||||
|
|
||||||
|
{% for role in roles %}
|
||||||
|
<option value="{{ role.id }}" {% if role.id==user.role.id %} selected="selected" {% endif %}>{{ role.name }}
|
||||||
|
</option>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
</select>
|
||||||
|
<input type="submit" class="btn btn-success m-2" name="Enregistrer" />
|
||||||
|
<input type="hidden" name="id" value="{{ user.id }}">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@@ -1,48 +1,43 @@
|
|||||||
|
{% extends "base.twig" %}
|
||||||
|
|
||||||
<!DOCTYPE html>
|
{% block title %}Liste des utilisateurs{% endblock %}
|
||||||
<html lang="fr">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
|
||||||
{# <link rel="stylesheet" href="style/style.css" /> #}
|
|
||||||
{# <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script> #}
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Liste des utilisateurs</title>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div class="container text-center bg-light">
|
|
||||||
<h1 class="">Liste des utilisateurs</h1>
|
|
||||||
<table class="table table-striped table-bordered table-condensed">
|
|
||||||
<thead>
|
|
||||||
<th>ID</th>
|
|
||||||
<th>Login</th>
|
|
||||||
<th>Nom</th>
|
|
||||||
<th>Prenom</th>
|
|
||||||
<th>Rôle</th>
|
|
||||||
<th>Actions</th>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{# afficher les utilisateurs #}
|
|
||||||
{% for user in users %}
|
|
||||||
<tr>
|
|
||||||
<td>{{ user.id }}</td>
|
|
||||||
<td>{{ user.login }}</td>
|
|
||||||
<td>{{ user.lastname }}</td>
|
|
||||||
<td>{{ user.firstname }}</td>
|
|
||||||
<td>{{ user.role }}</td>
|
|
||||||
<td>
|
|
||||||
<button type="button" class="btn btn-info" onclick="window.location.href='details.php?id={{ user.id }}'">Voir</button>
|
|
||||||
<button type="button" class="btn btn-warning" onclick="window.location.href='edit.php?id= {{ user.id }}'">Modifier</button>
|
|
||||||
<button type="button" class="btn btn-danger" onclick="window.location.href='delete.php?id= {{ user.id }}'">Supprimer</button>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<button type="button" class="btn btn-success" onclick="window.location.href='add.php'">Ajouter</button>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<h1 class="">Liste des utilisateurs</h1>
|
||||||
|
<table class="table table-striped table-bordered table-condensed">
|
||||||
|
<thead>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Login</th>
|
||||||
|
<th>Nom</th>
|
||||||
|
<th>Prenom</th>
|
||||||
|
<th>Rôle</th>
|
||||||
|
<th>Actions</th>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{# afficher les utilisateurs #}
|
||||||
|
{% for user in users %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ user.id }}</td>
|
||||||
|
<td>{{ user.login }}</td>
|
||||||
|
<td>{{ user.lastname }}</td>
|
||||||
|
<td>{{ user.firstname }}</td>
|
||||||
|
<td>{{ user.role.name }}</td>
|
||||||
|
<td>
|
||||||
|
<button type="button" class="btn btn-info"
|
||||||
|
onclick="window.location.href='users/details.php?id={{ user.id }}'">Voir</button>
|
||||||
|
<button type="button" class="btn btn-warning"
|
||||||
|
onclick="window.location.href='users/edit.php?id= {{ user.id }}'">Modifier</button>
|
||||||
|
<button type="button" class="btn btn-danger"
|
||||||
|
onclick="window.location.href='users/delete.php?id= {{ user.id }}'">Supprimer</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<button type="button" class="btn btn-success mb-2" onclick="window.location.href='users/add.php'">Ajouter</button>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user