diff --git a/controllers/commands.php b/controllers/commands.php index c05f64d..4d6206f 100755 --- a/controllers/commands.php +++ b/controllers/commands.php @@ -15,18 +15,9 @@ } /** - * Cette fonction est alias de showAll() + * Cette fonction retourne toutes les commandes, sous forme d'un tableau permettant l'administration de ces commandess */ public function byDefault() - { - $this->showAll(); - } - - /** - * Cette fonction retourne toutes les commandes, sous forme d'un tableau permettant l'administration de ces commandess - * @return void; - */ - public function showAll() { //Creation de l'object de base de données global $db; @@ -34,7 +25,7 @@ //Recupération des commandes $commands = $db->getFromTableWhere('commands'); - $this->render('commands', array( + $this->render('commands/default', array( 'commands' => $commands, )); @@ -67,7 +58,7 @@ */ public function add() { - $this->render('addCommand'); + $this->render('commands/add'); } /** @@ -79,7 +70,7 @@ global $db; $commands = $db->getCommandsIn($ids); - $this->render('editCommands', array( + $this->render('commands/edit', array( 'commands' => $commands, )); } diff --git a/controllers/connect.php b/controllers/connect.php index 12683e2..3660a50 100755 --- a/controllers/connect.php +++ b/controllers/connect.php @@ -5,20 +5,11 @@ class connect extends Controller { /** - * Cette fonction est alias de login() + * Cette fonction retourne la fenetre de connexion */ public function byDefault() { - $this->login(); - } - - /** - * Cette fonction retourne la fenetre de connexion - * @return void; - */ - public function login() - { - $this->render('login'); + $this->render('connect/login'); } /** diff --git a/controllers/contacts.php b/controllers/contacts.php index b0fa3ad..5800a7e 100755 --- a/controllers/contacts.php +++ b/controllers/contacts.php @@ -15,18 +15,9 @@ } /** - * Cette fonction est alias de showAll() + * Cette fonction retourne tous les contacts, sous forme d'un tableau permettant l'administration de ces contacts */ public function byDefault() - { - $this->showAll(); - } - - /** - * Cette fonction retourne tous les contacts, sous forme d'un tableau permettant l'administration de ces contacts - * @return void; - */ - public function showAll() { //Creation de l'object de base de données global $db; @@ -34,7 +25,7 @@ //Recupération des nombres des 4 panneaux d'accueil $contacts = $db->getFromTableWhere('contacts'); - $this->render('contacts', array( + $this->render('contacts/default', array( 'contacts' => $contacts, )); } @@ -51,7 +42,7 @@ if (!internalTools::verifyCSRF($csrf)) { $_SESSION['errormessage'] = 'Jeton CSRF invalide !'; - header('Location: ' . $this->generateUrl('contacts', 'showAll')); + header('Location: ' . $this->generateUrl('contacts')); return false; } @@ -68,7 +59,7 @@ */ public function add() { - $this->render('addContact'); + $this->render('contacts/add'); } /** @@ -80,7 +71,7 @@ global $db; $contacts = $db->getContactsIn($ids); - $this->render('editContacts', array( + $this->render('contacts/edit', array( 'contacts' => $contacts, )); } @@ -97,7 +88,7 @@ if (!internalTools::verifyCSRF($csrf)) { $_SESSION['errormessage'] = 'Jeton CSRF invalide !'; - header('Location: ' . $this->generateUrl('contacts', 'showAll')); + header('Location: ' . $this->generateUrl('contacts')); return false; } @@ -130,7 +121,7 @@ $db->insertIntoTable('events', ['type' => 'CONTACT_ADD', 'text' => 'Ajout contact : ' . $nom . ' (' . internalTools::phoneAddSpace($phone) . ')']); $_SESSION['successmessage'] = 'Le contact a bien été créé.'; - header('Location: ' . $this->generateUrl('contacts', 'showAll')); + header('Location: ' . $this->generateUrl('contacts')); return true; } @@ -146,7 +137,7 @@ if (!internalTools::verifyCSRF($csrf)) { $_SESSION['errormessage'] = 'Jeton CSRF invalide !'; - header('Location: ' . $this->generateUrl('contacts', 'showAll')); + header('Location: ' . $this->generateUrl('contacts')); } global $db; @@ -169,11 +160,11 @@ if (count($errors)) { $_SESSION['errormessage'] = 'Certains contacts n\'ont pas pu êtres mis à jour. Voici leurs identifiants : ' . implode(', ', $errors); - return header('Location: ' . $this->generateUrl('contacts', 'showAll')); + return header('Location: ' . $this->generateUrl('contacts')); } $_SESSION['successmessage'] = 'Tous les contacts ont été modifiés avec succès.'; - return header('Location: ' . $this->generateUrl('contacts', 'showAll')); + return header('Location: ' . $this->generateUrl('contacts')); } /** diff --git a/controllers/dashboard.php b/controllers/dashboard.php index ff63559..475d6c0 100755 --- a/controllers/dashboard.php +++ b/controllers/dashboard.php @@ -19,11 +19,6 @@ * @return void; */ public function byDefault() - { - $this->show(); - } - - public function show() { //Creation de l'object de base de données global $db; @@ -97,7 +92,7 @@ $array_area_chart = array_values($array_area_chart); - $this->render('dashboard', array( + $this->render('dashboard/default', array( 'nb_contacts' => $nb_contacts, 'nb_groups' => $nb_groups, 'nb_scheduleds' => $nb_scheduleds, diff --git a/controllers/events.php b/controllers/events.php index 52aa869..8b4f431 100755 --- a/controllers/events.php +++ b/controllers/events.php @@ -39,7 +39,7 @@ //Récupération des évènements triés par date, du plus récent au plus ancien, par paquets de $limit, en ignorant les $offset premiers $events = $db->getFromTableWhere('events', [], 'at', true, $limit, $offset); - $this->render('events', array( + $this->render('events/default', array( 'events' => $events, 'page' => $page, 'limit' => $limit, diff --git a/controllers/groups.php b/controllers/groups.php index bcb7ecf..cfa24f5 100755 --- a/controllers/groups.php +++ b/controllers/groups.php @@ -15,24 +15,15 @@ } /** - * Cette fonction est alias de showAll() + * Cette fonction retourne tous les groupes, sous forme d'un tableau permettant l'administration de ces groupes */ public function byDefault() - { - $this->showAll(); - } - - /** - * Cette fonction retourne tous les groupes, sous forme d'un tableau permettant l'administration de ces groupes - * @return void; - */ - public function showAll() { //Creation de l'object de base de données global $db; $groups = $db->getGroupsWithContactsNb(); - $this->render('groups', array( + $this->render('groups/default', array( 'groups' => $groups, )); } @@ -49,7 +40,7 @@ if (!internalTools::verifyCSRF($csrf)) { $_SESSION['errormessage'] = 'Jeton CSRF invalide !'; - header('Location: ' . $this->generateUrl('groups', 'showAll')); + header('Location: ' . $this->generateUrl('groups')); return false; } @@ -66,7 +57,7 @@ */ public function add() { - $this->render('addGroup'); + $this->render('groups/add'); } /** @@ -86,7 +77,7 @@ $groups[$key]['contacts'] = $db->getContactsForGroup($group['id']); } - $this->render('editGroups', array( + $this->render('groups/edit', array( 'groups' => $groups, )); } @@ -103,7 +94,7 @@ if (!internalTools::verifyCSRF($csrf)) { $_SESSION['errormessage'] = 'Jeton CSRF invalide !'; - header('Location: ' . $this->generateUrl('groups', 'showAll')); + header('Location: ' . $this->generateUrl('groups')); return false; } @@ -113,7 +104,7 @@ if (!$db->insertIntoTable('groups', ['name' => $nom])) { $_SESSION['errormessage'] = 'Impossible de créer ce groupe.'; - header('Location: ' . $this->generateUrl('groups', 'showAll')); + header('Location: ' . $this->generateUrl('groups')); return false; } @@ -126,7 +117,7 @@ } $_SESSION['successmessage'] = 'Le groupe a bien été créé.'; - header('Location: ' . $this->generateUrl('groups', 'showAll')); + header('Location: ' . $this->generateUrl('groups')); return true; } @@ -142,7 +133,7 @@ if (!internalTools::verifyCSRF($csrf)) { $_SESSION['errormessage'] = 'Jeton CSRF invalide !'; - header('Location: ' . $this->generateUrl('groups', 'showAll')); + header('Location: ' . $this->generateUrl('groups')); return false; } @@ -160,7 +151,7 @@ } $_SESSION['successmessage'] = 'Tous les groupes ont été modifiés avec succès.'; - header('Location: ' . $this->generateUrl('groups', 'showAll')); + header('Location: ' . $this->generateUrl('groups')); } /** diff --git a/controllers/internalIncs.php b/controllers/internalIncs.php index f787b92..aa47c6f 100755 --- a/controllers/internalIncs.php +++ b/controllers/internalIncs.php @@ -25,7 +25,7 @@ unset($_SESSION['successmessage']); } - $this->render('head', array( + $this->render('internalIncs/head', array( 'title' => $title, 'author' => $author, 'error_message' => $error_message, @@ -41,7 +41,7 @@ public function nav($page = '') { $email = isset($_SESSION['email']) ? $_SESSION['email'] : 'Mon compte'; - $this->render('nav', array( + $this->render('internalIncs/nav', array( 'email' => $email, 'page' => $page, )); @@ -49,6 +49,6 @@ public function footer() { - $this->render('footer'); + $this->render('internalIncs/footer'); } } diff --git a/controllers/profile.php b/controllers/profile.php index 8ce3177..377c6ad 100755 --- a/controllers/profile.php +++ b/controllers/profile.php @@ -15,20 +15,11 @@ } /** - * Cette fonction est alias de show() + * Cette fonction retourne la fenetre du profile */ public function byDefault() { - $this->show(); - } - - /** - * Cette fonction retourne la fenetre du profile - * @return void; - */ - public function show() - { - $this->render('profile'); + $this->render('profile/default'); } /** diff --git a/controllers/receiveds.php b/controllers/receiveds.php index f3f1ce5..8a0b68b 100755 --- a/controllers/receiveds.php +++ b/controllers/receiveds.php @@ -40,7 +40,7 @@ //Récupération des SMS envoyés triés par date, du plus récent au plus ancien, par paquets de $limit, en ignorant les $offset premiers $receiveds = $db->getFromTableWhere('receiveds', [], 'at', true, $limit, $offset); - return $this->render('receiveds', array( + return $this->render('receiveds/showAll', array( 'receiveds' => $receiveds, 'page' => $page, 'limit' => $limit, diff --git a/controllers/scheduleds.php b/controllers/scheduleds.php index 4893dbd..dde189d 100755 --- a/controllers/scheduleds.php +++ b/controllers/scheduleds.php @@ -15,24 +15,15 @@ } /** - * Cette fonction est alias de showAll() + * Cette fonction retourne tous les sms programmés, sous forme d'un tableau permettant l'administration de ces sms */ public function byDefault() - { - $this->showAll(); - } - - /** - * Cette fonction retourne tous les sms programmés, sous forme d'un tableau permettant l'administration de ces sms - * @return void; - */ - public function showAll() { //Creation de l'object de base de données global $db; $scheduleds = $db->getFromTableWhere('scheduleds'); - $this->render('scheduleds', array( + $this->render('scheduleds/default', array( 'scheduleds' => $scheduleds, )); } @@ -49,7 +40,7 @@ if (!internalTools::verifyCSRF($csrf)) { $_SESSION['errormessage'] = 'Jeton CSRF invalide !'; - header('Location: ' . $this->generateUrl('profile', 'showAll')); + header('Location: ' . $this->generateUrl('profile')); return false; } @@ -70,7 +61,7 @@ $babyonemoretime = new DateInterval('PT1M'); //Haha, i'm so a funny guy $now->add($babyonemoretime); $now = $now->format('Y-m-d H:i'); - return $this->render('addScheduled', array( + return $this->render('scheduleds/add', array( 'now' => $now )); } @@ -95,7 +86,7 @@ $scheduleds[$key]['groups'] = $db->getGroupsForScheduled($scheduled['id']); } - $this->render('editScheduleds', array( + $this->render('scheduleds/edit', array( 'scheduleds' => $scheduleds, )); } @@ -119,7 +110,7 @@ if (!internalTools::verifyCSRF($csrf)) { $_SESSION['errormessage'] = 'Jeton CSRF invalide !'; - header('Location: ' . $this->generateUrl('profile', 'showAll')); + header('Location: ' . $this->generateUrl('profile')); return false; } } @@ -138,7 +129,7 @@ if (!$api) { $_SESSION['errormessage'] = 'Pas de texte pour ce SMS !'; - header('Location: ' . $this->generateUrl('scheduleds', 'showAll')); + header('Location: ' . $this->generateUrl('scheduleds')); } return false; } @@ -149,7 +140,7 @@ if (!$api) { $_SESSION['errormessage'] = 'Pas numéro, de contacts, ni de groupes définis pour envoyer ce SMS !'; - header('Location: ' . $this->generateUrl('scheduleds', 'showAll')); + header('Location: ' . $this->generateUrl('scheduleds')); } return false; } @@ -159,7 +150,7 @@ if (!$api) { $_SESSION['errormessage'] = 'La date renseignée est invalide.'; - header('Location: ' . $this->generateUrl('scheduleds', 'showAll')); + header('Location: ' . $this->generateUrl('scheduleds')); } return false; @@ -170,7 +161,7 @@ if (!$api) { $_SESSION['errormessage'] = 'Impossible de créer ce SMS.'; - header('Location: ' . $this->generateUrl('scheduleds', 'showAll')); + header('Location: ' . $this->generateUrl('scheduleds')); } return false; } @@ -214,7 +205,7 @@ if (!$api) { $_SESSION['errormessage'] = 'Le SMS a bien été créé, mais certains numéro ne sont pas valides.'; - header('Location: ' . $this->generateUrl('scheduleds', 'showAll')); + header('Location: ' . $this->generateUrl('scheduleds')); } return true; } @@ -222,7 +213,7 @@ if (!$api) { $_SESSION['successmessage'] = 'Le SMS a bien été créé.'; - header('Location: ' . $this->generateUrl('scheduleds', 'showAll')); + header('Location: ' . $this->generateUrl('scheduleds')); } return true; } @@ -238,7 +229,7 @@ if (!internalTools::verifyCSRF($csrf)) { $_SESSION['successmessage'] = 'Jeton CSRF invalide !'; - header('Location: ' . $this->generateUrl('scheduleds', 'showAll')); + header('Location: ' . $this->generateUrl('scheduleds')); return false; } @@ -252,7 +243,7 @@ if (!internalTools::validateDate($date, 'Y-m-d H:i')) { $_SESSION['errormessage'] = 'La date renseignée pour le SMS numéro ' . $scheduled['id'] . ' est invalide.'; - header('Location: ' . $this->generateUrl('scheduleds', 'showAll')); + header('Location: ' . $this->generateUrl('scheduleds')); return false; } @@ -299,13 +290,13 @@ if ($errors) { $_SESSION['errormessage'] = 'Tous les SMS ont été modifiés mais certaines données incorrects ont été ignorées.'; - header('Location: ' . $this->generateUrl('scheduleds', 'showAll')); + header('Location: ' . $this->generateUrl('scheduleds')); return false; } else { $_SESSION['successmessage'] = 'Tous les SMS ont été modifiés avec succès.'; - header('Location: ' . $this->generateUrl('scheduleds', 'showAll')); + header('Location: ' . $this->generateUrl('scheduleds')); return true; } } diff --git a/controllers/sendeds.php b/controllers/sendeds.php index 4010d85..68402eb 100755 --- a/controllers/sendeds.php +++ b/controllers/sendeds.php @@ -41,7 +41,7 @@ //Récupération des SMS envoyés triés par date, du plus récent au plus ancien, par paquets de $limit, en ignorant les $offset premiers $sendeds = $db->getFromTableWhere('sendeds', [], 'at', true, $limit, $offset); - $this->render('sendeds', array( + $this->render('sendeds/showAll', array( 'sendeds' => $sendeds, 'page' => $page, 'limit' => $limit, diff --git a/controllers/smsAPI.php b/controllers/smsAPI.php index 93bb296..3d8e3f7 100755 --- a/controllers/smsAPI.php +++ b/controllers/smsAPI.php @@ -11,14 +11,6 @@ const API_ERROR_MISSING_FIELD = 3; - /** - * Cette fonction est alias de showAll() - */ - public function byDefault() - { - $this->send(); - } - /** * Cette fonction permet d'envoyer un SMS, en passant simplement des arguments à l'URL (ou pas $_GET) * @param string text = Le contenu du SMS @@ -27,7 +19,7 @@ * @param mixed groups = Les noms des groupes auxquels envoyer les SMS. Soit un seul et il s'agit d'un string. Soit plusieurs, et il s'agit d'un tableau * @param optionnal string date = La date à laquelle doit être envoyé le SMS. Au format 'Y-m-d H:i'. Si non fourni, le SMS sera envoyé dans 2 minutes */ - public function send() + public function byDefault() { global $db; diff --git a/controllers/users.php b/controllers/users.php index 1210803..ac414f6 100755 --- a/controllers/users.php +++ b/controllers/users.php @@ -15,18 +15,9 @@ } /** - * Cette fonction est alias de showAll() + * Cette fonction retourne tous les utilisateurs, sous forme d'un tableau permettant l'administration de ces utilisateurs */ public function byDefault() - { - $this->showAll(); - } - - /** - * Cette fonction retourne tous les utilisateurs, sous forme d'un tableau permettant l'administration de ces utilisateurs - * @return void; - */ - public function showAll() { //Creation de l'object de base de données global $db; @@ -35,7 +26,7 @@ //Récupération des utilisateurs $users = $db->getFromTableWhere('users'); - $this->render('users', array( + $this->render('users/default', array( 'users' => $users, )); } @@ -45,7 +36,7 @@ */ public function add() { - $this->render('addUser'); + $this->render('users/add'); } /** @@ -117,7 +108,7 @@ $db->insertIntoTable('events', ['type' => 'USER_ADD', 'text' => 'Ajout de l\'utilisateur : ' . $email]); $_SESSION['successmessage'] = 'L\'utilisateur a bien été créé.'; - header('Location: ' . $this->generateUrl('users', 'showAll')); + header('Location: ' . $this->generateUrl('users')); return true; } @@ -133,7 +124,7 @@ if (!internalTools::verifyCSRF($csrf)) { $_SESSION['errormessage'] = 'Jeton CSRF invalide !'; - header('Location: ' . $this->generateUrl('users', 'showAll')); + header('Location: ' . $this->generateUrl('users')); return false; } @@ -144,7 +135,7 @@ if (!$_SESSION['admin']) { $_SESSION['errormessage'] = 'Vous devez être administrateur pour effectuer cette action.'; - header('Location: ' . $this->generateUrl('users', 'showAll')); + header('Location: ' . $this->generateUrl('users')); return false; } diff --git a/createDatabase.sql b/createDatabase.sql index 1ae9f01..381c048 100755 --- a/createDatabase.sql +++ b/createDatabase.sql @@ -37,14 +37,16 @@ CREATE TABLE contacts id INT NOT NULL AUTO_INCREMENT, name VARCHAR(100) NOT NULL, number VARCHAR(12) NOT NULL, - PRIMARY KEY (id) + PRIMARY KEY (id), + UNIQUE (name) ); CREATE TABLE groups ( id INT NOT NULL AUTO_INCREMENT, name VARCHAR(100) NOT NULL, - PRIMARY KEY (id) + PRIMARY KEY (id), + UNIQUE (name) ); CREATE TABLE groups_contacts diff --git a/mvc/404.php b/mvc/404.php new file mode 100644 index 0000000..e45a7d3 --- /dev/null +++ b/mvc/404.php @@ -0,0 +1 @@ +

404 Not Found

diff --git a/templates/addCommand.php b/templates/commands/add.php similarity index 100% rename from templates/addCommand.php rename to templates/commands/add.php diff --git a/templates/commands.php b/templates/commands/default.php similarity index 100% rename from templates/commands.php rename to templates/commands/default.php diff --git a/templates/editCommands.php b/templates/commands/edit.php similarity index 100% rename from templates/editCommands.php rename to templates/commands/edit.php diff --git a/templates/forgetPassword.php b/templates/connect/forgetPassword.php similarity index 100% rename from templates/forgetPassword.php rename to templates/connect/forgetPassword.php diff --git a/templates/login.php b/templates/connect/login.php similarity index 100% rename from templates/login.php rename to templates/connect/login.php diff --git a/templates/addContact.php b/templates/contacts/add.php similarity index 100% rename from templates/addContact.php rename to templates/contacts/add.php diff --git a/templates/contacts.php b/templates/contacts/default.php similarity index 100% rename from templates/contacts.php rename to templates/contacts/default.php diff --git a/templates/editContacts.php b/templates/contacts/edit.php similarity index 100% rename from templates/editContacts.php rename to templates/contacts/edit.php diff --git a/templates/dashboard.php b/templates/dashboard/default.php similarity index 100% rename from templates/dashboard.php rename to templates/dashboard/default.php diff --git a/templates/events.php b/templates/events/default.php similarity index 100% rename from templates/events.php rename to templates/events/default.php diff --git a/templates/addGroup.php b/templates/groups/add.php similarity index 100% rename from templates/addGroup.php rename to templates/groups/add.php diff --git a/templates/groups.php b/templates/groups/default.php similarity index 100% rename from templates/groups.php rename to templates/groups/default.php diff --git a/templates/editGroups.php b/templates/groups/edit.php similarity index 100% rename from templates/editGroups.php rename to templates/groups/edit.php diff --git a/templates/footer.php b/templates/internalIncs/footer.php similarity index 100% rename from templates/footer.php rename to templates/internalIncs/footer.php diff --git a/templates/head.php b/templates/internalIncs/head.php similarity index 100% rename from templates/head.php rename to templates/internalIncs/head.php diff --git a/templates/nav.php b/templates/internalIncs/nav.php similarity index 100% rename from templates/nav.php rename to templates/internalIncs/nav.php diff --git a/templates/profile.php b/templates/profile/default.php similarity index 100% rename from templates/profile.php rename to templates/profile/default.php diff --git a/templates/receiveds.php b/templates/receiveds/showAll.php similarity index 100% rename from templates/receiveds.php rename to templates/receiveds/showAll.php diff --git a/templates/addScheduled.php b/templates/scheduleds/add.php similarity index 100% rename from templates/addScheduled.php rename to templates/scheduleds/add.php diff --git a/templates/scheduleds.php b/templates/scheduleds/default.php similarity index 100% rename from templates/scheduleds.php rename to templates/scheduleds/default.php diff --git a/templates/editScheduleds.php b/templates/scheduleds/edit.php similarity index 100% rename from templates/editScheduleds.php rename to templates/scheduleds/edit.php diff --git a/templates/sendeds.php b/templates/sendeds/showAll.php similarity index 100% rename from templates/sendeds.php rename to templates/sendeds/showAll.php diff --git a/templates/addUser.php b/templates/users/add.php similarity index 100% rename from templates/addUser.php rename to templates/users/add.php diff --git a/templates/users.php b/templates/users/default.php similarity index 100% rename from templates/users.php rename to templates/users/default.php