diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 1740fbf..dba8c84 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -686,7 +686,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $this->initializeTFtpLanguagePath(); } $this->handleSubmit($request); - $this->saveSccpSettings(); + // $this->saveSccpSettings(); //$this->createDefaultSccpConfig(); $this->createDefaultSccpXml(); @@ -1369,13 +1369,17 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $tz_id = $value; $TZdata = $this->extconfigs->getextConfig('sccp_timezone_offset', $tz_id); if (!empty($TZdata)) { - $save_settings[] = array('keyword' => 'tzoffset', 'data' => ($TZdata / 60), - 'seq' => '98', - 'type' => '2'); + $value = ($TZdata / 60); + if (!($this->sccpvalues['tzoffset']['data'] == $value)) { + $save_settings[] = array('keyword' => 'tzoffset', 'data' => $value, + 'seq' => '98', + 'type' => '2'); + } } break; } } + if (!empty($save_settings)) { $this->saveSccpSettings($save_settings); $this->getSccpSettingFromDB(); @@ -1857,8 +1861,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { */ private function saveSccpSettings($save_value = array()) { - global $db; - global $amp_conf; +// global $db; +// global $amp_conf; $save_settings = array(); if (empty($save_value)) { @@ -1928,6 +1932,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $f_linetype = ($dev_line_data['dial'] == 'PJSIP') ? 'pjsip' : 'sip'; $dev_line_data['sbind'] = $tmp_bind[$f_linetype]; if ((!$this->array_key_exists_recursive('udp', $tmp_bind[$f_linetype])) && (!$this->array_key_exists_recursive('tcp', $tmp_bind[$f_linetype]))) { + print_r("Wrong sip server Config ! Not enabled UDP or TCP protocol"); + die(); return -1; } diff --git a/Sccp_manager.inc/dbinterface.class.php b/Sccp_manager.inc/dbinterface.class.php index 7d06c13..efcb398 100644 --- a/Sccp_manager.inc/dbinterface.class.php +++ b/Sccp_manager.inc/dbinterface.class.php @@ -247,18 +247,20 @@ class dbinterface global $db; // global $amp_conf; $result = "Error"; - + $delete_value = array(); switch ($db_name) { case 'sccpsettings': foreach ($save_value as $key_v => $data) { if (!empty($data)) { if (isset($data[1])) { if ($data[1] == $this->val_null) { + $delete_value[] = $save_value[$key_v]['keyword']; unset($save_value[$key_v]); } } if (isset($data['data'])) { if ($data['data'] == $this->val_null) { + $delete_value[] = $save_value[$key_v]['keyword']; unset($save_value[$key_v]); } } @@ -271,8 +273,14 @@ class dbinterface $stmt = $db->prepare('INSERT INTO `sccpsettings` (`keyword`, `data`, `seq`, `type`) VALUES (?,?,?,?)'); $result = $db->executeMultiple($stmt, $save_value); } else { - $stmt = $db->prepare('REPLACE INTO `sccpsettings` (`keyword`, `data`, `seq`, `type`) VALUES (?,?,?,?)'); - $result = $db->executeMultiple($stmt, $save_value); + if (!empty($delete_value)) { + $stmt = $db->prepare('DELETE FROM `sccpsettings` WHERE `keyword`=?'); + $result = $db->executeMultiple($stmt, $delete_value); + } + if (!empty($save_value)) { + $stmt = $db->prepare('REPLACE INTO `sccpsettings` (`keyword`, `data`, `seq`, `type`) VALUES (?,?,?,?)'); + $result = $db->executeMultiple($stmt, $save_value); + } } break; case 'sccpdevmodel':