diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 67967b6..92c4a00 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -173,7 +173,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { * Generate Input elements in Html Code from sccpgeneral.xml */ - public function showGroup($group_name, $show_Header, $form_prefix = 'sccp', $form_values = null, $show_inherit = true) { + public function showGroup($group_name, $show_Header, $form_prefix = 'sccp', $form_values = array(), $show_inherit = true) { $htmlret = ""; if (empty($form_values)) { $form_values = $this->sccpvalues; diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index 4223446..900f16c 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -536,7 +536,7 @@ and open the template in the editor. Base Version before all crash :-) - vendorconfig_logserver + logserver sccp-custom @@ -546,7 +546,7 @@ and open the template in the editor. Base Version before all crash :-) - vendorconfig_daysdisplaynotactive + daysdisplaynotactive sccp-custom @@ -556,7 +556,7 @@ and open the template in the editor. Base Version before all crash :-) - vendorconfig_displayontime + displayontime sccp-custom @@ -566,7 +566,7 @@ and open the template in the editor. Base Version before all crash :-) - vendorconfig_displayonduration + displayonduration sccp-custom @@ -576,109 +576,97 @@ and open the template in the editor. Base Version before all crash :-) - vendorconfig_displayidletimeout + displayidletimeout sccp-custom Timeout in HH:MM format to automatically turn off phone display if outside the time specified by "daysDisplayNotActive", "displayOnTime" and "displayOnTimeout". - - vendorconfig_settingsaccess + settingsaccess - Inherit - + off Whether a user can access the phone settings. - vendorconfig_videocapability + videocapability - Inherit - + "off" - vendorconfig_webaccess + webaccess - Inherit - + "off" Enable the phone's HTTP server. - vendorconfig_webadmin + webadmin - Inherit - + "off" Enable remote administration using the phone's HTTP server. 8821 model only. - vendorconfig_pcport + pcport - Inherit - + "off" Disable the PC (computer) port - vendorconfig_spantopcport + spantopcport - Inherit - + "off" Forward packets sent and received on the SW (network) port to the PC (computer) port. - vendorconfig_voicevlanaccess + voicevlanaccess - Inherit - + "off" Allow devices connected to the PC (computer) port to access the voice VLAN. - vendorconfig_enablecdpswport + enablecdpswport - Inherit - + "off" Enable Cisco Discovery Protocol on the SW (network) port. - vendorconfig_enablecdppcport + enablecdppcport - Inherit - + "off" Enable Cisco Discovery Protocol on the PC (computer) port. - vendorconfig_enablelldpswport + enablelldpswport - Inherit - + "off" Enable Link Layer Discovery Protocol on the SW (network) port. - vendorconfig_enablelldppcport + enablelldppcport - Inherit - + "off" Enable Link Layer Discovery Protocol on the PC (computer) port. @@ -1136,16 +1124,16 @@ and open the template in the editor. Base Version before all crash :-) backgroundImageAccess true - - + + I'm guessing on this one, but on some devices, the background image on the display can be modified at the device. I think this is the thing that allows that to happen. phonePersonalization 0 - - + + This needs to be enabled to allow the server to push background or ringtones to the phone in the SEPXXXXXXXXXX.cnf.xml of each phone: @@ -1397,7 +1385,6 @@ and open the template in the editor. Base Version before all crash :-) transfer off - Transfer allowed @@ -1406,7 +1393,6 @@ and open the template in the editor. Base Version before all crash :-) park on - Inherit Take a look to the compile how-to. Park stuff is not compiled by default. @@ -1415,7 +1401,6 @@ and open the template in the editor. Base Version before all crash :-) cfwdall off - Activate the callforward softkeys. Default is On @@ -1424,7 +1409,6 @@ and open the template in the editor. Base Version before all crash :-) cfwdbusy off - Activate the callforward busy softkeys. Default is On @@ -1433,7 +1417,6 @@ and open the template in the editor. Base Version before all crash :-) cfwdnoanswer on - Activate the callforward NOANSWER stuff and softkeys. Default is On @@ -1442,7 +1425,6 @@ and open the template in the editor. Base Version before all crash :-) dndFeature off - Do Not Disturb. Default is Off @@ -1481,7 +1463,6 @@ and open the template in the editor. Base Version before all crash :-) mwioncall on - Set the MWI on call. @@ -1491,7 +1472,6 @@ and open the template in the editor. Base Version before all crash :-) mwilamp on - @@ -1635,7 +1615,6 @@ and open the template in the editor. Base Version before all crash :-) nat auto - @@ -1646,7 +1625,6 @@ and open the template in the editor. Base Version before all crash :-) off Auto - This option allow devices to do direct RTP sessions (default Off) @@ -1655,7 +1633,6 @@ and open the template in the editor. Base Version before all crash :-) earlyrtp NONE - Immediate diff --git a/install.php b/install.php index 47a0386..f80a411 100644 --- a/install.php +++ b/install.php @@ -257,7 +257,7 @@ function Get_DB_config($sccp_compatible) '_autocall_select' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), '_backgroundImageAccess' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), '_phonePersonalization' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), - '_callLogBlfEnabled' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')") + '_callLogBlfEnabled' => array('create' => "enum('3','2') NOT NULL default '2'", 'modify' => "enum('3','2')") ) ); diff --git a/module.xml b/module.xml index 57723fe..cd5c29f 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.1 + 14.3.0.0 setup SCCP Connectivity Steve Lad, Alex GP diff --git a/sccpManClasses/dbinterface.class.php b/sccpManClasses/dbinterface.class.php index a899069..9a03a00 100644 --- a/sccpManClasses/dbinterface.class.php +++ b/sccpManClasses/dbinterface.class.php @@ -110,7 +110,7 @@ class dbinterface $stmts = $dbh->prepare('DESCRIBE sccpuser'); break; case 'get_columns_sccpline': - $stmts = $dbh->prepare('DESCRIBE sccpuser'); + $stmts = $dbh->prepare('DESCRIBE sccpline'); break; case 'get_sccpdevice_byid': $stmt = $dbh->prepare('SELECT t1.*, types.dns, types.buttons, types.loadimage, types.nametemplate as nametemplate, @@ -145,6 +145,8 @@ class dbinterface $raw_settings = array(); } break; + // No default case so will give exception of $raw_settings undefined if there + // dataid is not in the switch. } if (!empty($stmt)) { $stmt->execute(); diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index 7b71c02..24d66ac 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -42,7 +42,6 @@ trait ajaxHelper { // ajaxHandler is called after ajaxRequest returns true public function ajaxHandler() { - dbug('REQUEST',$_REQUEST); $request = $_REQUEST; $msg = array(); $cmd_id = $request['command']; @@ -382,6 +381,7 @@ trait ajaxHelper { } function handleSubmit($request, $validateonly = false) { + dbug('Request', $request); $hdr_prefix = 'sccp_'; $hdr_arprefix = 'sccp-ar_'; $save_settings = array(); @@ -396,28 +396,45 @@ trait ajaxHelper { $this->initializeTFtpLanguagePath(); } foreach ($request as $key => $value) { - // Initallly saved all to sccpvalues. Now will save to db defaults if appropriate + // Originally saved all to sccpvalues. Now will save to db defaults if appropriate // TODO: Need to verify the tables defined in showGroup - some options maybe // device options, but if set by freePbx extensions, be in sccpline. $key = (str_replace('sccpdevice_', '', $key, $count_mods)); - if (($count_mods) && (!empty($value))) { + if ($count_mods) { // There will be some exceptions to be handled where there should be no underscore // Handle at db write // Have default to be saved to db sccpdevice - $dev_def = $this->getTableDefaults('sccpdevice'); + $dev_def = $this->getTableDefaults('sccpdevice', false); if (!array_key_exists($key, $dev_def)) { // This key needs to be prefixed with underscore - $key = '_'.$key; + $key = "_{$key}"; + } + if ((array_key_exists($key, $dev_def)) && (($dev_def[$key]['data'] == $value) || empty($dev_def[$key]['data']))) { + // Value unchanged or null so ignore and go to next key. + continue; + } + $dbSaveArray[] = array('table' => 'sccpdevice', 'field' => $key, 'Default' => $value); + continue; + } + $key = (str_replace('sccpline_', '', $key, $count_mods)); + if ($count_mods) { + // There will be some exceptions to be handled where there should be no underscore + // Handle at db write + // Have default to be saved to db sccpdevice + $dev_def = $this->getTableDefaults('sccpline', false); + if (!array_key_exists($key, $dev_def)) { + // This key needs to be prefixed with underscore + $key = "_{$key}"; } if ((array_key_exists($key, $dev_def)) && ($dev_def[$key]['data'] == $value)) { // Value unchanged so ignore and get next key. continue; } - $dbSaveArray[] = array('table' => 'sccpdevice', 'field' => $key, 'Default' => $value); + $dbSaveArray[] = array('table' => 'sccpline', 'field' => $key, 'Default' => $value); unset($request[$key]); continue; } - + dbug('still in loop with key', $key); $pos = strpos($key, $hdr_prefix); if ($pos !== false) { $key1 = substr_replace($key, '', 0, strlen($hdr_prefix)); @@ -493,7 +510,9 @@ trait ajaxHelper { break; } } + if (!empty($save_settings)) { + dbug('save settings', $save_settings); $this->saveSccpSettings($save_settings); $this->sccpvalues = $this->dbinterface->get_db_SccpSetting(); } diff --git a/sccpManTraits/helperFunctions.php b/sccpManTraits/helperFunctions.php index 37fead7..7b25332 100644 --- a/sccpManTraits/helperFunctions.php +++ b/sccpManTraits/helperFunctions.php @@ -69,13 +69,20 @@ trait helperfunctions { } return FALSE; } - private function getTableDefaults($table) { + private function getTableDefaults($table, $trim_underscore = true) { $def_val = array(); // TODO: This is ugly and overkill - needs to be cleaned up in dbinterface $sccpTableDesc = $this->dbinterface->HWextension_db_SccpTableData("get_columns_{$table}"); foreach ($sccpTableDesc as $data) { $key = (string) $data['Field']; + // function has 2 roles: return actual table keys (trim_underscore = false) + // return sanitised keys to add defaults (trim_underscore = true) + if ($trim_underscore) { + // Remove any leading (or trailing but should be none) underscore + // These are only used to hide fields from chan-sccp for compatibility + $key = trim($key,'_'); + } $def_val[$key] = array("keyword" => $key, "data" => $data['Default'], "seq" => "99"); } return $def_val; diff --git a/views/formShow.php b/views/formShow.php index 63dffc9..4f45827 100644 --- a/views/formShow.php +++ b/views/formShow.php @@ -24,9 +24,9 @@ $napref = $form_prefix.'-ar_'; if (empty($form_prefix)) { $npref = "sccp_"; $napref ="sccp-ar_"; -} elseif ($form_prefix == 'vendorconfig') { - $npref = 'vendorconfig'; - $napref = 'vendorconfig-ar'; +//} elseif ($form_prefix == 'vendorconfig') { +// $npref = 'vendorconfig'; +// $napref = 'vendorconfig-ar'; } $day_format = array("D.M.Y", "D.M.YA", "Y.M.D", "YA.M.D", "M-D-Y", "M-D-YA", "D-M-Y", "D-M-YA", "Y-M-D", "YA-M-D", "M/D/Y", "M/D/YA", "D/M/Y", "D/M/YA", "Y/M/D", "YA/M/D", "M/D/Y", "M/D/YA"); @@ -360,15 +360,16 @@ foreach ($items as $child) { // $res_v = 'no'; $opt_hide = ''; $res_v = ''; + // set res_v according to precedence Default here, value here, supplied value if (!empty($child->default)) { $res_v = (string)$child->default; } if (!empty($child->value)) { $res_v = (string)$child->value; } - if (!empty($fvalues[$res_ext])) { - if (($fvalues[$res_ext]['data'] != '') ) { - $res_v = (string)$fvalues[$res_ext]['data']; + if (!empty($fvalues[$res_n])) { + if (($fvalues[$res_n]['data'] != '') ) { + $res_v = (string)$fvalues[$res_n]['data']; } } if (!empty($child->option_hide)) { diff --git a/views/server.advanced.php b/views/server.advanced.php index 17facb9..eb9b93b 100644 --- a/views/server.advanced.php +++ b/views/server.advanced.php @@ -14,10 +14,10 @@ // originally, this was populated by sccpgeneral.xml but that should be static // now will populate from the db defaults. - $defaultVals = $this->getTableDefaults('sccpdevice'); + $defaultVals = $this->getTableDefaults('sccpdevice', true); echo $this->showGroup('sccp_srst', 1); - echo $this->showGroup('sccp_dev_vendor_conf', 1,'vendorconfig',$defaultVals,false); + echo $this->showGroup('sccp_dev_vendor_conf', 1,'sccpdevice', $defaultVals, false); ?> diff --git a/views/server.device.php b/views/server.device.php index 3f84306..ff3a135 100644 --- a/views/server.device.php +++ b/views/server.device.php @@ -14,10 +14,11 @@ $def_val_line = $this->getTableDefaults('sccpline'); $def_val_device = $this->getTableDefaults('sccpdevice'); - echo $this->showGroup('sccp_dev_config', 1, 'sccpdevice'); - echo $this->showGroup('sccp_dev_group_config', 1, 'sccpline'); - echo $this->showGroup('sccp_dev_advconfig', 1, 'sccpdevice'); - echo $this->showGroup('sccp_dev_softkey', 1, 'sccpdevice'); - echo $this->showGroup('sccp_hotline_config', 1, 'sccpdevice'); + + echo $this->showGroup('sccp_dev_config', 1, 'sccpdevice', $def_val_device); + echo $this->showGroup('sccp_dev_group_config', 1, 'sccpline', $def_val_line); + echo $this->showGroup('sccp_dev_advconfig', 1, 'sccpdevice', $def_val_device); + echo $this->showGroup('sccp_dev_softkey', 1, 'sccpdevice', $def_val_device); + echo $this->showGroup('sccp_hotline_config', 1, 'sccpdevice', $def_val_device); ?> diff --git a/views/server.setting.php b/views/server.setting.php index c9da1a8..c2ca156 100644 --- a/views/server.setting.php +++ b/views/server.setting.php @@ -22,11 +22,13 @@ getTableDefaults('sccpdevice'); + echo $this->showGroup('sccp_general', 1); echo $this->showGroup('sccp_dev_time_s', 1); echo $this->showGroup('sccp_net', 1); echo $this->showGroup('sccp_lang', 1); - echo $this->showGroup('sccp_qos_config', 1, 'sccpdevice'); + echo $this->showGroup('sccp_qos_config', 1, 'sccpdevice', $def_val_device); echo $this->showGroup('sccp_extpath_config', 1); ?>