Update all controllers to standard behavior
This commit is contained in:
parent
18c7cb019d
commit
ccfc69baca
|
@ -70,7 +70,8 @@ namespace controllers\internals;
|
|||
return $result;
|
||||
}
|
||||
|
||||
$this->internal_event->create($id_user, 'CONTACT_ADD', 'Ajout contact : '.$name.' ('.\controllers\internals\Tool::phone_format($number).')');
|
||||
$internal_event = new Event($this->bdd);
|
||||
$internal_event->create($id_user, 'CONTACT_ADD', 'Ajout contact : '.$name.' ('.\controllers\internals\Tool::phone_format($number).')');
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
|
|
@ -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\Group($this->bdd);
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
|
@ -43,23 +43,22 @@ namespace controllers\internals;
|
|||
'name' => $name,
|
||||
];
|
||||
|
||||
foreach ($contacts_ids as $key => $contact_id)
|
||||
{
|
||||
$contact = $this->get_model()->get_for_user($id_user, $contact_id);
|
||||
if (!$contact)
|
||||
{
|
||||
unset($contacts_ids[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$id_group = $this->get_model()->insert($group);
|
||||
if (!$id_group)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$internal_contact = new Contact($this->bdd);
|
||||
foreach ($contacts_ids as $contact_id)
|
||||
{
|
||||
$contact = $internal_contact->get_for_user($id_user, $contact_id);
|
||||
if (!$contact)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->get_model()->insert_group_contact_relation($id_group, $contact_id);
|
||||
}
|
||||
|
||||
|
@ -88,10 +87,11 @@ namespace controllers\internals;
|
|||
|
||||
$this->get_model()->delete_group_contact_relations($id_group);
|
||||
|
||||
$internal_contact = new Contact($this->bdd);
|
||||
$nb_contact_insert = 0;
|
||||
foreach ($contacts_ids as $contact_id)
|
||||
{
|
||||
$contact = $this->get_model()->get_for_user($id_user, $contact_id);
|
||||
$contact = $internal_contact->get_for_user($id_user, $contact_id);
|
||||
if (!$contact)
|
||||
{
|
||||
continue;
|
||||
|
|
|
@ -26,6 +26,17 @@ namespace controllers\internals;
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return all phones of a user.
|
||||
* @param int $id_user : user id
|
||||
* @return array
|
||||
*/
|
||||
public function gets_for_user (int $id_user)
|
||||
{
|
||||
return $this->get_model()->gets_for_user($id_user);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a phone by his number
|
||||
* @param string $number : Phone number
|
||||
|
|
|
@ -91,9 +91,9 @@ namespace controllers\internals;
|
|||
* @param string $origin : Number who sent the message
|
||||
* @return array
|
||||
*/
|
||||
public function gets_by_origin_for_user(int $id_user, string $origin)
|
||||
public function gets_by_origin_and_user(int $id_user, string $origin)
|
||||
{
|
||||
return $this->get_model()->gets_by_origin_for_user($id_user, $origin);
|
||||
return $this->get_model()->gets_by_origin_and_user($id_user, $origin);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -73,26 +73,28 @@ namespace controllers\internals;
|
|||
$this->get_model()->insert_scheduled_number($id_scheduled, $number);
|
||||
}
|
||||
|
||||
$internal_contact = new Contact($this->bdd);
|
||||
foreach ($contacts_ids as $contact_id)
|
||||
{
|
||||
$find_contact = $this->get_model()->get_for_user($id_user, $contact_id);
|
||||
$find_contact = $internal_contact->get_for_user($id_user, $contact_id);
|
||||
if (!$find_contact)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->get_model()->insert_scheduled_contact($id_scheduled, $contact_id);
|
||||
$this->get_model()->insert_scheduled_contact_relation($id_scheduled, $contact_id);
|
||||
}
|
||||
|
||||
$internal_group = new Group($this->bdd);
|
||||
foreach ($groups_ids as $group_id)
|
||||
{
|
||||
$find_group = $this->get_model()->get_for_user($id_user, $group_id);
|
||||
$find_group = $internal_group->get_for_user($id_user, $group_id);
|
||||
if (!$find_group)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->get_model()->insert_scheduled_group($id_scheduled, $group_id);
|
||||
$this->get_model()->insert_scheduled_group_relation($id_scheduled, $group_id);
|
||||
}
|
||||
|
||||
return $id_scheduled;
|
||||
|
@ -122,6 +124,7 @@ namespace controllers\internals;
|
|||
'flash' => $flash,
|
||||
];
|
||||
|
||||
|
||||
if ($origin)
|
||||
{
|
||||
$internal_phone = new Phone($this->bdd);
|
||||
|
@ -135,35 +138,37 @@ namespace controllers\internals;
|
|||
|
||||
$success = (bool) $this->get_model()->update_for_user($id_user, $id_scheduled, $scheduled);
|
||||
|
||||
$this->model_scheduled->delete_scheduled_numbers($id);
|
||||
$this->model_scheduled->delete_scheduled_contacts($id);
|
||||
$this->model_scheduled->delete_scheduled_groups($id);
|
||||
$this->get_model()->delete_scheduled_numbers($id_scheduled);
|
||||
$this->get_model()->delete_scheduled_contact_relations($id_scheduled);
|
||||
$this->get_model()->delete_scheduled_group_relations($id_scheduled);
|
||||
|
||||
foreach ($numbers as $number)
|
||||
{
|
||||
$this->get_model()->insert_scheduled_number($id_scheduled, $number);
|
||||
}
|
||||
|
||||
|
||||
$internal_contact = new Contact($this->bdd);
|
||||
foreach ($contacts_ids as $contact_id)
|
||||
{
|
||||
$find_contact = $this->get_model()->get_for_user($id_user, $contact_id);
|
||||
$find_contact = $internal_contact->get_for_user($id_user, $contact_id);
|
||||
if (!$find_contact)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->get_model()->insert_scheduled_contact($id_scheduled, $contact_id);
|
||||
$this->get_model()->insert_scheduled_contact_relation($id_scheduled, $contact_id);
|
||||
}
|
||||
|
||||
$internal_group = new Group($this->bdd);
|
||||
foreach ($groups_ids as $group_id)
|
||||
{
|
||||
$find_group = $this->get_model()->get_for_user($id_user, $group_id);
|
||||
$find_group = $internal_group->get_for_user($id_user, $group_id);
|
||||
if (!$find_group)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->get_model()->insert_scheduled_group($id_scheduled, $group_id);
|
||||
$this->get_model()->insert_scheduled_group_relation($id_scheduled, $group_id);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -177,9 +182,9 @@ namespace controllers\internals;
|
|||
* @param string $number : Number for which we want messages
|
||||
* @return array
|
||||
*/
|
||||
public function get_before_date_for_number_and_user (int $id_user, $date, string $number)
|
||||
public function gets_before_date_for_number_and_user (int $id_user, $date, string $number)
|
||||
{
|
||||
return $this->get_model()->get_before_date_for_number_and_user($id_user, $date, $number);
|
||||
return $this->get_model()->gets_before_date_for_number_and_user($id_user, $date, $number);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -112,9 +112,9 @@ namespace controllers\internals;
|
|||
* @param string $origin : Number who sent the message
|
||||
* @return array
|
||||
*/
|
||||
public function gets_by_destination_for_user(int $id_user, string $origin)
|
||||
public function gets_by_destination_and_user(int $id_user, string $origin)
|
||||
{
|
||||
return $this->get_model()->gets_by_destination_for_user($id_user, $origin);
|
||||
return $this->get_model()->gets_by_destination_and_user($id_user, $origin);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -34,6 +34,18 @@ namespace controllers\internals;
|
|||
{
|
||||
return $this->get_model()->get($id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a entry by his id and a user
|
||||
* @param int $id_user : Entry id
|
||||
* @param int $id : Entry id
|
||||
* @return array
|
||||
*/
|
||||
public function get_for_user (int $id_user, int $id)
|
||||
{
|
||||
return $this->get_model()->get_for_user($id_user, $id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -68,17 +68,6 @@ namespace controllers\publics;
|
|||
$ids = $_GET['ids'] ?? [];
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
$contact = $this->internal_contact->get($id);
|
||||
if (!$contact)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($contact['id_user'] !== $_SESSION['user']['id'])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->internal_contact->delete_for_user($_SESSION['user']['id'], $id);
|
||||
}
|
||||
|
||||
|
@ -101,8 +90,14 @@ namespace controllers\publics;
|
|||
public function edit()
|
||||
{
|
||||
$ids = $_GET['ids'] ?? [];
|
||||
$id_user = $_SESSION['user']['id'];
|
||||
|
||||
$contacts = $this->internal_contact->gets_for_user($ids, $id_user);
|
||||
$contacts = $this->internal_contact->gets_in_for_user($id_user, $ids);
|
||||
|
||||
if (!$contacts)
|
||||
{
|
||||
return $this->redirect(\descartes\Router::url('Contact', 'list'));
|
||||
}
|
||||
|
||||
$this->render('contact/edit', [
|
||||
'contacts' => $contacts,
|
||||
|
@ -144,7 +139,7 @@ namespace controllers\publics;
|
|||
return $this->redirect(\descartes\Router::url('Contact', 'add'));
|
||||
}
|
||||
|
||||
if (!$this->internal_contact->create($_SESSION['user']['id'], $id_user, $number, $name))
|
||||
if (!$this->internal_contact->create($id_user, $number, $name))
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'Impossible de créer ce contact.');
|
||||
|
||||
|
@ -174,21 +169,9 @@ namespace controllers\publics;
|
|||
}
|
||||
|
||||
$nb_contacts_update = 0;
|
||||
|
||||
foreach ($_POST['contacts'] as $contact)
|
||||
{
|
||||
$contact = $this->internal_contact->get($contact['id']);
|
||||
if (!$contact)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($contact['id_user'] !== $_SESSION['user']['id'])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$nb_contacts_update += $this->internal_contact->update_for_user($_SESSION['user']['id'], $contact['id'], $_SESSION['user']['id'], $contact['number'], $contact['name']);
|
||||
$nb_contacts_update += (int) $this->internal_contact->update_for_user($_SESSION['user']['id'], $contact['id'], $contact['number'], $contact['name']);
|
||||
}
|
||||
|
||||
if ($nb_contacts_update !== \count($_POST['contacts']))
|
||||
|
|
|
@ -73,6 +73,7 @@ namespace controllers\publics;
|
|||
$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_for_user($id_user, $formated_date);
|
||||
$nb_receiveds_by_day = $this->internal_received->count_by_day_since_for_user($id_user, $formated_date);
|
||||
|
|
|
@ -44,11 +44,11 @@ namespace controllers\publics;
|
|||
*/
|
||||
public function list()
|
||||
{
|
||||
$discussions = $this->internal_received->get_discussions();
|
||||
$discussions = $this->internal_received->get_discussions_for_user($_SESSION['user']['id']);
|
||||
|
||||
foreach ($discussions as $key => $discussion)
|
||||
{
|
||||
if (!$contact = $this->internal_contact->get_by_number($discussion['number']))
|
||||
if (!$contact = $this->internal_contact->get_by_number_and_user($_SESSION['user']['id'], $discussion['number']))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ namespace controllers\publics;
|
|||
*/
|
||||
public function show($number)
|
||||
{
|
||||
$contact = $this->internal_contact->get_by_number($number);
|
||||
$contact = $this->internal_contact->get_by_number_and_user($_SESSION['user']['id'], $number);
|
||||
|
||||
$this->render('discussion/show', [
|
||||
'number' => $number,
|
||||
|
@ -87,9 +87,11 @@ namespace controllers\publics;
|
|||
$now = new \DateTime();
|
||||
$now = $now->format('Y-m-d H:i:s');
|
||||
|
||||
$sendeds = $this->internal_sended->get_by_destination($number);
|
||||
$receiveds = $this->internal_received->get_by_origin($number);
|
||||
$scheduleds = $this->internal_scheduled->get_before_date_for_number($now, $number);
|
||||
$id_user = $_SESSION['user']['id'];
|
||||
|
||||
$sendeds = $this->internal_sended->gets_by_destination_and_user($id_user, $number);
|
||||
$receiveds = $this->internal_received->gets_by_origin_and_user($id_user, $number);
|
||||
$scheduleds = $this->internal_scheduled->gets_before_date_for_number_and_user($id_user, $now, $number);
|
||||
|
||||
$messages = [];
|
||||
|
||||
|
@ -99,7 +101,7 @@ namespace controllers\publics;
|
|||
'date' => htmlspecialchars($sended['at']),
|
||||
'text' => htmlspecialchars($sended['text']),
|
||||
'type' => 'sended',
|
||||
'status' => ($sended['delivered'] ? 'delivered' : ($sended['failed'] ? 'failed' : '')),
|
||||
'status' => $sended['status'],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -176,7 +178,7 @@ namespace controllers\publics;
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!$this->internal_scheduled->create($_SESSION['user']['id'], $id_user, $at, $text, false, false, $numbers))
|
||||
if (!$this->internal_scheduled->create($id_user, $at, $text, false, false, $numbers))
|
||||
{
|
||||
$return['success'] = false;
|
||||
$return['message'] = 'Impossible de créer le Sms';
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace controllers\publics;
|
|||
{
|
||||
$page = (int) $page;
|
||||
$limit = 25;
|
||||
$events = $this->internal_event->list_for_user($_SESSION['user']['id']$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)]);
|
||||
}
|
||||
|
||||
|
@ -63,13 +63,6 @@ namespace controllers\publics;
|
|||
return $this->redirect(\descartes\Router::url('Event', 'list'));
|
||||
}
|
||||
|
||||
if (!\controllers\internals\Tool::is_admin())
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'Vous devez être admin pour pouvoir supprimer des events.');
|
||||
|
||||
return $this->redirect(\descartes\Router::url('Event', 'list'));
|
||||
}
|
||||
|
||||
$ids = $_GET['ids'] ?? [];
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
|
|
|
@ -74,7 +74,10 @@ namespace controllers\publics;
|
|||
}
|
||||
|
||||
$ids = $_GET['ids'] ?? [];
|
||||
$this->internal_group->delete_for_user($_SESSION['user']['id'], $ids);
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
$this->internal_group->delete_for_user($_SESSION['user']['id'], $id);
|
||||
}
|
||||
|
||||
return $this->redirect(\descartes\Router::url('Group', 'list'));
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace controllers\publics;
|
|||
|
||||
foreach ($receiveds as $key => $received)
|
||||
{
|
||||
if (!$contact = $this->internal_contact->get_by_number($received['origin']))
|
||||
if (!$contact = $this->internal_contact->get_by_number_and_user($_SESSION['user']['id'], $received['origin']))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -78,19 +78,6 @@ namespace controllers\publics;
|
|||
$ids = $_GET['ids'] ?? [];
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
$received = $this->internal_received->get($id);
|
||||
|
||||
if (!$received)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$is_owner = (bool) $this->internal_phone->get_by_number_and_user($received['destination'], $_SESSION['user']['id']);
|
||||
if (!$is_owner)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->internal_received->delete_for_user($_SESSION['user']['id'], $id);
|
||||
}
|
||||
|
||||
|
@ -109,7 +96,7 @@ namespace controllers\publics;
|
|||
|
||||
foreach ($receiveds as $key => $received)
|
||||
{
|
||||
if (!$contact = $this->internal_contact->get_by_number($received['origin']))
|
||||
if (!$contact = $this->internal_contact->get_by_number_and_user($_SESSION['user']['id'], $received['origin']))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -213,14 +213,14 @@ namespace controllers\publics;
|
|||
}
|
||||
|
||||
|
||||
if ($origin && !$this->internal_phone->get_by_number_for_user($id_user, $origin))
|
||||
if ($origin && !$this->internal_phone->get_by_number_and_user($id_user, $origin))
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'Ce numéro n\'existe pas ou vous n\'en êtes pas propriétaire.');
|
||||
return $this->redirect(\descartes\Router::url('Scheduled', 'add'));
|
||||
}
|
||||
|
||||
|
||||
$scheduled_id = $this->internal_scheduled->create($_SESSION['user']['id'], $id_user, $at, $text, $origin, $flash, $numbers, $contacts, $groups);
|
||||
$scheduled_id = $this->internal_scheduled->create($id_user, $at, $text, $origin, $flash, $numbers, $contacts, $groups);
|
||||
if (!$scheduled_id)
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'Impossible de créer le Sms.');
|
||||
|
@ -307,13 +307,13 @@ namespace controllers\publics;
|
|||
}
|
||||
|
||||
|
||||
if ($origin && !$this->internal_phone->get_by_number_for_user($id_user, $origin))
|
||||
if ($origin && !$this->internal_phone->get_by_number_and_user($id_user, $origin))
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'Ce numéro n\'existe pas ou vous n\'en êtes pas propriétaire.');
|
||||
return $this->redirect(\descartes\Router::url('Scheduled', 'add'));
|
||||
}
|
||||
|
||||
$success = $this->internal_scheduled->update_for_user($_SESSION['user']['id'], $id_scheduled, $id_user, $at, $text, $origin, $flash, $numbers, $contacts, $groups);
|
||||
$success = $this->internal_scheduled->update_for_user($id_user, $id_scheduled, $at, $text, $origin, $flash, $numbers, $contacts, $groups);
|
||||
if (!$success)
|
||||
{
|
||||
$all_update_ok = false;
|
||||
|
|
|
@ -67,18 +67,6 @@ namespace controllers\publics;
|
|||
$ids = $_GET['ids'] ?? [];
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
$sended = $this->internal_sended->get($id);
|
||||
if (!$sended)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$is_owner = (bool) $this->internal_phone->get_by_number_and_user($sended['origin'], $_SESSION['user']['id']);
|
||||
if (!$is_owner)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->internal_sended->delete_for_user($_SESSION['user']['id'], $id);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace controllers\publics;
|
|||
{
|
||||
$page = (int) $page;
|
||||
$limit = 25;
|
||||
$smsstops = $this->internal_sms_stop->list_for_user($_SESSION['user']['id']$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)]);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,11 @@ class User extends \descartes\Controller
|
|||
$this->internal_user = new \controllers\internals\User($bdd);
|
||||
|
||||
\controllers\internals\Tool::verifyconnect();
|
||||
|
||||
if (!\controllers\internals\Tool::is_admin())
|
||||
{
|
||||
return $this->redirect(\descartes\Router::url('Dashboard', 'show'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace models;
|
|||
*/
|
||||
public function get_by_number_and_user (int $id_user, string $number)
|
||||
{
|
||||
return $this->_select($this->get_table_name(), ['id_user' => $id_user, 'number' => $number]);
|
||||
return $this->_select_one($this->get_table_name(), ['id_user' => $id_user, 'number' => $number]);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace models;
|
|||
*/
|
||||
public function delete_group_contact_relations (int $id_group)
|
||||
{
|
||||
return $this->delete('group_contact', ['id_group' => $id_group]);
|
||||
return $this->_delete('group_contact', ['id_group' => $id_group]);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -225,10 +225,8 @@ namespace models;
|
|||
* @param string $origin : Number who sent the message
|
||||
* @return array
|
||||
*/
|
||||
public function gets_by_origin_for_user(int $id_user, string $origin)
|
||||
public function gets_by_origin_and_user(int $id_user, string $origin)
|
||||
{
|
||||
$nb_entry = (int) $nb_entry;
|
||||
|
||||
$query = '
|
||||
SELECT *
|
||||
FROM received
|
||||
|
|
|
@ -136,7 +136,7 @@ namespace models;
|
|||
* @param string $number : Number for which we want messages
|
||||
* @return array
|
||||
*/
|
||||
public function get_before_date_for_number_and_user (int $id_user, $date, string $number)
|
||||
public function gets_before_date_for_number_and_user (int $id_user, $date, string $number)
|
||||
{
|
||||
$query = '
|
||||
SELECT *
|
||||
|
|
|
@ -225,10 +225,8 @@ namespace models;
|
|||
* @param string $destination : Number who sent the message
|
||||
* @return array
|
||||
*/
|
||||
public function gets_by_destination_for_user(int $id_user, string $destination)
|
||||
public function gets_by_destination_and_user(int $id_user, string $destination)
|
||||
{
|
||||
$nb_entry = (int) $nb_entry;
|
||||
|
||||
$query = '
|
||||
SELECT *
|
||||
FROM sended
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace models;
|
|||
*/
|
||||
public function get_for_user(int $id_user, int $id)
|
||||
{
|
||||
return $this->_select_one($this->get_table_name(), ['id' => $id]);
|
||||
return $this->_select_one($this->get_table_name(), ['id' => $id, 'id_user' => $id_user]);
|
||||
}
|
||||
|
||||
|
||||
|
@ -80,7 +80,7 @@ namespace models;
|
|||
public function gets_in_for_user(int $id_user, $ids)
|
||||
{
|
||||
$query = '
|
||||
SELECT * FROM ' . $this->get_table_name() . '
|
||||
SELECT * FROM `' . $this->get_table_name() . '`
|
||||
WHERE id_user = :id_user
|
||||
AND id ';
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@
|
|||
'<div class="clearfix message-container">' +
|
||||
'<div class="discussion-message message-sended">' +
|
||||
'<div class="discussion-message-text">' + message.text + '</div>' +
|
||||
'<div class="discussion-message-date">' + message.date + (message.status ? (message.status == 'delivered' ? ' <span class="fa fa-check-circle fa-fw text-success"></span>' : '<span class="fa fa-times-circle fa-fw text-danger"></span>' ) : '' ) + '</div>' +
|
||||
'<div class="discussion-message-date">' + message.date + ' ' + (message.status == 'delivered' ? '<span class="fa fa-check-circle fa-fw text-success"></span>' : (message.status == 'failed' ? '<span class="fa fa-times-circle fa-fw text-danger"></span>' : '<span class="fa fa-clock-o fa-fw text-info"></span>' )) + '</div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
break;
|
||||
|
|
|
@ -74,17 +74,17 @@
|
|||
<a href="<?php echo \descartes\Router::url('Event', 'list'); ?>"><i class="fa fa-fw fa-clock-o"></i> Évènements</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li <?php echo $page == 'users' ? 'class="active"' : ''; ?>>
|
||||
<a href="<?php echo \descartes\Router::url('User', 'list'); ?>"><i class="fa fa-fw fa-user"></i> Utilisateurs</a>
|
||||
</li>
|
||||
</li>
|
||||
<li <?php echo $page == 'phones' ? 'class="active"' : ''; ?>>
|
||||
<a href="<?php echo \descartes\Router::url('Phone', 'list'); ?>"><i class="fa fa-fw fa-phone"></i> Téléphones</a>
|
||||
</li>
|
||||
<?php if ($_SESSION['user']['admin']) { ?>
|
||||
<li <?php echo $page == 'settings' ? 'class="active"' : ''; ?>>
|
||||
<a href="<?php echo \descartes\Router::url('Setting', 'show'); ?>"><i class="fa fa-fw fa-cogs"></i> Réglages</a>
|
||||
</li>
|
||||
<li <?php echo $page == 'settings' ? 'class="active"' : ''; ?>>
|
||||
<a href="<?php echo \descartes\Router::url('Setting', 'show'); ?>"><i class="fa fa-fw fa-cogs"></i> Réglages</a>
|
||||
</li>
|
||||
<?php if (\controllers\internals\Tool::is_admin()) { ?>
|
||||
<li <?php echo $page == 'users' ? 'class="active"' : ''; ?>>
|
||||
<a href="<?php echo \descartes\Router::url('User', 'list'); ?>"><i class="fa fa-fw fa-user"></i> Utilisateurs</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue