Clean up and correct missing save settings
Remove unnecessary method from formcreate Correct indentation in formcreate Remove debug code in Sccp.class correct logic for updating TFTP mode
This commit is contained in:
parent
30cbe1ba95
commit
248abe6cb7
|
@ -216,7 +216,6 @@ class Sccp extends \FreePBX\modules\Core\Driver {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDeviceDisplay($display, $deviceInfo, $currentComponent, $primarySection) {
|
public function getDeviceDisplay($display, $deviceInfo, $currentComponent, $primarySection) {
|
||||||
dbug('',$primarySection);
|
|
||||||
$activeCodecs = array();
|
$activeCodecs = array();
|
||||||
// load xml data to get help from same source as rest of module
|
// load xml data to get help from same source as rest of module
|
||||||
$xml_vars = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/sccpgeneral.xml.v433';
|
$xml_vars = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/sccpgeneral.xml.v433';
|
||||||
|
@ -321,7 +320,6 @@ class Sccp extends \FreePBX\modules\Core\Driver {
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'IS':
|
case 'IS':
|
||||||
dbug('', $child);
|
|
||||||
$select = array();
|
$select = array();
|
||||||
foreach ($child->xpath('button') as $value) {
|
foreach ($child->xpath('button') as $value) {
|
||||||
$select[] = array('value' => strtolower((string)$value[@value]), 'text' => (string)$value);
|
$select[] = array('value' => strtolower((string)$value[@value]), 'text' => (string)$value);
|
||||||
|
|
|
@ -249,27 +249,27 @@ class extconfigs
|
||||||
'languages' => 'languages',
|
'languages' => 'languages',
|
||||||
'templates' => 'templates',
|
'templates' => 'templates',
|
||||||
'dialplan' => 'dialplan',
|
'dialplan' => 'dialplan',
|
||||||
'softkey' => 'softkey'
|
'softkey' => 'softkey',
|
||||||
|
'ringtones' => 'ringtones',
|
||||||
|
'wallpapers' => 'wallpapers'
|
||||||
);
|
);
|
||||||
|
$adv_tree = array('pro' => array('templates' => 'tftproot',
|
||||||
$adv_tree['pro'] = array('templates' => 'tftproot',
|
'settings' => 'tftproot',
|
||||||
'settings' => 'tftproot',
|
'locales' => 'tftproot',
|
||||||
'locales' => 'tftproot',
|
'firmware' => 'tftproot',
|
||||||
'firmware' => 'tftproot',
|
'languages' => 'locales',
|
||||||
'languages' => 'locales',
|
'dialplan' => 'tftproot',
|
||||||
'dialplan' => 'tftproot',
|
'softkey' => 'tftproot'
|
||||||
'softkey' => 'tftproot'
|
),
|
||||||
);
|
'def' => array('templates' => 'tftproot',
|
||||||
|
'settings' => '',
|
||||||
$adv_tree['def'] = array('templates' => 'tftproot',
|
'locales' => '',
|
||||||
'settings' => '',
|
'firmware' => '',
|
||||||
'locales' => '',
|
'languages' => 'tftproot',
|
||||||
'firmware' => '',
|
'dialplan' => '',
|
||||||
'languages' => 'tftproot',
|
'softkey' => ''
|
||||||
'dialplan' => '',
|
)
|
||||||
'softkey' => ''
|
);
|
||||||
);
|
|
||||||
|
|
||||||
$base_tree = array('tftp_templates_path' => 'templates',
|
$base_tree = array('tftp_templates_path' => 'templates',
|
||||||
'tftp_store_path' => 'settings',
|
'tftp_store_path' => 'settings',
|
||||||
'tftp_lang_path' => 'languages',
|
'tftp_lang_path' => 'languages',
|
||||||
|
@ -277,18 +277,17 @@ class extconfigs
|
||||||
'tftp_dialplan_path' => 'dialplan',
|
'tftp_dialplan_path' => 'dialplan',
|
||||||
'tftp_softkey_path' => 'softkey'
|
'tftp_softkey_path' => 'softkey'
|
||||||
);
|
);
|
||||||
|
|
||||||
$base_config = array();
|
$base_config = array();
|
||||||
|
|
||||||
if (!empty($settingsFromDb['tftp_rewrite_path']['data'])) {
|
if (!empty($settingsFromDb['tftp_rewrite_path']['data'])) {
|
||||||
// Have a setting in sccpsettings. It should start with $tftpRootPath
|
// Have a setting in sccpsettings. It should start with $tftp_path
|
||||||
// If not we will replace it with $tftpRootPath. Avoids issues with legacy values
|
// If not we will replace it with $tftp_path. Avoids issues with legacy values
|
||||||
if (!strpos($settingsFromDb['tftp_rewrite_path']["data"],$settingsFromDb['tftp_path']['data'])) {
|
if (!strpos($settingsFromDb['tftp_rewrite_path']["data"],$settingsFromDb['tftp_path']['data'])) {
|
||||||
|
|
||||||
$adv_ini = "{$tftpRootPath}/index.cnf";
|
$adv_ini = "{$settingsFromDb['tftp_path']['data']}/index.cnf";
|
||||||
$settingsToDb['tftp_rewrite_path'] = $settingsFromDb['tftp_rewrite_path'];
|
$settingsToDb['tftp_rewrite_path'] = $settingsFromDb['tftp_rewrite_path'];
|
||||||
$settingsToDb['tftp_rewrite_path']['data'] = $tftpRootPath;
|
$settingsToDb['tftp_rewrite_path']['data'] = $settingsFromDb['tftp_path']['data'];
|
||||||
}
|
}
|
||||||
$adv_ini = "{$settingsFromDb['tftp_rewrite_path']["data"]}/index.cnf";
|
$adv_ini = "{$settingsFromDb['tftp_rewrite_path']["data"]}/index.cnf";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,14 +300,14 @@ class extconfigs
|
||||||
$adv_ini_array = parse_ini_file($adv_ini);
|
$adv_ini_array = parse_ini_file($adv_ini);
|
||||||
$adv_config = array_merge($adv_config, $adv_ini_array);
|
$adv_config = array_merge($adv_config, $adv_ini_array);
|
||||||
}
|
}
|
||||||
|
$settingsToDb['tftp_rewrite'] =array( 'keyword' => 'tftp_rewrite', 'seq' => 20, 'type' => 2, 'data' => 'pro', 'systemdefault' => '');
|
||||||
break;
|
break;
|
||||||
case 'on':
|
case 'on':
|
||||||
case 'internal':
|
case 'internal':
|
||||||
case 'off':
|
case 'off':
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
// not defined so set here
|
// not defined so set here to off
|
||||||
$settingsToDb["tftp_rewrite"] =array( 'keyword' => 'tftp_rewrite', 'seq' => 20, 'type' => 2, 'data' => 'off');
|
$settingsToDb['tftp_rewrite'] =array( 'keyword' => 'tftp_rewrite', 'seq' => 20, 'type' => 2, 'data' => 'off', 'systemdefault' => '');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($adv_tree[$adv_tree_mode] as $key => $value) {
|
foreach ($adv_tree[$adv_tree_mode] as $key => $value) {
|
||||||
|
@ -322,10 +321,11 @@ class extconfigs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($base_tree as $key => $value) {
|
foreach ($base_tree as $key => $value) {
|
||||||
$base_config[$key] = $adv_config[$value];
|
$base_config[$key] = $adv_config[$value];
|
||||||
// Save to sccpsettings
|
// Save to sccpsettings
|
||||||
$settingsToDb[$key] =array( 'keyword' => $key, 'seq' => 20, 'type' => 0, 'data' => $adv_config[$value]);
|
$settingsToDb[$key] =array( 'keyword' => $key, 'seq' => 20, 'type' => 0, 'data' => $adv_config[$value], 'systemdefault' => '');
|
||||||
if (!is_dir($base_config[$key])) {
|
if (!is_dir($base_config[$key])) {
|
||||||
if (!mkdir($base_config[$key], 0755, true)) {
|
if (!mkdir($base_config[$key], 0755, true)) {
|
||||||
die_freepbx(_('Error creating dir : ' . $base_config[$key]));
|
die_freepbx(_('Error creating dir : ' . $base_config[$key]));
|
||||||
|
@ -342,7 +342,18 @@ class extconfigs
|
||||||
}
|
}
|
||||||
// Remove keys that are not required before returning $base_config.
|
// Remove keys that are not required before returning $base_config.
|
||||||
unset($base_config['asterisk'], $base_config['sccp_conf'], $base_config['tftp_path']);
|
unset($base_config['asterisk'], $base_config['sccp_conf'], $base_config['tftp_path']);
|
||||||
return $base_config;
|
return $settingsToDb;
|
||||||
|
}
|
||||||
|
private function initializeTFtpLanguagePath() {
|
||||||
|
$dir = $this->sccppath["tftp_lang_path"];
|
||||||
|
foreach ($this->extconfigs->getExtConfig('sccp_lang') as $lang_key => $lang_value) {
|
||||||
|
$filename = $dir . DIRECTORY_SEPARATOR . $lang_value['locale'];
|
||||||
|
if (!file_exists($filename)) {
|
||||||
|
if (!mkdir($filename, 0777, true)) {
|
||||||
|
die('Error creating tftp language directory');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validate_RealTime( $connector )
|
public function validate_RealTime( $connector )
|
||||||
|
|
|
@ -476,93 +476,7 @@ class formcreate
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
function addElementSL($child, $fvalues, $sccp_defaults, $npref) {
|
function addElementSL($child, $fvalues, $sccp_defaults,$npref, $tftpLang) {
|
||||||
// TODO: Unused function. Integrated into SL2. To be removed after full testing.
|
|
||||||
/*
|
|
||||||
* Input element Select SLD - Date format
|
|
||||||
* SLM - Music on hold
|
|
||||||
* SLK - System KeySet
|
|
||||||
* SLP - Dial Paterns
|
|
||||||
*/
|
|
||||||
$res_n = (string)$child ->name;
|
|
||||||
$res_id = $npref.$res_n;
|
|
||||||
// $select_opt is a simple array for these types.
|
|
||||||
$select_opt = array();
|
|
||||||
|
|
||||||
if (!empty($metainfo[$res_n])) {
|
|
||||||
if ($child->meta_help == '1' || $child->help == 'Help!') {
|
|
||||||
$child->help = $metaInfo[$res_n];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (empty($child->class)) {
|
|
||||||
$child->class = 'form-control';
|
|
||||||
}
|
|
||||||
switch ($child['type']) {
|
|
||||||
case 'SLD':
|
|
||||||
$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");
|
|
||||||
$select_opt= $day_format;
|
|
||||||
break;
|
|
||||||
case 'SLM':
|
|
||||||
if (function_exists('music_list')) {
|
|
||||||
$moh_list = music_list();
|
|
||||||
}
|
|
||||||
if (!is_array($moh_list)) {
|
|
||||||
$moh_list = array('default');
|
|
||||||
}
|
|
||||||
$select_opt= $moh_list;
|
|
||||||
break;
|
|
||||||
case 'SLK':
|
|
||||||
$softKeyList = \FreePBX::Sccp_manager()->aminterface->sccp_list_keysets();
|
|
||||||
$select_opt= $softKeyList;
|
|
||||||
break;
|
|
||||||
case 'SLP':
|
|
||||||
$dialplan_list = array();
|
|
||||||
foreach (\FreePBX::Sccp_manager()->getDialPlanList() as $tmpkey) {
|
|
||||||
$tmp_id = $tmpkey['id'];
|
|
||||||
$dialplan_list[$tmp_id] = $tmp_id;
|
|
||||||
}
|
|
||||||
$select_opt= $dialplan_list;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!empty($fvalues[$res_n])) {
|
|
||||||
if (!empty($fvalues[$res_n]['data'])) {
|
|
||||||
$child->value = $fvalues[$res_n]['data'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<div class="element-container">
|
|
||||||
<div class="row"> <div class="form-group">
|
|
||||||
<div class="col-md-3">
|
|
||||||
<label class="control-label" for="<?php echo $res_id; ?>"><?php echo _($child->label);?></label>
|
|
||||||
<i class="fa fa-question-circle fpbx-help-icon" data-for="<?php echo $res_id; ?>"></i>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-9"><div class = "lnet form-group form-inline" data-nextid=1>
|
|
||||||
<?php
|
|
||||||
echo '<select name="'.$res_id.'" class="'. $child->class . '" id="' . $res_id . '">';
|
|
||||||
|
|
||||||
foreach ($select_opt as $key) {
|
|
||||||
echo '<option value="' . $key . '"';
|
|
||||||
if ($key == $child->value) {
|
|
||||||
echo ' selected="selected"';
|
|
||||||
}
|
|
||||||
echo '>' . $key . '</option>';
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row"><div class="col-md-12">
|
|
||||||
<span id="<?php echo $res_id;?>-help" class="help-block fpbx-help-block"><?php echo _($child->help);?></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
function addElementSL2($child, $fvalues, $sccp_defaults,$npref, $tftpLang) {
|
|
||||||
// Input element Select SLS - System Language
|
// Input element Select SLS - System Language
|
||||||
$res_n = (string)$child ->name;
|
$res_n = (string)$child ->name;
|
||||||
$res_id = $npref.$res_n;
|
$res_id = $npref.$res_n;
|
||||||
|
@ -652,42 +566,46 @@ class formcreate
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<div class="element-container">
|
<div class="element-container">
|
||||||
<div class="row"> <div class="form-group">
|
<div class="row">
|
||||||
<div class="col-md-3">
|
<div class="form-group">
|
||||||
|
<div class="col-md-3">
|
||||||
<label class="control-label" for="<?php echo $res_id; ?>"><?php echo _($child->label);?></label>
|
<label class="control-label" for="<?php echo $res_id; ?>"><?php echo _($child->label);?></label>
|
||||||
<i class="fa fa-question-circle fpbx-help-icon" data-for="<?php echo $res_id; ?>"></i>
|
<i class="fa fa-question-circle fpbx-help-icon" data-for="<?php echo $res_id; ?>"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-9"><div class = "lnet form-group form-inline" data-nextid=1>
|
<div class="col-md-9">
|
||||||
<?php
|
<div class = "lnet form-group form-inline" data-nextid=1>
|
||||||
|
<?php
|
||||||
echo '<select name="'.$res_id.'" class="'. $child->class . '" id="' . $res_id . '">';
|
echo '<select name="'.$res_id.'" class="'. $child->class . '" id="' . $res_id . '">';
|
||||||
dbug('', $res_id);
|
foreach ($select_opt as $key => $val) {
|
||||||
foreach ($select_opt as $key => $val) {
|
if (is_array($val)) {
|
||||||
if (is_array($val)) {
|
$opt_key = (isset($val['id'])) ? $val['id'] : $key;
|
||||||
$opt_key = (isset($val['id'])) ? $val['id'] : $key;
|
$opt_val = (isset($val['val'])) ? $val['val'] : $val;
|
||||||
$opt_val = (isset($val['val'])) ? $val['val'] : $val;
|
} else if (\FreePBX::Sccp_manager()->is_assoc($select_opt)){
|
||||||
} else if (\FreePBX::Sccp_manager()->is_assoc($select_opt)){
|
// have associative array
|
||||||
// have associative array
|
$opt_key = $key;
|
||||||
$opt_key = $key;
|
$opt_val = $val;
|
||||||
$opt_val = $val;
|
} else {
|
||||||
} else {
|
// Have simple array
|
||||||
// Have simple array
|
$opt_key = $val;
|
||||||
$opt_key = $val;
|
$opt_val = $val;
|
||||||
$opt_val = $val;
|
}
|
||||||
}
|
echo '<option value="' . $opt_key . '"';
|
||||||
echo '<option value="' . $opt_key . '"';
|
if ($opt_key == $child->value) {
|
||||||
if ($opt_key == $child->value) {
|
echo ' selected="selected"';
|
||||||
echo ' selected="selected"';
|
}
|
||||||
}
|
echo "> {$opt_val} </option>";
|
||||||
echo '>' . $opt_val. '</option>';
|
}
|
||||||
}
|
?>
|
||||||
?> </select>
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row"><div class="col-md-12">
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
<span id="<?php echo $res_id;?>-help" class="help-block fpbx-help-block"><?php echo _($child->help);?></span>
|
<span id="<?php echo $res_id;?>-help" class="help-block fpbx-help-block"><?php echo _($child->help);?></span>
|
||||||
</div></div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
|
@ -405,6 +405,7 @@ trait ajaxHelper {
|
||||||
if ($action == 'yes') {
|
if ($action == 'yes') {
|
||||||
$this->initializeTFtpLanguagePath();
|
$this->initializeTFtpLanguagePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($request as $key => $value) {
|
foreach ($request as $key => $value) {
|
||||||
// Originally 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
|
// TODO: Need to verify the tables defined in showGroup - some options maybe
|
||||||
|
@ -448,7 +449,7 @@ trait ajaxHelper {
|
||||||
$key = (str_replace($hdr_prefix, '', $key, $count_mods));
|
$key = (str_replace($hdr_prefix, '', $key, $count_mods));
|
||||||
if ($count_mods) {
|
if ($count_mods) {
|
||||||
if (!empty($this->sccpvalues[$key]) && (!($this->sccpvalues[$key]['data'] == $value))) {
|
if (!empty($this->sccpvalues[$key]) && (!($this->sccpvalues[$key]['data'] == $value))) {
|
||||||
$save_settings[] = array(
|
$save_settings[$this->sccpvalues[$key]['keyword']] = array(
|
||||||
'keyword' => $this->sccpvalues[$key]['keyword'],
|
'keyword' => $this->sccpvalues[$key]['keyword'],
|
||||||
'data' => $value,
|
'data' => $value,
|
||||||
'seq' => $this->sccpvalues[$key]['seq'],
|
'seq' => $this->sccpvalues[$key]['seq'],
|
||||||
|
@ -457,7 +458,6 @@ trait ajaxHelper {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$key = (str_replace($hdr_arprefix, '', $key, $count_mods));
|
$key = (str_replace($hdr_arprefix, '', $key, $count_mods));
|
||||||
if ($count_mods) {
|
if ($count_mods) {
|
||||||
$arr_data = '';
|
$arr_data = '';
|
||||||
|
@ -537,11 +537,14 @@ trait ajaxHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$extSettings = $this->extconfigs->updateTftpStructure(array_merge($this->sccpvalues, $save_settings));
|
||||||
|
$save_settings = array_merge($save_settings, $extSettings);
|
||||||
if (!empty($save_settings)) {
|
if (!empty($save_settings)) {
|
||||||
$this->saveSccpSettings($save_settings);
|
$this->saveSccpSettings($save_settings);
|
||||||
$this->sccpvalues = $this->dbinterface->get_db_SccpSetting();
|
$this->sccpvalues = $this->dbinterface->get_db_SccpSetting();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
foreach ($dbSaveArray as $rowToSave) {
|
foreach ($dbSaveArray as $rowToSave) {
|
||||||
$this->dbinterface->updateTableDefaults($rowToSave['table'], $rowToSave['field'], $rowToSave['Default']);
|
$this->dbinterface->updateTableDefaults($rowToSave['table'], $rowToSave['field'], $rowToSave['Default']);
|
||||||
}
|
}
|
||||||
|
@ -549,6 +552,9 @@ trait ajaxHelper {
|
||||||
$this->createDefaultSccpConfig(); // Rewrite Config.
|
$this->createDefaultSccpConfig(); // Rewrite Config.
|
||||||
$save_settings[] = array('status' => true);
|
$save_settings[] = array('status' => true);
|
||||||
$this->createDefaultSccpXml();
|
$this->createDefaultSccpXml();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return $save_settings;
|
return $save_settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ foreach ($items as $child) {
|
||||||
case 'SLA':
|
case 'SLA':
|
||||||
case 'SLZ':
|
case 'SLZ':
|
||||||
case 'SL':
|
case 'SL':
|
||||||
\FreePbx::sccp_manager()->formcreate->addElementSL2($child, $fvalues, $sccp_defaults,$npref, $tftpLang);
|
\FreePbx::sccp_manager()->formcreate->addElementSL($child, $fvalues, $sccp_defaults,$npref, $tftpLang);
|
||||||
break;
|
break;
|
||||||
case 'SDM':
|
case 'SDM':
|
||||||
case 'SDMS':
|
case 'SDMS':
|
||||||
|
|
Loading…
Reference in a new issue