diff --git a/sccpManTraits/helperFunctions.php b/sccpManTraits/helperFunctions.php index 4441e46..3e135d0 100644 --- a/sccpManTraits/helperFunctions.php +++ b/sccpManTraits/helperFunctions.php @@ -69,6 +69,16 @@ trait helperfunctions { } return FALSE; } + private function getDeviceDefaults() { + $def_val = array(); + $sccpDeviceDesc = $this->dbinterface->HWextension_db_SccpTableData('get_columns_sccpdevice'); + + foreach ($sccpDeviceDesc as $data) { + $key = (string) $data['Field']; + $def_val[$key] = array("keyword" => $key, "data" => $data['Default'], "seq" => "99"); + } + return $def_val; + } private function findAllFiles($dir, $file_mask = null, $mode = 'full') { $result = null; diff --git a/views/form.adddevice.php b/views/form.adddevice.php index f220a6e..e0cae98 100644 --- a/views/form.adddevice.php +++ b/views/form.adddevice.php @@ -37,13 +37,8 @@ if (!empty($_REQUEST['new_id'])) { } } if (empty($_REQUEST['id'])) { - // Adding new device to database - $sccpDeviceDesc = $this->dbinterface->HWextension_db_SccpTableData('get_columns_sccpdevice'); - - foreach ($sccpDeviceDesc as $data) { - $key = (string) $data['Field']; - $def_val[$key] = array("keyword" => $key, "data" => $data['Default'], "seq" => "99"); - } + // Adding new device to database. Get default values + $def_val = $this->getDeviceDefaults(); } else { // Editing an existing Device $dev_id = $_REQUEST['id']; diff --git a/views/server.advanced.php b/views/server.advanced.php index f592dff..d712320 100644 --- a/views/server.advanced.php +++ b/views/server.advanced.php @@ -14,15 +14,10 @@ // originally, this was populated by sccpgeneral.xml but that should be static // now will populate from the db defaults. - $defaultVal = array(); - $sccpDeviceDesc = $this->dbinterface->HWextension_db_SccpTableData('get_columns_sccpdevice'); + $defaultVals = $this->getDeviceDefaults(); - foreach ($sccpDeviceDesc as $data) { - $key = (string) $data['Field']; - $defaultVal[$key] = array("keyword" => $key, "data" => $data['Default'], "seq" => "99"); - } echo $this->showGroup('sccp_srst', 1); - echo $this->showGroup('sccp_dev_vendor_conf', 1,'vendorconfig',$defaultVal,false); + echo $this->showGroup('sccp_dev_vendor_conf', 1,'vendorconfig',$defaultVals,false); ?>