gestion de guides + ajouts divers
This commit is contained in:
parent
cb1fc55388
commit
634e58c507
10 changed files with 352 additions and 57 deletions
|
|
@ -624,3 +624,53 @@ function updateUserPermissions($bdd, $user, $permissions)
|
|||
|
||||
return $success;
|
||||
}
|
||||
|
||||
function deleteRaccourcis($bdd, $id)
|
||||
{
|
||||
$sql = "DELETE FROM raccourcis WHERE id = ?";
|
||||
$req = $bdd->prepare($sql);
|
||||
$req->bind_param("i", $id);
|
||||
$req->execute();
|
||||
return $req->affected_rows > 0;
|
||||
}
|
||||
|
||||
function getEventVisibility($bdd, $event)
|
||||
{
|
||||
$stmt = mysqli_prepare(
|
||||
$bdd,
|
||||
"SELECT public FROM evenements WHERE id = ? LIMIT 1"
|
||||
);
|
||||
|
||||
mysqli_stmt_bind_param($stmt, "s", $event);
|
||||
mysqli_stmt_execute($stmt);
|
||||
|
||||
$result = mysqli_stmt_get_result($stmt);
|
||||
$row = mysqli_fetch_assoc($result);
|
||||
|
||||
mysqli_stmt_close($stmt);
|
||||
|
||||
return $row ? $row['public'] : null;
|
||||
}
|
||||
|
||||
function createGuide($bdd, $nom, $lien, $image)
|
||||
{
|
||||
|
||||
$stmt = mysqli_prepare(
|
||||
$bdd,
|
||||
"INSERT INTO guides (nom, lien, image) VALUES (?, ?, ?)"
|
||||
);
|
||||
mysqli_stmt_bind_param($stmt, "sss", $nom, $lien, $image);
|
||||
mysqli_stmt_execute($stmt);
|
||||
$guideId = mysqli_insert_id($bdd);
|
||||
mysqli_stmt_close($stmt);
|
||||
return $guideId;
|
||||
}
|
||||
|
||||
function deleteGuide($bdd, $id)
|
||||
{
|
||||
$sql = "DELETE FROM guides WHERE id = ?";
|
||||
$req = $bdd->prepare($sql);
|
||||
$req->bind_param("i", $id);
|
||||
$req->execute();
|
||||
return $req->affected_rows > 0;
|
||||
}
|
||||
|
|
@ -153,6 +153,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||
</button>
|
||||
</li>
|
||||
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="./gestionGuides.php">
|
||||
Guides
|
||||
</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
<div class="tab-content mt-4">
|
||||
|
|
@ -168,21 +174,26 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||
|
||||
<?php foreach ($shortcuts as $shortcut): ?>
|
||||
|
||||
<div class="card p-3 mb-2 d-flex flex-row align-items-center shortcut"
|
||||
data-id="<?= $shortcut['id'] ?>">
|
||||
<div class="card p-3 mb-2 d-flex flex-column shortcut" data-id="<?= $shortcut['id'] ?>">
|
||||
|
||||
<img class="editable-image"
|
||||
src="<?= (str_starts_with($shortcut['image'], 'http') || str_starts_with($shortcut['image'], 'data')) ? htmlspecialchars($shortcut['image']) : "." . htmlspecialchars($shortcut['image']) ?>"
|
||||
style="width:40px;height:40px;margin-right:10px;cursor:pointer;">
|
||||
<div class="d-flex align-items-center">
|
||||
<img class="editable-image"
|
||||
src="<?= (str_starts_with($shortcut['image'], 'http') || str_starts_with($shortcut['image'], 'data')) ? htmlspecialchars($shortcut['image']) : "." . htmlspecialchars($shortcut['image']) ?>"
|
||||
style="width:40px;height:40px;margin-right:10px;cursor:pointer;">
|
||||
|
||||
<div>
|
||||
<strong class="editable" data-field="nom">
|
||||
<?= htmlspecialchars($shortcut['nom']) ?>
|
||||
</strong>
|
||||
<br>
|
||||
<small class="editable" data-field="url">
|
||||
<?= htmlspecialchars($shortcut['url']) ?>
|
||||
</small>
|
||||
<div>
|
||||
<strong class="editable" data-field="nom">
|
||||
<?= htmlspecialchars($shortcut['nom']) ?>
|
||||
</strong>
|
||||
<br>
|
||||
<small class="editable" data-field="url">
|
||||
<?= htmlspecialchars($shortcut['url']) ?>
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-end mt-2">
|
||||
<button class="btn btn-danger" onclick="window.location.replace('./delete.php?type=raccourcis&id=<?= $shortcut['id'] ?>')">Supprimer</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
@ -221,7 +232,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||
<input type="number" id="site" name="site"><br>
|
||||
<label for="permissions">Permission de l'utilisateur</label>
|
||||
<select name="permissions" id="permissions">
|
||||
<option value="void">Sélectionner</option>
|
||||
<option value="">Sélectionner</option>
|
||||
<?php foreach ($roles as $role) { ?>
|
||||
<option value="<?php echo $role; ?>">
|
||||
<?php echo $role; ?>
|
||||
|
|
|
|||
|
|
@ -21,15 +21,34 @@ if (!verifyPoids($bdd, $_SESSION['username'], $minPoids)) {
|
|||
header('location: ../index.php');
|
||||
}
|
||||
|
||||
if(!empty($_GET['type'])){
|
||||
if (!empty($_GET['type'])) {
|
||||
$type = $_GET['type'];
|
||||
$id = $_GET['id'];
|
||||
|
||||
if($type == 'event'){
|
||||
$success = deleteEvent($bdd, $id);
|
||||
}elseif($type == 'actu'){
|
||||
$success = deleteActu($bdd, $id);
|
||||
}
|
||||
switch ($type):
|
||||
case 'guide':
|
||||
deleteGuide($bdd, $_GET['id']);
|
||||
header('location: gestionGuides.php');
|
||||
exit();
|
||||
break;
|
||||
|
||||
case 'raccourcis':
|
||||
deleteRaccourcis($bdd, $_GET['id']);
|
||||
header('location: admin.php');
|
||||
exit();
|
||||
|
||||
case 'actu':
|
||||
$success = deleteActu($bdd, $id);
|
||||
break;
|
||||
|
||||
case 'event':
|
||||
$success = deleteEvent($bdd, $id);
|
||||
break;
|
||||
|
||||
default:
|
||||
header('location: index.php');
|
||||
break;
|
||||
endswitch;
|
||||
|
||||
header('location: index.php');
|
||||
exit();
|
||||
|
|
|
|||
185
admin/gestionGuides.php
Normal file
185
admin/gestionGuides.php
Normal file
|
|
@ -0,0 +1,185 @@
|
|||
<?php
|
||||
include("../Assets/functions.php");
|
||||
$config = json_decode(file_get_contents("../Assets/config.json"), true);
|
||||
$bdd = connectBDD("localhost", $config["BDD_USER"], $config["BDD_PASSWD"], $config["BDD_NAME"]);
|
||||
|
||||
/* Gestion de la connexion */
|
||||
session_start();
|
||||
if (!isset($_SESSION['connected']) || $_SESSION['connected'] == false) {
|
||||
header('location: ../login.php?redirect_to=./admin/');
|
||||
}
|
||||
|
||||
$permission = $_SESSION["permission"];
|
||||
if ($permission == "admin") {
|
||||
$evenements = getEvenements($bdd, $_SESSION['site'], true);
|
||||
} else {
|
||||
$evenements = getEvenements($bdd, $_SESSION['site']);
|
||||
}
|
||||
|
||||
/* Récupération des infos */
|
||||
$permissions = $_SESSION['permission'];
|
||||
$site = $_SESSION['site'];
|
||||
|
||||
/* Gestion de l'accès à la page */
|
||||
$minPoids = 99;
|
||||
if (!verifyPoids($bdd, $_SESSION['username'], $minPoids)) {
|
||||
die("Vous n'avez pas l'autorisation");
|
||||
header('location: ./index.php');
|
||||
}
|
||||
|
||||
$uploadDir = "../Photos/INTRANET/guides/";
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
|
||||
$titre = htmlspecialchars($_POST["titre"]);
|
||||
|
||||
$pdfDir = "../Photos/INTRANET/guides/file/";
|
||||
$imageDir = "../Photos/INTRANET/guides/image/";
|
||||
|
||||
$renduPdfDir = "./Photos/INTRANET/guides/file/";
|
||||
$renduImageDir = "./Photos/INTRANET/guides/image/";
|
||||
|
||||
$pdfName = basename($_FILES["pdf"]["name"]);
|
||||
$imageName = basename($_FILES["image"]["name"]);
|
||||
|
||||
$pdfPath = $pdfDir . $pdfName;
|
||||
$imagePath = $imageDir . $imageName;
|
||||
|
||||
if (
|
||||
move_uploaded_file($_FILES["pdf"]["tmp_name"], $pdfPath) &&
|
||||
move_uploaded_file($_FILES["image"]["tmp_name"], $imagePath)
|
||||
) {
|
||||
|
||||
createGuide($bdd, $_POST['titre'], $renduPdfDir.$pdfName, $renduImageDir.$imageName);
|
||||
|
||||
echo "<div class='alert alert-success'>Guide ajouté avec succès</div>";
|
||||
} else {
|
||||
echo "<div class='alert alert-danger'>Erreur lors de l'upload</div>";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Gestion Intranet</title>
|
||||
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="../styles-scripts/index.admin.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<h1>Gestion de l'intranet</h1>
|
||||
|
||||
<!-- navbar -->
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
|
||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
<ul class="navbar-nav mr-auto">
|
||||
|
||||
<li class="nav-item">
|
||||
<a href="index.php" class="nav-link">Évènements</a>
|
||||
</li>
|
||||
|
||||
<li class="nav-item">
|
||||
<a href="modifyActuality.php" class="nav-link">Actualités</a>
|
||||
</li>
|
||||
|
||||
<li class="nav-item">
|
||||
<a href="admin.php" class="nav-link">Administration</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container mt-4">
|
||||
|
||||
<!-- Onglets -->
|
||||
<ul class="nav nav-tabs" id="adminTabs" role="tablist">
|
||||
<li class="nav-item" role="presentation">
|
||||
<a class="nav-link" href="./admin.php">
|
||||
Raccourcis / Utilisateurs
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="./gestionGuides.php">
|
||||
Guides
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- Gestion des guides -->
|
||||
<div class="container mt-4">
|
||||
<div class="mb-4">
|
||||
|
||||
<?php $guides = getGuides($bdd); ?>
|
||||
|
||||
<?php foreach ($guides as $guide): ?>
|
||||
|
||||
<div class="card p-3 mb-2 d-flex flex-column shortcut" data-id="<?= $shortcut['id'] ?>">
|
||||
|
||||
<div class="d-flex align-items-center">
|
||||
<img class="image"
|
||||
src="<?= ".".$guide['image'] ?>"
|
||||
style="width:40px;height:40px;margin-right:10px;cursor:pointer;">
|
||||
|
||||
<div>
|
||||
<strong class="" data-field="nom">
|
||||
<?= htmlspecialchars($guide['nom']) ?>
|
||||
</strong>
|
||||
<br>
|
||||
<small class="editable" data-field="url">
|
||||
<?= htmlspecialchars($guide['lien']) ?>
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-end mt-2">
|
||||
<button class="btn btn-danger" onclick="window.location.replace('./delete.php?type=guide&id=<?= $guide['id'] ?>')">Supprimer</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container mt-4">
|
||||
|
||||
<h3>Ajouter un guide</h3>
|
||||
|
||||
<form method="POST" enctype="multipart/form-data">
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Titre du guide</label>
|
||||
<input type="text" name="titre" class="form-control" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Fichier PDF</label>
|
||||
<input type="file" name="pdf" class="form-control" accept=".pdf" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Image</label>
|
||||
<input type="file" name="image" class="form-control" accept="image/*" required>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Ajouter le guide
|
||||
</button>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
|
|
@ -7,12 +7,13 @@ if (userExists($bdd, $_POST['username'])) {
|
|||
if (isset($_POST['password']) && !empty($_POST["password"])) {
|
||||
updateUserPassword($bdd, $_POST['username'], hash('sha256', $_POST['password']));
|
||||
}
|
||||
if(isset($_POST['site']) && $_POST["site"] != ""){
|
||||
if (isset($_POST['site']) && $_POST["site"] != "") {
|
||||
updateUserSite($bdd, $_POST["username"], $_POST["site"]);
|
||||
}
|
||||
if($_POST['permissions'] != "Sélectionner"){
|
||||
if (!empty($_POST['permissions'])) {
|
||||
updateUserPermissions($bdd, $_POST['username'], $_POST['permissions']);
|
||||
}
|
||||
}else{
|
||||
header('location: admin.php');
|
||||
} else {
|
||||
die('L\'utilisateur n\'existe pas...');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,8 +22,11 @@ $eventId = $_GET['id'] ?? null;
|
|||
$titre = getEventName($bdd, $eventId) ?? '';
|
||||
$site = getEventSite($bdd, $eventId) ?? '';
|
||||
$couverture = getEventBigImage($bdd, $eventId) ?? '';
|
||||
$public = getEventVisibility($bdd, $eventId);
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && empty($_POST['new'])) {
|
||||
var_dump($_POST);
|
||||
die();
|
||||
if (!empty($_POST['title'])) {
|
||||
updateEventTitle($bdd, $eventId, trim($_POST['title']));
|
||||
}
|
||||
|
|
@ -188,6 +191,10 @@ if (!empty($_POST['new'])) {
|
|||
<input type="number" name="site" id="site" class="form-control" value="<?= $site ?>">
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<div class="mb-3">
|
||||
<label for="public">Public ?</label>
|
||||
<input type="checkbox" name="public" id="public" value="<?= $public ?>">
|
||||
</div>
|
||||
<?php if (empty($_GET['id'])): ?>
|
||||
<input type="text" name="new" id="new" value="new" style="display: none;">
|
||||
<?php endif ?>
|
||||
|
|
|
|||
43
guides.php
43
guides.php
|
|
@ -8,26 +8,29 @@ $guides = getGuides($bdd);
|
|||
?>
|
||||
<!doctype html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Intranet de l'APEI</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-sRIl4kxILFvY47J16cr9ZwB07vP4J8+LH7qKQnuqkuIAvNWLzeN8tE5YBujZqJLB" crossorigin="anonymous">
|
||||
<link rel="shortcut icon" href="./Assets/Icones/APEIMBGE.jpg" type="image/x-icon">
|
||||
</head>
|
||||
<body>
|
||||
<?php include('./Assets/navbar.php');?>
|
||||
|
||||
<div class="grid-container">
|
||||
<?php foreach ($guides as $guide): ?>
|
||||
<div class="card" onclick="window.location.href='<?= $guide['lien'] ?>'">
|
||||
<h4><?= $guide['nom'] ?></h4>
|
||||
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/c/c1/Google_%22G%22_logo.svg/3840px-Google_%22G%22_logo.svg.png" alt="Image de couverture">
|
||||
</div>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Intranet de l'APEI</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-sRIl4kxILFvY47J16cr9ZwB07vP4J8+LH7qKQnuqkuIAvNWLzeN8tE5YBujZqJLB" crossorigin="anonymous">
|
||||
<link rel="shortcut icon" href="./Assets/Icones/APEIMBGE.jpg" type="image/x-icon">
|
||||
<link rel="stylesheet" href="./styles-scripts/guides.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php include('./Assets/navbar.php'); ?>
|
||||
|
||||
<div class="grid-container">
|
||||
<?php foreach ($guides as $guide): ?>
|
||||
<div class="card" style="" onclick="window.location.href='<?= $guide['lien'] ?>'">
|
||||
<h4><?= $guide['nom'] ?></h4>
|
||||
<img src="<?= $guide['image'] ?>">
|
||||
</div>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
<!-- footer pas toucher -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js" integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI" crossorigin="anonymous"></script>
|
||||
</body>
|
||||
|
||||
<!-- footer pas toucher -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js" integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI" crossorigin="anonymous"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -25,6 +25,7 @@ if(isset($_POST['user']) && isset($_POST['password']) && isset($_GET['redirect_t
|
|||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-sRIl4kxILFvY47J16cr9ZwB07vP4J8+LH7qKQnuqkuIAvNWLzeN8tE5YBujZqJLB" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="./styles-scripts/login.css">
|
||||
<title>Se connecter !</title>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
|||
|
|
@ -1,14 +1,28 @@
|
|||
.grid-container {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
||||
gap: 1rem;
|
||||
padding: 1rem;
|
||||
}
|
||||
.grid-container {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 20px;
|
||||
justify-items: center;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.card {
|
||||
background: #f0f0f0;
|
||||
border: 2px solid #ccc;
|
||||
padding: 20px;
|
||||
/* text-align: center; */
|
||||
border-radius: 8px;
|
||||
.card {
|
||||
width: 100%;
|
||||
height: 40vh;
|
||||
cursor: pointer;
|
||||
padding: 10px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
max-height: 250px;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.grid-container {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
4
styles-scripts/login.css
Normal file
4
styles-scripts/login.css
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
body
|
||||
{
|
||||
padding: 1rem;
|
||||
}
|
||||
Loading…
Reference in a new issue