diff --git a/controllers/internals/Command.php b/controllers/internals/Command.php index 4cc00ab..e66b853 100755 --- a/controllers/internals/Command.php +++ b/controllers/internals/Command.php @@ -21,7 +21,7 @@ namespace controllers\internals; */ protected function get_model () : \descartes\Model { - $this->model = $this->model ?? new \models\Command($this->$bdd); + $this->model = $this->model ?? new \models\Command($this->bdd); return $this->model; } diff --git a/controllers/internals/Contact.php b/controllers/internals/Contact.php index ac68876..35264ad 100755 --- a/controllers/internals/Contact.php +++ b/controllers/internals/Contact.php @@ -21,7 +21,7 @@ namespace controllers\internals; */ protected function get_model () : \descartes\Model { - $this->model = $this->model ?? new \models\Contact($this->$bdd); + $this->model = $this->model ?? new \models\Contact($this->bdd); return $this->model; } diff --git a/controllers/internals/Event.php b/controllers/internals/Event.php index e868811..eb7a412 100755 --- a/controllers/internals/Event.php +++ b/controllers/internals/Event.php @@ -21,7 +21,7 @@ namespace controllers\internals; */ protected function get_model () : \descartes\Model { - $this->model = $this->model ?? new \models\Event($this->$bdd); + $this->model = $this->model ?? new \models\Event($this->bdd); return $this->model; } @@ -40,7 +40,7 @@ namespace controllers\internals; */ public function get_lasts_by_date_for_user (int $id_user, int $nb_entry) { - return $this->get_lasts_by_date_for_user($id_user, $nb_entry); + return $this->get_model()->get_lasts_by_date_for_user($id_user, $nb_entry); } @@ -59,6 +59,6 @@ namespace controllers\internals; 'text' => $text, ]; - return $this->model_event->insert($event); + return $this->get_model()->insert($event); } } diff --git a/controllers/internals/Group.php b/controllers/internals/Group.php index f528384..ab715a9 100755 --- a/controllers/internals/Group.php +++ b/controllers/internals/Group.php @@ -24,7 +24,7 @@ namespace controllers\internals; */ protected function get_model () : \descartes\Model { - $this->model = $this->model ?? new \models\Event($this->$bdd); + $this->model = $this->model ?? new \models\Event($this->bdd); return $this->model; } diff --git a/controllers/internals/Phone.php b/controllers/internals/Phone.php index e371c70..59b676c 100755 --- a/controllers/internals/Phone.php +++ b/controllers/internals/Phone.php @@ -21,7 +21,7 @@ namespace controllers\internals; */ protected function get_model () : \descartes\Model { - $this->model = $this->model ?? new \models\Phone($this->$bdd); + $this->model = $this->model ?? new \models\Phone($this->bdd); return $this->model; } diff --git a/controllers/internals/Received.php b/controllers/internals/Received.php index ffa3231..dff3ee9 100755 --- a/controllers/internals/Received.php +++ b/controllers/internals/Received.php @@ -21,7 +21,7 @@ namespace controllers\internals; */ protected function get_model () : \descartes\Model { - $this->model = $this->model ?? new \models\Received($this->$bdd); + $this->model = $this->model ?? new \models\Received($this->bdd); return $this->model; } @@ -105,7 +105,15 @@ namespace controllers\internals; */ public function count_by_day_since_for_user(int $id_user, $date) { - return $this->get_model()->count_by_day_since_for_user($id_user, $date); + $counts_by_day = $this->get_model()->count_by_day_since_for_user($id_user, $date); + $return = []; + + foreach ($counts_by_day as $count_by_day) + { + $return[$count_by_day['at_ymd']] = $count_by_day['nb']; + } + + return $return; } @@ -122,8 +130,8 @@ namespace controllers\internals; /** * Get SMS received since a date for a user - * @param $date : La date depuis laquelle on veux les SMS (au format 2014-10-25 20:10:05) * @param int $id_user : User id + * @param $date : La date depuis laquelle on veux les SMS (au format 2014-10-25 20:10:05) * @return array : Tableau avec tous les SMS depuis la date */ public function get_since_by_date_for_user(int $id_user, $date) diff --git a/controllers/internals/Scheduled.php b/controllers/internals/Scheduled.php index eb891d2..2949641 100755 --- a/controllers/internals/Scheduled.php +++ b/controllers/internals/Scheduled.php @@ -21,7 +21,7 @@ namespace controllers\internals; */ protected function get_model () : \descartes\Model { - $this->model = $this->model ?? new \models\Scheduled($this->$bdd); + $this->model = $this->model ?? new \models\Scheduled($this->bdd); return $this->model; } diff --git a/controllers/internals/Sended.php b/controllers/internals/Sended.php index ae5cb98..5253c4a 100755 --- a/controllers/internals/Sended.php +++ b/controllers/internals/Sended.php @@ -21,7 +21,7 @@ namespace controllers\internals; */ protected function get_model () : \descartes\Model { - $this->model = $this->model ?? new \models\Sended($this->$bdd); + $this->model = $this->model ?? new \models\Sended($this->bdd); return $this->model; } @@ -126,6 +126,14 @@ namespace controllers\internals; */ public function count_by_day_since_for_user(int $id_user, $date) { - return $this->get_model()->count_by_day_since_for_user($id_user, $date); + $counts_by_day = $this->get_model()->count_by_day_since_for_user($id_user, $date); + $return = []; + + foreach ($counts_by_day as $count_by_day) + { + $return[$count_by_day['at_ymd']] = $count_by_day['nb']; + } + + return $return; } } diff --git a/controllers/internals/SmsStop.php b/controllers/internals/SmsStop.php index 9b80402..e59cf02 100755 --- a/controllers/internals/SmsStop.php +++ b/controllers/internals/SmsStop.php @@ -21,7 +21,7 @@ namespace controllers\internals; */ protected function get_model () : \descartes\Model { - $this->model = $this->model ?? new \models\SmsStop($this->$bdd); + $this->model = $this->model ?? new \models\SmsStop($this->bdd); return $this->model; } diff --git a/controllers/publics/Account.php b/controllers/publics/Account.php index 5ff7442..9c6808e 100755 --- a/controllers/publics/Account.php +++ b/controllers/publics/Account.php @@ -182,7 +182,7 @@ namespace controllers\publics; return $this->redirect(\descartes\Router::url('Account', 'show')); } - $delete_account_result = $this->internal_user->delete($_SESSION['user']['id']); + $delete_account_result = $this->internal_user->delete_for_user($_SESSION['user']['id'], $_SESSION['user']['id']); if (!$delete_account_result) { \FlashMessage\FlashMessage::push('danger', 'Impossible de supprimer le compte.'); diff --git a/controllers/publics/Command.php b/controllers/publics/Command.php index e00ef63..7b0f3e8 100755 --- a/controllers/publics/Command.php +++ b/controllers/publics/Command.php @@ -37,7 +37,7 @@ namespace controllers\publics; public function list($page = 0) { $page = (int) $page; - $commands = $this->internal_command->list(25, $page); + $commands = $this->internal_command->list_for_user($_SESSION['user']['id'], 25, $page); $this->render('command/list', ['commands' => $commands]); } @@ -62,7 +62,7 @@ namespace controllers\publics; $ids = $_GET['ids'] ?? []; foreach ($ids as $id) { - $this->internal_command->delete($id); + $this->internal_command->delete_for_user($_SESSION['user']['id'], $id); } return $this->redirect(\descartes\Router::url('Command', 'list')); @@ -85,7 +85,7 @@ namespace controllers\publics; { $ids = $_GET['ids'] ?? []; - $commands = $this->internal_command->gets($ids); + $commands = $this->internal_command->gets_in_for_user($_SESSION['user']['id'], $ids); $this->render('command/edit', [ 'commands' => $commands, @@ -122,7 +122,7 @@ namespace controllers\publics; return $this->redirect(\descartes\Router::url('Command', 'list')); } - if (!$this->internal_command->create($name, $script, $admin)) + if (!$this->internal_command->create($_SESSION['user']['id'], $name, $script, $admin)) { \FlashMessage\FlashMessage::push('danger', 'Impossible de créer cette commande.'); @@ -154,7 +154,7 @@ namespace controllers\publics; $nb_commands_update = 0; foreach ($_POST['commands'] as $command) { - $update_command = $this->internal_command->update($command['id'], $command['name'], $command['script'], $command['admin']); + $update_command = $this->internal_command->update_for_user($_SESSION['user']['id'], $command['id'], $command['name'], $command['script'], $command['admin']); $nb_commands_update += (int) $update_command; } diff --git a/controllers/publics/Contact.php b/controllers/publics/Contact.php index 999c6a6..7d5d060 100755 --- a/controllers/publics/Contact.php +++ b/controllers/publics/Contact.php @@ -43,7 +43,7 @@ namespace controllers\publics; public function list($page = 0) { $page = (int) $page; - $contacts = $this->internal_contact->list($_SESSION['user']['id'], 25, $page); + $contacts = $this->internal_contact->list_for_user($_SESSION['user']['id'], 25, $page); return $this->render('contact/list', ['contacts' => $contacts]); } @@ -79,7 +79,7 @@ namespace controllers\publics; continue; } - $this->internal_contact->delete($id); + $this->internal_contact->delete_for_user($_SESSION['user']['id'], $id); } return $this->redirect(\descartes\Router::url('Contact', 'list')); @@ -144,7 +144,7 @@ namespace controllers\publics; return $this->redirect(\descartes\Router::url('Contact', 'add')); } - if (!$this->internal_contact->create($id_user, $number, $name)) + if (!$this->internal_contact->create($_SESSION['user']['id'], $id_user, $number, $name)) { \FlashMessage\FlashMessage::push('danger', 'Impossible de créer ce contact.'); @@ -188,7 +188,7 @@ namespace controllers\publics; continue; } - $nb_contacts_update += $this->internal_contact->update($contact['id'], $_SESSION['user']['id'], $contact['number'], $contact['name']); + $nb_contacts_update += $this->internal_contact->update_for_user($_SESSION['user']['id'], $contact['id'], $_SESSION['user']['id'], $contact['number'], $contact['name']); } if ($nb_contacts_update !== \count($_POST['contacts'])) @@ -209,6 +209,6 @@ namespace controllers\publics; public function json_list() { header('Content-Type: application/json'); - echo json_encode($this->internal_contact->list($_SESSION['user']['id'])); + echo json_encode($this->internal_contact->list_for_user($_SESSION['user']['id'])); } } diff --git a/controllers/publics/Dashboard.php b/controllers/publics/Dashboard.php index 624b2ad..bbb818c 100755 --- a/controllers/publics/Dashboard.php +++ b/controllers/publics/Dashboard.php @@ -55,12 +55,12 @@ namespace controllers\publics; $id_user = $_SESSION['user']['id']; //Recupération des nombres des 4 panneaux d'accueil - $nb_contacts = $this->internal_contact->count($id_user); - $nb_groups = $this->internal_group->count($id_user); - $nb_scheduleds = $this->internal_scheduled->count($id_user); - $nb_commands = $this->internal_command->count($id_user); - $nb_sendeds = $this->internal_sended->count($id_user); - $nb_receiveds = $this->internal_received->count($id_user); + $nb_contacts = $this->internal_contact->count_for_user($id_user); + $nb_groups = $this->internal_group->count_for_user($id_user); + $nb_scheduleds = $this->internal_scheduled->count_for_user($id_user); + $nb_commands = $this->internal_command->count_for_user($id_user); + $nb_sendeds = $this->internal_sended->count_for_user($id_user); + $nb_receiveds = $this->internal_received->count_for_user($id_user); //Création de la date d'il y a une semaine $now = new \DateTime(); @@ -69,13 +69,13 @@ namespace controllers\publics; $formated_date = $date->format('Y-m-d'); //Récupération des 10 derniers Sms envoyés, Sms reçus et evenements enregistrés. Par date. - $sendeds = $this->internal_sended->get_lasts_by_date(10); - $receiveds = $this->internal_received->get_lasts_for_user_by_date($id_user, 10); - $events = $this->internal_event->get_lasts_by_date(10); + $sendeds = $this->internal_sended->get_lasts_by_date_for_user($id_user, 10); + $receiveds = $this->internal_received->get_lasts_by_date_for_user($id_user, 10); + $events = $this->internal_event->get_lasts_by_date_for_user($id_user, 10); //Récupération du nombre de Sms envoyés et reçus depuis les 7 derniers jours - $nb_sendeds_by_day = $this->internal_sended->count_by_day_since($formated_date); - $nb_receiveds_by_day = $this->internal_received->count_for_user_by_day_since($id_user, $formated_date); + $nb_sendeds_by_day = $this->internal_sended->count_by_day_since_for_user($id_user, $formated_date); + $nb_receiveds_by_day = $this->internal_received->count_by_day_since_for_user($id_user, $formated_date); //On va traduire ces données pour les afficher en graphique $array_area_chart = []; diff --git a/controllers/publics/Discussion.php b/controllers/publics/Discussion.php index 62bf2e3..791a38d 100755 --- a/controllers/publics/Discussion.php +++ b/controllers/publics/Discussion.php @@ -176,7 +176,7 @@ namespace controllers\publics; return false; } - if (!$this->internal_scheduled->create($id_user, $at, $text, false, false, $numbers)) + if (!$this->internal_scheduled->create($_SESSION['user']['id'], $id_user, $at, $text, false, false, $numbers)) { $return['success'] = false; $return['message'] = 'Impossible de créer le Sms'; @@ -199,7 +199,7 @@ namespace controllers\publics; { $_SESSION['discussion_wait_progress'] = isset($_SESSION['discussion_wait_progress']) ? $_SESSION['discussion_wait_progress'] : []; - $scheduleds = $this->internal_scheduled->gets($_SESSION['discussion_wait_progress']); + $scheduleds = $this->internal_scheduled->gets_in_for_user($_SESSION['user']['id'], $_SESSION['discussion_wait_progress']); //On va chercher à chaque fois si on a trouvé le sms. Si ce n'est pas le cas c'est qu'il a été envoyé $sendeds = []; diff --git a/controllers/publics/Event.php b/controllers/publics/Event.php index 01f4c45..fcd862c 100755 --- a/controllers/publics/Event.php +++ b/controllers/publics/Event.php @@ -42,7 +42,7 @@ namespace controllers\publics; { $page = (int) $page; $limit = 25; - $events = $this->internal_event->list($limit, $page); + $events = $this->internal_event->list_for_user($_SESSION['user']['id']$limit, $page); $this->render('event/list', ['events' => $events, 'limit' => $limit, 'page' => $page, 'nb_results' => \count($events)]); } @@ -73,7 +73,7 @@ namespace controllers\publics; $ids = $_GET['ids'] ?? []; foreach ($ids as $id) { - $this->internal_event->delete($id); + $this->internal_event->delete_for_user($_SESSION['user']['id'], $id); } return $this->redirect(\descartes\Router::url('Event', 'list')); diff --git a/controllers/publics/Group.php b/controllers/publics/Group.php index 51ae843..c47f012 100755 --- a/controllers/publics/Group.php +++ b/controllers/publics/Group.php @@ -45,7 +45,7 @@ namespace controllers\publics; public function list($page = 0) { $page = (int) $page; - $groups = $this->internal_group->list(25, $page); + $groups = $this->internal_group->list_for_user($_SESSION['user']['id'], 25, $page); foreach ($groups as $key => $group) { @@ -74,7 +74,7 @@ namespace controllers\publics; } $ids = $_GET['ids'] ?? []; - $this->internal_group->delete($ids); + $this->internal_group->delete_for_user($_SESSION['user']['id'], $ids); return $this->redirect(\descartes\Router::url('Group', 'list')); } @@ -96,7 +96,7 @@ namespace controllers\publics; { $ids = $_GET['ids'] ?? []; - $groups = $this->internal_group->gets($ids); + $groups = $this->internal_group->gets_in_for_user($_SESSION['user']['id'], $ids); foreach ($groups as $key => $group) { @@ -134,7 +134,7 @@ namespace controllers\publics; return $this->redirect(\descartes\Router::url('Group', 'add')); } - $id_group = $this->internal_group->create($name, $contacts_ids); + $id_group = $this->internal_group->create($_SESSION['user']['id'], $name, $contacts_ids); if (!$id_group) { \FlashMessage\FlashMessage::push('danger', 'Impossible de créer ce groupe.'); @@ -169,7 +169,7 @@ namespace controllers\publics; $nb_groups_update = 0; foreach ($groups as $id => $group) { - $nb_groups_update += (int) $this->internal_group->update($id, $group['name'], $group['contacts_ids']); + $nb_groups_update += (int) $this->internal_group->update_for_user($_SESSION['user']['id'], $id, $group['name'], $group['contacts_ids']); } if ($nb_groups_update !== \count($groups)) @@ -190,6 +190,6 @@ namespace controllers\publics; public function json_list() { header('Content-Type: application/json'); - echo json_encode($this->internal_group->list()); + echo json_encode($this->internal_group->list_for_user($_SESSION['user']['id'])); } } diff --git a/controllers/publics/Phone.php b/controllers/publics/Phone.php index dfb2fef..c30bdff 100755 --- a/controllers/publics/Phone.php +++ b/controllers/publics/Phone.php @@ -37,7 +37,7 @@ class Phone extends \descartes\Controller { $id_user = $_SESSION['user']['id']; $page = (int) $page; - $phones = $this->internal_phone->list($id_user, 25, $page); + $phones = $this->internal_phone->list_for_user($_SESSION['user']['id']$id_user, 25, $page); $adapters = []; $adapters_metas = $this->internal_adapter->list_adapters(); @@ -81,7 +81,7 @@ class Phone extends \descartes\Controller $ids = $_GET['ids'] ?? []; foreach ($ids as $id) { - $this->internal_phone->delete($id); + $this->internal_phone->delete_for_user($_SESSION['user']['id'], $id); } return $this->redirect(\descartes\Router::url('Phone', 'list')); @@ -163,7 +163,7 @@ class Phone extends \descartes\Controller } - $success = $this->internal_phone->create($id_user, $number, $adapter, $adapter_datas); + $success = $this->internal_phone->create($_SESSION['user']['id'], $id_user, $number, $adapter, $adapter_datas); if (!$success) { \FlashMessage\FlashMessage::push('danger', 'Impossible de créer ce téléphone.'); diff --git a/controllers/publics/Received.php b/controllers/publics/Received.php index c2d957e..bbbada6 100755 --- a/controllers/publics/Received.php +++ b/controllers/publics/Received.php @@ -45,7 +45,7 @@ namespace controllers\publics; { $page = (int) $page; $limit = 25; - $receiveds = $this->internal_received->list($_SESSION['user']['id'], $limit, $page); + $receiveds = $this->internal_received->list_for_user($_SESSION['user']['id'], $limit, $page); foreach ($receiveds as $key => $received) { @@ -91,7 +91,7 @@ namespace controllers\publics; continue; } - $this->internal_received->delete($id); + $this->internal_received->delete_for_user($_SESSION['user']['id'], $id); } return $this->redirect(\descartes\Router::url('Received', 'list')); @@ -105,7 +105,7 @@ namespace controllers\publics; public function popup() { $now = new \DateTime(); - $receiveds = $this->internal_received->get_since_by_date_for_user($now->format('Y-m-d'), $_SESSION['user']['id']); + $receiveds = $this->internal_received->get_since_by_date_for_user($_SESSION['user']['id'], $now->format('Y-m-d')); foreach ($receiveds as $key => $received) { diff --git a/controllers/publics/Scheduled.php b/controllers/publics/Scheduled.php index 8bab24c..3dc8f0f 100755 --- a/controllers/publics/Scheduled.php +++ b/controllers/publics/Scheduled.php @@ -42,7 +42,7 @@ namespace controllers\publics; public function list($page = 0) { $page = (int) $page; - $scheduleds = $this->internal_scheduled->list($_SESSION['user']['id'], 25, $page); + $scheduleds = $this->internal_scheduled->list_for_user($_SESSION['user']['id'], 25, $page); $this->render('scheduled/list', ['scheduleds' => $scheduleds]); } @@ -72,7 +72,7 @@ namespace controllers\publics; continue; } - $this->internal_scheduled->delete($id); + $this->internal_scheduled->delete_for_user($_SESSION['user']['id'], $id); } return $this->redirect(\descartes\Router::url('Scheduled', 'list')); @@ -111,7 +111,7 @@ namespace controllers\publics; } $phones = $this->internal_phone->gets_for_user($_SESSION['user']['id']); - $scheduleds = $this->internal_scheduled->gets($ids); + $scheduleds = $this->internal_scheduled->gets_in_for_user($_SESSION['user']['id'], $ids); //Pour chaque message on ajoute les numéros, les contacts & les groups foreach ($scheduleds as $key => $scheduled) @@ -220,7 +220,7 @@ namespace controllers\publics; } - $scheduled_id = $this->internal_scheduled->create($id_user, $at, $text, $origin, $flash, $numbers, $contacts, $groups); + $scheduled_id = $this->internal_scheduled->create($_SESSION['user']['id'], $id_user, $at, $text, $origin, $flash, $numbers, $contacts, $groups); if (!$scheduled_id) { \FlashMessage\FlashMessage::push('danger', 'Impossible de créer le Sms.'); @@ -313,7 +313,7 @@ namespace controllers\publics; return $this->redirect(\descartes\Router::url('Scheduled', 'add')); } - $success = $this->internal_scheduled->update($id_scheduled, $id_user, $at, $text, $origin, $flash, $numbers, $contacts, $groups); + $success = $this->internal_scheduled->update_for_user($_SESSION['user']['id'], $id_scheduled, $id_user, $at, $text, $origin, $flash, $numbers, $contacts, $groups); if (!$success) { $all_update_ok = false; diff --git a/controllers/publics/Sended.php b/controllers/publics/Sended.php index bdb2757..46217e7 100755 --- a/controllers/publics/Sended.php +++ b/controllers/publics/Sended.php @@ -43,7 +43,7 @@ namespace controllers\publics; { $page = (int) $page; $limit = 25; - $sendeds = $this->internal_sended->list($_SESSION['user']['id'], $limit, $page); + $sendeds = $this->internal_sended->list_for_user($_SESSION['user']['id'], $limit, $page); $this->render('sended/list', ['sendeds' => $sendeds, 'page' => $page, 'limit' => $limit, 'nb_results' => \count($sendeds)]); } @@ -79,7 +79,7 @@ namespace controllers\publics; continue; } - $this->internal_sended->delete($id); + $this->internal_sended->delete_for_user($_SESSION['user']['id'], $id); } return $this->redirect(\descartes\Router::url('Sended', 'list')); diff --git a/controllers/publics/Setting.php b/controllers/publics/Setting.php index b82a1d5..4a6f62f 100755 --- a/controllers/publics/Setting.php +++ b/controllers/publics/Setting.php @@ -60,7 +60,7 @@ namespace controllers\publics; return $this->redirect(\descartes\Router::url('Setting', 'show')); } - $update_setting_result = $this->internal_setting->update($_SESSION['user']['id'], $setting_name, $setting_value); + $update_setting_result = $this->internal_setting->update_for_user($_SESSION['user']['id'], $_SESSION['user']['id'], $setting_name, $setting_value); if (false === $update_setting_result) { \FlashMessage\FlashMessage::push('danger', 'Impossible de mettre à jour ce réglage.'); diff --git a/controllers/publics/SmsStop.php b/controllers/publics/SmsStop.php index 7183f72..f4fd062 100755 --- a/controllers/publics/SmsStop.php +++ b/controllers/publics/SmsStop.php @@ -41,7 +41,7 @@ namespace controllers\publics; { $page = (int) $page; $limit = 25; - $smsstops = $this->internal_sms_stop->list($limit, $page); + $smsstops = $this->internal_sms_stop->list_for_user($_SESSION['user']['id']$limit, $page); $this->render('smsstop/list', ['page' => $page, 'smsstops' => $smsstops, 'limit' => $limit, 'nb_results' => \count($smsstops)]); } @@ -72,7 +72,7 @@ namespace controllers\publics; $ids = $_GET['ids'] ?? []; foreach ($ids as $id) { - $this->internal_sms_stop->delete($id); + $this->internal_sms_stop->delete_for_user($_SESSION['user']['id'], $id); } return $this->redirect(\descartes\Router::url('SmsStop', 'list')); diff --git a/controllers/publics/User.php b/controllers/publics/User.php index 72d0d7c..750b7d6 100755 --- a/controllers/publics/User.php +++ b/controllers/publics/User.php @@ -40,7 +40,7 @@ class User extends \descartes\Controller public function list($page = 0) { $page = (int) $page; - $users = $this->internal_user->list(25, $page); + $users = $this->internal_user->list_for_user($_SESSION['user']['id'], 25, $page); $this->render('user/list', ['users' => $users]); } @@ -71,7 +71,7 @@ class User extends \descartes\Controller $ids = $_GET['ids'] ?? []; foreach ($ids as $id) { - $this->internal_user->delete($id); + $this->internal_user->delete_for_user($_SESSION['user']['id'], $id); } return $this->redirect(\descartes\Router::url('User', 'list')); @@ -122,7 +122,7 @@ class User extends \descartes\Controller return $this->redirect(\descartes\Router::url('User', 'add')); } - $user_id = $this->internal_user->create($email, $password, $admin); + $user_id = $this->internal_user->create($_SESSION['user']['id'], $email, $password, $admin); if (!$user_id) { \FlashMessage\FlashMessage::push('danger', 'Impossible de créer ce user.'); diff --git a/models/Received.php b/models/Received.php index f13dfe3..d058269 100755 --- a/models/Received.php +++ b/models/Received.php @@ -163,11 +163,11 @@ namespace models; //If try to update destination, also check it does belong to user if ($sets['set_destination'] ?? false) { - $query .= ' AND :set_destination IN (SELECT number FROM phone WHERE id_user = :id_user)' + $query .= ' AND :set_destination IN (SELECT number FROM phone WHERE id_user = :id_user)'; } $params['id'] = $id; - $params['id_user'] = $id_user; + $params['id_user'] = $id_user; return $this->_run_query($query, $params, self::ROWCOUNT); } @@ -336,7 +336,7 @@ namespace models; "; $params = [ - 'id_user' => $id_user + 'id_user' => $id_user, 'date' => $date, 'origin' => $origin, ]; diff --git a/models/Sended.php b/models/Sended.php index 0b44708..c6fa06a 100755 --- a/models/Sended.php +++ b/models/Sended.php @@ -163,11 +163,11 @@ namespace models; //If try to update origin, also check it does belong to user if ($sets['set_origin'] ?? false) { - $query .= ' AND :set_origin IN (SELECT number FROM phone WHERE id_user = :id_user)' + $query .= ' AND :set_origin IN (SELECT number FROM phone WHERE id_user = :id_user)'; } $params['id'] = $id; - $params['id_user'] = $id_user; + $params['id_user'] = $id_user; return $this->_run_query($query, $params, self::ROWCOUNT); } diff --git a/models/StandardModel.php b/models/StandardModel.php index 77a3286..f6d4827 100755 --- a/models/StandardModel.php +++ b/models/StandardModel.php @@ -100,7 +100,7 @@ namespace models; * @param int $id : Entry id * @return int : Number of removed rows */ - public function delete_for_user(int $id_user, $id) + public function delete_for_user(int $id_user, int $id) { return $this->_delete($this->get_table_name(), ['id_user' => $id_user, 'id' => $id]); } @@ -126,7 +126,7 @@ namespace models; * * @return int : number of modified rows */ - public function update_for_user(int $id_user, $id, $entry) + public function update_for_user(int $id_user, int $id, array $entry) { return $this->_update($this->get_table_name(), $entry, ['id_user' => $id_user, 'id' => $id]); } diff --git a/templates/dashboard/show.php b/templates/dashboard/show.php index e292ff8..51e5b6a 100755 --- a/templates/dashboard/show.php +++ b/templates/dashboard/show.php @@ -210,7 +210,7 @@
- Aucun évènement n'est encore survenus. + Aucun évènement n'est encore survenu.