mirror of
https://github.com/RaspbianFrance/raspisms.git
synced 2025-07-22 04:48:45 +02:00
fix style
This commit is contained in:
parent
cc233f726a
commit
aac464704e
34 changed files with 147 additions and 107 deletions
|
@ -15,9 +15,9 @@ namespace models;
|
|||
{
|
||||
/**
|
||||
* Return a list of groups for a user.
|
||||
* Add a column nb_contacts
|
||||
* Add a column nb_contacts.
|
||||
*
|
||||
* @param int $id_user : user id
|
||||
* @param int $id_user : user id
|
||||
* @param ?int $limit : Number of entry to return or null
|
||||
* @param ?int $offset : Number of entry to ignore or null
|
||||
*
|
||||
|
@ -30,28 +30,29 @@ namespace models;
|
|||
FROM `group` as g
|
||||
LEFT JOIN group_contact as gc
|
||||
ON g.id = gc.id_group
|
||||
WHERE id_user = :id_user
|
||||
WHERE id_user = :id_user
|
||||
GROUP BY g.id
|
||||
';
|
||||
|
||||
if ($limit !== null)
|
||||
if (null !== $limit)
|
||||
{
|
||||
$limit = (int) $limit;
|
||||
|
||||
$query .= ' LIMIT ' . $limit;
|
||||
if ($offset !== null)
|
||||
if (null !== $offset)
|
||||
{
|
||||
$offset = (int) $offset;
|
||||
$query .= ' OFFSET ' . $offset;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$params = [
|
||||
'id_user' => $id_user,
|
||||
];
|
||||
|
||||
return $this->_run_query($query, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a group by his name for a user.
|
||||
*
|
||||
|
@ -102,7 +103,7 @@ namespace models;
|
|||
public function get_contacts(int $id_group)
|
||||
{
|
||||
$query = '
|
||||
SELECT *
|
||||
SELECT *
|
||||
FROM `contact`
|
||||
WHERE id IN (SELECT id_contact FROM `group_contact` WHERE id_group = :id_group)
|
||||
';
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace models;
|
|||
*/
|
||||
public function get_for_user(int $id_user, int $id)
|
||||
{
|
||||
$query = '
|
||||
$query = '
|
||||
SELECT * FROM `' . $this->get_table_name() . '`
|
||||
WHERE id_scheduled IN (SELECT id FROM scheduled WHERE id_user = :id_user)
|
||||
AND id = :id
|
||||
|
@ -51,7 +51,7 @@ namespace models;
|
|||
*/
|
||||
public function gets_for_user(int $id_user)
|
||||
{
|
||||
$query = '
|
||||
$query = '
|
||||
SELECT * FROM `' . $this->get_table_name() . '`
|
||||
WHERE id_scheduled IN (SELECT id FROM scheduled WHERE id_user = :id_user)
|
||||
';
|
||||
|
@ -73,7 +73,7 @@ namespace models;
|
|||
*/
|
||||
public function get_for_scheduled_and_user(int $id_user, int $id_scheduled)
|
||||
{
|
||||
$query = '
|
||||
$query = '
|
||||
SELECT * FROM `' . $this->get_table_name() . '`
|
||||
WHERE id_scheduled IN (SELECT id FROM scheduled WHERE id_user = :id_user)
|
||||
AND id_scheduled = :id_scheduled
|
||||
|
@ -105,7 +105,7 @@ namespace models;
|
|||
$limit = (int) $limit;
|
||||
$offset = (int) $offset;
|
||||
|
||||
$query = '
|
||||
$query = '
|
||||
SELECT * FROM media
|
||||
WHERE id_scheduled IN (SELECT id FROM scheduled WHERE id_user = :id_user)
|
||||
LIMIT ' . $limit . ' OFFSET ' . $offset;
|
||||
|
@ -127,7 +127,7 @@ namespace models;
|
|||
*/
|
||||
public function gets_in_for_user(int $id_user, $ids)
|
||||
{
|
||||
$query = '
|
||||
$query = '
|
||||
SELECT * FROM media
|
||||
WHERE id_scheduled IN (SELECT id FROM scheduled WHERE id_user = :id_user)
|
||||
AND id ';
|
||||
|
@ -151,7 +151,7 @@ namespace models;
|
|||
*/
|
||||
public function delete_for_user(int $id_user, int $id)
|
||||
{
|
||||
$query = '
|
||||
$query = '
|
||||
DELETE FROM media
|
||||
WHERE id = :id
|
||||
AND id_scheduled IN (SELECT id FROM scheduled WHERE id_user = :id_user)
|
||||
|
@ -172,7 +172,7 @@ namespace models;
|
|||
*/
|
||||
public function delete_for_scheduled_and_user(int $id_user, int $id_scheduled)
|
||||
{
|
||||
$query = '
|
||||
$query = '
|
||||
DELETE FROM media
|
||||
WHERE id_scheduled = :id_scheduled
|
||||
AND id_scheduled IN (SELECT id FROM scheduled WHERE id_user = :id_user)
|
||||
|
|
|
@ -18,12 +18,12 @@ namespace models;
|
|||
{
|
||||
const STATUS_UNREAD = 'unread';
|
||||
const STATUS_READ = 'read';
|
||||
|
||||
|
||||
/**
|
||||
* Return a list of received messages for a user.
|
||||
* Add a column contact_name and phone_name when available
|
||||
* Add a column contact_name and phone_name when available.
|
||||
*
|
||||
* @param int $id_user : user id
|
||||
* @param int $id_user : user id
|
||||
* @param ?int $limit : Number of entry to return or null
|
||||
* @param ?int $offset : Number of entry to ignore or null
|
||||
*
|
||||
|
@ -42,31 +42,30 @@ namespace models;
|
|||
WHERE received.id_user = :id_user
|
||||
';
|
||||
|
||||
if ($limit !== null)
|
||||
if (null !== $limit)
|
||||
{
|
||||
$limit = (int) $limit;
|
||||
|
||||
$query .= ' LIMIT ' . $limit;
|
||||
if ($offset !== null)
|
||||
if (null !== $offset)
|
||||
{
|
||||
$offset = (int) $offset;
|
||||
$query .= ' OFFSET ' . $offset;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$params = [
|
||||
'id_user' => $id_user,
|
||||
];
|
||||
|
||||
return $this->_run_query($query, $params);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return a list of unread received messages for a user.
|
||||
* Add a column contact_name and phone_name when available
|
||||
* Add a column contact_name and phone_name when available.
|
||||
*
|
||||
* @param int $id_user : user id
|
||||
* @param int $id_user : user id
|
||||
* @param ?int $limit : Number of entry to return or null
|
||||
* @param ?int $offset : Number of entry to ignore or null
|
||||
*
|
||||
|
@ -86,18 +85,18 @@ namespace models;
|
|||
AND status = :status
|
||||
';
|
||||
|
||||
if ($limit !== null)
|
||||
if (null !== $limit)
|
||||
{
|
||||
$limit = (int) $limit;
|
||||
|
||||
$query .= ' LIMIT ' . $limit;
|
||||
if ($offset !== null)
|
||||
if (null !== $offset)
|
||||
{
|
||||
$offset = (int) $offset;
|
||||
$query .= ' OFFSET ' . $offset;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$params = [
|
||||
'id_user' => $id_user,
|
||||
'status' => self::STATUS_UNREAD,
|
||||
|
@ -190,7 +189,7 @@ namespace models;
|
|||
*/
|
||||
public function count_by_day_since_for_user(int $id_user, $date)
|
||||
{
|
||||
$query = "
|
||||
$query = "
|
||||
SELECT COUNT(id) as nb, DATE_FORMAT(at, '%Y-%m-%d') as at_ymd
|
||||
FROM received
|
||||
WHERE at > :date
|
||||
|
@ -215,7 +214,7 @@ namespace models;
|
|||
*/
|
||||
public function get_discussions_for_user(int $id_user)
|
||||
{
|
||||
$query = '
|
||||
$query = '
|
||||
SELECT discussions.at, discussions.number, contact.name as contact_name
|
||||
FROM (
|
||||
SELECT at, destination as number FROM sended
|
||||
|
@ -246,7 +245,7 @@ namespace models;
|
|||
*/
|
||||
public function get_since_by_date_for_user(int $id_user, $date)
|
||||
{
|
||||
$query = "
|
||||
$query = "
|
||||
SELECT *
|
||||
FROM received
|
||||
WHERE at > STR_TO_DATE(:date, '%Y-%m-%d %h:%i:%s')
|
||||
|
@ -272,7 +271,7 @@ namespace models;
|
|||
*/
|
||||
public function get_since_by_date_for_origin_and_user(int $id_user, $date, string $origin)
|
||||
{
|
||||
$query = "
|
||||
$query = "
|
||||
SELECT *
|
||||
FROM received
|
||||
WHERE at > STR_TO_DATE(:date, '%Y-%m-%d %h:%i:%s')
|
||||
|
|
|
@ -19,12 +19,12 @@ namespace models;
|
|||
const STATUS_UNKNOWN = 'unknown';
|
||||
const STATUS_DELIVERED = 'delivered';
|
||||
const STATUS_FAILED = 'failed';
|
||||
|
||||
|
||||
/**
|
||||
* Return a list of sended messages for a user.
|
||||
* Add a column contact_name and phone_name when available
|
||||
* Add a column contact_name and phone_name when available.
|
||||
*
|
||||
* @param int $id_user : user id
|
||||
* @param int $id_user : user id
|
||||
* @param ?int $limit : Number of entry to return or null
|
||||
* @param ?int $offset : Number of entry to ignore or null
|
||||
*
|
||||
|
@ -43,18 +43,18 @@ namespace models;
|
|||
WHERE sended.id_user = :id_user
|
||||
';
|
||||
|
||||
if ($limit !== null)
|
||||
if (null !== $limit)
|
||||
{
|
||||
$limit = (int) $limit;
|
||||
|
||||
$query .= ' LIMIT ' . $limit;
|
||||
if ($offset !== null)
|
||||
if (null !== $offset)
|
||||
{
|
||||
$offset = (int) $offset;
|
||||
$query .= ' OFFSET ' . $offset;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$params = [
|
||||
'id_user' => $id_user,
|
||||
];
|
||||
|
@ -137,7 +137,7 @@ namespace models;
|
|||
*/
|
||||
public function count_by_day_since_for_user($id_user, $date)
|
||||
{
|
||||
$query = "
|
||||
$query = "
|
||||
SELECT COUNT(id) as nb, DATE_FORMAT(at, '%Y-%m-%d') as at_ymd
|
||||
FROM sended
|
||||
WHERE at > :date
|
||||
|
@ -163,7 +163,7 @@ namespace models;
|
|||
*/
|
||||
public function get_since_by_date_for_user($date, $id_user)
|
||||
{
|
||||
$query = "
|
||||
$query = "
|
||||
SELECT *
|
||||
FROM sended
|
||||
WHERE at > STR_TO_DATE(:date, '%Y-%m-%d %h:%i:%s')
|
||||
|
|
|
@ -93,9 +93,9 @@ namespace models;
|
|||
return [];
|
||||
}
|
||||
|
||||
$query = '
|
||||
$query = '
|
||||
SELECT * FROM `' . $this->get_table_name() . '`
|
||||
WHERE id_user = :id_user
|
||||
WHERE id_user = :id_user
|
||||
AND id ';
|
||||
|
||||
$params = [];
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace models;
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete a user
|
||||
* Delete a user.
|
||||
*
|
||||
* @param int $id : Id de l'utilisateur a supprimer
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue