-- Bug Fix Delete Empty Key

This commit is contained in:
PhantomVl 2020-11-16 10:33:18 +03:00 committed by Diederik de Groot
parent 7b48b289af
commit 3bf8857759
No known key found for this signature in database
GPG key ID: AFA728250A1BECD6
2 changed files with 23 additions and 9 deletions

View file

@ -686,7 +686,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
$this->initializeTFtpLanguagePath(); $this->initializeTFtpLanguagePath();
} }
$this->handleSubmit($request); $this->handleSubmit($request);
$this->saveSccpSettings(); // $this->saveSccpSettings();
//$this->createDefaultSccpConfig(); //$this->createDefaultSccpConfig();
$this->createDefaultSccpXml(); $this->createDefaultSccpXml();
@ -1369,13 +1369,17 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
$tz_id = $value; $tz_id = $value;
$TZdata = $this->extconfigs->getextConfig('sccp_timezone_offset', $tz_id); $TZdata = $this->extconfigs->getextConfig('sccp_timezone_offset', $tz_id);
if (!empty($TZdata)) { if (!empty($TZdata)) {
$save_settings[] = array('keyword' => 'tzoffset', 'data' => ($TZdata / 60), $value = ($TZdata / 60);
'seq' => '98', if (!($this->sccpvalues['tzoffset']['data'] == $value)) {
'type' => '2'); $save_settings[] = array('keyword' => 'tzoffset', 'data' => $value,
'seq' => '98',
'type' => '2');
}
} }
break; break;
} }
} }
if (!empty($save_settings)) { if (!empty($save_settings)) {
$this->saveSccpSettings($save_settings); $this->saveSccpSettings($save_settings);
$this->getSccpSettingFromDB(); $this->getSccpSettingFromDB();
@ -1857,8 +1861,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
*/ */
private function saveSccpSettings($save_value = array()) { private function saveSccpSettings($save_value = array()) {
global $db; // global $db;
global $amp_conf; // global $amp_conf;
$save_settings = array(); $save_settings = array();
if (empty($save_value)) { 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'; $f_linetype = ($dev_line_data['dial'] == 'PJSIP') ? 'pjsip' : 'sip';
$dev_line_data['sbind'] = $tmp_bind[$f_linetype]; $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]))) { 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; return -1;
} }

View file

@ -247,18 +247,20 @@ class dbinterface
global $db; global $db;
// global $amp_conf; // global $amp_conf;
$result = "Error"; $result = "Error";
$delete_value = array();
switch ($db_name) { switch ($db_name) {
case 'sccpsettings': case 'sccpsettings':
foreach ($save_value as $key_v => $data) { foreach ($save_value as $key_v => $data) {
if (!empty($data)) { if (!empty($data)) {
if (isset($data[1])) { if (isset($data[1])) {
if ($data[1] == $this->val_null) { if ($data[1] == $this->val_null) {
$delete_value[] = $save_value[$key_v]['keyword'];
unset($save_value[$key_v]); unset($save_value[$key_v]);
} }
} }
if (isset($data['data'])) { if (isset($data['data'])) {
if ($data['data'] == $this->val_null) { if ($data['data'] == $this->val_null) {
$delete_value[] = $save_value[$key_v]['keyword'];
unset($save_value[$key_v]); unset($save_value[$key_v]);
} }
} }
@ -271,8 +273,14 @@ class dbinterface
$stmt = $db->prepare('INSERT INTO `sccpsettings` (`keyword`, `data`, `seq`, `type`) VALUES (?,?,?,?)'); $stmt = $db->prepare('INSERT INTO `sccpsettings` (`keyword`, `data`, `seq`, `type`) VALUES (?,?,?,?)');
$result = $db->executeMultiple($stmt, $save_value); $result = $db->executeMultiple($stmt, $save_value);
} else { } else {
$stmt = $db->prepare('REPLACE INTO `sccpsettings` (`keyword`, `data`, `seq`, `type`) VALUES (?,?,?,?)'); if (!empty($delete_value)) {
$result = $db->executeMultiple($stmt, $save_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; break;
case 'sccpdevmodel': case 'sccpdevmodel':