mirror of
https://github.com/RaspbianFrance/raspisms.git
synced 2025-04-20 16:37:48 +02:00
to keep
This commit is contained in:
parent
65dacb5302
commit
4c27d8ccf2
13 changed files with 121 additions and 137 deletions
|
@ -109,7 +109,7 @@ namespace controllers\internals;
|
|||
return false;
|
||||
}
|
||||
|
||||
$this->internal_event->create('COMMAND_ADD', 'Ajout commande : '.$name.' => '.$script);
|
||||
$this->internal_event->create($_SESSION['user']['id'], 'COMMAND_ADD', 'Ajout commande : '.$name.' => '.$script);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
|
|
@ -26,30 +26,37 @@ namespace controllers\internals;
|
|||
}
|
||||
|
||||
/**
|
||||
* Cette fonction retourne une liste des contactes sous forme d'un tableau.
|
||||
*
|
||||
* @param mixed(int|bool) $nb_entry : Le nombre d'entrées à retourner par page
|
||||
* @param mixed(int|bool) $page : Le numéro de page en cours
|
||||
*
|
||||
* @return array : La liste des contactes
|
||||
* List contacts for a user
|
||||
* @param int $id_user : user id
|
||||
* @param mixed(int|bool) $nb_entry : Number of entry to return
|
||||
* @param mixed(int|bool) $page : Pagination, will offset $nb_entry * $page results
|
||||
* @return array
|
||||
*/
|
||||
public function list($nb_entry = null, $page = null)
|
||||
public function list($id_user, $nb_entry = null, $page = null)
|
||||
{
|
||||
//Recupération des contactes
|
||||
return $this->model_contact->list($nb_entry, $nb_entry * $page);
|
||||
return $this->model_contact->list_for_user($id_user, $nb_entry, $nb_entry * $page);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a contact
|
||||
* @param $id : contact id
|
||||
* @return array
|
||||
*/
|
||||
public function get($id)
|
||||
{
|
||||
return $this->model_contact->get($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cette fonction retourne une liste des contactes sous forme d'un tableau.
|
||||
*
|
||||
* @param int $id_user : user id
|
||||
* @param array int $ids : Les ids des entrées à retourner
|
||||
*
|
||||
* @return array : La liste des contactes
|
||||
*/
|
||||
public function gets($ids)
|
||||
public function gets_for_user($id_user, $ids)
|
||||
{
|
||||
//Recupération des contactes
|
||||
return $this->model_contact->gets($ids);
|
||||
return $this->model_contact->gets_for_user($id_user, $ids);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -116,15 +123,16 @@ namespace controllers\internals;
|
|||
/**
|
||||
* Cette fonction insert une nouvelle contacte.
|
||||
*
|
||||
* @param array $contact : Un tableau représentant la contacte à insérer
|
||||
* @param int $id_user : user id
|
||||
* @param mixed $number
|
||||
* @param mixed $name
|
||||
*
|
||||
* @return mixed bool|int : false si echec, sinon l'id de la nouvelle contacte insérée
|
||||
*/
|
||||
public function create($number, $name)
|
||||
public function create($id_user, $number, $name)
|
||||
{
|
||||
$contact = [
|
||||
'id_user' => $id_user,
|
||||
'number' => $number,
|
||||
'name' => $name,
|
||||
];
|
||||
|
@ -135,7 +143,7 @@ namespace controllers\internals;
|
|||
return $result;
|
||||
}
|
||||
|
||||
$this->internal_event->create('CONTACT_ADD', 'Ajout contact : '.$name.' ('.\controllers\internals\Tool::phone_format($number).')');
|
||||
$this->internal_event->create($id_user, 'CONTACT_ADD', 'Ajout contact : '.$name.' ('.\controllers\internals\Tool::phone_format($number).')');
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
@ -144,14 +152,16 @@ namespace controllers\internals;
|
|||
* Cette fonction met à jour une série de contactes.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @param int $id_user : user id
|
||||
* @param mixed $number
|
||||
* @param mixed $name
|
||||
*
|
||||
* @return int : le nombre de ligne modifiées
|
||||
*/
|
||||
public function update($id, $number, $name)
|
||||
public function update($id, $id_user, $number, $name)
|
||||
{
|
||||
$contact = [
|
||||
'id_user' => $id_user,
|
||||
'number' => $number,
|
||||
'name' => $name,
|
||||
];
|
||||
|
|
|
@ -65,16 +65,16 @@ namespace controllers\internals;
|
|||
|
||||
/**
|
||||
* Cette fonction insert un nouvel event.
|
||||
*
|
||||
* @param array $event : Un tableau représentant l'event à insérer
|
||||
* @param int $id_user : user id
|
||||
* @param mixed $type
|
||||
* @param mixed $text
|
||||
*
|
||||
* @return mixed bool|int : false si echec, sinon l'id du nouvel event inséré
|
||||
*/
|
||||
public function create($type, $text)
|
||||
public function create($id_user, $type, $text)
|
||||
{
|
||||
$event = [
|
||||
'id_user' => $id_user,
|
||||
'type' => $type,
|
||||
'text' => $text,
|
||||
];
|
||||
|
|
|
@ -112,7 +112,7 @@ namespace controllers\internals;
|
|||
$this->model_group->insert_group_contact($id_group, $contact_id);
|
||||
}
|
||||
|
||||
$this->internal_event->create('GROUP_ADD', 'Ajout group : '.$name);
|
||||
$this->internal_event->create($_SESSION['user']['id'], 'GROUP_ADD', 'Ajout group : '.$name);
|
||||
|
||||
return $id_group;
|
||||
}
|
||||
|
|
|
@ -30,9 +30,9 @@ namespace controllers\internals;
|
|||
*
|
||||
* @return array|bool : List of user or false
|
||||
*/
|
||||
public function list(int $id_user, ?int $nb_entry = null, ?int $page = null)
|
||||
public function list_for_user(int $id_user, ?int $nb_entry = null, ?int $page = null)
|
||||
{
|
||||
return $this->model_phone->list($id_user, $nb_entry, $page * $nb_entry);
|
||||
return $this->model_phone->list_for_user($id_user, $nb_entry, $page * $nb_entry);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,26 +46,15 @@ namespace controllers\internals;
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a phone by is number
|
||||
* @param string $number : phone number
|
||||
* @return array
|
||||
*/
|
||||
public function get_by_number (string $number)
|
||||
{
|
||||
return $this->model_phone->get_by_number($number);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a phone by his number and user
|
||||
* @param string $number : phone number
|
||||
* @param int $id_user : user id
|
||||
* @param string $number : phone number
|
||||
* @return array
|
||||
*/
|
||||
public function get_by_number_and_user (string $number, int $id_user)
|
||||
public function get_by_number_for_user (int $id_user, string $number)
|
||||
{
|
||||
return $this->model_phone->get_by_number_and_user($number, $id_user);
|
||||
return $this->model_phone->get_by_number_for_user($id_user, $number);
|
||||
}
|
||||
|
||||
|
||||
|
@ -78,16 +67,6 @@ namespace controllers\internals;
|
|||
{
|
||||
return $this->model_phone->gets_for_user($id_user);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return all phones
|
||||
* @return array
|
||||
*/
|
||||
public function get_all ()
|
||||
{
|
||||
return $this->model_phone->get_all();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -95,9 +74,9 @@ namespace controllers\internals;
|
|||
* @param int $id : Phone id
|
||||
* @return bool
|
||||
*/
|
||||
public function delete (int $id) : bool
|
||||
public function delete_for_user (int $id_user, int $id) : bool
|
||||
{
|
||||
return (bool) $this->model_phone->delete($id);
|
||||
return (bool) $this->model_phone->delete_for_user($id_user, $id);
|
||||
}
|
||||
|
||||
|
||||
|
@ -131,7 +110,7 @@ namespace controllers\internals;
|
|||
* @param array $adapter_datas : An array of the datas of the adapter (for example credentials for an api)
|
||||
* @return bool : false on error, true on success
|
||||
*/
|
||||
public function update (int $id, int $id_user, string $number, string $adapter, array $adapter_datas) : bool
|
||||
public function update_for_user (int $id, int $id_user, string $number, string $adapter, array $adapter_datas) : bool
|
||||
{
|
||||
$phone = [
|
||||
'id_user' => $id_user,
|
||||
|
@ -140,7 +119,7 @@ namespace controllers\internals;
|
|||
'adapter_datas' => json_encode($adapter_datas),
|
||||
];
|
||||
|
||||
return (bool) $this->model_phone->update($id, $phone);
|
||||
return (bool) $this->model_phone->update_for_user($id, $phone);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ namespace controllers\internals;
|
|||
if (!$id_scheduled = $this->model_scheduled->insert($scheduled))
|
||||
{
|
||||
$date = date('Y-m-d H:i:s');
|
||||
$this->internal_event->create('SCHEDULED_ADD', 'Ajout d\'un Sms pour le '.$date.'.');
|
||||
$this->internal_event->create($id_user, 'SCHEDULED_ADD', 'Ajout d\'un Sms pour le '.$date.'.');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -185,7 +185,7 @@ namespace controllers\internals;
|
|||
return false;
|
||||
}
|
||||
|
||||
$this->internal_event->create('CONTACT_ADD', 'Ajout de l\'utilisateur : '.$email.'.');
|
||||
$this->internal_event->create($_SESSION['user']['id'], 'CONTACT_ADD', 'Ajout de l\'utilisateur : '.$email.'.');
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue