1
0
Fork 0
mirror of https://github.com/RaspbianFrance/raspisms.git synced 2025-05-12 03:06:26 +02:00

use correct model and fix style

This commit is contained in:
osaajani 2021-07-19 17:32:23 +02:00
parent e21b89cc7c
commit e957c9feb7
29 changed files with 105 additions and 111 deletions

View file

@ -136,7 +136,7 @@ namespace controllers\internals;
/**
* Get the model for the Controller.
*/
protected function get_model(): \descartes\Model
protected function get_model(): \models\Call
{
$this->model = $this->model ?? new \models\Call($this->bdd);

View file

@ -150,7 +150,7 @@ namespace controllers\internals;
/**
* Get the model for the Controller.
*/
protected function get_model(): \descartes\Model
protected function get_model(): \models\Command
{
$this->model = $this->model ?? new \models\Command($this->bdd);

View file

@ -134,7 +134,7 @@ namespace controllers\internals;
/**
* Get the model for the Controller.
*/
protected function get_model(): \descartes\Model
protected function get_model(): \models\ConditionalGroup
{
$this->model = $this->model ?? new \models\ConditionalGroup($this->bdd);

View file

@ -351,7 +351,7 @@ namespace controllers\internals;
/**
* Get the model for the Controller.
*/
protected function get_model(): \descartes\Model
protected function get_model(): \models\Contact
{
$this->model = $this->model ?? new \models\Contact($this->bdd);

View file

@ -74,7 +74,7 @@ namespace controllers\internals;
/**
* Get the model for the Controller.
*/
protected function get_model(): \descartes\Model
protected function get_model(): \models\Event
{
$this->model = $this->model ?? new \models\Event($this->bdd);

View file

@ -130,7 +130,7 @@ namespace controllers\internals;
/**
* Get the model for the Controller.
*/
protected function get_model(): \descartes\Model
protected function get_model(): \models\Group
{
$this->model = $this->model ?? new \models\Group($this->bdd);

View file

@ -313,7 +313,7 @@ class Media extends StandardController
/**
* Get the model for the Controller.
*/
protected function get_model(): \descartes\Model
protected function get_model(): \models\Media
{
$this->model = $this->model ?? new \models\Media($this->bdd);

View file

@ -166,7 +166,7 @@ namespace controllers\internals;
/**
* Get the model for the Controller.
*/
protected function get_model(): \descartes\Model
protected function get_model(): \models\Phone
{
$this->model = $this->model ?? new \models\Phone($this->bdd);

View file

@ -288,7 +288,7 @@ class Quota extends StandardController
/**
* Get the model for the Controller.
*/
protected function get_model(): \descartes\Model
protected function get_model(): \models\Quota
{
$this->model = $this->model ?? new \models\Quota($this->bdd);

View file

@ -18,15 +18,15 @@ namespace controllers\internals;
/**
* Return the list of entries for a user.
*
* @param int $id_user : User id
* @param ?int $limit : Number of entry to return
* @param ?int $offset : Number of entry to avoid
* @param ?string $search : String to search for
* @param ?array $search_columns : List of columns to search on
* @param ?string $order_column : Name of the column to order by
* @param bool $order_desc : Should result be ordered DESC, if false order ASC
* @param bool $count : Should the query only count results
* @param bool $unread : Should only unread messages be returned
* @param int $id_user : User id
* @param ?int $limit : Number of entry to return
* @param ?int $offset : Number of entry to avoid
* @param ?string $search : String to search for
* @param ?array $search_columns : List of columns to search on
* @param ?string $order_column : Name of the column to order by
* @param bool $order_desc : Should result be ordered DESC, if false order ASC
* @param bool $count : Should the query only count results
* @param bool $unread : Should only unread messages be returned
*
* @return array : Entrys list
*/
@ -375,7 +375,7 @@ namespace controllers\internals;
/**
* Get the model for the Controller.
*/
protected function get_model(): \descartes\Model
protected function get_model(): \models\Received
{
$this->model = $this->model ?? new \models\Received($this->bdd);

View file

@ -544,7 +544,7 @@ namespace controllers\internals;
/**
* Get the model for the Controller.
*/
protected function get_model(): \descartes\Model
protected function get_model(): \models\Scheduled
{
$this->model = $this->model ?? new \models\Scheduled($this->bdd);

View file

@ -14,17 +14,16 @@ namespace controllers\internals;
class Sended extends StandardController
{
protected $model;
/**
*
* @param int $id_user : User id
* @param ?int $limit : Number of entry to return
* @param ?int $offset : Number of entry to avoid
* @param ?string $search : String to search for
* @param ?array $search_columns : List of columns to search on
* @param ?string $order_column : Name of the column to order by
* @param bool $order_desc : Should result be ordered DESC, if false order ASC
* @param bool $count : Should the query only count results
* @param int $id_user : User id
* @param ?int $limit : Number of entry to return
* @param ?int $offset : Number of entry to avoid
* @param ?string $search : String to search for
* @param ?array $search_columns : List of columns to search on
* @param ?string $order_column : Name of the column to order by
* @param bool $order_desc : Should result be ordered DESC, if false order ASC
* @param bool $count : Should the query only count results
*
* @return array : Entries list
*/
@ -307,7 +306,7 @@ namespace controllers\internals;
/**
* Get the model for the Controller.
*/
protected function get_model(): \descartes\Model
protected function get_model(): \models\Sended
{
$this->model = $this->model ?? new \models\Sended($this->bdd);

View file

@ -89,7 +89,7 @@ namespace controllers\internals;
/**
* Get the model for the Controller.
*/
protected function get_model(): \descartes\Model
protected function get_model(): \models\Setting
{
$this->model = $this->model ?? new \models\Setting($this->bdd);

View file

@ -64,24 +64,25 @@ namespace controllers\internals;
return $this->get_model()->get_by_number_for_user($id_user, $number);
}
/**
* Parse a string to check if its a SMS stop.
*
* @param string $str : The string to check
*
* @return bool : true if sms stop, false else
*/
public function check_for_stop(string $str)
{
return 'stop' == trim(mb_strtolower($str));
}
/**
* Get the model for the Controller.
*/
protected function get_model(): \descartes\Model
protected function get_model(): \models\SmsStop
{
$this->model = $this->model ?? new \models\SmsStop($this->bdd);
return $this->model;
}
/**
* Parse a string to check if its a SMS stop
*
* @param string $str : The string to check
* @return bool : true if sms stop, false else
*/
public function check_for_stop (string $str)
{
return trim(mb_strtolower($str)) == 'stop';
}
}

View file

@ -138,5 +138,5 @@ namespace controllers\internals;
/**
* Get the model for the Controller.
*/
abstract protected function get_model(): \descartes\Model;
abstract protected function get_model(): \models\StandardModel;
}

View file

@ -146,7 +146,7 @@ class Webhook extends StandardController
/**
* Get the model for the Controller.
*/
protected function get_model(): \descartes\Model
protected function get_model(): \models\Webhook
{
$this->model = $this->model ?? new \models\Webhook($this->bdd);

View file

@ -204,10 +204,11 @@ namespace controllers\publics;
return $this->redirect(\descartes\Router::url('Connect', 'login'));
}
/**
* Allow to stop impersonating a user
* @param mixed $csrf
* Allow to stop impersonating a user.
*
* @param mixed $csrf
*/
public function stop_impersonate()
{
@ -223,6 +224,7 @@ namespace controllers\publics;
$_SESSION = $old_session;
\FlashMessage\FlashMessage::push('success', 'Vous n\'incarnez plus l\'utilisateur ' . $user_email . '.');
return $this->redirect(\descartes\Router::url('Dashboard', 'show'));
}
}

View file

@ -164,5 +164,4 @@ namespace controllers\publics;
return $this->redirect(\descartes\Router::url('Connect', 'login'));
}
}

View file

@ -48,12 +48,12 @@ namespace controllers\publics;
/**
* Return receiveds as json.
*
*
* @param bool $unread : Should we only search for unread messages
*/
public function list_json(bool $unread = false)
{
$draw = (int)($_GET['draw'] ?? false);
$draw = (int) ($_GET['draw'] ?? false);
$columns = [
0 => 'searchable_origin',

View file

@ -53,8 +53,7 @@ namespace controllers\publics;
*/
public function list_json()
{
$draw = (int)($_GET['draw'] ?? false);
$draw = (int) ($_GET['draw'] ?? false);
$columns = [
0 => 'phone_name',

View file

@ -410,13 +410,13 @@ class User extends \descartes\Controller
return $this->redirect(\descartes\Router::url('User', 'list'));
}
/**
* Allow an admin to impersonate a user
* Allow an admin to impersonate a user.
*
* @param mixed $csrf
* @param array int $_GET['user_ids'] : Ids of users to impersonate, the array should actually contain one id only, we keep use of array for simpler compatibility in UI
*/
public function impersonate ($csrf)
public function impersonate($csrf)
{
if (!$this->verify_csrf($csrf))
{
@ -425,7 +425,7 @@ class User extends \descartes\Controller
return $this->redirect(\descartes\Router::url('User', 'list'));
}
if (count($_GET['user_ids']) != 1)
if (1 != count($_GET['user_ids']))
{
\FlashMessage\FlashMessage::push('danger', 'Vous devez séléctionner un et un seul utilisateur à incarner !');
@ -460,17 +460,17 @@ class User extends \descartes\Controller
$user['settings'] = $settings;
//Save old session to get it back later
//Save old session to get it back later
$old_session = $_SESSION;
$_SESSION = [
'old_session' => $old_session,
'old_session' => $old_session,
'impersonate' => true,
'connect' => true,
'user' => $user,
];
\FlashMessage\FlashMessage::push('success', 'Vous incarnez désormais l\'utilisateur ' . $user['email'] . '.');
return $this->redirect(\descartes\Router::url('Dashboard', 'show'));
}
}