Optimise handlerSubmit and activate TZ

Simplify process
Reenable TZ offset test on save
This commit is contained in:
steve-lad 2021-06-18 13:13:38 +02:00
parent de3c58178b
commit 510b4259ac
2 changed files with 33 additions and 27 deletions

View file

@ -520,13 +520,13 @@ and open the template in the editor. Base Version before all crash :-)
</select>
<help>Date Format: The date format for the on-screen display. Can be one of the following: (D-M-YA, M.D.Y, Y/M/D) where 'D' is Day, 'M' is Month, 'Y' is Year, 'A' is 24-hour, 'a' is 12-hour, and the separators can be '.','-','/'</help>
</item>
<item type="SLTZN" id="2" seq="95">
<item type="IE" id="4" seq="10">
<label>Time Zone</label>
<input>
<name>ntp_timezone</name>
<class>sccp-custom</class>
<select>
<default>UTC</default>
</select>
<default></default>
<options readonly="readonly"></options>
</input>
<help>System Time zone - this is set by FreePBX and can be changed in Settings : Advanced Settings</help>
</item>
</page_group>

View file

@ -381,7 +381,6 @@ trait ajaxHelper {
}
function handleSubmit($request, $validateonly = false) {
dbug('Request', $request);
$hdr_prefix = 'sccp_';
$hdr_arprefix = 'sccp-ar_';
$save_settings = array();
@ -434,22 +433,23 @@ trait ajaxHelper {
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));
if (!empty($this->sccpvalues[$key1])) {
if (!($this->sccpvalues[$key1]['data'] == $value)) {
$save_settings[] = array('keyword' => $this->sccpvalues[$key1]['keyword'], 'data' => $value,
'seq' => $this->sccpvalues[$key1]['seq'], 'type' => $this->sccpvalues[$key1]['type']);
$key = (str_replace($hdr_prefix, '', $key, $count_mods));
if ($count_mods) {
if (!empty($this->sccpvalues[$key]) && (!($this->sccpvalues[$key]['data'] == $value))) {
$save_settings[] = array(
'keyword' => $this->sccpvalues[$key]['keyword'],
'data' => $value,
'seq' => $this->sccpvalues[$key]['seq'],
'type' => $this->sccpvalues[$key1]['type']
);
}
}
}
$pos = strpos($key, $hdr_arprefix);
if ($pos !== false) {
$key1 = substr_replace($key, '', 0, strlen($hdr_arprefix));
$key = (str_replace($hdr_arprefix, '', $key, $count_mods));
if ($count_mods) {
$arr_data = '';
if (!empty($this->sccpvalues[$key1])) {
if (!empty($this->sccpvalues[$key])) {
foreach ($value as $vkey => $vval) {
$tmp_data = '';
foreach ($vval as $vkey => $vval) {
@ -475,9 +475,13 @@ trait ajaxHelper {
while (substr($arr_data, -1) == ';') {
$arr_data = substr($arr_data, 0, -1);
}
if (!($this->sccpvalues[$key1]['data'] == $arr_data)) {
$save_settings[] = array('keyword' => $this->sccpvalues[$key1]['keyword'], 'data' => $arr_data,
'seq' => $this->sccpvalues[$key1]['seq'], 'type' => $this->sccpvalues[$key1]['type']);
if (!($this->sccpvalues[$key]['data'] == $arr_data)) {
$save_settings[] = array(
'keyword' => $this->sccpvalues[$key]['keyword'],
'data' => $arr_data,
'seq' => $this->sccpvalues[$key]['seq'],
'type' => $this->sccpvalues[$key]['type']
);
}
}
}
@ -496,15 +500,18 @@ trait ajaxHelper {
}
break;
case 'sccp_ntp_timezone':
case 'ntp_timezone':
$tz_id = $value;
$TZdata = $this->extconfigs->getextConfig('sccp_timezone', $tz_id);
if (!empty($TZdata)) {
$value = $TZdata['offset']/60;
if (!($this->sccpvalues['tzoffset']['data'] == $value)) {
$save_settings[] = array('keyword' => 'tzoffset', 'data' => $value,
$save_settings[] = array(
'keyword' => 'tzoffset',
'data' => $value,
'seq' => '98',
'type' => '2');
'type' => '2'
);
}
}
break;
@ -512,7 +519,6 @@ trait ajaxHelper {
}
if (!empty($save_settings)) {
dbug('save settings', $save_settings);
$this->saveSccpSettings($save_settings);
$this->sccpvalues = $this->dbinterface->get_db_SccpSetting();
}