You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
1.7 KiB
76 lines
1.7 KiB
<?php
|
|
|
|
class ControllerUserPlayers
|
|
{
|
|
private $mdPlayer;
|
|
|
|
private $twig;
|
|
private $vues;
|
|
|
|
function __construct()
|
|
{
|
|
global $dns, $user, $pass, $vues, $twig;
|
|
session_start();
|
|
try {
|
|
|
|
if($_SESSION["idAdminConnected"] != null){
|
|
$this->twig =$twig;
|
|
$this->vues = $vues;
|
|
|
|
$this->mdPlayer = new ModelPlayer();
|
|
}
|
|
else {
|
|
header("Location:/login");
|
|
}
|
|
} catch (PDOException $e) {
|
|
// Gérez les erreurs PDO ici
|
|
} catch (Exception $e2) {
|
|
// Gérez d'autres erreurs ici
|
|
}
|
|
}
|
|
|
|
function delete($param) {
|
|
$this->mdPlayer->deleteAdministratorByID($param["id"]);
|
|
header("Location:/admin/administrators");
|
|
}
|
|
|
|
function add($param) {
|
|
|
|
$username = $_POST['username'];
|
|
$password = $_POST['password'];
|
|
|
|
$Player = [
|
|
'username' => $username,
|
|
'password' => $password,
|
|
];
|
|
|
|
$this->mdPlayer->addAdministrator($Player);
|
|
|
|
header("Location:/loginPlayer");
|
|
}
|
|
|
|
function updatemodal($param) {
|
|
|
|
$administrator = $this->mdPlayer->getAdministratorByID($param["id"]);
|
|
|
|
echo $this->twig->render($this->vues["adminAdministratorsModal"], [
|
|
'administrator' => $administrator,
|
|
]);
|
|
}
|
|
|
|
function update($param) {
|
|
|
|
$id = $_POST['id'];
|
|
$username = $_POST['username'];
|
|
$password = $_POST['password'];
|
|
|
|
$Admin = [
|
|
'username' => $username,
|
|
'password' => $password,
|
|
];
|
|
|
|
$this->mdPlayer->updateAdministrator($id,$Admin);
|
|
|
|
header("Location:/admin/administrators");
|
|
}
|
|
} |