Resolve issue of softkeysets lost across installs
This commit is contained in:
parent
b6485313fd
commit
2367203ece
|
@ -714,16 +714,9 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
'tftp_countries_path' => $this->sccpvalues['tftp_countries_path']['data']
|
||||
);
|
||||
|
||||
$read_config = $this->cnf_read->getConfig('sccp.conf');
|
||||
$this->sccp_conf_init['general'] = $read_config['general'];
|
||||
foreach ($read_config as $key => $value) {
|
||||
if (isset($read_config[$key]['type'])) { // copy soft key
|
||||
if ($read_config[$key]['type'] == 'softkeyset') {
|
||||
$this->sccp_conf_init[$key] = $read_config[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
// initialise $sccp_conf_init
|
||||
$this->sccp_conf_init = $this->initialiseConfInit();
|
||||
|
||||
$hint = $this->aminterface->core_list_hints();
|
||||
foreach ($hint as $key => $value) {
|
||||
if ($this->hint_context['default'] != $value) {
|
||||
|
|
14
install.php
14
install.php
|
@ -1024,13 +1024,6 @@ function addDriver($sccp_compatible) {
|
|||
$file = $amp_conf['AMPWEBROOT'] . '/admin/modules/core/functions.inc/drivers/Sccp.class.php';
|
||||
$contents = "<?php include '/var/www/html/admin/modules/sccp_manager/sccpManClasses/Sccp.class.php.v{$sccp_compatible}'; ?>";
|
||||
file_put_contents($file, $contents);
|
||||
|
||||
$dir = $cnf_int->get('ASTETCDIR');
|
||||
if (!file_exists("{$dir}/sccp.conf")) { // System re Config
|
||||
outn("<li>" . _("Adding default configuration file ...") . "</li>");
|
||||
$sccpfile = file_get_contents($amp_conf['AMPWEBROOT'] . '/admin/modules/sccp_manager/conf/sccp.conf');
|
||||
file_put_contents("{$dir}/sccp.conf", $sccpfile);
|
||||
}
|
||||
}
|
||||
function checkTftpServer() {
|
||||
outn("<li>" . _("Checking TFTP server path and availability ...") . "</li>");
|
||||
|
@ -1292,9 +1285,10 @@ function cleanUpSccpSettings() {
|
|||
)";
|
||||
$results = $db->query($sql);
|
||||
}
|
||||
|
||||
// Now correct sccp.conf to replace any illegal settings
|
||||
$thisInstaller->createDefaultSccpConfig($settingsFromDb, $cnf_int->get('ASTETCDIR'));
|
||||
// Need to load any existing sccp.conf so that retain softkeys section if exists.
|
||||
$sccp_conf_init = $thisInstaller->initialiseConfInit();
|
||||
// Now correct sccp.conf to replace any illegal settings passing $sccp_conf_init
|
||||
$thisInstaller->createDefaultSccpConfig($settingsFromDb, $cnf_int->get('ASTETCDIR'), $sccp_conf_init);
|
||||
|
||||
// have to correct prior verion sccpline lists for allow/disallow and deny permit. Prior
|
||||
// versions used csl, but chan-sccp expects ; separated lists when returned by db.
|
||||
|
|
|
@ -42,7 +42,9 @@
|
|||
* Version 14.4.0.3 * - Change method of selecting phonecodepage depending on if is java phone.
|
||||
* Version 14.4.0.5 * - Fix issue #59.
|
||||
* Version 14.5.0.1 * - Fix issue #32.
|
||||
* Version 14.5.0.4 * - Fix issue where values with spaces are truncated. Preserve softkeys accross installs
|
||||
* Version 16.0.0.1 * - Improve compliance and use of BMO to optimise performance
|
||||
|
||||
</changelog>
|
||||
<location>https://github.com/chan-sccp/sccp_manager</location>
|
||||
<depends>
|
||||
|
|
|
@ -231,11 +231,11 @@ trait ajaxHelper {
|
|||
|
||||
case 'deleteSoftKey':
|
||||
if (!empty($request['softkey'])) {
|
||||
//$id_name = $request['softkey'];
|
||||
unset($this->sccp_conf_init[$request['softkey']]);
|
||||
$this->createDefaultSccpConfig($this->sccpvalues, $this->sccppath["asterisk"]);
|
||||
$msg = $this->aminterface->core_sccp_reload();
|
||||
return array('status' => true, 'reload' => true, 'message' => $msg['Response'] .' - Softkey set deleted');
|
||||
$id_name = $request['softkey'];
|
||||
unset($this->sccp_conf_init[$id_name]);
|
||||
$this->createDefaultSccpConfig($this->sccpvalues, $this->sccppath["asterisk"], $this->sccp_conf_init);
|
||||
$msg = print_r($this->aminterface->core_sccp_reload(), 1);
|
||||
return array('status' => true, 'table_reload' => true);
|
||||
}
|
||||
break;
|
||||
case 'updateSoftKey':
|
||||
|
@ -247,7 +247,7 @@ trait ajaxHelper {
|
|||
$this->sccp_conf_init[$id_name][$keyl] = $request[$keyl];
|
||||
}
|
||||
}
|
||||
$this->createDefaultSccpConfig($this->sccpvalues, $this->sccppath["asterisk"]);
|
||||
$this->createDefaultSccpConfig($this->sccpvalues, $this->sccppath["asterisk"], $this->sccp_conf_init);
|
||||
|
||||
// !TODO!: -TODO-: Check SIP Support Enabled
|
||||
$this->createSccpXmlSoftkey();
|
||||
|
@ -403,7 +403,7 @@ trait ajaxHelper {
|
|||
$this->dbinterface->updateTableDefaults($rowToSave['table'], $rowToSave['field'], $rowToSave['Default']);
|
||||
}
|
||||
// rewrite sccp.conf
|
||||
$this->createDefaultSccpConfig($this->sccpvalues, $this->sccppath["asterisk"]);
|
||||
$this->createDefaultSccpConfig($this->sccpvalues, $this->sccppath["asterisk"], $this->sccp_conf_init);
|
||||
$this->createDefaultSccpXml();
|
||||
// TODO: Need to be more specific on reload and only reload if critical settings changed.
|
||||
$res = $this->aminterface->core_sccp_reload();
|
||||
|
|
|
@ -268,6 +268,20 @@ trait helperfunctions {
|
|||
return false;
|
||||
}
|
||||
|
||||
public function initialiseConfInit(){
|
||||
$read_config = \FreePBX::LoadConfig()->getConfig('sccp.conf');
|
||||
$sccp_conf_init['general'] = $read_config['general'];
|
||||
foreach ($read_config as $key => $value) {
|
||||
if (isset($read_config[$key]['type'])) { // copy soft key
|
||||
if ($read_config[$key]['type'] == 'softkeyset') {
|
||||
$sccp_conf_init[$key] = $read_config[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $sccp_conf_init;
|
||||
}
|
||||
|
||||
|
||||
public function checkTftpMapping(){
|
||||
exec('in.tftpd -V', $tftpInfo);
|
||||
$info['TFTP Server'] = array('Version' => 'Not Found', 'about' => 'Mapping not available');
|
||||
|
@ -336,18 +350,18 @@ trait helperfunctions {
|
|||
unset($sysConfig);
|
||||
}
|
||||
|
||||
public function createDefaultSccpConfig(array $sccpvalues, string $asteriskPath) {
|
||||
public function createDefaultSccpConfig(array $sccpvalues, string $asteriskPath, $conf_init) {
|
||||
global $cnf_wr;
|
||||
// Make sccp.conf data
|
||||
// [general] section
|
||||
// TODO: Need to review sccpsettings seq numbering, as will speed this up, and remove the need for $permittedSettings.
|
||||
$cnf_wr = \FreePBX::WriteConfig();
|
||||
//clear old general settings, and initiate with allow/disallow and permit/deny keys in correct order
|
||||
$this->sccp_conf_init['general'] = array();
|
||||
$this->sccp_conf_init['general']['disallow'] = 'all';
|
||||
$this->sccp_conf_init['general']['allow'] = '';
|
||||
$this->sccp_conf_init['general']['deny'] = '0.0.0.0/0.0.0.0';
|
||||
$this->sccp_conf_init['general']['permit'] = '0.0.0.0/0.0.0.0';
|
||||
$conf_init['general'] = array();
|
||||
$conf_init['general']['disallow'] = 'all';
|
||||
$conf_init['general']['allow'] = '';
|
||||
$conf_init['general']['deny'] = '0.0.0.0/0.0.0.0';
|
||||
$conf_init['general']['permit'] = '0.0.0.0/0.0.0.0';
|
||||
// permitted chan-sccp settings array
|
||||
$permittedSettings = array(
|
||||
'debug', 'servername', 'keepalive', 'context', 'dateformat', 'bindaddr', 'port', 'secbindaddr', 'secport', 'disallow', 'allow', 'deny', 'permit',
|
||||
|
@ -371,7 +385,7 @@ trait helperfunctions {
|
|||
case "deny":
|
||||
case "localnet":
|
||||
case "permit":
|
||||
$this->sccp_conf_init['general'][$key] = explode(';', $value['data']);
|
||||
$conf_init['general'][$key] = explode(';', $value['data']);
|
||||
break;
|
||||
case "devlang":
|
||||
/*
|
||||
|
@ -388,7 +402,7 @@ trait helperfunctions {
|
|||
break;
|
||||
default:
|
||||
if (!empty($value['data'])) {
|
||||
$this->sccp_conf_init['general'][$key] = $value['data'];
|
||||
$conf_init['general'][$key] = $value['data'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -398,7 +412,7 @@ trait helperfunctions {
|
|||
// This will complicate solving problems caused by unexpected solutions from users.
|
||||
//
|
||||
if (file_exists($asteriskPath . "/sccp_custom.conf")) {
|
||||
$this->sccp_conf_init['HEADER'] = array(
|
||||
$conf_init['HEADER'] = array(
|
||||
"; ;",
|
||||
"; It is a very bad idea to add an external configuration file !!!! ;",
|
||||
"; This will complicate solving problems caused by unexpected solutions ;",
|
||||
|
@ -407,7 +421,7 @@ trait helperfunctions {
|
|||
"#include sccp_custom.conf"
|
||||
);
|
||||
}
|
||||
$cnf_wr->WriteConfig('sccp.conf', $this->sccp_conf_init);
|
||||
$cnf_wr->WriteConfig('sccp.conf', $conf_init);
|
||||
}
|
||||
|
||||
public function initVarfromXml() {
|
||||
|
|
Loading…
Reference in a new issue