Update templating and conditional groups to add contact_metas

This commit is contained in:
osaajani 2020-09-26 21:34:42 +02:00
parent 6062446027
commit 8d86f576d8
4 changed files with 22 additions and 3 deletions

View File

@ -114,8 +114,13 @@ namespace controllers\internals;
{
$contact['datas'] = json_decode($contact['datas']);
$contact = (object) $contact;
//Add metas of contact by adding contact without datas
$metas = clone $contact;
unset($metas->datas);
unset($metas->id_user);
$datas = ['contact' => $contact->datas];
$datas = ['contact' => $contact->datas, 'contact_metas' => $metas];
$is_valid = $ruler->evaluate_condition($condition, $datas);
if (!$is_valid)
{

View File

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

View File

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

View File

@ -68,8 +68,14 @@ namespace controllers\publics;
$contact['datas'] = json_decode($contact['datas'], true);
//Add metas of contact by adding contact without datas
$metas = $contact;
unset($metas['datas']);
unset($metas['id_user']);
$datas = [
'contact' => $contact['datas'],
'contact_metas' => $metas,
];
$result = $this->internal_templating->render($template, $datas);