From 039054a300a8ba22ae30a8d4ff0c250e2b72940d Mon Sep 17 00:00:00 2001 From: Pek5892 Date: Wed, 24 Jan 2024 17:50:16 +0100 Subject: [PATCH] Aggiunta metodo getValue per la lettura dei valori dei campi personalizzati --- src/HTMLBuilder/Manager/FieldManager.php | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/HTMLBuilder/Manager/FieldManager.php b/src/HTMLBuilder/Manager/FieldManager.php index 6fc9a2624..6d426bf61 100755 --- a/src/HTMLBuilder/Manager/FieldManager.php +++ b/src/HTMLBuilder/Manager/FieldManager.php @@ -125,4 +125,35 @@ class FieldManager implements ManagerInterface return $result; } + + + public function getValue($options, $name) { + $database = database(); + + $query = 'SELECT `zz_fields`.*'.(isset($options['id_record']) ? ', `zz_field_record`.`value`' : '').' FROM `zz_fields`'; + + if (isset($options['id_record'])) { + $query .= ' LEFT JOIN `zz_field_record` ON `zz_fields`.`id` = `zz_field_record`.`id_field` AND `zz_field_record`.`id_record` = '.prepare($options['id_record']); + } + + $query .= ' WHERE '; + + if (!empty($options['id_plugin'])) { + $query .= '`id_plugin` = '.prepare($options['id_plugin']); + } else { + $query .= '`id_module` = '.prepare($options['id_module']); + } + + if (isset($options['place']) && $options['place'] == 'add') { + $query .= ' AND `on_add` = 1'; + } + $query .= ' AND `zz_fields`.`name` = '.prepare($name); + + $query .= ' AND `top` = '.((isset($options['position']) && $options['position'] == 'top') ? 1 : 0).' ORDER BY `order`'; + + $results = $database->fetchArray($query); + + return $results[0]['value']; + } } +