From ace4945eb083893e472b12acf40da0fabaa2c21b Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Wed, 30 Jun 2021 07:02:22 +0200 Subject: [PATCH] Load help from chan-sccp Load metainfo descriptions which provide help if not in XML --- Sccp_manager.class.php | 21 +++++++++++++++------ sccpManClasses/dbinterface.class.php | 1 - views/formShowSysDefs.php | 6 ++++-- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index e3682ac..b87a79b 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -94,7 +94,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { private $hint_context = array('default' => '@ext-local'); /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Get it from Config !!! private $val_null = 'NONE'; /// REPLACE to null Field public $sccp_model_list = array(); - public $sccp_metainfo = array(); private $cnf_wr = null; public $sccppath = array(); public $sccpvalues = array(); @@ -102,6 +101,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { public $xml_data; public $class_error; //error construct public $info_warning; + public $sccp_metainfo = array(); // Move all non sccp_manager specific functions to traits use \FreePBX\modules\Sccp_Manager\sccpManTraits\helperFunctions; @@ -149,12 +149,20 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { */ public function showGroup($group_name, $show_Header, $form_prefix = 'sccp', $form_values = array()) { - if (empty($form_values)) { - $form_values = $this->sccpvalues; - } - // load xml data - moved from Construct to simplify Construct + + // load xml data - moved from Construct to simplify Construct. + // TODO: This is static data so only load first time. Left as is for dbug. $xml_vars = __DIR__ . '/conf/sccpgeneral.xml.v433'; $this->xml_data = simplexml_load_file($xml_vars); + // load metainfo from chan-sccp - help information if not in xml. Only load first time as static data. + if (empty($this->sccp_metainfo)) { + $sysConfiguration = $this->aminterface->getSCCPConfigMetaData('general'); + + foreach ($sysConfiguration['Options'] as $key => $valueArray) { + $this->sccp_metainfo[$valueArray['Name']] = $valueArray['Description']; + } + unset($sysConfiguration); + } if ((array) $this->xml_data) { foreach ($this->xml_data->xpath('//page_group[@name="' . $group_name . '"]') as $item) { @@ -166,7 +174,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { 'form_prefix' => $form_prefix, 'fvalues' => $form_values, 'tftp_lang' => $this->tftpLang, - 'metainfo' => $this->sccp_metainfo + 'metainfo' => $this->sccp_metainfo, + 'sccp_defaults' => $this->sccpvalues )); } else { $htmlret = load_view(__DIR__ . '/views/formShow.php', array( diff --git a/sccpManClasses/dbinterface.class.php b/sccpManClasses/dbinterface.class.php index 3730aea..a192c8d 100644 --- a/sccpManClasses/dbinterface.class.php +++ b/sccpManClasses/dbinterface.class.php @@ -247,7 +247,6 @@ class dbinterface $result = false; switch ($table_name) { case 'sccpsettings': - dbug('savevalue', $save_value); if ($mode == 'replace') { // Change mode name to be more transparent $dbh->prepare('TRUNCATE sccpsettings')->execute(); $stmt = $dbh->prepare('INSERT INTO sccpsettings (keyword, data, seq, type, systemdefault) VALUES (:keyword,:data,:seq,:type,:systemdefault)'); diff --git a/views/formShowSysDefs.php b/views/formShowSysDefs.php index 044a3de..e1497a4 100644 --- a/views/formShowSysDefs.php +++ b/views/formShowSysDefs.php @@ -58,6 +58,9 @@ if (function_exists('music_list')) { if (!is_array($moh_list)) { $moh_list = array('default'); } +if (empty($fvalues)) { + $fvalues = $sccp_defaults; +} $items = $itm -> children(); @@ -115,8 +118,7 @@ foreach ($items as $child) { } if (!empty($fvalues[$res_n])) { if (!empty($fvalues[$res_n]['data'])) { - // TODO: Need to store sysvalues in a separate array - if (!empty($fvalues[$res_n]['systemdefault']) && ($fvalues[$res_n]['systemdefault'] != $fvalues[$res_n]['data'])) { + if (!empty($sccp_defaults[$res_n]['systemdefault']) && ($sccp_defaults[$res_n]['systemdefault'] != $fvalues[$res_n]['data'])) { $usingSysDefaults = false; } $value->value = $fvalues[$res_n]['data'];