mirror of
https://github.com/RaspbianFrance/raspisms.git
synced 2025-04-20 16:37:48 +02:00
rename all instances of 'datas' to 'data'
This commit is contained in:
parent
730ac8963b
commit
61d644c247
48 changed files with 316 additions and 316 deletions
|
@ -59,13 +59,13 @@ namespace controllers\internals;
|
|||
*/
|
||||
public function update_for_user(int $id_user, int $id, string $name, string $script, bool $admin)
|
||||
{
|
||||
$datas = [
|
||||
$data = [
|
||||
'name' => $name,
|
||||
'script' => $script,
|
||||
'admin' => $admin,
|
||||
];
|
||||
|
||||
return $this->get_model()->update_for_user($id_user, $id, $datas);
|
||||
return $this->get_model()->update_for_user($id_user, $id, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace controllers\internals;
|
|||
];
|
||||
|
||||
$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)
|
||||
{
|
||||
return false;
|
||||
|
@ -69,7 +69,7 @@ namespace controllers\internals;
|
|||
];
|
||||
|
||||
$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)
|
||||
{
|
||||
return false;
|
||||
|
@ -112,16 +112,16 @@ namespace controllers\internals;
|
|||
|
||||
foreach ($contacts as $key => $contact)
|
||||
{
|
||||
$contact['datas'] = json_decode($contact['datas']);
|
||||
$contact['data'] = json_decode($contact['data']);
|
||||
$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->datas = null;
|
||||
$metas->data = null;
|
||||
$metas->id_user = null;
|
||||
|
||||
$datas = ['contact' => $contact->datas, 'contact_metas' => $metas];
|
||||
$is_valid = $ruler->evaluate_condition($condition, $datas);
|
||||
$data = ['contact' => $contact->data, 'contact_metas' => $metas];
|
||||
$is_valid = $ruler->evaluate_condition($condition, $data);
|
||||
if (!$is_valid)
|
||||
{
|
||||
unset($contacts[$key]);
|
||||
|
|
|
@ -59,17 +59,17 @@ namespace controllers\internals;
|
|||
* @param int $id_user : User id
|
||||
* @param string $number : Contact number
|
||||
* @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
|
||||
*/
|
||||
public function create($id_user, $number, $name, $datas)
|
||||
public function create($id_user, $number, $name, $data)
|
||||
{
|
||||
$contact = [
|
||||
'id_user' => $id_user,
|
||||
'number' => $number,
|
||||
'name' => $name,
|
||||
'datas' => $datas,
|
||||
'data' => $data,
|
||||
];
|
||||
|
||||
$result = $this->get_model()->insert($contact);
|
||||
|
@ -91,16 +91,16 @@ namespace controllers\internals;
|
|||
* @param int $id : Contact id
|
||||
* @param string $number : Contact number
|
||||
* @param string $name : Contact name
|
||||
* @param ?string $datas : Contact datas
|
||||
* @param ?string $data : Contact data
|
||||
*
|
||||
* @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 = [
|
||||
'number' => $number,
|
||||
'name' => $name,
|
||||
'datas' => $datas,
|
||||
'data' => $data,
|
||||
];
|
||||
|
||||
return $this->get_model()->update_for_user($id_user, $id, $contact);
|
||||
|
@ -144,7 +144,7 @@ namespace controllers\internals;
|
|||
continue;
|
||||
}
|
||||
|
||||
$datas = [];
|
||||
$data = [];
|
||||
$i = 0;
|
||||
foreach ($line as $key => $value)
|
||||
{
|
||||
|
@ -160,13 +160,13 @@ namespace controllers\internals;
|
|||
}
|
||||
|
||||
$key = mb_ereg_replace('[\W]', '', $key);
|
||||
$datas[$key] = $value;
|
||||
$data[$key] = $value;
|
||||
}
|
||||
$datas = json_encode($datas);
|
||||
$data = json_encode($data);
|
||||
|
||||
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)
|
||||
{
|
||||
++$nb_insert;
|
||||
|
@ -224,12 +224,12 @@ namespace controllers\internals;
|
|||
continue;
|
||||
}
|
||||
|
||||
$datas = $contact['datas'] ?? [];
|
||||
$datas = json_encode($datas);
|
||||
$data = $contact['data'] ?? [];
|
||||
$data = json_encode($data);
|
||||
|
||||
try
|
||||
{
|
||||
$success = $this->create($id_user, $contact['number'], $contact['name'], $datas);
|
||||
$success = $this->create($id_user, $contact['number'], $contact['name'], $data);
|
||||
if ($success)
|
||||
{
|
||||
++$nb_insert;
|
||||
|
@ -264,8 +264,8 @@ namespace controllers\internals;
|
|||
|
||||
foreach ($contacts as $contact)
|
||||
{
|
||||
$datas = json_decode($contact['datas'], true);
|
||||
foreach ($datas as $key => $value)
|
||||
$data = json_decode($contact['data'], true);
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
$columns[] = $key;
|
||||
}
|
||||
|
@ -275,14 +275,14 @@ namespace controllers\internals;
|
|||
$lines = [];
|
||||
foreach ($contacts as $contact)
|
||||
{
|
||||
$datas = json_decode($contact['datas'], true);
|
||||
$data = json_decode($contact['data'], true);
|
||||
|
||||
$line = [$contact['name'], $contact['number']];
|
||||
foreach ($columns as $column)
|
||||
{
|
||||
if (isset($datas[$column]))
|
||||
if (isset($data[$column]))
|
||||
{
|
||||
$line[] = $datas[$column];
|
||||
$line[] = $data[$column];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
@ -327,7 +327,7 @@ namespace controllers\internals;
|
|||
{
|
||||
unset($contact['id'], $contact['id_user']);
|
||||
|
||||
$contact['datas'] = json_decode($contact['datas']);
|
||||
$contact['data'] = json_decode($contact['data']);
|
||||
}
|
||||
$content = json_encode($contacts);
|
||||
|
||||
|
|
|
@ -100,13 +100,13 @@ class Mailer extends \descartes\Controller
|
|||
*
|
||||
* @param string $destination : email address to send email to
|
||||
* @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
|
||||
*/
|
||||
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 = [
|
||||
'destinations' => [$destination],
|
||||
|
@ -131,18 +131,18 @@ class Mailer extends \descartes\Controller
|
|||
* string 'template' => Email template to use
|
||||
* ?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 [
|
||||
* string 'body' => email body
|
||||
* ?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
|
||||
ob_start();
|
||||
$this->render($settings['template'], $datas);
|
||||
$this->render($settings['template'], $data);
|
||||
$body = ob_get_clean();
|
||||
|
||||
//Generate alt body if needed
|
||||
|
@ -150,7 +150,7 @@ class Mailer extends \descartes\Controller
|
|||
if ($settings['alt_template'] ?? false)
|
||||
{
|
||||
ob_start();
|
||||
$this->render($settings['alt_template'], $datas);
|
||||
$this->render($settings['alt_template'], $data);
|
||||
$alt_body = ob_get_clean();
|
||||
}
|
||||
|
||||
|
|
|
@ -39,12 +39,12 @@ namespace controllers\internals;
|
|||
return false;
|
||||
}
|
||||
|
||||
$datas = [
|
||||
$data = [
|
||||
'id_scheduled' => $id_scheduled,
|
||||
'path' => $result_upload_media['content'],
|
||||
];
|
||||
|
||||
return (bool) $this->get_model()->insert($datas);
|
||||
return (bool) $this->get_model()->insert($data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -58,17 +58,17 @@ namespace controllers\internals;
|
|||
* @param int $id_user : User to insert phone for
|
||||
* @param string $name : The name of 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
|
||||
*/
|
||||
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 = [
|
||||
'id_user' => $id_user,
|
||||
'name' => $name,
|
||||
'adapter' => $adapter,
|
||||
'adapter_datas' => $adapter_datas,
|
||||
'adapter_data' => $adapter_data,
|
||||
];
|
||||
|
||||
return $this->get_model()->insert($phone);
|
||||
|
@ -81,17 +81,17 @@ namespace controllers\internals;
|
|||
* @param int $id : Phone id
|
||||
* @param string $name : The name of 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
|
||||
*/
|
||||
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 = [
|
||||
'id_user' => $id_user,
|
||||
'name' => $name,
|
||||
'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);
|
||||
|
|
|
@ -35,15 +35,15 @@ use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
|
|||
* Verify if a condition is valid. i.e we can evaluate it without error.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
public function validate_condition(string $condition, array $datas = []): bool
|
||||
public function validate_condition(string $condition, array $data = []): bool
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->expression_language->parse($condition, array_keys($datas));
|
||||
$this->expression_language->parse($condition, array_keys($data));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -61,15 +61,15 @@ use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
|
|||
* Evaluate a condition.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
public function evaluate_condition(string $condition, array $datas = []): ?bool
|
||||
public function evaluate_condition(string $condition, array $data = []): ?bool
|
||||
{
|
||||
try
|
||||
{
|
||||
$result = $this->expression_language->evaluate($condition, $datas);
|
||||
$result = $this->expression_language->evaluate($condition, $data);
|
||||
|
||||
return (bool) $result;
|
||||
}
|
||||
|
|
|
@ -334,15 +334,15 @@ namespace controllers\internals;
|
|||
|
||||
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;
|
||||
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'])
|
||||
{
|
||||
|
|
|
@ -44,11 +44,11 @@ namespace controllers\internals;
|
|||
*/
|
||||
public function update_for_user(int $id_user, int $id_smsstop, string $number)
|
||||
{
|
||||
$datas = [
|
||||
$data = [
|
||||
'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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -57,11 +57,11 @@ namespace controllers\internals;
|
|||
* Render a string as a twig template.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
public function render(string $template, array $datas = [])
|
||||
public function render(string $template, array $data = [])
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -80,7 +80,7 @@ namespace controllers\internals;
|
|||
]);
|
||||
|
||||
$twig->addExtension($this->sandbox);
|
||||
$result = $twig->render('template', $datas);
|
||||
$result = $twig->render('template', $data);
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
|
|
|
@ -344,7 +344,7 @@ namespace controllers\internals;
|
|||
return $result;
|
||||
}
|
||||
|
||||
$new_file_path = PWD_DATAS . '/' . $md5_filename;
|
||||
$new_file_path = PWD_DATA . '/' . $md5_filename;
|
||||
|
||||
if (file_exists($new_file_path))
|
||||
{
|
||||
|
|
|
@ -66,12 +66,12 @@ class Webhook extends StandardController
|
|||
return false;
|
||||
}
|
||||
|
||||
$datas = [
|
||||
$data = [
|
||||
'url' => $url,
|
||||
'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 = [
|
||||
'url' => $webhook['url'],
|
||||
'datas' => [
|
||||
'data' => [
|
||||
'webhook_type' => $webhook['type'],
|
||||
'id' => $sms['id'],
|
||||
'at' => $sms['at'],
|
||||
|
|
|
@ -311,7 +311,7 @@ namespace controllers\publics;
|
|||
*
|
||||
* @param string $_POST['name'] : Phone name
|
||||
* @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
|
||||
*/
|
||||
|
@ -321,7 +321,7 @@ namespace controllers\publics;
|
|||
|
||||
$name = $_POST['name'] ?? 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)
|
||||
{
|
||||
|
@ -373,14 +373,14 @@ namespace controllers\publics;
|
|||
}
|
||||
|
||||
//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'])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!empty($adapter_datas[$field['name']]))
|
||||
if (!empty($adapter_data[$field['name']]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -393,18 +393,18 @@ namespace controllers\publics;
|
|||
}
|
||||
|
||||
//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))
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
@ -417,11 +417,11 @@ namespace controllers\publics;
|
|||
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_instance = new $adapter_classname($adapter_datas);
|
||||
$adapter_instance = new $adapter_classname($adapter_data);
|
||||
$adapter_working = $adapter_instance->test();
|
||||
|
||||
if (!$adapter_working)
|
||||
|
@ -433,7 +433,7 @@ namespace controllers\publics;
|
|||
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)
|
||||
{
|
||||
$return['error'] = self::ERROR_CODES['CANNOT_CREATE'];
|
||||
|
|
|
@ -101,7 +101,7 @@ use Monolog\Logger;
|
|||
$callback_return = $adapter_classname::status_change_callback();
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -210,7 +210,7 @@ namespace controllers\publics;
|
|||
}
|
||||
|
||||
$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)
|
||||
{
|
||||
$return['result'] = 'Syntaxe de la condition invalide.';
|
||||
|
|
|
@ -111,9 +111,9 @@ namespace controllers\publics;
|
|||
|
||||
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;
|
||||
$number = $_POST['number'] ?? false;
|
||||
$id_user = $_SESSION['user']['id'];
|
||||
$datas = $_POST['datas'] ?? [];
|
||||
$data = $_POST['data'] ?? [];
|
||||
|
||||
if (!$name || !$number)
|
||||
{
|
||||
|
@ -158,8 +158,8 @@ namespace controllers\publics;
|
|||
return $this->redirect(\descartes\Router::url('Contact', 'add'));
|
||||
}
|
||||
|
||||
$clean_datas = [];
|
||||
foreach ($datas as $key => $value)
|
||||
$clean_data = [];
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
if ('' === $value)
|
||||
{
|
||||
|
@ -167,12 +167,12 @@ namespace controllers\publics;
|
|||
}
|
||||
|
||||
$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.');
|
||||
|
||||
|
@ -212,7 +212,7 @@ namespace controllers\publics;
|
|||
$name = $contact['name'] ?? false;
|
||||
$number = $contact['number'] ?? false;
|
||||
$id_user = $_SESSION['user']['id'];
|
||||
$datas = $contact['datas'] ?? [];
|
||||
$data = $contact['data'] ?? [];
|
||||
|
||||
if (!$name || !$number)
|
||||
{
|
||||
|
@ -225,8 +225,8 @@ namespace controllers\publics;
|
|||
continue;
|
||||
}
|
||||
|
||||
$clean_datas = [];
|
||||
foreach ($datas as $key => $value)
|
||||
$clean_data = [];
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
if ('' === $value)
|
||||
{
|
||||
|
@ -234,11 +234,11 @@ namespace controllers\publics;
|
|||
}
|
||||
|
||||
$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']))
|
||||
|
|
|
@ -129,7 +129,7 @@ namespace controllers\publics;
|
|||
'sendeds' => $sendeds,
|
||||
'receiveds' => $receiveds,
|
||||
'events' => $events,
|
||||
'datas_area_chart' => json_encode($array_area_chart),
|
||||
'data_area_chart' => json_encode($array_area_chart),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
@ -159,7 +159,7 @@ class Phone extends \descartes\Controller
|
|||
* @param $csrf : CSRF token
|
||||
* @param string $_POST['name'] : Phone name
|
||||
* @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)
|
||||
{
|
||||
|
@ -173,7 +173,7 @@ class Phone extends \descartes\Controller
|
|||
$id_user = $_SESSION['user']['id'];
|
||||
$name = $_POST['name'] ?? 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)
|
||||
{
|
||||
|
@ -210,14 +210,14 @@ class Phone extends \descartes\Controller
|
|||
}
|
||||
|
||||
//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'])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!empty($adapter_datas[$field['name']]))
|
||||
if (!empty($adapter_data[$field['name']]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -228,18 +228,18 @@ class Phone extends \descartes\Controller
|
|||
}
|
||||
|
||||
//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))
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
@ -250,11 +250,11 @@ class Phone extends \descartes\Controller
|
|||
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_instance = new $adapter_classname($adapter_datas);
|
||||
$adapter_instance = new $adapter_classname($adapter_data);
|
||||
$adapter_working = $adapter_instance->test();
|
||||
|
||||
if (!$adapter_working)
|
||||
|
@ -264,7 +264,7 @@ class Phone extends \descartes\Controller
|
|||
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)
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'Impossible de créer ce téléphone.');
|
||||
|
|
|
@ -66,18 +66,18 @@ namespace controllers\publics;
|
|||
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;
|
||||
unset($metas['datas'], $metas['id_user']);
|
||||
unset($metas['data'], $metas['id_user']);
|
||||
|
||||
$datas = [
|
||||
'contact' => $contact['datas'],
|
||||
$data = [
|
||||
'contact' => $contact['data'],
|
||||
'contact_metas' => $metas,
|
||||
];
|
||||
|
||||
$result = $this->internal_templating->render($template, $datas);
|
||||
$result = $this->internal_templating->render($template, $data);
|
||||
$return = $result;
|
||||
if (!trim($result['result']))
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue