use correct model and fix style
This commit is contained in:
parent
e21b89cc7c
commit
e957c9feb7
|
@ -3,6 +3,7 @@
|
||||||
.php_cs.cache
|
.php_cs.cache
|
||||||
.credentials
|
.credentials
|
||||||
.credentials*
|
.credentials*
|
||||||
|
.vscode/
|
||||||
vendor/
|
vendor/
|
||||||
scripts/
|
scripts/
|
||||||
composer.lock
|
composer.lock
|
||||||
|
|
|
@ -38,9 +38,9 @@ class OctopushShortcodeAdapter implements AdapterInterface
|
||||||
* Sender name to use instead of shortcode.
|
* Sender name to use instead of shortcode.
|
||||||
*/
|
*/
|
||||||
private $sender;
|
private $sender;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Octopush SMS type
|
* Octopush SMS type.
|
||||||
*/
|
*/
|
||||||
private $sms_type;
|
private $sms_type;
|
||||||
|
|
||||||
|
@ -49,7 +49,6 @@ class OctopushShortcodeAdapter implements AdapterInterface
|
||||||
*/
|
*/
|
||||||
private $api_url = 'https://api.octopush.com/v1/public';
|
private $api_url = 'https://api.octopush.com/v1/public';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapter constructor, called when instanciated by RaspiSMS.
|
* Adapter constructor, called when instanciated by RaspiSMS.
|
||||||
*
|
*
|
||||||
|
@ -64,7 +63,7 @@ class OctopushShortcodeAdapter implements AdapterInterface
|
||||||
$this->api_key = $this->data['api_key'];
|
$this->api_key = $this->data['api_key'];
|
||||||
|
|
||||||
$this->sms_type = self::SMS_TYPE_LOWCOST;
|
$this->sms_type = self::SMS_TYPE_LOWCOST;
|
||||||
if (($this->data['sms_type'] ?? false) && $this->data['sms_type'] === 'premium')
|
if (($this->data['sms_type'] ?? false) && 'premium' === $this->data['sms_type'])
|
||||||
{
|
{
|
||||||
$this->sms_type = self::SMS_TYPE_PREMIUM;
|
$this->sms_type = self::SMS_TYPE_PREMIUM;
|
||||||
}
|
}
|
||||||
|
@ -234,7 +233,7 @@ class OctopushShortcodeAdapter implements AdapterInterface
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'text' => $text,
|
'text' => $text,
|
||||||
'recipients' => [['phone_number' => $destination]],
|
'recipients' => [['phone_number' => $destination]],
|
||||||
'sms_type' => $this->sms_type,
|
'sms_type' => $this->sms_type,
|
||||||
'purpose' => 'alert',
|
'purpose' => 'alert',
|
||||||
];
|
];
|
||||||
|
@ -245,12 +244,11 @@ class OctopushShortcodeAdapter implements AdapterInterface
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$data['with_replies'] = "True";
|
$data['with_replies'] = 'True';
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = json_encode($data);
|
$data = json_encode($data);
|
||||||
|
|
||||||
|
|
||||||
$endpoint = $this->api_url . '/sms-campaign/send';
|
$endpoint = $this->api_url . '/sms-campaign/send';
|
||||||
|
|
||||||
$curl = curl_init();
|
$curl = curl_init();
|
||||||
|
@ -260,7 +258,7 @@ class OctopushShortcodeAdapter implements AdapterInterface
|
||||||
curl_setopt($curl, CURLOPT_POST, true);
|
curl_setopt($curl, CURLOPT_POST, true);
|
||||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
|
||||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
||||||
|
|
||||||
$curl_response = curl_exec($curl);
|
$curl_response = curl_exec($curl);
|
||||||
$http_code = (int) curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
$http_code = (int) curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||||
curl_close($curl);
|
curl_close($curl);
|
||||||
|
@ -332,7 +330,7 @@ class OctopushShortcodeAdapter implements AdapterInterface
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$headers = [
|
$headers = [
|
||||||
'api-login: ' . $this->login,
|
'api-login: ' . $this->login,
|
||||||
'api-key: ' . $this->api_key,
|
'api-key: ' . $this->api_key,
|
||||||
|
@ -350,7 +348,7 @@ class OctopushShortcodeAdapter implements AdapterInterface
|
||||||
$http_code = (int) curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
$http_code = (int) curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||||
curl_close($curl);
|
curl_close($curl);
|
||||||
|
|
||||||
if ($http_code !== 200)
|
if (200 !== $http_code)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -369,14 +367,13 @@ class OctopushShortcodeAdapter implements AdapterInterface
|
||||||
header('Content-Encoding: none');
|
header('Content-Encoding: none');
|
||||||
header('Content-Length: 0');
|
header('Content-Length: 0');
|
||||||
|
|
||||||
|
|
||||||
$input = file_get_contents('php://input');
|
$input = file_get_contents('php://input');
|
||||||
$content = json_decode($input, true);
|
$content = json_decode($input, true);
|
||||||
if (null === $content)
|
if (null === $content)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$uid = $content['message_id'] ?? false;
|
$uid = $content['message_id'] ?? false;
|
||||||
$status = $content['status'] ?? false;
|
$status = $content['status'] ?? false;
|
||||||
|
|
||||||
|
@ -385,7 +382,6 @@ class OctopushShortcodeAdapter implements AdapterInterface
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
switch ($status)
|
switch ($status)
|
||||||
{
|
{
|
||||||
case 'DELIVERED':
|
case 'DELIVERED':
|
||||||
|
@ -420,14 +416,14 @@ class OctopushShortcodeAdapter implements AdapterInterface
|
||||||
header('Connection: close');
|
header('Connection: close');
|
||||||
header('Content-Encoding: none');
|
header('Content-Encoding: none');
|
||||||
header('Content-Length: 0');
|
header('Content-Length: 0');
|
||||||
|
|
||||||
$input = file_get_contents('php://input');
|
$input = file_get_contents('php://input');
|
||||||
$content = json_decode($input, true);
|
$content = json_decode($input, true);
|
||||||
if (null === $content)
|
if (null === $content)
|
||||||
{
|
{
|
||||||
$response['error'] = true;
|
$response['error'] = true;
|
||||||
$response['error_message'] = 'Cannot read input data from callback request.';
|
$response['error_message'] = 'Cannot read input data from callback request.';
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
|
||||||
private $api_key;
|
private $api_key;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Octopush SMS type
|
* Octopush SMS type.
|
||||||
*/
|
*/
|
||||||
private $sms_type;
|
private $sms_type;
|
||||||
|
|
||||||
|
@ -45,11 +45,10 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
|
||||||
private $api_url = 'https://api.octopush.com/v1/public';
|
private $api_url = 'https://api.octopush.com/v1/public';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Octopush phone number
|
* Octopush phone number.
|
||||||
*/
|
*/
|
||||||
private $number;
|
private $number;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapter constructor, called when instanciated by RaspiSMS.
|
* Adapter constructor, called when instanciated by RaspiSMS.
|
||||||
*
|
*
|
||||||
|
@ -65,7 +64,7 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
|
||||||
$this->number = $this->data['number'];
|
$this->number = $this->data['number'];
|
||||||
|
|
||||||
$this->sms_type = self::SMS_TYPE_LOWCOST;
|
$this->sms_type = self::SMS_TYPE_LOWCOST;
|
||||||
if (($this->data['sms_type'] ?? false) && $this->data['sms_type'] === 'premium')
|
if (($this->data['sms_type'] ?? false) && 'premium' === $this->data['sms_type'])
|
||||||
{
|
{
|
||||||
$this->sms_type = self::SMS_TYPE_PREMIUM;
|
$this->sms_type = self::SMS_TYPE_PREMIUM;
|
||||||
}
|
}
|
||||||
|
@ -118,7 +117,6 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
|
||||||
Envoi de SMS avec un numéro virtuel en utilisant <a target="_blank" href="https://www.octopush.com/">Octopush</a>. Pour trouver vos clés API Octopush <a target="_blank" href="' . $credentials_url . '">cliquez ici.</a><br/>
|
Envoi de SMS avec un numéro virtuel en utilisant <a target="_blank" href="https://www.octopush.com/">Octopush</a>. Pour trouver vos clés API Octopush <a target="_blank" href="' . $credentials_url . '">cliquez ici.</a><br/>
|
||||||
Pour plus d\'information sur l\'utilisation de ce téléphone, reportez-vous à <a href="https://documentation.raspisms.fr/users/adapters/octopush_virtual_number.html" target="_blank">la documentation sur les téléphones "Octopush Numéro Virtuel".</a>
|
Pour plus d\'information sur l\'utilisation de ce téléphone, reportez-vous à <a href="https://documentation.raspisms.fr/users/adapters/octopush_virtual_number.html" target="_blank">la documentation sur les téléphones "Octopush Numéro Virtuel".</a>
|
||||||
';
|
';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -154,7 +152,7 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
|
||||||
'description' => 'Type de SMS à employer coté Octopush, rentrez "low cost" ou "premium" selon le type de SMS que vous souhaitez employer. Laissez vide pour utiliser par défaut des SMS low cost.',
|
'description' => 'Type de SMS à employer coté Octopush, rentrez "low cost" ou "premium" selon le type de SMS que vous souhaitez employer. Laissez vide pour utiliser par défaut des SMS low cost.',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -233,16 +231,15 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'text' => $text,
|
'text' => $text,
|
||||||
'recipients' => [['phone_number' => $destination]],
|
'recipients' => [['phone_number' => $destination]],
|
||||||
'sms_type' => $this->sms_type,
|
'sms_type' => $this->sms_type,
|
||||||
'purpose' => 'alert',
|
'purpose' => 'alert',
|
||||||
'sender' => $this->number,
|
'sender' => $this->number,
|
||||||
'with_replies' => "True",
|
'with_replies' => 'True',
|
||||||
];
|
];
|
||||||
|
|
||||||
$data = json_encode($data);
|
$data = json_encode($data);
|
||||||
|
|
||||||
|
|
||||||
$endpoint = $this->api_url . '/sms-campaign/send';
|
$endpoint = $this->api_url . '/sms-campaign/send';
|
||||||
|
|
||||||
$curl = curl_init();
|
$curl = curl_init();
|
||||||
|
@ -252,7 +249,7 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
|
||||||
curl_setopt($curl, CURLOPT_POST, true);
|
curl_setopt($curl, CURLOPT_POST, true);
|
||||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
|
||||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
||||||
|
|
||||||
$curl_response = curl_exec($curl);
|
$curl_response = curl_exec($curl);
|
||||||
$http_code = (int) curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
$http_code = (int) curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||||
curl_close($curl);
|
curl_close($curl);
|
||||||
|
@ -325,7 +322,7 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$headers = [
|
$headers = [
|
||||||
'api-login: ' . $this->login,
|
'api-login: ' . $this->login,
|
||||||
'api-key: ' . $this->api_key,
|
'api-key: ' . $this->api_key,
|
||||||
|
@ -343,7 +340,7 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
|
||||||
$http_code = (int) curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
$http_code = (int) curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||||
curl_close($curl);
|
curl_close($curl);
|
||||||
|
|
||||||
if ($http_code !== 200)
|
if (200 !== $http_code)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -362,14 +359,13 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
|
||||||
header('Content-Encoding: none');
|
header('Content-Encoding: none');
|
||||||
header('Content-Length: 0');
|
header('Content-Length: 0');
|
||||||
|
|
||||||
|
|
||||||
$input = file_get_contents('php://input');
|
$input = file_get_contents('php://input');
|
||||||
$content = json_decode($input, true);
|
$content = json_decode($input, true);
|
||||||
if (null === $content)
|
if (null === $content)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$uid = $content['message_id'] ?? false;
|
$uid = $content['message_id'] ?? false;
|
||||||
$status = $content['status'] ?? false;
|
$status = $content['status'] ?? false;
|
||||||
|
|
||||||
|
@ -378,7 +374,6 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
switch ($status)
|
switch ($status)
|
||||||
{
|
{
|
||||||
case 'DELIVERED':
|
case 'DELIVERED':
|
||||||
|
@ -413,14 +408,14 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
|
||||||
header('Connection: close');
|
header('Connection: close');
|
||||||
header('Content-Encoding: none');
|
header('Content-Encoding: none');
|
||||||
header('Content-Length: 0');
|
header('Content-Length: 0');
|
||||||
|
|
||||||
$input = file_get_contents('php://input');
|
$input = file_get_contents('php://input');
|
||||||
$content = json_decode($input, true);
|
$content = json_decode($input, true);
|
||||||
if (null === $content)
|
if (null === $content)
|
||||||
{
|
{
|
||||||
$response['error'] = true;
|
$response['error'] = true;
|
||||||
$response['error_message'] = 'Cannot read input data from callback request.';
|
$response['error_message'] = 'Cannot read input data from callback request.';
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,7 @@ namespace controllers\internals;
|
||||||
/**
|
/**
|
||||||
* Get the model for the Controller.
|
* 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);
|
$this->model = $this->model ?? new \models\Call($this->bdd);
|
||||||
|
|
||||||
|
|
|
@ -150,7 +150,7 @@ namespace controllers\internals;
|
||||||
/**
|
/**
|
||||||
* Get the model for the Controller.
|
* 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);
|
$this->model = $this->model ?? new \models\Command($this->bdd);
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,7 @@ namespace controllers\internals;
|
||||||
/**
|
/**
|
||||||
* Get the model for the Controller.
|
* 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);
|
$this->model = $this->model ?? new \models\ConditionalGroup($this->bdd);
|
||||||
|
|
||||||
|
|
|
@ -351,7 +351,7 @@ namespace controllers\internals;
|
||||||
/**
|
/**
|
||||||
* Get the model for the Controller.
|
* 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);
|
$this->model = $this->model ?? new \models\Contact($this->bdd);
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ namespace controllers\internals;
|
||||||
/**
|
/**
|
||||||
* Get the model for the Controller.
|
* 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);
|
$this->model = $this->model ?? new \models\Event($this->bdd);
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ namespace controllers\internals;
|
||||||
/**
|
/**
|
||||||
* Get the model for the Controller.
|
* 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);
|
$this->model = $this->model ?? new \models\Group($this->bdd);
|
||||||
|
|
||||||
|
|
|
@ -313,7 +313,7 @@ class Media extends StandardController
|
||||||
/**
|
/**
|
||||||
* Get the model for the Controller.
|
* 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);
|
$this->model = $this->model ?? new \models\Media($this->bdd);
|
||||||
|
|
||||||
|
|
|
@ -166,7 +166,7 @@ namespace controllers\internals;
|
||||||
/**
|
/**
|
||||||
* Get the model for the Controller.
|
* 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);
|
$this->model = $this->model ?? new \models\Phone($this->bdd);
|
||||||
|
|
||||||
|
|
|
@ -288,7 +288,7 @@ class Quota extends StandardController
|
||||||
/**
|
/**
|
||||||
* Get the model for the Controller.
|
* 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);
|
$this->model = $this->model ?? new \models\Quota($this->bdd);
|
||||||
|
|
||||||
|
|
|
@ -18,15 +18,15 @@ namespace controllers\internals;
|
||||||
/**
|
/**
|
||||||
* Return the list of entries for a user.
|
* Return the list of entries for a user.
|
||||||
*
|
*
|
||||||
* @param int $id_user : User id
|
* @param int $id_user : User id
|
||||||
* @param ?int $limit : Number of entry to return
|
* @param ?int $limit : Number of entry to return
|
||||||
* @param ?int $offset : Number of entry to avoid
|
* @param ?int $offset : Number of entry to avoid
|
||||||
* @param ?string $search : String to search for
|
* @param ?string $search : String to search for
|
||||||
* @param ?array $search_columns : List of columns to search on
|
* @param ?array $search_columns : List of columns to search on
|
||||||
* @param ?string $order_column : Name of the column to order by
|
* @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 $order_desc : Should result be ordered DESC, if false order ASC
|
||||||
* @param bool $count : Should the query only count results
|
* @param bool $count : Should the query only count results
|
||||||
* @param bool $unread : Should only unread messages be returned
|
* @param bool $unread : Should only unread messages be returned
|
||||||
*
|
*
|
||||||
* @return array : Entrys list
|
* @return array : Entrys list
|
||||||
*/
|
*/
|
||||||
|
@ -375,7 +375,7 @@ namespace controllers\internals;
|
||||||
/**
|
/**
|
||||||
* Get the model for the Controller.
|
* 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);
|
$this->model = $this->model ?? new \models\Received($this->bdd);
|
||||||
|
|
||||||
|
|
|
@ -544,7 +544,7 @@ namespace controllers\internals;
|
||||||
/**
|
/**
|
||||||
* Get the model for the Controller.
|
* 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);
|
$this->model = $this->model ?? new \models\Scheduled($this->bdd);
|
||||||
|
|
||||||
|
|
|
@ -14,17 +14,16 @@ namespace controllers\internals;
|
||||||
class Sended extends StandardController
|
class Sended extends StandardController
|
||||||
{
|
{
|
||||||
protected $model;
|
protected $model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @param int $id_user : User id
|
||||||
* @param int $id_user : User id
|
* @param ?int $limit : Number of entry to return
|
||||||
* @param ?int $limit : Number of entry to return
|
* @param ?int $offset : Number of entry to avoid
|
||||||
* @param ?int $offset : Number of entry to avoid
|
* @param ?string $search : String to search for
|
||||||
* @param ?string $search : String to search for
|
* @param ?array $search_columns : List of columns to search on
|
||||||
* @param ?array $search_columns : List of columns to search on
|
* @param ?string $order_column : Name of the column to order by
|
||||||
* @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 $order_desc : Should result be ordered DESC, if false order ASC
|
* @param bool $count : Should the query only count results
|
||||||
* @param bool $count : Should the query only count results
|
|
||||||
*
|
*
|
||||||
* @return array : Entries list
|
* @return array : Entries list
|
||||||
*/
|
*/
|
||||||
|
@ -307,7 +306,7 @@ namespace controllers\internals;
|
||||||
/**
|
/**
|
||||||
* Get the model for the Controller.
|
* 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);
|
$this->model = $this->model ?? new \models\Sended($this->bdd);
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ namespace controllers\internals;
|
||||||
/**
|
/**
|
||||||
* Get the model for the Controller.
|
* 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);
|
$this->model = $this->model ?? new \models\Setting($this->bdd);
|
||||||
|
|
||||||
|
|
|
@ -64,24 +64,25 @@ namespace controllers\internals;
|
||||||
return $this->get_model()->get_by_number_for_user($id_user, $number);
|
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.
|
* 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);
|
$this->model = $this->model ?? new \models\SmsStop($this->bdd);
|
||||||
|
|
||||||
return $this->model;
|
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';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,5 +138,5 @@ namespace controllers\internals;
|
||||||
/**
|
/**
|
||||||
* Get the model for the Controller.
|
* Get the model for the Controller.
|
||||||
*/
|
*/
|
||||||
abstract protected function get_model(): \descartes\Model;
|
abstract protected function get_model(): \models\StandardModel;
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,7 +146,7 @@ class Webhook extends StandardController
|
||||||
/**
|
/**
|
||||||
* Get the model for the Controller.
|
* 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);
|
$this->model = $this->model ?? new \models\Webhook($this->bdd);
|
||||||
|
|
||||||
|
|
|
@ -204,10 +204,11 @@ namespace controllers\publics;
|
||||||
|
|
||||||
return $this->redirect(\descartes\Router::url('Connect', 'login'));
|
return $this->redirect(\descartes\Router::url('Connect', 'login'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow to stop impersonating a user
|
* Allow to stop impersonating a user.
|
||||||
* @param mixed $csrf
|
*
|
||||||
|
* @param mixed $csrf
|
||||||
*/
|
*/
|
||||||
public function stop_impersonate()
|
public function stop_impersonate()
|
||||||
{
|
{
|
||||||
|
@ -223,6 +224,7 @@ namespace controllers\publics;
|
||||||
$_SESSION = $old_session;
|
$_SESSION = $old_session;
|
||||||
|
|
||||||
\FlashMessage\FlashMessage::push('success', 'Vous n\'incarnez plus l\'utilisateur ' . $user_email . '.');
|
\FlashMessage\FlashMessage::push('success', 'Vous n\'incarnez plus l\'utilisateur ' . $user_email . '.');
|
||||||
|
|
||||||
return $this->redirect(\descartes\Router::url('Dashboard', 'show'));
|
return $this->redirect(\descartes\Router::url('Dashboard', 'show'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,5 +164,4 @@ namespace controllers\publics;
|
||||||
|
|
||||||
return $this->redirect(\descartes\Router::url('Connect', 'login'));
|
return $this->redirect(\descartes\Router::url('Connect', 'login'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,12 +48,12 @@ namespace controllers\publics;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return receiveds as json.
|
* Return receiveds as json.
|
||||||
*
|
*
|
||||||
* @param bool $unread : Should we only search for unread messages
|
* @param bool $unread : Should we only search for unread messages
|
||||||
*/
|
*/
|
||||||
public function list_json(bool $unread = false)
|
public function list_json(bool $unread = false)
|
||||||
{
|
{
|
||||||
$draw = (int)($_GET['draw'] ?? false);
|
$draw = (int) ($_GET['draw'] ?? false);
|
||||||
|
|
||||||
$columns = [
|
$columns = [
|
||||||
0 => 'searchable_origin',
|
0 => 'searchable_origin',
|
||||||
|
|
|
@ -53,8 +53,7 @@ namespace controllers\publics;
|
||||||
*/
|
*/
|
||||||
public function list_json()
|
public function list_json()
|
||||||
{
|
{
|
||||||
|
$draw = (int) ($_GET['draw'] ?? false);
|
||||||
$draw = (int)($_GET['draw'] ?? false);
|
|
||||||
|
|
||||||
$columns = [
|
$columns = [
|
||||||
0 => 'phone_name',
|
0 => 'phone_name',
|
||||||
|
|
|
@ -410,13 +410,13 @@ class User extends \descartes\Controller
|
||||||
return $this->redirect(\descartes\Router::url('User', 'list'));
|
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 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
|
* @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))
|
if (!$this->verify_csrf($csrf))
|
||||||
{
|
{
|
||||||
|
@ -425,7 +425,7 @@ class User extends \descartes\Controller
|
||||||
return $this->redirect(\descartes\Router::url('User', 'list'));
|
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 !');
|
\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;
|
$user['settings'] = $settings;
|
||||||
|
|
||||||
//Save old session to get it back later
|
//Save old session to get it back later
|
||||||
$old_session = $_SESSION;
|
$old_session = $_SESSION;
|
||||||
$_SESSION = [
|
$_SESSION = [
|
||||||
'old_session' => $old_session,
|
'old_session' => $old_session,
|
||||||
'impersonate' => true,
|
'impersonate' => true,
|
||||||
'connect' => true,
|
'connect' => true,
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
];
|
];
|
||||||
|
|
||||||
\FlashMessage\FlashMessage::push('success', 'Vous incarnez désormais l\'utilisateur ' . $user['email'] . '.');
|
\FlashMessage\FlashMessage::push('success', 'Vous incarnez désormais l\'utilisateur ' . $user['email'] . '.');
|
||||||
|
|
||||||
return $this->redirect(\descartes\Router::url('Dashboard', 'show'));
|
return $this->redirect(\descartes\Router::url('Dashboard', 'show'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,15 +20,15 @@ namespace models;
|
||||||
const STATUS_READ = 'read';
|
const STATUS_READ = 'read';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $id_user : User id
|
* @param int $id_user : User id
|
||||||
* @param ?int $limit : Number of entry to return
|
* @param ?int $limit : Number of entry to return
|
||||||
* @param ?int $offset : Number of entry to avoid
|
* @param ?int $offset : Number of entry to avoid
|
||||||
* @param ?string $search : String to search for
|
* @param ?string $search : String to search for
|
||||||
* @param ?array $search_columns : List of columns to search on
|
* @param ?array $search_columns : List of columns to search on
|
||||||
* @param ?string $order_column : Name of the column to order by
|
* @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 $order_desc : Should result be ordered DESC, if false order ASC
|
||||||
* @param bool $count : Should the query only count results
|
* @param bool $count : Should the query only count results
|
||||||
* @param bool $unread : Should only unread messages be returned
|
* @param bool $unread : Should only unread messages be returned
|
||||||
*
|
*
|
||||||
* @return array : Entrys list
|
* @return array : Entrys list
|
||||||
*/
|
*/
|
||||||
|
@ -57,9 +57,9 @@ namespace models;
|
||||||
{
|
{
|
||||||
$like_search = '%' . str_replace(['\\', '%', '_'], ['\\\\', '\%', '\_'], $search) . '%';
|
$like_search = '%' . str_replace(['\\', '%', '_'], ['\\\\', '\%', '\_'], $search) . '%';
|
||||||
$params[':like_search'] = $like_search;
|
$params[':like_search'] = $like_search;
|
||||||
|
|
||||||
$query .= ' WHERE (0';
|
$query .= ' WHERE (0';
|
||||||
|
|
||||||
foreach ($search_columns as $column)
|
foreach ($search_columns as $column)
|
||||||
{
|
{
|
||||||
$query .= ' OR ' . $column . ' LIKE :like_search';
|
$query .= ' OR ' . $column . ' LIKE :like_search';
|
||||||
|
@ -85,7 +85,7 @@ namespace models;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ($count ? $this->_run_query($query, $params)[0]['nb'] ?? 0 : $this->_run_query($query, $params)) ;
|
return $count ? $this->_run_query($query, $params)[0]['nb'] ?? 0 : $this->_run_query($query, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -48,15 +48,15 @@ namespace models;
|
||||||
ON phone.id = sended.id_phone
|
ON phone.id = sended.id_phone
|
||||||
WHERE sended.id_user = :id_user
|
WHERE sended.id_user = :id_user
|
||||||
) as results
|
) as results
|
||||||
';
|
';
|
||||||
|
|
||||||
if ($search && $search_columns)
|
if ($search && $search_columns)
|
||||||
{
|
{
|
||||||
$like_search = '%' . str_replace(['\\', '%', '_'], ['\\\\', '\%', '\_'], $search) . '%';
|
$like_search = '%' . str_replace(['\\', '%', '_'], ['\\\\', '\%', '\_'], $search) . '%';
|
||||||
$params[':like_search'] = $like_search;
|
$params[':like_search'] = $like_search;
|
||||||
|
|
||||||
$query .= ' WHERE (0';
|
$query .= ' WHERE (0';
|
||||||
|
|
||||||
foreach ($search_columns as $column)
|
foreach ($search_columns as $column)
|
||||||
{
|
{
|
||||||
$query .= ' OR ' . $column . ' LIKE :like_search';
|
$query .= ' OR ' . $column . ' LIKE :like_search';
|
||||||
|
@ -82,7 +82,7 @@ namespace models;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ($count ? $this->_run_query($query, $params)[0]['nb'] ?? 0 : $this->_run_query($query, $params)) ;
|
return $count ? $this->_run_query($query, $params)[0]['nb'] ?? 0 : $this->_run_query($query, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -83,6 +83,7 @@ jQuery(document).ready(function ()
|
||||||
"language": {
|
"language": {
|
||||||
"url": HTTP_PWD + "/assets/js/datatables/french.json",
|
"url": HTTP_PWD + "/assets/js/datatables/french.json",
|
||||||
},
|
},
|
||||||
|
"orderMulti": false,
|
||||||
"columnDefs": [{
|
"columnDefs": [{
|
||||||
'targets': 'checkcolumn',
|
'targets': 'checkcolumn',
|
||||||
'orderable': false,
|
'orderable': false,
|
||||||
|
|
|
@ -73,6 +73,7 @@ jQuery(document).ready(function ()
|
||||||
"language": {
|
"language": {
|
||||||
"url": HTTP_PWD + "/assets/js/datatables/french.json",
|
"url": HTTP_PWD + "/assets/js/datatables/french.json",
|
||||||
},
|
},
|
||||||
|
"orderMulti": false,
|
||||||
"columnDefs": [{
|
"columnDefs": [{
|
||||||
'targets': 'checkcolumn',
|
'targets': 'checkcolumn',
|
||||||
'orderable': false,
|
'orderable': false,
|
||||||
|
|
|
@ -86,9 +86,9 @@ jQuery(document).ready(function ()
|
||||||
"columns" : [
|
"columns" : [
|
||||||
{
|
{
|
||||||
data: 'number_formatted',
|
data: 'number_formatted',
|
||||||
},
|
}
|
||||||
<?php if ($_SESSION['user']['admin'] ?? false) { ?>
|
<?php if ($_SESSION['user']['admin'] ?? false) { ?>
|
||||||
{
|
,{
|
||||||
data: 'id',
|
data: 'id',
|
||||||
render: function (data, type, row, meta) {
|
render: function (data, type, row, meta) {
|
||||||
return '<input name="ids[]" type="checkbox" value="' + data + '">';
|
return '<input name="ids[]" type="checkbox" value="' + data + '">';
|
||||||
|
|
Loading…
Reference in New Issue