Move most Ajax Submit functions into handleSubmit
Improves readability and simplifies variables
This commit is contained in:
parent
efdf2d0469
commit
f36c224f87
|
@ -48,18 +48,11 @@ trait ajaxHelper {
|
||||||
$cmd_id = $request['command'];
|
$cmd_id = $request['command'];
|
||||||
switch ($cmd_id) {
|
switch ($cmd_id) {
|
||||||
case 'savesettings':
|
case 'savesettings':
|
||||||
$action = isset($request['sccp_createlangdir']) ? $request['sccp_createlangdir'] : '';
|
// Consolidate this into a separate method to improve legibility
|
||||||
if ($action == 'yes') {
|
|
||||||
$this->initializeTFtpLanguagePath();
|
|
||||||
}
|
|
||||||
$this->handleSubmit($request);
|
$this->handleSubmit($request);
|
||||||
// $this->saveSccpSettings();
|
|
||||||
//$this->createDefaultSccpConfig();
|
|
||||||
$this->createDefaultSccpXml();
|
|
||||||
|
|
||||||
$res = $this->aminterface->core_sccp_reload();
|
$res = $this->aminterface->core_sccp_reload();
|
||||||
$msg [] = 'Config Saved: ' . $res['Response'];
|
$msg [] = array ("Config Saved: {$res['Response']}", "Info : {$res['data']}");
|
||||||
$msg [] = 'Info :' . $res['data'];
|
|
||||||
// !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg)
|
// !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg)
|
||||||
return array('status' => true, 'message' => $msg, 'reload' => true);
|
return array('status' => true, 'message' => $msg, 'reload' => true);
|
||||||
break;
|
break;
|
||||||
|
@ -388,7 +381,7 @@ trait ajaxHelper {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSubmit($get_settings, $validateonly = false) {
|
function handleSubmit($request, $validateonly = false) {
|
||||||
$hdr_prefix = 'sccp_';
|
$hdr_prefix = 'sccp_';
|
||||||
$hdr_arprefix = 'sccp-ar_';
|
$hdr_arprefix = 'sccp-ar_';
|
||||||
$save_settings = array();
|
$save_settings = array();
|
||||||
|
@ -398,7 +391,11 @@ trait ajaxHelper {
|
||||||
$integer_msg = _("%s must be a non-negative integer");
|
$integer_msg = _("%s must be a non-negative integer");
|
||||||
$errors = array();
|
$errors = array();
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($get_settings as $key => $value) {
|
$action = isset($request['sccp_createlangdir']) ? $request['sccp_createlangdir'] : '';
|
||||||
|
if ($action == 'yes') {
|
||||||
|
$this->initializeTFtpLanguagePath();
|
||||||
|
}
|
||||||
|
foreach ($request as $key => $value) {
|
||||||
// Initallly saved all to sccpvalues. Now will save to db defaults if appropriate
|
// Initallly saved all to sccpvalues. Now will save to db defaults if appropriate
|
||||||
// TODO: Need to verify the tables defined in showGroup - some options maybe
|
// TODO: Need to verify the tables defined in showGroup - some options maybe
|
||||||
// device options, but if set by freePbx extensions, be in sccpline.
|
// device options, but if set by freePbx extensions, be in sccpline.
|
||||||
|
@ -417,7 +414,7 @@ trait ajaxHelper {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$dbSaveArray[] = array('table' => 'sccpdevice', 'field' => $key, 'Default' => $value);
|
$dbSaveArray[] = array('table' => 'sccpdevice', 'field' => $key, 'Default' => $value);
|
||||||
unset($get_settings[$key]);
|
unset($request[$key]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,6 +504,7 @@ trait ajaxHelper {
|
||||||
|
|
||||||
$this->createDefaultSccpConfig(); // Rewrite Config.
|
$this->createDefaultSccpConfig(); // Rewrite Config.
|
||||||
$save_settings[] = array('status' => true);
|
$save_settings[] = array('status' => true);
|
||||||
|
$this->createDefaultSccpXml();
|
||||||
return $save_settings;
|
return $save_settings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue