rename all instances of 'datas' to 'data'

This commit is contained in:
osaajani 2021-01-17 03:16:57 +01:00
parent 730ac8963b
commit 61d644c247
48 changed files with 316 additions and 316 deletions

4
.gitignore vendored
View File

@ -8,7 +8,7 @@ composer.lock
env.* env.*
phinx.* phinx.*
datas/test_write_sms.json data/test_write_sms.json
datas/test_read_sms.json data/test_read_sms.json
!*.dist !*.dist

View File

@ -23,9 +23,9 @@ namespace adapters;
/** /**
* Adapter constructor, called when instanciated by RaspiSMS. * Adapter constructor, called when instanciated by RaspiSMS.
* *
* @param json string $datas : JSON string of the datas to configure interaction with the implemented service * @param json string $data : JSON string of the data to configure interaction with the implemented service
*/ */
public function __construct(string $datas); public function __construct(string $data);
/** /**
* Classname of the adapter. * Classname of the adapter.
@ -51,11 +51,11 @@ namespace adapters;
public static function meta_description(): string; public static function meta_description(): string;
/** /**
* List of entries we want in datas for the adapter. * List of entries we want in data for the adapter.
* *
* @return array : Eachline line is a field as an array with keys : name, title, description, required * @return array : Eachline line is a field as an array with keys : name, title, description, required
*/ */
public static function meta_datas_fields(): array; public static function meta_data_fields(): array;
/** /**
* Does the implemented service support flash smss. * Does the implemented service support flash smss.

View File

@ -21,9 +21,9 @@ namespace adapters;
class BenchmarkAdapter implements AdapterInterface class BenchmarkAdapter implements AdapterInterface
{ {
/** /**
* Datas used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.). * Data used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.).
*/ */
private $datas; private $data;
/** /**
* API URL. * API URL.
@ -33,11 +33,11 @@ namespace adapters;
/** /**
* Adapter constructor, called when instanciated by RaspiSMS. * Adapter constructor, called when instanciated by RaspiSMS.
* *
* @param json string $datas : JSON string of the datas to configure interaction with the implemented service * @param json string $data : JSON string of the data to configure interaction with the implemented service
*/ */
public function __construct(string $datas) public function __construct(string $data)
{ {
$this->datas = $datas; $this->data = $data;
} }
/** /**
@ -76,11 +76,11 @@ namespace adapters;
} }
/** /**
* List of entries we want in datas for the adapter. * List of entries we want in data for the adapter.
* *
* @return array : Eachline line is a field as an array with keys : name, title, description, required * @return array : Eachline line is a field as an array with keys : name, title, description, required
*/ */
public static function meta_datas_fields(): array public static function meta_data_fields(): array
{ {
return []; return [];
} }
@ -140,7 +140,7 @@ namespace adapters;
try try
{ {
$datas = [ $data = [
'sms_text' => $text, 'sms_text' => $text,
'sms_destination' => $destination, 'sms_destination' => $destination,
'sms_flash' => $flash, 'sms_flash' => $flash,
@ -153,7 +153,7 @@ namespace adapters;
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($datas)); curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
$curl_response = curl_exec($curl); $curl_response = curl_exec($curl);
curl_close($curl); curl_close($curl);

View File

@ -21,18 +21,18 @@ namespace adapters;
class GammuAdapter implements AdapterInterface class GammuAdapter implements AdapterInterface
{ {
/** /**
* Datas used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.). * Data used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.).
*/ */
private $datas; private $data;
/** /**
* Adapter constructor, called when instanciated by RaspiSMS. * Adapter constructor, called when instanciated by RaspiSMS.
* *
* @param json string $datas : JSON string of the datas to configure interaction with the implemented service * @param json string $data : JSON string of the data to configure interaction with the implemented service
*/ */
public function __construct(string $datas) public function __construct(string $data)
{ {
$this->datas = json_decode($datas, true); $this->data = json_decode($data, true);
} }
/** /**
@ -73,11 +73,11 @@ namespace adapters;
} }
/** /**
* List of entries we want in datas for the adapter. * List of entries we want in data for the adapter.
* *
* @return array : Every line is a field as an array with keys : name, title, description, required * @return array : Every line is a field as an array with keys : name, title, description, required
*/ */
public static function meta_datas_fields(): array public static function meta_data_fields(): array
{ {
return [ return [
[ [
@ -159,7 +159,7 @@ namespace adapters;
$command_parts = [ $command_parts = [
'gammu', 'gammu',
'--config', '--config',
escapeshellarg($this->datas['config_file']), escapeshellarg($this->data['config_file']),
'sendsms', 'sendsms',
'TEXT', 'TEXT',
escapeshellarg($destination), escapeshellarg($destination),
@ -248,7 +248,7 @@ namespace adapters;
$command_parts = [ $command_parts = [
PWD . '/bin/gammu_get_unread_sms.py', PWD . '/bin/gammu_get_unread_sms.py',
escapeshellarg($this->datas['config_file']), escapeshellarg($this->data['config_file']),
]; ];
$return = $this->exec_command($command_parts); $return = $this->exec_command($command_parts);
@ -326,7 +326,7 @@ namespace adapters;
*/ */
private function unlock_sim(): bool private function unlock_sim(): bool
{ {
if (!$this->datas['pin']) if (!$this->data['pin'])
{ {
return true; return true;
} }
@ -334,10 +334,10 @@ namespace adapters;
$command_parts = [ $command_parts = [
'gammu', 'gammu',
'--config', '--config',
escapeshellarg($this->datas['config_file']), escapeshellarg($this->data['config_file']),
'entersecuritycode', 'entersecuritycode',
'PIN', 'PIN',
escapeshellarg($this->datas['pin']), escapeshellarg($this->data['pin']),
]; ];
$result = $this->exec_command($command_parts); $result = $this->exec_command($command_parts);
@ -346,7 +346,7 @@ namespace adapters;
$command_parts = [ $command_parts = [
'gammu', 'gammu',
'--config', '--config',
escapeshellarg($this->datas['config_file']), escapeshellarg($this->data['config_file']),
'getsecuritystatus', 'getsecuritystatus',
]; ];

View File

@ -22,9 +22,9 @@ class OctopushShortcodeAdapter implements AdapterInterface
const SMS_TYPE_INTERNATIONAL = 'WWW'; const SMS_TYPE_INTERNATIONAL = 'WWW';
/** /**
* Datas used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.). * Data used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.).
*/ */
private $datas; private $data;
/** /**
* Octopush login. * Octopush login.
@ -50,15 +50,15 @@ class OctopushShortcodeAdapter implements AdapterInterface
* Adapter constructor, called when instanciated by RaspiSMS. * Adapter constructor, called when instanciated by RaspiSMS.
* *
* @param string $number : Phone number the adapter is used for * @param string $number : Phone number the adapter is used for
* @param json string $datas : JSON string of the datas to configure interaction with the implemented service * @param json string $data : JSON string of the data to configure interaction with the implemented service
*/ */
public function __construct(string $datas) public function __construct(string $data)
{ {
$this->datas = json_decode($datas, true); $this->data = json_decode($data, true);
$this->login = $this->datas['login']; $this->login = $this->data['login'];
$this->api_key = $this->datas['api_key']; $this->api_key = $this->data['api_key'];
$this->sender = $this->datas['sender'] ?? null; $this->sender = $this->data['sender'] ?? null;
} }
/** /**
@ -102,11 +102,11 @@ class OctopushShortcodeAdapter implements AdapterInterface
} }
/** /**
* List of entries we want in datas for the adapter. * List of entries we want in data for the adapter.
* *
* @return array : Every line is a field as an array with keys : name, title, description, required * @return array : Every line is a field as an array with keys : name, title, description, required
*/ */
public static function meta_datas_fields(): array public static function meta_data_fields(): array
{ {
return [ return [
[ [
@ -187,7 +187,7 @@ class OctopushShortcodeAdapter implements AdapterInterface
try try
{ {
$datas = [ $data = [
'user_login' => $this->login, 'user_login' => $this->login,
'api_key' => $this->api_key, 'api_key' => $this->api_key,
'sms_text' => $text, 'sms_text' => $text,
@ -198,7 +198,7 @@ class OctopushShortcodeAdapter implements AdapterInterface
if (null !== $this->sender) if (null !== $this->sender)
{ {
$datas['sms_sender'] = $this->sender; $data['sms_sender'] = $this->sender;
} }
$endpoint = $this->api_url . '/sms/json'; $endpoint = $this->api_url . '/sms/json';
@ -208,7 +208,7 @@ class OctopushShortcodeAdapter implements AdapterInterface
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $datas); curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($curl); $response = curl_exec($curl);
curl_close($curl); curl_close($curl);
@ -285,12 +285,12 @@ class OctopushShortcodeAdapter implements AdapterInterface
{ {
$success = true; $success = true;
if ($this->datas['sender'] && (mb_strlen($this->datas['sender']) < 3 || mb_strlen($this->datas['sender'] > 11))) if ($this->data['sender'] && (mb_strlen($this->data['sender']) < 3 || mb_strlen($this->data['sender'] > 11)))
{ {
return false; return false;
} }
$datas = [ $data = [
'user_login' => $this->login, 'user_login' => $this->login,
'api_key' => $this->api_key, 'api_key' => $this->api_key,
]; ];
@ -302,7 +302,7 @@ class OctopushShortcodeAdapter implements AdapterInterface
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $datas); curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($curl); $response = curl_exec($curl);
curl_close($curl); curl_close($curl);

View File

@ -22,9 +22,9 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
const SMS_TYPE_INTERNATIONAL = 'WWW'; const SMS_TYPE_INTERNATIONAL = 'WWW';
/** /**
* Datas used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.). * Data used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.).
*/ */
private $datas; private $data;
/** /**
* Octopush login. * Octopush login.
@ -55,16 +55,16 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
* Adapter constructor, called when instanciated by RaspiSMS. * Adapter constructor, called when instanciated by RaspiSMS.
* *
* @param string $number : Phone number the adapter is used for * @param string $number : Phone number the adapter is used for
* @param json string $datas : JSON string of the datas to configure interaction with the implemented service * @param json string $data : JSON string of the data to configure interaction with the implemented service
*/ */
public function __construct(string $datas) public function __construct(string $data)
{ {
$this->datas = json_decode($datas, true); $this->data = json_decode($data, true);
$this->login = $this->datas['login']; $this->login = $this->data['login'];
$this->api_key = $this->datas['api_key']; $this->api_key = $this->data['api_key'];
$this->number = $this->datas['number']; $this->number = $this->data['number'];
$this->formatted_number = '+' . mb_substr($this->datas['number'], 2); $this->formatted_number = '+' . mb_substr($this->data['number'], 2);
} }
/** /**
@ -108,11 +108,11 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
} }
/** /**
* List of entries we want in datas for the adapter. * List of entries we want in data for the adapter.
* *
* @return array : Every line is a field as an array with keys : name, title, description, required * @return array : Every line is a field as an array with keys : name, title, description, required
*/ */
public static function meta_datas_fields(): array public static function meta_data_fields(): array
{ {
return [ return [
[ [
@ -192,7 +192,7 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
try try
{ {
$datas = [ $data = [
'user_login' => $this->login, 'user_login' => $this->login,
'api_key' => $this->api_key, 'api_key' => $this->api_key,
'sms_text' => $text, 'sms_text' => $text,
@ -208,7 +208,7 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $datas); curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($curl); $response = curl_exec($curl);
curl_close($curl); curl_close($curl);
@ -285,12 +285,12 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
{ {
$success = true; $success = true;
if ($this->datas['sender'] && (mb_strlen($this->datas['sender']) < 3 || mb_strlen($this->datas['sender'] > 11))) if ($this->data['sender'] && (mb_strlen($this->data['sender']) < 3 || mb_strlen($this->data['sender'] > 11)))
{ {
return false; return false;
} }
$datas = [ $data = [
'user_login' => $this->login, 'user_login' => $this->login,
'api_key' => $this->api_key, 'api_key' => $this->api_key,
]; ];
@ -302,7 +302,7 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $datas); curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($curl); $response = curl_exec($curl);
curl_close($curl); curl_close($curl);

View File

@ -19,9 +19,9 @@ namespace adapters;
class OvhSmsShortcodeAdapter implements AdapterInterface class OvhSmsShortcodeAdapter implements AdapterInterface
{ {
/** /**
* Datas used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.). * Data used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.).
*/ */
private $datas; private $data;
/** /**
* OVH Api instance. * OVH Api instance.
@ -32,17 +32,17 @@ namespace adapters;
* Adapter constructor, called when instanciated by RaspiSMS. * Adapter constructor, called when instanciated by RaspiSMS.
* *
* @param string $number : Phone number the adapter is used for * @param string $number : Phone number the adapter is used for
* @param json string $datas : JSON string of the datas to configure interaction with the implemented service * @param json string $data : JSON string of the data to configure interaction with the implemented service
*/ */
public function __construct(string $datas) public function __construct(string $data)
{ {
$this->datas = json_decode($datas, true); $this->data = json_decode($data, true);
$this->api = new Api( $this->api = new Api(
$this->datas['app_key'], $this->data['app_key'],
$this->datas['app_secret'], $this->data['app_secret'],
'ovh-eu', 'ovh-eu',
$this->datas['consumer_key'] $this->data['consumer_key']
); );
} }
@ -87,11 +87,11 @@ namespace adapters;
} }
/** /**
* List of entries we want in datas for the adapter. * List of entries we want in data for the adapter.
* *
* @return array : Every line is a field as an array with keys : name, title, description, required * @return array : Every line is a field as an array with keys : name, title, description, required
*/ */
public static function meta_datas_fields(): array public static function meta_data_fields(): array
{ {
return [ return [
[ [
@ -186,16 +186,16 @@ namespace adapters;
{ {
$success = true; $success = true;
$endpoint = '/sms/' . $this->datas['service_name'] . '/jobs'; $endpoint = '/sms/' . $this->data['service_name'] . '/jobs';
$params = [ $params = [
'message' => $text, 'message' => $text,
'receivers' => [$destination], 'receivers' => [$destination],
'senderForResponse' => true, 'senderForResponse' => true,
]; ];
if ($this->datas['sender']) if ($this->data['sender'])
{ {
$params['sender'] = $this->datas['sender']; $params['sender'] = $this->data['sender'];
$params['senderForResponse'] = false; $params['senderForResponse'] = false;
} }
@ -252,12 +252,12 @@ namespace adapters;
try try
{ {
//If we use a sender we cannot receive response, no need to make queries //If we use a sender we cannot receive response, no need to make queries
if ($this->datas['sended']) if ($this->data['sended'])
{ {
return $response; return $response;
} }
$endpoint = '/sms/' . $this->datas['service_name'] . '/incoming'; $endpoint = '/sms/' . $this->data['service_name'] . '/incoming';
$uids = $this->api->get($endpoint); $uids = $this->api->get($endpoint);
if (!\is_array($uids) || !$uids) if (!\is_array($uids) || !$uids)
@ -267,7 +267,7 @@ namespace adapters;
foreach ($uids as $uid) foreach ($uids as $uid)
{ {
$endpoint = '/sms/' . $this->datas['service_name'] . '/incoming/' . $uid; $endpoint = '/sms/' . $this->data['service_name'] . '/incoming/' . $uid;
$sms_details = $this->api->get($endpoint); $sms_details = $this->api->get($endpoint);
if (!isset($sms_details['creationDatetime'], $sms_details['message'], $sms_details['sender'])) if (!isset($sms_details['creationDatetime'], $sms_details['message'], $sms_details['sender']))
@ -282,7 +282,7 @@ namespace adapters;
]; ];
//Remove the sms to prevent double reading as ovh do not offer a filter for unread messages only //Remove the sms to prevent double reading as ovh do not offer a filter for unread messages only
$endpoint = '/sms/' . $this->datas['service_name'] . '/incoming/' . $uid; $endpoint = '/sms/' . $this->data['service_name'] . '/incoming/' . $uid;
$this->api->delete($endpoint); $this->api->delete($endpoint);
} }
@ -309,13 +309,13 @@ namespace adapters;
{ {
$success = true; $success = true;
if ($this->datas['sender'] && (mb_strlen($this->datas['sender']) < 3 || mb_strlen($this->datas['sender'] > 11))) if ($this->data['sender'] && (mb_strlen($this->data['sender']) < 3 || mb_strlen($this->data['sender'] > 11)))
{ {
return false; return false;
} }
//Check service name //Check service name
$endpoint = '/sms/' . $this->datas['service_name']; $endpoint = '/sms/' . $this->data['service_name'];
$response = $this->api->get($endpoint); $response = $this->api->get($endpoint);
return $success && (bool) $response; return $success && (bool) $response;

View File

@ -19,9 +19,9 @@ namespace adapters;
class OvhSmsVirtualNumberAdapter implements AdapterInterface class OvhSmsVirtualNumberAdapter implements AdapterInterface
{ {
/** /**
* Datas used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.). * Data used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.).
*/ */
private $datas; private $data;
/** /**
* OVH Api instance. * OVH Api instance.
@ -41,20 +41,20 @@ namespace adapters;
/** /**
* Adapter constructor, called when instanciated by RaspiSMS. * Adapter constructor, called when instanciated by RaspiSMS.
* *
* @param json string $datas : JSON string of the datas to configure interaction with the implemented service * @param json string $data : JSON string of the data to configure interaction with the implemented service
*/ */
public function __construct(string $datas) public function __construct(string $data)
{ {
$this->datas = json_decode($datas, true); $this->data = json_decode($data, true);
$this->api = new Api( $this->api = new Api(
$this->datas['app_key'], $this->data['app_key'],
$this->datas['app_secret'], $this->data['app_secret'],
'ovh-eu', 'ovh-eu',
$this->datas['consumer_key'] $this->data['consumer_key']
); );
$this->number = $this->datas['number']; $this->number = $this->data['number'];
$this->formatted_number = str_replace('+', '00', $this->number); $this->formatted_number = str_replace('+', '00', $this->number);
} }
@ -99,11 +99,11 @@ namespace adapters;
} }
/** /**
* List of entries we want in datas for the adapter. * List of entries we want in data for the adapter.
* *
* @return array : Every line is a field as an array with keys : name, title, description, required * @return array : Every line is a field as an array with keys : name, title, description, required
*/ */
public static function meta_datas_fields(): array public static function meta_data_fields(): array
{ {
return [ return [
[ [
@ -197,7 +197,7 @@ namespace adapters;
{ {
$success = true; $success = true;
$endpoint = '/sms/' . $this->datas['service_name'] . '/virtualNumbers/' . $this->formatted_number . '/jobs'; $endpoint = '/sms/' . $this->data['service_name'] . '/virtualNumbers/' . $this->formatted_number . '/jobs';
$params = [ $params = [
'message' => $text, 'message' => $text,
'receivers' => [$destination], 'receivers' => [$destination],
@ -255,7 +255,7 @@ namespace adapters;
try try
{ {
$endpoint = '/sms/' . $this->datas['service_name'] . '/virtualNumbers/' . $this->formatted_number . '/incoming'; $endpoint = '/sms/' . $this->data['service_name'] . '/virtualNumbers/' . $this->formatted_number . '/incoming';
$uids = $this->api->get($endpoint); $uids = $this->api->get($endpoint);
if (!\is_array($uids) || !$uids) if (!\is_array($uids) || !$uids)
@ -265,7 +265,7 @@ namespace adapters;
foreach ($uids as $uid) foreach ($uids as $uid)
{ {
$endpoint = '/sms/' . $this->datas['service_name'] . '/virtualNumbers/' . $this->formatted_number . '/incoming/' . $uid; $endpoint = '/sms/' . $this->data['service_name'] . '/virtualNumbers/' . $this->formatted_number . '/incoming/' . $uid;
$sms_details = $this->api->get($endpoint); $sms_details = $this->api->get($endpoint);
if (!isset($sms_details['creationDatetime'], $sms_details['message'], $sms_details['sender'])) if (!isset($sms_details['creationDatetime'], $sms_details['message'], $sms_details['sender']))
@ -280,7 +280,7 @@ namespace adapters;
]; ];
//Remove the sms to prevent double reading as ovh do not offer a filter for unread messages only //Remove the sms to prevent double reading as ovh do not offer a filter for unread messages only
$endpoint = '/sms/' . $this->datas['service_name'] . '/virtualNumbers/' . $this->formatted_number . '/incoming/' . $uid; $endpoint = '/sms/' . $this->data['service_name'] . '/virtualNumbers/' . $this->formatted_number . '/incoming/' . $uid;
$this->api->delete($endpoint); $this->api->delete($endpoint);
} }
@ -309,7 +309,7 @@ namespace adapters;
$success = true; $success = true;
//Check service name //Check service name
$endpoint = '/sms/' . $this->datas['service_name']; $endpoint = '/sms/' . $this->data['service_name'];
$response = $this->api->get($endpoint); $response = $this->api->get($endpoint);
$success = $success && (bool) $response; $success = $success && (bool) $response;

View File

@ -21,28 +21,28 @@ namespace adapters;
class TestAdapter implements AdapterInterface class TestAdapter implements AdapterInterface
{ {
/** /**
* Datas used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.). * Data used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.).
*/ */
private $datas; private $data;
/** /**
* Path for the file to read sms as a json from. * Path for the file to read sms as a json from.
*/ */
private $test_file_read = PWD_DATAS . '/test_read_sms.json'; private $test_file_read = PWD_DATA . '/test_read_sms.json';
/** /**
* Path for the file to write sms as a json in. * Path for the file to write sms as a json in.
*/ */
private $test_file_write = PWD_DATAS . '/test_write_sms.json'; private $test_file_write = PWD_DATA . '/test_write_sms.json';
/** /**
* Adapter constructor, called when instanciated by RaspiSMS. * Adapter constructor, called when instanciated by RaspiSMS.
* *
* @param json string $datas : JSON string of the datas to configure interaction with the implemented service * @param json string $data : JSON string of the data to configure interaction with the implemented service
*/ */
public function __construct(string $datas) public function __construct(string $data)
{ {
$this->datas = $datas; $this->data = $data;
} }
/** /**
@ -81,11 +81,11 @@ namespace adapters;
} }
/** /**
* List of entries we want in datas for the adapter. * List of entries we want in data for the adapter.
* *
* @return array : Eachline line is a field as an array with keys : name, title, description, required * @return array : Eachline line is a field as an array with keys : name, title, description, required
*/ */
public static function meta_datas_fields(): array public static function meta_data_fields(): array
{ {
return []; return [];
} }

View File

@ -19,9 +19,9 @@ use Twilio\Rest\Client;
class TwilioVirtualNumberAdapter implements AdapterInterface class TwilioVirtualNumberAdapter implements AdapterInterface
{ {
/** /**
* Datas used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.). * Data used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.).
*/ */
private $datas; private $data;
/** /**
* Twilio Api client. * Twilio Api client.
@ -42,19 +42,19 @@ class TwilioVirtualNumberAdapter implements AdapterInterface
* Adapter constructor, called when instanciated by RaspiSMS. * Adapter constructor, called when instanciated by RaspiSMS.
* *
* @param string $number : Phone number the adapter is used for * @param string $number : Phone number the adapter is used for
* @param json string $datas : JSON string of the datas to configure interaction with the implemented service * @param json string $data : JSON string of the data to configure interaction with the implemented service
*/ */
public function __construct(string $datas) public function __construct(string $data)
{ {
$this->datas = json_decode($datas, true); $this->data = json_decode($data, true);
$this->client = new Client( $this->client = new Client(
$this->datas['account_sid'], $this->data['account_sid'],
$this->datas['auth_token'] $this->data['auth_token']
); );
$this->number = $this->datas['number']; $this->number = $this->data['number'];
$this->status_change_callback = $this->datas['status_change_callback']; $this->status_change_callback = $this->data['status_change_callback'];
} }
/** /**
@ -98,11 +98,11 @@ class TwilioVirtualNumberAdapter implements AdapterInterface
} }
/** /**
* List of entries we want in datas for the adapter. * List of entries we want in data for the adapter.
* *
* @return array : Every line is a field as an array with keys : name, title, description, required * @return array : Every line is a field as an array with keys : name, title, description, required
*/ */
public static function meta_datas_fields(): array public static function meta_data_fields(): array
{ {
return [ return [
[ [

View File

@ -333,29 +333,29 @@ footer img
display: inline-block !important; display: inline-block !important;
} }
.contact-datas-container input .contact-data-container input
{ {
display: inline-block; display: inline-block;
} }
.contact-datas-container .contact-data-name .contact-data-container .contact-data-name
{ {
width: 25%; width: 25%;
} }
.contact-datas-container .contact-data-value .contact-data-container .contact-data-value
{ {
width: 50%; width: 50%;
} }
.contact-datas-container .contact-datas-remove .contact-data-container .contact-data-remove
{ {
color: #c9302c; color: #c9302c;
} }
/* PHONE */ /* PHONE */
#adapter-datas-container #adapter-data-container
{ {
margin-top: 35px; margin-top: 35px;
} }
@ -365,7 +365,7 @@ footer img
margin-top: 20px; margin-top: 20px;
} }
#adapter-datas-fields #adapter-data-fields
{ {
padding-top: 15px; padding-top: 15px;
padding-left: 15px; padding-left: 15px;

View File

@ -59,13 +59,13 @@ namespace controllers\internals;
*/ */
public function update_for_user(int $id_user, int $id, string $name, string $script, bool $admin) public function update_for_user(int $id_user, int $id, string $name, string $script, bool $admin)
{ {
$datas = [ $data = [
'name' => $name, 'name' => $name,
'script' => $script, 'script' => $script,
'admin' => $admin, 'admin' => $admin,
]; ];
return $this->get_model()->update_for_user($id_user, $id, $datas); return $this->get_model()->update_for_user($id_user, $id, $data);
} }
/** /**

View File

@ -33,7 +33,7 @@ namespace controllers\internals;
]; ];
$internal_ruler = new Ruler(); $internal_ruler = new Ruler();
$valid_condition = $internal_ruler->validate_condition($condition, ['contact' => (object) ['datas' => (object) null]]); $valid_condition = $internal_ruler->validate_condition($condition, ['contact' => (object) ['data' => (object) null]]);
if (!$valid_condition) if (!$valid_condition)
{ {
return false; return false;
@ -69,7 +69,7 @@ namespace controllers\internals;
]; ];
$internal_ruler = new Ruler(); $internal_ruler = new Ruler();
$valid_condition = $internal_ruler->validate_condition($condition, ['contact' => (object) ['datas' => (object) null]]); $valid_condition = $internal_ruler->validate_condition($condition, ['contact' => (object) ['data' => (object) null]]);
if (!$valid_condition) if (!$valid_condition)
{ {
return false; return false;
@ -112,16 +112,16 @@ namespace controllers\internals;
foreach ($contacts as $key => $contact) foreach ($contacts as $key => $contact)
{ {
$contact['datas'] = json_decode($contact['datas']); $contact['data'] = json_decode($contact['data']);
$contact = (object) $contact; $contact = (object) $contact;
//Add metas of contact by adding contact without datas //Add metas of contact by adding contact without data
$metas = clone $contact; $metas = clone $contact;
$metas->datas = null; $metas->data = null;
$metas->id_user = null; $metas->id_user = null;
$datas = ['contact' => $contact->datas, 'contact_metas' => $metas]; $data = ['contact' => $contact->data, 'contact_metas' => $metas];
$is_valid = $ruler->evaluate_condition($condition, $datas); $is_valid = $ruler->evaluate_condition($condition, $data);
if (!$is_valid) if (!$is_valid)
{ {
unset($contacts[$key]); unset($contacts[$key]);

View File

@ -59,17 +59,17 @@ namespace controllers\internals;
* @param int $id_user : User id * @param int $id_user : User id
* @param string $number : Contact number * @param string $number : Contact number
* @param string $name : Contact name * @param string $name : Contact name
* @param string $datas : Contact datas * @param string $data : Contact data
* *
* @return mixed bool|int : False if cannot create contact, id of the new contact else * @return mixed bool|int : False if cannot create contact, id of the new contact else
*/ */
public function create($id_user, $number, $name, $datas) public function create($id_user, $number, $name, $data)
{ {
$contact = [ $contact = [
'id_user' => $id_user, 'id_user' => $id_user,
'number' => $number, 'number' => $number,
'name' => $name, 'name' => $name,
'datas' => $datas, 'data' => $data,
]; ];
$result = $this->get_model()->insert($contact); $result = $this->get_model()->insert($contact);
@ -91,16 +91,16 @@ namespace controllers\internals;
* @param int $id : Contact id * @param int $id : Contact id
* @param string $number : Contact number * @param string $number : Contact number
* @param string $name : Contact name * @param string $name : Contact name
* @param ?string $datas : Contact datas * @param ?string $data : Contact data
* *
* @return int : number of modified rows * @return int : number of modified rows
*/ */
public function update_for_user(int $id_user, int $id, string $number, string $name, string $datas) public function update_for_user(int $id_user, int $id, string $number, string $name, string $data)
{ {
$contact = [ $contact = [
'number' => $number, 'number' => $number,
'name' => $name, 'name' => $name,
'datas' => $datas, 'data' => $data,
]; ];
return $this->get_model()->update_for_user($id_user, $id, $contact); return $this->get_model()->update_for_user($id_user, $id, $contact);
@ -144,7 +144,7 @@ namespace controllers\internals;
continue; continue;
} }
$datas = []; $data = [];
$i = 0; $i = 0;
foreach ($line as $key => $value) foreach ($line as $key => $value)
{ {
@ -160,13 +160,13 @@ namespace controllers\internals;
} }
$key = mb_ereg_replace('[\W]', '', $key); $key = mb_ereg_replace('[\W]', '', $key);
$datas[$key] = $value; $data[$key] = $value;
} }
$datas = json_encode($datas); $data = json_encode($data);
try try
{ {
$success = $this->create($id_user, $line[array_keys($line)[1]], $line[array_keys($line)[0]], $datas); $success = $this->create($id_user, $line[array_keys($line)[1]], $line[array_keys($line)[0]], $data);
if ($success) if ($success)
{ {
++$nb_insert; ++$nb_insert;
@ -224,12 +224,12 @@ namespace controllers\internals;
continue; continue;
} }
$datas = $contact['datas'] ?? []; $data = $contact['data'] ?? [];
$datas = json_encode($datas); $data = json_encode($data);
try try
{ {
$success = $this->create($id_user, $contact['number'], $contact['name'], $datas); $success = $this->create($id_user, $contact['number'], $contact['name'], $data);
if ($success) if ($success)
{ {
++$nb_insert; ++$nb_insert;
@ -264,8 +264,8 @@ namespace controllers\internals;
foreach ($contacts as $contact) foreach ($contacts as $contact)
{ {
$datas = json_decode($contact['datas'], true); $data = json_decode($contact['data'], true);
foreach ($datas as $key => $value) foreach ($data as $key => $value)
{ {
$columns[] = $key; $columns[] = $key;
} }
@ -275,14 +275,14 @@ namespace controllers\internals;
$lines = []; $lines = [];
foreach ($contacts as $contact) foreach ($contacts as $contact)
{ {
$datas = json_decode($contact['datas'], true); $data = json_decode($contact['data'], true);
$line = [$contact['name'], $contact['number']]; $line = [$contact['name'], $contact['number']];
foreach ($columns as $column) foreach ($columns as $column)
{ {
if (isset($datas[$column])) if (isset($data[$column]))
{ {
$line[] = $datas[$column]; $line[] = $data[$column];
continue; continue;
} }
@ -327,7 +327,7 @@ namespace controllers\internals;
{ {
unset($contact['id'], $contact['id_user']); unset($contact['id'], $contact['id_user']);
$contact['datas'] = json_decode($contact['datas']); $contact['data'] = json_decode($contact['data']);
} }
$content = json_encode($contacts); $content = json_encode($contacts);

View File

@ -100,13 +100,13 @@ class Mailer extends \descartes\Controller
* *
* @param string $destination : email address to send email to * @param string $destination : email address to send email to
* @param array $settings : Email settings * @param array $settings : Email settings
* @param array $datas : Datas to inject into email template * @param array $data : Data to inject into email template
* *
* @return bool : true on success, false on error * @return bool : true on success, false on error
*/ */
public function enqueue(string $destination, array $settings, array $datas): bool public function enqueue(string $destination, array $settings, array $data): bool
{ {
$response = $this->generate_body($settings, $datas); $response = $this->generate_body($settings, $data);
$message = [ $message = [
'destinations' => [$destination], 'destinations' => [$destination],
@ -131,18 +131,18 @@ class Mailer extends \descartes\Controller
* string 'template' => Email template to use * string 'template' => Email template to use
* ?string 'alt_template' => Template to use for alt message, if null ignore * ?string 'alt_template' => Template to use for alt message, if null ignore
* ] * ]
* @param array : Datas to inject into email template * @param array : Data to inject into email template
* *
* @return array [ * @return array [
* string 'body' => email body * string 'body' => email body
* ?string 'alt_body' => email alternative body if needed * ?string 'alt_body' => email alternative body if needed
* ] * ]
*/ */
private function generate_body(array $settings, array $datas): array private function generate_body(array $settings, array $data): array
{ {
//Generate body of email //Generate body of email
ob_start(); ob_start();
$this->render($settings['template'], $datas); $this->render($settings['template'], $data);
$body = ob_get_clean(); $body = ob_get_clean();
//Generate alt body if needed //Generate alt body if needed
@ -150,7 +150,7 @@ class Mailer extends \descartes\Controller
if ($settings['alt_template'] ?? false) if ($settings['alt_template'] ?? false)
{ {
ob_start(); ob_start();
$this->render($settings['alt_template'], $datas); $this->render($settings['alt_template'], $data);
$alt_body = ob_get_clean(); $alt_body = ob_get_clean();
} }

View File

@ -39,12 +39,12 @@ namespace controllers\internals;
return false; return false;
} }
$datas = [ $data = [
'id_scheduled' => $id_scheduled, 'id_scheduled' => $id_scheduled,
'path' => $result_upload_media['content'], 'path' => $result_upload_media['content'],
]; ];
return (bool) $this->get_model()->insert($datas); return (bool) $this->get_model()->insert($data);
} }
/** /**

View File

@ -58,17 +58,17 @@ namespace controllers\internals;
* @param int $id_user : User to insert phone for * @param int $id_user : User to insert phone for
* @param string $name : The name of the phone * @param string $name : The name of the phone
* @param string $adapter : The adapter to use the phone * @param string $adapter : The adapter to use the phone
* @param string json $adapter_datas : A JSON string representing adapter's datas (for example credentials for an api) * @param string json $adapter_data : A JSON string representing adapter's data (for example credentials for an api)
* *
* @return bool|int : false on error, new id on success * @return bool|int : false on error, new id on success
*/ */
public function create(int $id_user, string $name, string $adapter, string $adapter_datas) public function create(int $id_user, string $name, string $adapter, string $adapter_data)
{ {
$phone = [ $phone = [
'id_user' => $id_user, 'id_user' => $id_user,
'name' => $name, 'name' => $name,
'adapter' => $adapter, 'adapter' => $adapter,
'adapter_datas' => $adapter_datas, 'adapter_data' => $adapter_data,
]; ];
return $this->get_model()->insert($phone); return $this->get_model()->insert($phone);
@ -81,17 +81,17 @@ namespace controllers\internals;
* @param int $id : Phone id * @param int $id : Phone id
* @param string $name : The name of the phone * @param string $name : The name of the phone
* @param string $adapter : The adapter to use the phone * @param string $adapter : The adapter to use the phone
* @param array $adapter_datas : An array of the datas of the adapter (for example credentials for an api) * @param array $adapter_data : An array of the data of the adapter (for example credentials for an api)
* *
* @return bool : false on error, true on success * @return bool : false on error, true on success
*/ */
public function update_for_user(int $id_user, int $id, string $name, string $adapter, array $adapter_datas): bool public function update_for_user(int $id_user, int $id, string $name, string $adapter, array $adapter_data): bool
{ {
$phone = [ $phone = [
'id_user' => $id_user, 'id_user' => $id_user,
'name' => $name, 'name' => $name,
'adapter' => $adapter, 'adapter' => $adapter,
'adapter_datas' => json_encode($adapter_datas), 'adapter_data' => json_encode($adapter_data),
]; ];
return (bool) $this->get_model()->update_for_user($id_user, $id, $phone); return (bool) $this->get_model()->update_for_user($id_user, $id, $phone);

View File

@ -35,15 +35,15 @@ use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
* Verify if a condition is valid. i.e we can evaluate it without error. * Verify if a condition is valid. i.e we can evaluate it without error.
* *
* @param string $condition : The condition to evaluate * @param string $condition : The condition to evaluate
* @param array $datas : The datas to made available to condition * @param array $data : The data to made available to condition
* *
* @return bool : false if invalid, true else * @return bool : false if invalid, true else
*/ */
public function validate_condition(string $condition, array $datas = []): bool public function validate_condition(string $condition, array $data = []): bool
{ {
try try
{ {
$this->expression_language->parse($condition, array_keys($datas)); $this->expression_language->parse($condition, array_keys($data));
return true; return true;
} }
@ -61,15 +61,15 @@ use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
* Evaluate a condition. * Evaluate a condition.
* *
* @param string $condition : The condition to evaluate * @param string $condition : The condition to evaluate
* @param array $datas : The datas to made available to condition * @param array $data : The data to made available to condition
* *
* @return ?bool : false if invalid, true else, null only on error * @return ?bool : false if invalid, true else, null only on error
*/ */
public function evaluate_condition(string $condition, array $datas = []): ?bool public function evaluate_condition(string $condition, array $data = []): ?bool
{ {
try try
{ {
$result = $this->expression_language->evaluate($condition, $datas); $result = $this->expression_language->evaluate($condition, $data);
return (bool) $result; return (bool) $result;
} }

View File

@ -334,15 +334,15 @@ namespace controllers\internals;
if ((int) ($users_settings[$scheduled['id_user']]['templating'] ?? false)) if ((int) ($users_settings[$scheduled['id_user']]['templating'] ?? false))
{ {
$contact['datas'] = json_decode($contact['datas'], true); $contact['data'] = json_decode($contact['data'], true);
//Add metas of contact by adding contact without datas //Add metas of contact by adding contact without data
$metas = $contact; $metas = $contact;
unset($metas['datas'], $metas['id_user']); unset($metas['data'], $metas['id_user']);
$datas = ['contact' => $contact['datas'], 'contact_metas' => $metas]; $data = ['contact' => $contact['data'], 'contact_metas' => $metas];
$render = $internal_templating->render($scheduled['text'], $datas); $render = $internal_templating->render($scheduled['text'], $data);
if (!$render['success']) if (!$render['success'])
{ {

View File

@ -44,11 +44,11 @@ namespace controllers\internals;
*/ */
public function update_for_user(int $id_user, int $id_smsstop, string $number) public function update_for_user(int $id_user, int $id_smsstop, string $number)
{ {
$datas = [ $data = [
'number' => $number, 'number' => $number,
]; ];
return $this->get_model()->update_for_user($id_user, $id_smsstop, $datas); return $this->get_model()->update_for_user($id_user, $id_smsstop, $data);
} }
/** /**

View File

@ -57,11 +57,11 @@ namespace controllers\internals;
* Render a string as a twig template. * Render a string as a twig template.
* *
* @param string $template : Template string * @param string $template : Template string
* @param array $datas : Datas to pass to the template * @param array $data : Data to pass to the template
* *
* @return array : keys, success, error, result * @return array : keys, success, error, result
*/ */
public function render(string $template, array $datas = []) public function render(string $template, array $data = [])
{ {
try try
{ {
@ -80,7 +80,7 @@ namespace controllers\internals;
]); ]);
$twig->addExtension($this->sandbox); $twig->addExtension($this->sandbox);
$result = $twig->render('template', $datas); $result = $twig->render('template', $data);
return [ return [
'success' => true, 'success' => true,

View File

@ -344,7 +344,7 @@ namespace controllers\internals;
return $result; return $result;
} }
$new_file_path = PWD_DATAS . '/' . $md5_filename; $new_file_path = PWD_DATA . '/' . $md5_filename;
if (file_exists($new_file_path)) if (file_exists($new_file_path))
{ {

View File

@ -66,12 +66,12 @@ class Webhook extends StandardController
return false; return false;
} }
$datas = [ $data = [
'url' => $url, 'url' => $url,
'type' => $type, 'type' => $type,
]; ];
return $this->get_model()->update_for_user($id_user, $id, $datas); return $this->get_model()->update_for_user($id_user, $id, $data);
} }
/** /**
@ -117,7 +117,7 @@ class Webhook extends StandardController
{ {
$message = [ $message = [
'url' => $webhook['url'], 'url' => $webhook['url'],
'datas' => [ 'data' => [
'webhook_type' => $webhook['type'], 'webhook_type' => $webhook['type'],
'id' => $sms['id'], 'id' => $sms['id'],
'at' => $sms['at'], 'at' => $sms['at'],

View File

@ -311,7 +311,7 @@ namespace controllers\publics;
* *
* @param string $_POST['name'] : Phone name * @param string $_POST['name'] : Phone name
* @param string $_POST['adapter'] : Phone adapter * @param string $_POST['adapter'] : Phone adapter
* @param array $_POST['adapter_datas'] : Phone adapter datas * @param array $_POST['adapter_data'] : Phone adapter data
* *
* @return int : id phone the new phone on success * @return int : id phone the new phone on success
*/ */
@ -321,7 +321,7 @@ namespace controllers\publics;
$name = $_POST['name'] ?? false; $name = $_POST['name'] ?? false;
$adapter = $_POST['adapter'] ?? false; $adapter = $_POST['adapter'] ?? false;
$adapter_datas = !empty($_POST['adapter_datas']) ? $_POST['adapter_datas'] : []; $adapter_data = !empty($_POST['adapter_data']) ? $_POST['adapter_data'] : [];
if (!$name) if (!$name)
{ {
@ -373,14 +373,14 @@ namespace controllers\publics;
} }
//If missing required data fields, error //If missing required data fields, error
foreach ($find_adapter['meta_datas_fields'] as $field) foreach ($find_adapter['meta_data_fields'] as $field)
{ {
if (false === $field['required']) if (false === $field['required'])
{ {
continue; continue;
} }
if (!empty($adapter_datas[$field['name']])) if (!empty($adapter_data[$field['name']]))
{ {
continue; continue;
} }
@ -393,18 +393,18 @@ namespace controllers\publics;
} }
//If field phone number is invalid //If field phone number is invalid
foreach ($find_adapter['meta_datas_fields'] as $field) foreach ($find_adapter['meta_data_fields'] as $field)
{ {
if (false === ($field['number'] ?? false)) if (false === ($field['number'] ?? false))
{ {
continue; continue;
} }
if (!empty($adapter_datas[$field['name']])) if (!empty($adapter_data[$field['name']]))
{ {
$adapter_datas[$field['name']] = \controllers\internals\Tool::parse_phone($adapter_datas[$field['name']]); $adapter_data[$field['name']] = \controllers\internals\Tool::parse_phone($adapter_data[$field['name']]);
if ($adapter_datas[$field['name']]) if ($adapter_data[$field['name']])
{ {
continue; continue;
} }
@ -417,11 +417,11 @@ namespace controllers\publics;
return $this->json($return); return $this->json($return);
} }
$adapter_datas = json_encode($adapter_datas); $adapter_data = json_encode($adapter_data);
//Check adapter is working correctly with thoses names and datas //Check adapter is working correctly with thoses names and data
$adapter_classname = $find_adapter['meta_classname']; $adapter_classname = $find_adapter['meta_classname'];
$adapter_instance = new $adapter_classname($adapter_datas); $adapter_instance = new $adapter_classname($adapter_data);
$adapter_working = $adapter_instance->test(); $adapter_working = $adapter_instance->test();
if (!$adapter_working) if (!$adapter_working)
@ -433,7 +433,7 @@ namespace controllers\publics;
return $this->json($return); return $this->json($return);
} }
$phone_id = $this->internal_phone->create($this->user['id'], $name, $adapter, $adapter_datas); $phone_id = $this->internal_phone->create($this->user['id'], $name, $adapter, $adapter_data);
if (false === $phone_id) if (false === $phone_id)
{ {
$return['error'] = self::ERROR_CODES['CANNOT_CREATE']; $return['error'] = self::ERROR_CODES['CANNOT_CREATE'];

View File

@ -101,7 +101,7 @@ use Monolog\Logger;
$callback_return = $adapter_classname::status_change_callback(); $callback_return = $adapter_classname::status_change_callback();
if (!$callback_return) if (!$callback_return)
{ {
$this->logger->error('Callback status with adapter ' . $adapter_uid . ' failed because adapter cannot process datas with success.'); $this->logger->error('Callback status with adapter ' . $adapter_uid . ' failed because adapter cannot process data with success.');
return false; return false;
} }

View File

@ -210,7 +210,7 @@ namespace controllers\publics;
} }
$internal_ruler = new \controllers\internals\Ruler(); $internal_ruler = new \controllers\internals\Ruler();
$valid_condition = $internal_ruler->validate_condition($condition, ['contact' => (object) ['datas' => (object) null], 'contact_metas' => (object) null]); $valid_condition = $internal_ruler->validate_condition($condition, ['contact' => (object) ['data' => (object) null], 'contact_metas' => (object) null]);
if (!$valid_condition) if (!$valid_condition)
{ {
$return['result'] = 'Syntaxe de la condition invalide.'; $return['result'] = 'Syntaxe de la condition invalide.';

View File

@ -111,9 +111,9 @@ namespace controllers\publics;
foreach ($contacts as &$contact) foreach ($contacts as &$contact)
{ {
if ($contact['datas']) if ($contact['data'])
{ {
$contact['datas'] = json_decode($contact['datas']); $contact['data'] = json_decode($contact['data']);
} }
} }
@ -141,7 +141,7 @@ namespace controllers\publics;
$name = $_POST['name'] ?? false; $name = $_POST['name'] ?? false;
$number = $_POST['number'] ?? false; $number = $_POST['number'] ?? false;
$id_user = $_SESSION['user']['id']; $id_user = $_SESSION['user']['id'];
$datas = $_POST['datas'] ?? []; $data = $_POST['data'] ?? [];
if (!$name || !$number) if (!$name || !$number)
{ {
@ -158,8 +158,8 @@ namespace controllers\publics;
return $this->redirect(\descartes\Router::url('Contact', 'add')); return $this->redirect(\descartes\Router::url('Contact', 'add'));
} }
$clean_datas = []; $clean_data = [];
foreach ($datas as $key => $value) foreach ($data as $key => $value)
{ {
if ('' === $value) if ('' === $value)
{ {
@ -167,12 +167,12 @@ namespace controllers\publics;
} }
$key = mb_ereg_replace('[\W]', '', $key); $key = mb_ereg_replace('[\W]', '', $key);
$clean_datas[$key] = (string) $value; $clean_data[$key] = (string) $value;
} }
$clean_datas = json_encode($clean_datas); $clean_data = json_encode($clean_data);
if (!$this->internal_contact->create($id_user, $number, $name, $clean_datas)) if (!$this->internal_contact->create($id_user, $number, $name, $clean_data))
{ {
\FlashMessage\FlashMessage::push('danger', 'Impossible de créer ce contact.'); \FlashMessage\FlashMessage::push('danger', 'Impossible de créer ce contact.');
@ -212,7 +212,7 @@ namespace controllers\publics;
$name = $contact['name'] ?? false; $name = $contact['name'] ?? false;
$number = $contact['number'] ?? false; $number = $contact['number'] ?? false;
$id_user = $_SESSION['user']['id']; $id_user = $_SESSION['user']['id'];
$datas = $contact['datas'] ?? []; $data = $contact['data'] ?? [];
if (!$name || !$number) if (!$name || !$number)
{ {
@ -225,8 +225,8 @@ namespace controllers\publics;
continue; continue;
} }
$clean_datas = []; $clean_data = [];
foreach ($datas as $key => $value) foreach ($data as $key => $value)
{ {
if ('' === $value) if ('' === $value)
{ {
@ -234,11 +234,11 @@ namespace controllers\publics;
} }
$key = mb_ereg_replace('[\W]', '', $key); $key = mb_ereg_replace('[\W]', '', $key);
$clean_datas[$key] = (string) $value; $clean_data[$key] = (string) $value;
} }
$clean_datas = json_encode($clean_datas); $clean_data = json_encode($clean_data);
$nb_contacts_update += (int) $this->internal_contact->update_for_user($id_user, $id_contact, $number, $name, $clean_datas); $nb_contacts_update += (int) $this->internal_contact->update_for_user($id_user, $id_contact, $number, $name, $clean_data);
} }
if ($nb_contacts_update !== \count($_POST['contacts'])) if ($nb_contacts_update !== \count($_POST['contacts']))

View File

@ -129,7 +129,7 @@ namespace controllers\publics;
'sendeds' => $sendeds, 'sendeds' => $sendeds,
'receiveds' => $receiveds, 'receiveds' => $receiveds,
'events' => $events, 'events' => $events,
'datas_area_chart' => json_encode($array_area_chart), 'data_area_chart' => json_encode($array_area_chart),
]); ]);
} }
} }

View File

@ -73,7 +73,7 @@ class Phone extends \descartes\Controller
} }
/** /**
* Return phones as json with additionnals datas about callbacks. * Return phones as json with additionnals data about callbacks.
*/ */
public function list_json() public function list_json()
{ {
@ -159,7 +159,7 @@ class Phone extends \descartes\Controller
* @param $csrf : CSRF token * @param $csrf : CSRF token
* @param string $_POST['name'] : Phone name * @param string $_POST['name'] : Phone name
* @param string $_POST['adapter'] : Phone adapter * @param string $_POST['adapter'] : Phone adapter
* @param array $_POST['adapter_datas'] : Phone adapter datas * @param array $_POST['adapter_data'] : Phone adapter data
*/ */
public function create($csrf) public function create($csrf)
{ {
@ -173,7 +173,7 @@ class Phone extends \descartes\Controller
$id_user = $_SESSION['user']['id']; $id_user = $_SESSION['user']['id'];
$name = $_POST['name'] ?? false; $name = $_POST['name'] ?? false;
$adapter = $_POST['adapter'] ?? false; $adapter = $_POST['adapter'] ?? false;
$adapter_datas = !empty($_POST['adapter_datas']) ? $_POST['adapter_datas'] : []; $adapter_data = !empty($_POST['adapter_data']) ? $_POST['adapter_data'] : [];
if (!$name || !$adapter) if (!$name || !$adapter)
{ {
@ -210,14 +210,14 @@ class Phone extends \descartes\Controller
} }
//If missing required data fields, error //If missing required data fields, error
foreach ($find_adapter['meta_datas_fields'] as $field) foreach ($find_adapter['meta_data_fields'] as $field)
{ {
if (false === $field['required']) if (false === $field['required'])
{ {
continue; continue;
} }
if (!empty($adapter_datas[$field['name']])) if (!empty($adapter_data[$field['name']]))
{ {
continue; continue;
} }
@ -228,18 +228,18 @@ class Phone extends \descartes\Controller
} }
//If field phone number is invalid //If field phone number is invalid
foreach ($find_adapter['meta_datas_fields'] as $field) foreach ($find_adapter['meta_data_fields'] as $field)
{ {
if (false === ($field['number'] ?? false)) if (false === ($field['number'] ?? false))
{ {
continue; continue;
} }
if (!empty($adapter_datas[$field['name']])) if (!empty($adapter_data[$field['name']]))
{ {
$adapter_datas[$field['name']] = \controllers\internals\Tool::parse_phone($adapter_datas[$field['name']]); $adapter_data[$field['name']] = \controllers\internals\Tool::parse_phone($adapter_data[$field['name']]);
if ($adapter_datas[$field['name']]) if ($adapter_data[$field['name']])
{ {
continue; continue;
} }
@ -250,11 +250,11 @@ class Phone extends \descartes\Controller
return $this->redirect(\descartes\Router::url('Phone', 'add')); return $this->redirect(\descartes\Router::url('Phone', 'add'));
} }
$adapter_datas = json_encode($adapter_datas); $adapter_data = json_encode($adapter_data);
//Check adapter is working correctly with thoses names and datas //Check adapter is working correctly with thoses names and data
$adapter_classname = $find_adapter['meta_classname']; $adapter_classname = $find_adapter['meta_classname'];
$adapter_instance = new $adapter_classname($adapter_datas); $adapter_instance = new $adapter_classname($adapter_data);
$adapter_working = $adapter_instance->test(); $adapter_working = $adapter_instance->test();
if (!$adapter_working) if (!$adapter_working)
@ -264,7 +264,7 @@ class Phone extends \descartes\Controller
return $this->redirect(\descartes\Router::url('Phone', 'add')); return $this->redirect(\descartes\Router::url('Phone', 'add'));
} }
$success = $this->internal_phone->create($id_user, $name, $adapter, $adapter_datas); $success = $this->internal_phone->create($id_user, $name, $adapter, $adapter_data);
if (!$success) if (!$success)
{ {
\FlashMessage\FlashMessage::push('danger', 'Impossible de créer ce téléphone.'); \FlashMessage\FlashMessage::push('danger', 'Impossible de créer ce téléphone.');

View File

@ -66,18 +66,18 @@ namespace controllers\publics;
return false; return false;
} }
$contact['datas'] = json_decode($contact['datas'], true); $contact['data'] = json_decode($contact['data'], true);
//Add metas of contact by adding contact without datas //Add metas of contact by adding contact without data
$metas = $contact; $metas = $contact;
unset($metas['datas'], $metas['id_user']); unset($metas['data'], $metas['id_user']);
$datas = [ $data = [
'contact' => $contact['datas'], 'contact' => $contact['data'],
'contact_metas' => $metas, 'contact_metas' => $metas,
]; ];
$result = $this->internal_templating->render($template, $datas); $result = $this->internal_templating->render($template, $data);
$return = $result; $return = $result;
if (!trim($result['result'])) if (!trim($result['result']))
{ {

View File

@ -82,7 +82,7 @@ class Phone extends AbstractDaemon
//Instanciate adapter //Instanciate adapter
$adapter_class = $this->phone['adapter']; $adapter_class = $this->phone['adapter'];
$this->adapter = new $adapter_class($this->phone['adapter_datas']); $this->adapter = new $adapter_class($this->phone['adapter_data']);
$this->logger->info('Starting Phone daemon with pid ' . getmypid()); $this->logger->info('Starting Phone daemon with pid ' . getmypid());
} }

View File

@ -79,7 +79,7 @@ class Webhook extends AbstractDaemon
$this->logger->info('Trigger webhook : ' . json_encode($message)); $this->logger->info('Trigger webhook : ' . json_encode($message));
$promises[] = $this->guzzle_client->postAsync($message['url'], ['form_params' => $message['datas']]); $promises[] = $this->guzzle_client->postAsync($message['url'], ['form_params' => $message['data']]);
} }
try try

View File

@ -91,21 +91,21 @@
/** /**
* Cette fonction permet de faire un retour sous forme de json * Cette fonction permet de faire un retour sous forme de json
* @param array $datas : Les données à retourner sous forme de json * @param array $data : Les données à retourner sous forme de json
* @param boolean $secure : Défini si l'affichage doit être sécurisé contre les XSS, par défaut true * @param boolean $secure : Défini si l'affichage doit être sécurisé contre les XSS, par défaut true
* @return ApiController : On retourne l'API controlleur lui meme pour pouvoir chainer * @return ApiController : On retourne l'API controlleur lui meme pour pouvoir chainer
*/ */
public function json ($datas, $secure = true) public function json ($data, $secure = true)
{ {
header('Content-Type: application/json'); header('Content-Type: application/json');
if ($secure) if ($secure)
{ {
echo htmlspecialchars(json_encode($datas), ENT_NOQUOTES); echo htmlspecialchars(json_encode($data), ENT_NOQUOTES);
} }
else else
{ {
echo json_encode($datas); echo json_encode($data);
} }
return $this; return $this;

View File

@ -54,28 +54,28 @@
/** /**
* Run a query and return result * Run a query and return result
* @param string $query : Query to run * @param string $query : Query to run
* @param array $datas : Datas to pass to query * @param array $data : Data to pass to query
* @param const $return_type : Type of return, by default all results, see Model constants * @param const $return_type : Type of return, by default all results, see Model constants
* @param const $fetch_mode : Format of result from db, by default array, FETCH_ASSOC * @param const $fetch_mode : Format of result from db, by default array, FETCH_ASSOC
* @param boolean $debug : If we must return debug info instead of data, by default false * @param boolean $debug : If we must return debug info instead of data, by default false
* @return mixed : Result of query, depend of $return_type | null | array | object | int * @return mixed : Result of query, depend of $return_type | null | array | object | int
*/ */
protected function _run_query (string $query, array $datas = array(), int $return_type = self::FETCHALL, int $fetch_mode = \PDO::FETCH_ASSOC, bool $debug = false) protected function _run_query (string $query, array $data = array(), int $return_type = self::FETCHALL, int $fetch_mode = \PDO::FETCH_ASSOC, bool $debug = false)
{ {
try try
{ {
//Must convert bool to 1 or 0 because of some strange inconsistent behavior between PHP versions //Must convert bool to 1 or 0 because of some strange inconsistent behavior between PHP versions
foreach ($datas as $key => $value) foreach ($data as $key => $value)
{ {
if (is_bool($value)) if (is_bool($value))
{ {
$datas[$key] = (int) $value; $data[$key] = (int) $value;
} }
} }
$query = $this->pdo->prepare($query); $query = $this->pdo->prepare($query);
$query->setFetchMode($return_type); $query->setFetchMode($return_type);
$query->execute($datas); $query->execute($data);
if ($debug) if ($debug)
{ {
@ -397,18 +397,18 @@
/** /**
* Update data from table with some conditions * Update data from table with some conditions
* @param string $table : table name * @param string $table : table name
* @param array $datas : new data to set * @param array $data : new data to set
* @param array $conditions : conditions of update, Les conditions pour la mise à jour sous la forme "label" => "valeur". Un operateur '<, >, <=, >=, !' peux précder le label pour modifier l'opérateur par défaut (=) * @param array $conditions : conditions of update, Les conditions pour la mise à jour sous la forme "label" => "valeur". Un operateur '<, >, <=, >=, !' peux précder le label pour modifier l'opérateur par défaut (=)
* @param array $conditions : conditions to use, format 'fieldname' => 'value', fieldname can be preceed by operator '<, >, <=, >=, ! or = (by default)' to adapt comparaison operator * @param array $conditions : conditions to use, format 'fieldname' => 'value', fieldname can be preceed by operator '<, >, <=, >=, ! or = (by default)' to adapt comparaison operator
* @return mixed : Number of line modified * @return mixed : Number of line modified
*/ */
protected function _update (string $table, array $datas, array $conditions = array()) : int protected function _update (string $table, array $data, array $conditions = array()) : int
{ {
$params = array(); $params = array();
$sets = array(); $sets = array();
foreach ($datas as $label => $value) foreach ($data as $label => $value)
{ {
$label = preg_replace('#[^a-zA-Z0-9_]#', '', $label); $label = preg_replace('#[^a-zA-Z0-9_]#', '', $label);
$params['set_' . $label] = $value; $params['set_' . $label] = $value;
@ -454,15 +454,15 @@
/** /**
* Insert new line into table * Insert new line into table
* @param string $table : table name * @param string $table : table name
* @param array $datas : new datas * @param array $data : new data
* @return mixed : null on error, number of line inserted else * @return mixed : null on error, number of line inserted else
*/ */
protected function _insert (string $table, array $datas) : ?int protected function _insert (string $table, array $data) : ?int
{ {
$params = array(); $params = array();
$field_names = array(); $field_names = array();
foreach ($datas as $field_name => $value) foreach ($data as $field_name => $value)
{ {
//Protect against injection in fieldname //Protect against injection in fieldname
$field_name = preg_replace('#[^a-zA-Z0-9_]#', '', $field_name); $field_name = preg_replace('#[^a-zA-Z0-9_]#', '', $field_name);

View File

@ -15,7 +15,7 @@
'PWD_RECEIVEDS' => PWD . '/receiveds', 'PWD_RECEIVEDS' => PWD . '/receiveds',
'HTTP_PWD_SOUND' => HTTP_PWD_ASSETS . '/sounds', 'HTTP_PWD_SOUND' => HTTP_PWD_ASSETS . '/sounds',
'PWD_ADAPTERS' => PWD . '/adapters', 'PWD_ADAPTERS' => PWD . '/adapters',
'PWD_DATAS' => PWD . '/datas', 'PWD_DATA' => PWD . '/data',
'PWD_LOGS' => '/var/log/raspisms', 'PWD_LOGS' => '/var/log/raspisms',
'PWD_PID' => '/var/run/raspisms', 'PWD_PID' => '/var/run/raspisms',
'APP_SECRET' => '%APP_SECRET%', 'APP_SECRET' => '%APP_SECRET%',

View File

@ -188,16 +188,16 @@ namespace models;
* *
* @param int $id_user : User id * @param int $id_user : User id
* @param int $id : Entry id * @param int $id : Entry id
* @param array $datas : datas to update * @param array $data : data to update
* *
* @return int : number of modified rows * @return int : number of modified rows
*/ */
public function update_for_user(int $id_user, int $id, array $datas) public function update_for_user(int $id_user, int $id, array $data)
{ {
$params = []; $params = [];
$sets = []; $sets = [];
foreach ($datas as $label => $value) foreach ($data as $label => $value)
{ {
$label = preg_replace('#[^a-zA-Z0-9_]#', '', $label); $label = preg_replace('#[^a-zA-Z0-9_]#', '', $label);
$params['set_' . $label] = $value; $params['set_' . $label] = $value;

View File

@ -154,7 +154,7 @@ namespace models;
* *
* @param int $id_user : User id * @param int $id_user : User id
* @param int $id : Entry id * @param int $id : Entry id
* @param array $datas : datas to update * @param array $data : data to update
* *
* @return int : number of modified rows * @return int : number of modified rows
*/ */
@ -167,7 +167,7 @@ namespace models;
* Update a entry by his id. * Update a entry by his id.
* *
* @param int $id : Entry id * @param int $id : Entry id
* @param array $datas : datas to update * @param array $data : data to update
* *
* @return int : number of modified rows * @return int : number of modified rows
*/ */

View File

@ -96,13 +96,13 @@ namespace models;
* Update a user using his is. * Update a user using his is.
* *
* @param int $id : User id * @param int $id : User id
* @param array $datas : Datas to update * @param array $data : Data to update
* *
* @return int : number of modified rows * @return int : number of modified rows
*/ */
public function update($id, $datas) public function update($id, $data)
{ {
return $this->_update('user', $datas, ['id' => $id]); return $this->_update('user', $data, ['id' => $id]);
} }
/** /**

View File

@ -90,16 +90,16 @@ jQuery(document).ready(function()
e.preventDefault(); e.preventDefault();
var condition = jQuery(this).parents('.form-group').find('input').val(); var condition = jQuery(this).parents('.form-group').find('input').val();
var datas = { var data = {
'condition' : condition, 'condition' : condition,
}; };
jQuery.ajax({ jQuery.ajax({
type: "POST", type: "POST",
url: HTTP_PWD + '/conditional_group/preview/', url: HTTP_PWD + '/conditional_group/preview/',
data: datas, data: data,
success: function (datas) { success: function (data) {
jQuery('#preview-text-modal').find('.modal-body pre').text(datas.result); jQuery('#preview-text-modal').find('.modal-body pre').text(data.result);
jQuery('#preview-text-modal').modal({'keyboard': true}); jQuery('#preview-text-modal').modal({'keyboard': true});
}, },
dataType: 'json' dataType: 'json'

View File

@ -93,16 +93,16 @@ jQuery(document).ready(function()
e.preventDefault(); e.preventDefault();
var condition = jQuery(this).parents('.form-group').find('input').val(); var condition = jQuery(this).parents('.form-group').find('input').val();
var datas = { var data = {
'condition' : condition, 'condition' : condition,
}; };
jQuery.ajax({ jQuery.ajax({
type: "POST", type: "POST",
url: HTTP_PWD + '/conditional_group/preview/', url: HTTP_PWD + '/conditional_group/preview/',
data: datas, data: data,
success: function (datas) { success: function (data) {
jQuery('#preview-text-modal').find('.modal-body pre').text(datas.result); jQuery('#preview-text-modal').find('.modal-body pre').text(data.result);
jQuery('#preview-text-modal').modal({'keyboard': true}); jQuery('#preview-text-modal').modal({'keyboard': true});
}, },
dataType: 'json' dataType: 'json'

View File

@ -53,18 +53,18 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label>Données du contact</label> <label>Données du contact</label>
<p class="italic small help" id="description-datas"> <p class="italic small help" id="description-data">
Les données d'un contact vous permettent de l'enrichir afin de pouvoir accéder à ces données au sein d'un message via <a href="#">l'utilisation de templates.</a><br/> Les données d'un contact vous permettent de l'enrichir afin de pouvoir accéder à ces données au sein d'un message via <a href="#">l'utilisation de templates.</a><br/>
Laissez vide si vous ne souhaitez pas renseigner d'informations supplémentaires pour le contact. Utilisez uniquement des lettres, des chiffres et des underscore pour les noms de données, ni espace ni caractères spéciaux. Laissez vide si vous ne souhaitez pas renseigner d'informations supplémentaires pour le contact. Utilisez uniquement des lettres, des chiffres et des underscore pour les noms de données, ni espace ni caractères spéciaux.
</p> </p>
<div class="contact-datas-container"> <div class="contact-data-container">
<?php foreach ($_SESSION['previous_http_post']['datas'] ?? [] as $key => $value) { ?> <?php foreach ($_SESSION['previous_http_post']['data'] ?? [] as $key => $value) { ?>
<?php if ($value == null) { continue; } ?> <?php if ($value == null) { continue; } ?>
<div class="form-group"> <div class="form-group">
<input name="" class="form-control contact-data-name" type="text" placeholder="Nom de la donnée" pattern="[a-zA-Z0-9_]*" value="<?php $this->s($key) ?>"> <input name="" class="form-control contact-data-name" type="text" placeholder="Nom de la donnée" pattern="[a-zA-Z0-9_]*" value="<?php $this->s($key) ?>">
: :
<input name="" class="form-control contact-data-value" type="text" placeholder="Valeur de la donnée" value="<?php $this->s($value) ?>"> <input name="" class="form-control contact-data-value" type="text" placeholder="Valeur de la donnée" value="<?php $this->s($value) ?>">
<a href="#" class="contact-datas-remove"><span class="fa fa-times"></span></a> <a href="#" class="contact-data-remove"><span class="fa fa-times"></span></a>
</div> </div>
<?php } ?> <?php } ?>
@ -101,14 +101,14 @@
}); });
jQuery('.contact-datas-container').on('input', '.contact-data-value, .contact-data-name', function (e) jQuery('.contact-data-container').on('input', '.contact-data-value, .contact-data-name', function (e)
{ {
var focus_group = jQuery(this).parent('.form-group'); var focus_group = jQuery(this).parent('.form-group');
var focus_input = this; var focus_input = this;
var input_name = focus_group.find('.contact-data-name'); var input_name = focus_group.find('.contact-data-name');
var input_value = focus_group.find('.contact-data-value'); var input_value = focus_group.find('.contact-data-value');
jQuery('.contact-datas-container .form-group').each(function (e) jQuery('.contact-data-container .form-group').each(function (e)
{ {
var current_input_name = jQuery(this).find('.contact-data-name'); var current_input_name = jQuery(this).find('.contact-data-name');
var current_input_value = jQuery(this).find('.contact-data-value'); var current_input_value = jQuery(this).find('.contact-data-value');
@ -136,15 +136,15 @@
'<input name="" class="form-control contact-data-name" type="text" placeholder="Nom de la donnée" pattern="[a-zA-Z0-9_]*">' + '<input name="" class="form-control contact-data-name" type="text" placeholder="Nom de la donnée" pattern="[a-zA-Z0-9_]*">' +
' : ' + ' : ' +
'<input name="" class="form-control contact-data-value" type="text" placeholder="Valeur de la donnée">' + '<input name="" class="form-control contact-data-value" type="text" placeholder="Valeur de la donnée">' +
' <a href="#" class="contact-datas-remove"><span class="fa fa-times"></span></a>' + ' <a href="#" class="contact-data-remove"><span class="fa fa-times"></span></a>' +
'</div>'; '</div>';
jQuery('.contact-datas-container').append(template); jQuery('.contact-data-container').append(template);
}); });
jQuery('.contact-datas-container').on('click', '.contact-datas-remove', function (e) jQuery('.contact-data-container').on('click', '.contact-data-remove', function (e)
{ {
e.preventDefault(); e.preventDefault();
if (jQuery('.contact-datas-container .form-group').length > 1) if (jQuery('.contact-data-container .form-group').length > 1)
{ {
jQuery(this).parent('.form-group').remove(); jQuery(this).parent('.form-group').remove();
} }
@ -156,11 +156,11 @@
{ {
e.preventDefault(); e.preventDefault();
jQuery('.contact-datas-container .form-group').each(function () jQuery('.contact-data-container .form-group').each(function ()
{ {
var name = jQuery(this).find('.contact-data-name').val(); var name = jQuery(this).find('.contact-data-name').val();
name = name.replace(/\W/g, ''); name = name.replace(/\W/g, '');
name = 'datas[' + name + ']'; name = 'data[' + name + ']';
jQuery(this).find('.contact-data-value').attr('name', name); jQuery(this).find('.contact-data-value').attr('name', name);
}); });

View File

@ -55,31 +55,31 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label>Données du contact</label> <label>Données du contact</label>
<p class="italic small help" id="description-datas"> <p class="italic small help" id="description-data">
Les données d'un contact vous permettent de l'enrichir afin de pouvoir accéder à ces données au sein d'un message via <a href="#">l'utilisation de templates.</a><br/> Les données d'un contact vous permettent de l'enrichir afin de pouvoir accéder à ces données au sein d'un message via <a href="#">l'utilisation de templates.</a><br/>
Laissez vide si vous ne souhaitez pas renseigner d'informations supplémentaires pour le contact. Utilisez uniquement des lettres, des chiffres et des underscore pour les noms de données, ni espace ni caractères spéciaux. Laissez vide si vous ne souhaitez pas renseigner d'informations supplémentaires pour le contact. Utilisez uniquement des lettres, des chiffres et des underscore pour les noms de données, ni espace ni caractères spéciaux.
</p> </p>
<div class="contact-datas-container" data-id-contact="<?php $this->s($contact['id']); ?>"> <div class="contact-data-container" data-id-contact="<?php $this->s($contact['id']); ?>">
<?php if (!$contact['datas']) { ?> <?php if (!$contact['data']) { ?>
<div class="form-group"> <div class="form-group">
<input name="" class="form-control contact-data-name" type="text" placeholder="Nom de la donnée" pattern="[a-zA-Z0-9_]*"> <input name="" class="form-control contact-data-name" type="text" placeholder="Nom de la donnée" pattern="[a-zA-Z0-9_]*">
: :
<input name="" class="form-control contact-data-value" type="text" placeholder="Valeur de la donnée"> <input name="" class="form-control contact-data-value" type="text" placeholder="Valeur de la donnée">
</div> </div>
<?php } else {?> <?php } else {?>
<?php foreach ($contact['datas'] as $name => $data) { ?> <?php foreach ($contact['data'] as $name => $data) { ?>
<div class="form-group"> <div class="form-group">
<input name="" class="form-control contact-data-name" type="text" placeholder="Nom de la donnée" pattern="[a-zA-Z0-9_]*" value="<?php $this->s($name); ?>"> <input name="" class="form-control contact-data-name" type="text" placeholder="Nom de la donnée" pattern="[a-zA-Z0-9_]*" value="<?php $this->s($name); ?>">
: :
<input name="" class="form-control contact-data-value" type="text" placeholder="Valeur de la donnée" value="<?php $this->s($data); ?>"> <input name="" class="form-control contact-data-value" type="text" placeholder="Valeur de la donnée" value="<?php $this->s($data); ?>">
<a href="#" class="contact-datas-remove"><span class="fa fa-times"></span></a> <a href="#" class="contact-data-remove"><span class="fa fa-times"></span></a>
</div> </div>
<?php } ?> <?php } ?>
<div class="form-group"> <div class="form-group">
<input name="" class="form-control contact-data-name" type="text" placeholder="Nom de la donnée" pattern="[a-zA-Z0-9_]*"> <input name="" class="form-control contact-data-name" type="text" placeholder="Nom de la donnée" pattern="[a-zA-Z0-9_]*">
: :
<input name="" class="form-control contact-data-value" type="text" placeholder="Valeur de la donnée"> <input name="" class="form-control contact-data-value" type="text" placeholder="Valeur de la donnée">
<a href="#" class="contact-datas-remove"><span class="fa fa-times"></span></a> <a href="#" class="contact-data-remove"><span class="fa fa-times"></span></a>
</div> </div>
<?php } ?> <?php } ?>
</div> </div>
@ -116,16 +116,16 @@
}); });
jQuery('.contact-datas-container').on('input', '.contact-data-value, .contact-data-name', function (e) jQuery('.contact-data-container').on('input', '.contact-data-value, .contact-data-name', function (e)
{ {
var focus_group = jQuery(this).parent('.form-group'); var focus_group = jQuery(this).parent('.form-group');
var focus_input = this; var focus_input = this;
var input_name = focus_group.find('.contact-data-name'); var input_name = focus_group.find('.contact-data-name');
var input_value = focus_group.find('.contact-data-value'); var input_value = focus_group.find('.contact-data-value');
var datas_container = jQuery(this).parents('.contact-datas-container'); var data_container = jQuery(this).parents('.contact-data-container');
datas_container.find('.form-group').each(function (e) data_container.find('.form-group').each(function (e)
{ {
console.log(this); console.log(this);
var current_input_name = jQuery(this).find('.contact-data-name'); var current_input_name = jQuery(this).find('.contact-data-name');
@ -154,15 +154,15 @@
'<input name="" class="form-control contact-data-name" type="text" placeholder="Nom de la donnée" pattern="[a-zA-Z0-9_]*">' + '<input name="" class="form-control contact-data-name" type="text" placeholder="Nom de la donnée" pattern="[a-zA-Z0-9_]*">' +
' : ' + ' : ' +
'<input name="" class="form-control contact-data-value" type="text" placeholder="Valeur de la donnée">' + '<input name="" class="form-control contact-data-value" type="text" placeholder="Valeur de la donnée">' +
' <a href="#" class="contact-datas-remove"><span class="fa fa-times"></span></a>' + ' <a href="#" class="contact-data-remove"><span class="fa fa-times"></span></a>' +
'</div>'; '</div>';
datas_container.append(template); data_container.append(template);
}); });
jQuery('.contact-datas-container').on('click', '.contact-datas-remove', function (e) jQuery('.contact-data-container').on('click', '.contact-data-remove', function (e)
{ {
e.preventDefault(); e.preventDefault();
if (jQuery('.contact-datas-container .form-group').length > 1) if (jQuery('.contact-data-container .form-group').length > 1)
{ {
jQuery(this).parent('.form-group').remove(); jQuery(this).parent('.form-group').remove();
} }
@ -174,13 +174,13 @@
{ {
e.preventDefault(); e.preventDefault();
jQuery('.contact-datas-container .form-group').each(function () jQuery('.contact-data-container .form-group').each(function ()
{ {
var contact_id = jQuery(this).parents('.contact-datas-container').attr('data-id-contact'); var contact_id = jQuery(this).parents('.contact-data-container').attr('data-id-contact');
var name = jQuery(this).find('.contact-data-name').val(); var name = jQuery(this).find('.contact-data-name').val();
name = name.replace(/\W/g, ''); name = name.replace(/\W/g, '');
name = 'contacts[' + contact_id + '][datas][' + name + ']'; name = 'contacts[' + contact_id + '][data][' + name + ']';
jQuery(this).find('.contact-data-value').attr('name', name); jQuery(this).find('.contact-data-value').attr('name', name);
}); });

View File

@ -244,7 +244,7 @@
element: 'morris-area-chart', element: 'morris-area-chart',
behaveLikeLine: true, behaveLikeLine: true,
fillOpacity: 0.4, fillOpacity: 0.4,
data: <?php echo $datas_area_chart;?>, data: <?php echo $data_area_chart;?>,
xkey: 'period', xkey: 'period',
parseTime: false, parseTime: false,
ykeys: ['sendeds', 'receiveds'], ykeys: ['sendeds', 'receiveds'],

View File

@ -57,7 +57,7 @@
<option <option
value="<?= $adapter['meta_classname'] ?>" value="<?= $adapter['meta_classname'] ?>"
data-description="<?php $this->s($adapter['meta_description']); ?>" data-description="<?php $this->s($adapter['meta_description']); ?>"
data-datas-fields="<?php $this->s(json_encode($adapter['meta_datas_fields'])); ?>" data-data-fields="<?php $this->s(json_encode($adapter['meta_data_fields'])); ?>"
<?= ($_SESSION['previous_http_post']['adapter'] ?? '') == $adapter['meta_classname'] ? 'selected' : '' ?> <?= ($_SESSION['previous_http_post']['adapter'] ?? '') == $adapter['meta_classname'] ? 'selected' : '' ?>
> >
<?php $this->s($adapter['meta_name']); ?> <?php $this->s($adapter['meta_name']); ?>
@ -65,15 +65,15 @@
<?php } ?> <?php } ?>
</select> </select>
</div> </div>
<div id="adapter-datas-container" class="form-group"> <div id="adapter-data-container" class="form-group">
<div id="adapter-datas-description-container"> <div id="adapter-data-description-container">
<h4>Description de l'adaptateur</h4> <h4>Description de l'adaptateur</h4>
<div id="adapter-datas-description"></div> <div id="adapter-data-description"></div>
</div> </div>
<div id="adapter-data-fields-container"> <div id="adapter-data-fields-container">
<h4>Réglages de l'adaptateur</h4> <h4>Réglages de l'adaptateur</h4>
<div id="adapter-datas-fields"></div> <div id="adapter-data-fields"></div>
</div> </div>
</div> </div>
<a class="btn btn-danger" href="<?php echo \descartes\Router::url('Phone', 'list'); ?>">Annuler</a> <a class="btn btn-danger" href="<?php echo \descartes\Router::url('Phone', 'list'); ?>">Annuler</a>
@ -91,17 +91,17 @@
function change_adapter () function change_adapter ()
{ {
var option = jQuery('#adapter-select').find('option:selected'); var option = jQuery('#adapter-select').find('option:selected');
jQuery('#adapter-datas-description').html(option.attr('data-description')); jQuery('#adapter-data-description').html(option.attr('data-description'));
jQuery('#description-adapter-datas').text(option.attr('data-datas-help')); jQuery('#description-adapter-data').text(option.attr('data-data-help'));
var datas_fields = option.attr('data-datas-fields'); var data_fields = option.attr('data-data-fields');
datas_fields = JSON.parse(datas_fields); data_fields = JSON.parse(data_fields);
var numbers = []; var numbers = [];
var html = ''; var html = '';
jQuery.each(datas_fields, function (index, field) jQuery.each(data_fields, function (index, field)
{ {
if (!field.number) if (!field.number)
{ {
@ -109,7 +109,7 @@
'<label>' + field.title + '</label>' + '<label>' + field.title + '</label>' +
'<p class="italic small help">' + field.description + '</p>' + '<p class="italic small help">' + field.description + '</p>' +
'<div class="form-group">' + '<div class="form-group">' +
'<input name="adapter_datas[' + field.name + ']" class="form-control" ' + (field.required ? 'required' : '') + ' ' + (field.default_value ? 'value="' + field.default_value + '"' : '') + '>' + '<input name="adapter_data[' + field.name + ']" class="form-control" ' + (field.required ? 'required' : '') + ' ' + (field.default_value ? 'value="' + field.default_value + '"' : '') + '>' +
'</div>' + '</div>' +
'</div>'; '</div>';
} }
@ -139,12 +139,12 @@
html = 'Pas de réglages.'; html = 'Pas de réglages.';
} }
jQuery('#adapter-datas-fields').html(html); jQuery('#adapter-data-fields').html(html);
for (i = 0; i < numbers.length; i++) for (i = 0; i < numbers.length; i++)
{ {
var iti_number_input = window.intlTelInput(document.getElementById(numbers[i].id), { var iti_number_input = window.intlTelInput(document.getElementById(numbers[i].id), {
hiddenInput: 'adapter_datas[' + numbers[i].name + ']', hiddenInput: 'adapter_data[' + numbers[i].name + ']',
defaultCountry: '<?php $this->s($_SESSION['user']['settings']['default_phone_country']); ?>', defaultCountry: '<?php $this->s($_SESSION['user']['settings']['default_phone_country']); ?>',
preferredCountries: <?php $this->s(json_encode(explode(',', $_SESSION['user']['settings']['preferred_phone_country'])), false, false); ?>, preferredCountries: <?php $this->s(json_encode(explode(',', $_SESSION['user']['settings']['preferred_phone_country'])), false, false); ?>,
nationalMode: true, nationalMode: true,

View File

@ -249,7 +249,7 @@
var id_contact = jQuery(this).parents('.scheduled-preview-container').find('select').val(); var id_contact = jQuery(this).parents('.scheduled-preview-container').find('select').val();
var template = jQuery(this).parents('.form-group').find('textarea').val(); var template = jQuery(this).parents('.form-group').find('textarea').val();
var datas = { var data = {
'id_contact' : id_contact, 'id_contact' : id_contact,
'template' : template, 'template' : template,
}; };
@ -257,9 +257,9 @@
jQuery.ajax({ jQuery.ajax({
type: "POST", type: "POST",
url: HTTP_PWD + '/template/preview', url: HTTP_PWD + '/template/preview',
data: datas, data: data,
success: function (datas) { success: function (data) {
jQuery('#scheduled-preview-text-modal').find('.modal-body pre').text(datas.result); jQuery('#scheduled-preview-text-modal').find('.modal-body pre').text(data.result);
jQuery('#scheduled-preview-text-modal').modal({'keyboard': true}); jQuery('#scheduled-preview-text-modal').modal({'keyboard': true});
}, },
dataType: 'json' dataType: 'json'

View File

@ -256,7 +256,7 @@
var id_contact = jQuery(this).parents('.scheduled-preview-container').find('select').val(); var id_contact = jQuery(this).parents('.scheduled-preview-container').find('select').val();
var template = jQuery(this).parents('.form-group').find('textarea').val(); var template = jQuery(this).parents('.form-group').find('textarea').val();
var datas = { var data = {
'id_contact' : id_contact, 'id_contact' : id_contact,
'template' : template, 'template' : template,
}; };
@ -264,9 +264,9 @@
jQuery.ajax({ jQuery.ajax({
type: "POST", type: "POST",
url: HTTP_PWD + '/template/preview', url: HTTP_PWD + '/template/preview',
data: datas, data: data,
success: function (datas) { success: function (data) {
jQuery('#scheduled-preview-text-modal').find('.modal-body pre').text(datas.result); jQuery('#scheduled-preview-text-modal').find('.modal-body pre').text(data.result);
jQuery('#scheduled-preview-text-modal').modal({'keyboard': true}); jQuery('#scheduled-preview-text-modal').modal({'keyboard': true});
}, },
dataType: 'json' dataType: 'json'