279 lines
12 KiB
PHP
279 lines
12 KiB
PHP
<?php
|
|
// Titre de l'onglet
|
|
$pageTitle = 'Administration';
|
|
|
|
// On ajoute ici le header
|
|
require_once('./../elements/header.php');
|
|
|
|
// Ajout de la base de donnée
|
|
require_once '../functions/databaseConnection.php';
|
|
require_once("../functions/listUser.php");
|
|
require_once('../functions/listProject.php');
|
|
require_once('../functions/listXP.php');
|
|
require_once('../functions/listSchool.php');
|
|
require_once('../functions/listSkills.php');
|
|
require_once('../functions/listSettings.php');
|
|
|
|
|
|
// L'utilisateur doit être administrateur
|
|
if (!isset($_SESSION['role']) || $_SESSION['role'] !== 'admin') {
|
|
header('Location: ../pages/home.php');
|
|
exit;
|
|
}
|
|
|
|
// On met les variables à null ici pour éviter qu'il garde les options en premier chargement
|
|
$projetAModifier = null;
|
|
$xpAModifier = null;
|
|
$ecoleAModifier = null;
|
|
$skillAModifier = null;
|
|
|
|
|
|
// Si on modifie XP, Projets, École ou Compétence
|
|
if (isset($_GET['edit_project']) && is_numeric($_GET['edit_project'])) {
|
|
$projetAModifier = recupererProjetParId((int) $_GET['edit_project']);
|
|
}
|
|
if (isset($_GET['edit_xp']) && is_numeric($_GET['edit_xp'])) {
|
|
$xpAModifier = recupererXPParId((int) $_GET['edit_xp']);
|
|
}
|
|
if (isset($_GET['edit_school']) && is_numeric($_GET['edit_school'])) {
|
|
$ecoleAModifier = recupererEcoleParId((int) $_GET['edit_school']);
|
|
}
|
|
if (isset($_GET['edit_skill']) && is_numeric($_GET['edit_skill'])) {
|
|
$skillAModifier = recupererSkillParId((int) $_GET['edit_skill']);
|
|
}
|
|
|
|
// Valeurs actuelles de la notification de la page d'accueil
|
|
$noticeTitle = recupererSetting('site_notice_title') ?? '';
|
|
$noticeText = recupererSetting('site_notice_text') ?? '';
|
|
$noticeEnabled = recupererSetting('site_notice_enabled') ?? '1';
|
|
|
|
// Page du panneau d'administration
|
|
?>
|
|
|
|
<div class="admin-forms">
|
|
|
|
<!-- Formulaire de création de projet -->
|
|
<div class="project-container">
|
|
<div class="project-form-card">
|
|
|
|
<div class="project-header">
|
|
<h2><?php echo $projetAModifier ? 'Modifier le projet' : 'Nouveau projet'; ?></h2>
|
|
</div>
|
|
|
|
<!-- en envoie les données à addProject.php -->
|
|
<form method="POST" action="<?php echo $projetAModifier ? '../scripts/updateProject.php' : '../scripts/addProject.php'; ?>">
|
|
|
|
<?php if ($projetAModifier): ?>
|
|
<input type="hidden" name="id" value="<?php echo (int) $projetAModifier['id']; ?>">
|
|
<?php endif; ?>
|
|
|
|
<label>Titre *</label>
|
|
<input type="text" name="title" required value="<?php echo $projetAModifier ? htmlspecialchars($projetAModifier['title']) : ''; ?>">
|
|
|
|
<label>Tags (virgules)</label>
|
|
<input type="text" name="tags" value="<?php echo $projetAModifier ? htmlspecialchars($projetAModifier['tags']) : ''; ?>">
|
|
|
|
<label>Description *</label>
|
|
<textarea name="description" required><?php echo $projetAModifier ? htmlspecialchars($projetAModifier['description']) : ''; ?></textarea>
|
|
|
|
<label>Lien de l'image *</label>
|
|
<input type="url" name="imageurl" placeholder="https://..." required value="<?php echo $projetAModifier ? htmlspecialchars($projetAModifier['image_url']) : ''; ?>">
|
|
|
|
<input type="submit" name="submitproject" value="<?php echo $projetAModifier ? 'Modifier le projet' : '+ Ajouter le projet'; ?>" class="btn-submit">
|
|
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Formulaire de création d'expérience -->
|
|
<div class="project-container">
|
|
<div class="project-form-card">
|
|
|
|
<div class="project-header">
|
|
<h2><?php echo $xpAModifier ? 'Modifier l\'experience' : 'Nouvelle expérience'; ?></h2>
|
|
</div>
|
|
|
|
<!-- en envoie les données à addXP.php -->
|
|
<form method="POST" action="<?php echo $xpAModifier ? '../scripts/updateXP.php' : '../scripts/addXP.php'; ?>">
|
|
|
|
<?php if ($xpAModifier): ?>
|
|
<input type="hidden" name="id" value="<?php echo (int) $xpAModifier['id']; ?>">
|
|
<?php endif; ?>
|
|
|
|
<label>Titre *</label>
|
|
<input type="text" name="title" required value="<?php echo $xpAModifier ? htmlspecialchars($xpAModifier['title']) : ''; ?>">
|
|
|
|
<label>Type *</label>
|
|
<textarea name="xptype" required><?php echo $xpAModifier ? htmlspecialchars($xpAModifier['xptype']) : ''; ?></textarea>
|
|
|
|
<label>Tags (virgules)</label>
|
|
<input type="text" name="tags" value="<?php echo $xpAModifier ? htmlspecialchars($xpAModifier['tags']) : ''; ?>">
|
|
|
|
<label>Description *</label>
|
|
<textarea name="description" required><?php echo $xpAModifier ? htmlspecialchars($xpAModifier['description']) : ''; ?></textarea>
|
|
|
|
<label>Durée *</label>
|
|
<textarea name="duration" required><?php echo $xpAModifier ? htmlspecialchars($xpAModifier['duration']) : ''; ?></textarea>
|
|
|
|
<label>Lien de l'image *</label>
|
|
<input type="url" name="imageurl" placeholder="https://..." required value="<?php echo $xpAModifier ? htmlspecialchars($xpAModifier['image_url']) : ''; ?>">
|
|
|
|
<input type="submit" name="submitxp" value="<?php echo $xpAModifier ? 'Modifier l\'experience' : '+ Ajouter l\'experience'; ?>" class="btn-submit">
|
|
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Formulaire de création d'école / formation -->
|
|
<div class="project-container">
|
|
<div class="project-form-card">
|
|
|
|
<div class="project-header">
|
|
<h2><?php echo $ecoleAModifier ? 'Modifier l\'école' : 'Nouvelle école'; ?></h2>
|
|
</div>
|
|
|
|
<!-- on envoie les données à addSchool.php -->
|
|
<form method="POST" action="<?php echo $ecoleAModifier ? '../scripts/updateSchool.php' : '../scripts/addSchool.php'; ?>">
|
|
|
|
<?php if ($ecoleAModifier): ?>
|
|
<input type="hidden" name="id" value="<?php echo (int) $ecoleAModifier['id']; ?>">
|
|
<?php endif; ?>
|
|
|
|
<label>Nom de l'école *</label>
|
|
<input type="text" name="title" required value="<?php echo $ecoleAModifier ? htmlspecialchars($ecoleAModifier['title']) : ''; ?>">
|
|
|
|
<label>Tags (virgules)</label>
|
|
<input type="text" name="tags" value="<?php echo $ecoleAModifier ? htmlspecialchars($ecoleAModifier['tags']) : ''; ?>">
|
|
|
|
<label>Description (diplôme, spécialité...) *</label>
|
|
<textarea name="description" required><?php echo $ecoleAModifier ? htmlspecialchars($ecoleAModifier['description']) : ''; ?></textarea>
|
|
|
|
<label>Période (ex : 2023 - 2025) *</label>
|
|
<input type="text" name="duration" required value="<?php echo $ecoleAModifier ? htmlspecialchars($ecoleAModifier['duration']) : ''; ?>">
|
|
|
|
<label>Lien de l'image *</label>
|
|
<input type="url" name="imageurl" placeholder="https://..." required value="<?php echo $ecoleAModifier ? htmlspecialchars($ecoleAModifier['image_url']) : ''; ?>">
|
|
|
|
<input type="submit" name="submitschool" value="<?php echo $ecoleAModifier ? 'Modifier l\'école' : '+ Ajouter l\'école'; ?>" class="btn-submit">
|
|
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Formulaire de création de catégorie de compétences -->
|
|
<div class="project-container">
|
|
<div class="project-form-card">
|
|
|
|
<div class="project-header">
|
|
<h2><?php echo $skillAModifier ? 'Modifier la compétence' : 'Nouvelle compétence'; ?></h2>
|
|
</div>
|
|
|
|
<!-- on envoie les données à addSkill.php -->
|
|
<form method="POST" action="<?php echo $skillAModifier ? '../scripts/updateSkill.php' : '../scripts/addSkill.php'; ?>">
|
|
|
|
<?php if ($skillAModifier): ?>
|
|
<input type="hidden" name="id" value="<?php echo (int) $skillAModifier['id']; ?>">
|
|
<?php endif; ?>
|
|
|
|
<label>Titre de la catégorie *</label>
|
|
<input type="text" name="title" required value="<?php echo $skillAModifier ? htmlspecialchars($skillAModifier['title']) : ''; ?>">
|
|
|
|
<label>Icône de la catégorie (classes Font Awesome, ex : fa-solid fa-terminal)</label>
|
|
<input type="text" name="icon" placeholder="fa-solid fa-star" value="<?php echo $skillAModifier ? htmlspecialchars($skillAModifier['icon']) : ''; ?>">
|
|
|
|
<label>Compétences (une par ligne, format : "icone|texte" ou juste "texte") *</label>
|
|
<textarea name="items" placeholder="fa-brands fa-python|Python fa-solid fa-terminal|Bash Ansible" required><?php echo $skillAModifier ? htmlspecialchars($skillAModifier['items']) : ''; ?></textarea>
|
|
|
|
<label>Position (ordre d'affichage, du plus petit au plus grand)</label>
|
|
<input type="text" name="position" value="<?php echo $skillAModifier ? (int) $skillAModifier['position'] : '0'; ?>">
|
|
|
|
<input type="submit" name="submitskill" value="<?php echo $skillAModifier ? 'Modifier la compétence' : '+ Ajouter la compétence'; ?>" class="btn-submit">
|
|
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Formulaire de la notification de la page d'accueil -->
|
|
<div class="project-container">
|
|
<div class="project-form-card">
|
|
|
|
<div class="project-header">
|
|
<h2>Notification de la page d'accueil</h2>
|
|
</div>
|
|
|
|
<!-- on envoie les données à updateSettings.php -->
|
|
<form method="POST" action="../scripts/updateSettings.php">
|
|
|
|
<label>Titre (affiché en gras)</label>
|
|
<input type="text" name="notice_title" value="<?php echo htmlspecialchars($noticeTitle); ?>">
|
|
|
|
<label>Texte</label>
|
|
<textarea name="notice_text"><?php echo htmlspecialchars($noticeText); ?></textarea>
|
|
|
|
<!-- Checkbox pour activer / désactiver la notification sans la supprimer -->
|
|
<label class="checkbox-row">
|
|
<input type="checkbox" name="notice_enabled" value="1" <?php echo $noticeEnabled === '1' ? 'checked' : ''; ?>>
|
|
Afficher la notification sur la page d'accueil
|
|
</label>
|
|
|
|
<input type="submit" name="submitsettings" value="Enregistrer la notification" class="btn-submit">
|
|
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
// Liste des projets / xps => en gros on pourra supprimer, et modifier à la vollée sans aller dans la bdd
|
|
?>
|
|
<h2 class="projects-title">Gérer les projets</h2>
|
|
<?php afficherProjetsAdmin(); ?>
|
|
<h2 class="projects-title">Gérer les experiences</h2>
|
|
<?php afficherXPAdmin(); ?>
|
|
<h2 class="projects-title">Gérer les écoles</h2>
|
|
<?php afficherEcolesAdmin(); ?>
|
|
<h2 class="projects-title">Gérer les compétences</h2>
|
|
<section class="skills-section skills-section-admin">
|
|
<?php afficherSkillsAdmin(); ?>
|
|
</section>
|
|
<?php
|
|
|
|
// Création de compte
|
|
?>
|
|
|
|
<!-- Formulaire de création de compte -->
|
|
<div class="project-container">
|
|
<div class="project-form-card">
|
|
<div class="project-header">
|
|
<h2>Nouveau compte</h2>
|
|
</div>
|
|
|
|
<!-- en envoie les données addUser.php -->
|
|
<form method="POST" action="../scripts/addUser.php">
|
|
<label>Nom du compte</label>
|
|
<input type="text" name="user" required>
|
|
|
|
<!-- role admin ou user -->
|
|
<label>Rôle (admin/user)</label>
|
|
<textarea name="role" required></textarea>
|
|
|
|
<!-- mot de passe -->
|
|
<label>Mot de passe</label>
|
|
<input type="password" name="passwd" required>
|
|
|
|
<!-- Le bouton qui déclenche le PHP en haut de page -->
|
|
<input type="submit" name="submituser" value="Ajouter l'utilisateur" class="btn-submit">
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Liste des utilisateurs -->
|
|
<h2 class="projects-title">Gérer les utilisateurs</h2>
|
|
|
|
<!-- Affichage de la liste des utilisateurs -->
|
|
<?php
|
|
afficherUsersAdmin();
|
|
|
|
// On ajoute ici le footer
|
|
require_once('../elements/footer.php'); ?>
|