Affichage de tous les profils existants

This commit is contained in:
Yohann 2019-12-04 12:05:53 +01:00
parent 204080f1b0
commit d33b404ca7
6 changed files with 33 additions and 13 deletions

View File

@ -59,7 +59,8 @@ $ROUTES["^ma-participation/([A-Z]{3})/?$"] = ["server_files/controllers/ma_parti
$ROUTES["^poser-questions-2$"] = ["server_files/controllers/poser_questions.php"]; $ROUTES["^poser-questions-2$"] = ["server_files/controllers/poser_questions.php"];
$ROUTES["^poser-questions-2/([A-Z]{3})$"] = ["server_files/controllers/poser_questions.php", "trigram"]; $ROUTES["^poser-questions-2/([A-Z]{3})$"] = ["server_files/controllers/poser_questions.php", "trigram"];
$ROUTES["^probleme/([0-4])/?$"] = ["server_files/controllers/probleme.php", "probleme"]; $ROUTES["^probleme/([0-4])/?$"] = ["server_files/controllers/probleme.php", "probleme"];
$ROUTES["^profils-orphelins/?$"] = ["server_files/controllers/profils_orphelins.php"]; $ROUTES["^profils/?$"] = ["server_files/controllers/profiles.php"];
$ROUTES["^profils-(orphelins)/?$"] = ["server_files/controllers/profiles.php", "orphans"];
$ROUTES["^rejoindre-equipe/?$"] = ["server_files/controllers/rejoindre_equipe.php"]; $ROUTES["^rejoindre-equipe/?$"] = ["server_files/controllers/rejoindre_equipe.php"];
$ROUTES["^repondre-questions-3$"] = ["server_files/controllers/repondre_questions.php"]; $ROUTES["^repondre-questions-3$"] = ["server_files/controllers/repondre_questions.php"];
$ROUTES["^repondre-questions-3/([A-Z]{3})$"] = ["server_files/controllers/repondre_questions.php"]; $ROUTES["^repondre-questions-3/([A-Z]{3})$"] = ["server_files/controllers/repondre_questions.php"];

View File

@ -67,11 +67,28 @@ class User
return $admins; return $admins;
} }
public static function getAllUsers()
{
global $DB, $YEAR;
$orphans = [];
$req = $DB->query("SELECT * FROM `users` WHERE `role` != 'ADMIN' AND `year` = $YEAR ORDER BY `role`, `inscription_date`;");
while (($data = $req->fetch()) !== false) {
$orphan = new User();
$orphan->fill($data);
$orphans[] = $orphan;
}
return $orphans;
}
public static function getOrphanUsers() public static function getOrphanUsers()
{ {
global $DB, $YEAR; global $DB, $YEAR;
$orphans = []; $orphans = [];
$req = $DB->query("SELECT * FROM `users` WHERE `role` != 'ADMIN' AND `team_id` IS NULL AND `year` = $YEAR ORDER BY `role`, `inscription_date`;"); $req = $DB->query("SELECT * FROM `users` WHERE `role` != 'ADMIN' AND `team_id` IS NULL "
. "AND NOT EXISTS (SELECT 1 FROM `teams` WHERE `encadrant` = `users`.`id`) "
. "AND `year` = $YEAR ORDER BY `role`, `inscription_date`;");
while (($data = $req->fetch()) !== false) { while (($data = $req->fetch()) !== false) {
$orphan = new User(); $orphan = new User();

View File

@ -0,0 +1,9 @@
<?php
if (!isset($_SESSION["user_id"]) || $_SESSION["role"] != Role::ADMIN)
require_once "server_files/403.php";
$orphans = isset($_GET["orphans"]);
$users = $orphans ? User::getOrphanUsers() : User::getAllUsers();
require_once "server_files/views/profiles.php";

View File

@ -1,8 +0,0 @@
<?php
if (!isset($_SESSION["user_id"]) || $_SESSION["role"] != Role::ADMIN)
require_once "server_files/403.php";
$orphan_users = User::getOrphanUsers();
require_once "server_files/views/profils_orphelins.php";

View File

@ -94,6 +94,7 @@
<li class="nav-item active"><a class="nav-link" href="/probleme/4">Problème 4</a></li> <li class="nav-item active"><a class="nav-link" href="/probleme/4">Problème 4</a></li>
<li class="nav-item active"><a class="nav-link" href="/probleme/0">Équipes sans problème</a></li> <li class="nav-item active"><a class="nav-link" href="/probleme/0">Équipes sans problème</a></li>
<li class="nav-item active"><a class="nav-link" href="/profils-orphelins">Profils orphelins</a></li> <li class="nav-item active"><a class="nav-link" href="/profils-orphelins">Profils orphelins</a></li>
<li class="nav-item active"><a class="nav-link" href="/profils">Tous les profils</a></li>
<li class="nav-item active"><a class="nav-link" href="/admins">Administrateurs</a></li> <li class="nav-item active"><a class="nav-link" href="/admins">Administrateurs</a></li>
</ul> </ul>
</li> </li>

View File

@ -3,11 +3,11 @@ require_once "header.php";
?> ?>
<div class="mt-4 mb-4"> <div class="mt-4 mb-4">
<h2 class="display-3">Profils orphelins</h2> <h2 class="display-3"><?= $orphans ? "Profils orphelins" : "Tous les profils" ?></h2>
</div> </div>
<div> <div>
Cette page recense tous les utilisateurs inscrits mais qui n'ont pas rejoint d'équipe. Cette page recense tous les utilisateurs inscrits<?= $orphans ? " mais qui n'ont pas rejoint d'équipe" : "" ?>.
</div> </div>
<br /> <br />
@ -29,7 +29,7 @@ require_once "header.php";
<tbody> <tbody>
<?php <?php
/** @var User $user */ /** @var User $user */
foreach ($orphan_users as $user) { foreach ($users as $user) {
?> ?>
<tr> <tr>
<th scope="row"> <th scope="row">