mirror of
https://github.com/RaspbianFrance/raspisms.git
synced 2025-04-23 01:46:27 +02:00
Fix php style
This commit is contained in:
parent
461bd9c98d
commit
b8bd067dc7
59 changed files with 2307 additions and 1868 deletions
|
@ -14,15 +14,10 @@ namespace models;
|
|||
class Scheduled extends StandardModel
|
||||
{
|
||||
/**
|
||||
* Return table name
|
||||
* @return string
|
||||
*/
|
||||
protected function get_table_name() : string { return 'scheduled'; }
|
||||
|
||||
|
||||
/**
|
||||
* Return numbers for a scheduled message
|
||||
* Return numbers for a scheduled message.
|
||||
*
|
||||
* @param int $id_scheduled : Scheduled id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_numbers(int $id_scheduled)
|
||||
|
@ -30,134 +25,152 @@ namespace models;
|
|||
return $this->_select('scheduled_number', ['id_scheduled' => $id_scheduled]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return contacts for a scheduled message
|
||||
* Return contacts for a scheduled message.
|
||||
*
|
||||
* @param int $id_scheduled : Scheduled id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_contacts(int $id_scheduled)
|
||||
{
|
||||
$query = 'SELECT * FROM contact WHERE id IN (SELECT id_contact FROM scheduled_contact WHERE id_scheduled = :id_scheduled)';
|
||||
$params = ['id_scheduled' => $id_scheduled];
|
||||
|
||||
return $this->_run_query($query, $params);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return groups for a scheduled message
|
||||
* Return groups for a scheduled message.
|
||||
*
|
||||
* @param int $id_scheduled : Scheduled id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_groups(int $id_scheduled)
|
||||
{
|
||||
$query = 'SELECT * FROM `group` WHERE id IN (SELECT id_group FROM scheduled_group WHERE id_scheduled = :id_scheduled)';
|
||||
$params = ['id_scheduled' => $id_scheduled];
|
||||
|
||||
return $this->_run_query($query, $params);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return conitional groups for a scheduled message
|
||||
* Return conitional groups for a scheduled message.
|
||||
*
|
||||
* @param int $id_scheduled : Scheduled id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_conditional_groups(int $id_scheduled)
|
||||
{
|
||||
$query = 'SELECT * FROM `conditional_group` WHERE id IN (SELECT id_conditional_group FROM scheduled_conditional_group WHERE id_scheduled = :id_scheduled)';
|
||||
$params = ['id_scheduled' => $id_scheduled];
|
||||
|
||||
return $this->_run_query($query, $params);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert a number for a scheduled
|
||||
* @param int $id_scheduled : Scheduled id
|
||||
* @param string $number : Number
|
||||
* Insert a number for a scheduled.
|
||||
*
|
||||
* @param int $id_scheduled : Scheduled id
|
||||
* @param string $number : Number
|
||||
*
|
||||
* @return mixed (bool|int) : False on error, new row id else
|
||||
*/
|
||||
public function insert_scheduled_number(int $id_scheduled, string $number)
|
||||
{
|
||||
$success = $this->_insert('scheduled_number', ['id_scheduled' => $id_scheduled, 'number' => $number]);
|
||||
return ($success ? $this->_last_id() : false);
|
||||
|
||||
return $success ? $this->_last_id() : false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Insert a relation between a scheduled and a contact
|
||||
* Insert a relation between a scheduled and a contact.
|
||||
*
|
||||
* @param int $id_scheduled : Scheduled id
|
||||
* @param int $id_contact : Group id
|
||||
* @param int $id_contact : Group id
|
||||
*
|
||||
* @return mixed (bool|int) : False on error, new row id else
|
||||
*/
|
||||
public function insert_scheduled_contact_relation(int $id_scheduled, int $id_contact)
|
||||
{
|
||||
$success = $this->_insert('scheduled_contact', ['id_scheduled' => $id_scheduled, 'id_contact' => $id_contact]);
|
||||
return ($success ? $this->_last_id() : false);
|
||||
|
||||
return $success ? $this->_last_id() : false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert a relation between a scheduled and a group
|
||||
* Insert a relation between a scheduled and a group.
|
||||
*
|
||||
* @param int $id_scheduled : Scheduled id
|
||||
* @param int $id_group : Group id
|
||||
* @param int $id_group : Group id
|
||||
*
|
||||
* @return mixed (bool|int) : False on error, new row id else
|
||||
*/
|
||||
public function insert_scheduled_group_relation(int $id_scheduled, int $id_group)
|
||||
{
|
||||
$success = $this->_insert('scheduled_group', ['id_scheduled' => $id_scheduled, 'id_group' => $id_group]);
|
||||
return ($success ? $this->_last_id() : false);
|
||||
|
||||
return $success ? $this->_last_id() : false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Insert a relation between a scheduled and a conditional group
|
||||
* @param int $id_scheduled : Scheduled id
|
||||
* Insert a relation between a scheduled and a conditional group.
|
||||
*
|
||||
* @param int $id_scheduled : Scheduled id
|
||||
* @param int $id_conditional_group : Group id
|
||||
*
|
||||
* @return mixed (bool|int) : False on error, new row id else
|
||||
*/
|
||||
public function insert_scheduled_conditional_group_relation(int $id_scheduled, int $id_conditional_group)
|
||||
{
|
||||
$success = $this->_insert('scheduled_conditional_group', ['id_scheduled' => $id_scheduled, 'id_conditional_group' => $id_conditional_group]);
|
||||
return ($success ? $this->_last_id() : false);
|
||||
|
||||
return $success ? $this->_last_id() : false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Delete numbers for a scheduled
|
||||
* Delete numbers for a scheduled.
|
||||
*
|
||||
* @param int $id_scheduled : Scheduled id
|
||||
*
|
||||
* @return mixed int : Number of deleted rows
|
||||
*/
|
||||
public function delete_scheduled_numbers(int $id_scheduled)
|
||||
{
|
||||
return $this->_delete('scheduled_number', ['id_scheduled' => $id_scheduled]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Delete contact scheduled relations for a scheduled
|
||||
* Delete contact scheduled relations for a scheduled.
|
||||
*
|
||||
* @param int $id_scheduled : Scheduled id
|
||||
*
|
||||
* @return mixed int : Number of deleted rows
|
||||
*/
|
||||
public function delete_scheduled_contact_relations(int $id_scheduled)
|
||||
{
|
||||
return $this->_delete('scheduled_contact', ['id_scheduled' => $id_scheduled]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Delete group scheduled relations for a scheduled
|
||||
* Delete group scheduled relations for a scheduled.
|
||||
*
|
||||
* @param int $id_scheduled : Scheduled id
|
||||
*
|
||||
* @return mixed int : Number of deleted rows
|
||||
*/
|
||||
public function delete_scheduled_group_relations(int $id_scheduled)
|
||||
{
|
||||
return $this->_delete('scheduled_group', ['id_scheduled' => $id_scheduled]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Delete conditional group scheduled relations for a scheduled
|
||||
* Delete conditional group scheduled relations for a scheduled.
|
||||
*
|
||||
* @param int $id_scheduled : Scheduled id
|
||||
*
|
||||
* @return mixed int : Number of deleted rows
|
||||
*/
|
||||
public function delete_scheduled_conditional_group_relations(int $id_scheduled)
|
||||
|
@ -165,15 +178,16 @@ namespace models;
|
|||
return $this->_delete('scheduled_conditional_group', ['id_scheduled' => $id_scheduled]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get messages scheduled before a date for a number and a user
|
||||
* Get messages scheduled before a date for a number and a user.
|
||||
*
|
||||
* @param int $id_user : User id
|
||||
* @param $date : Date before which we want messages
|
||||
* @param string $number : Number for which we want messages
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function gets_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 *
|
||||
|
@ -220,14 +234,25 @@ namespace models;
|
|||
return $this->_run_query($query, $params);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get scheduleds before a date
|
||||
* Get scheduleds before a date.
|
||||
*
|
||||
* @param string $date : Date to get scheduleds before
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function gets_before_date (string $date)
|
||||
public function gets_before_date(string $date)
|
||||
{
|
||||
return $this->_select($this->get_table_name(), ['<=at' => $date]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return table name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function get_table_name(): string
|
||||
{
|
||||
return 'scheduled';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue