diff --git a/dispatcher.php b/dispatcher.php index 3422fb8..f1bdade 100644 --- a/dispatcher.php +++ b/dispatcher.php @@ -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/([A-Z]{3})$"] = ["server_files/controllers/poser_questions.php", "trigram"]; $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["^repondre-questions-3$"] = ["server_files/controllers/repondre_questions.php"]; $ROUTES["^repondre-questions-3/([A-Z]{3})$"] = ["server_files/controllers/repondre_questions.php"]; diff --git a/server_files/classes/User.php b/server_files/classes/User.php index 36b37e8..2aa8382 100644 --- a/server_files/classes/User.php +++ b/server_files/classes/User.php @@ -67,11 +67,28 @@ class User 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() { global $DB, $YEAR; $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) { $orphan = new User(); diff --git a/server_files/controllers/profiles.php b/server_files/controllers/profiles.php new file mode 100644 index 0000000..cf4d789 --- /dev/null +++ b/server_files/controllers/profiles.php @@ -0,0 +1,9 @@ +Problème 4 + diff --git a/server_files/views/profils_orphelins.php b/server_files/views/profiles.php similarity index 77% rename from server_files/views/profils_orphelins.php rename to server_files/views/profiles.php index 14baad5..cc8f2e6 100644 --- a/server_files/views/profils_orphelins.php +++ b/server_files/views/profiles.php @@ -3,11 +3,11 @@ require_once "header.php"; ?>
-

Profils orphelins

+

- Cette page recense tous les utilisateurs inscrits mais qui n'ont pas rejoint d'équipe. + Cette page recense tous les utilisateurs inscrits.

@@ -29,7 +29,7 @@ require_once "header.php";