Resolve issue of softkeysets lost across installs

This commit is contained in:
stevenA 2022-01-28 11:14:34 +01:00
parent 4cf414e995
commit f5e51a52b7
6 changed files with 38 additions and 37 deletions

View file

@ -692,15 +692,8 @@ 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) {

View file

@ -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>");
@ -1279,9 +1272,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.

View file

@ -42,7 +42,7 @@
* 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.2 * - Fix issue #32.
* Version 14.5.0.4 * - Fix issue where values with spaces are truncated.
* Version 14.5.0.4 * - Fix issue where values with spaces are truncated. Preserve softkeys accross installs
</changelog>
<location>https://github.com/chan-sccp/sccp_manager</location>
<depends>

View file

@ -243,7 +243,7 @@ trait ajaxHelper {
if (!empty($request['softkey'])) {
$id_name = $request['softkey'];
unset($this->sccp_conf_init[$id_name]);
$this->createDefaultSccpConfig($this->sccpvalues, $this->sccppath["asterisk"]);
$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);
}
@ -257,7 +257,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();
@ -521,7 +521,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();
}

View file

@ -275,6 +275,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');
@ -342,18 +356,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',
@ -377,7 +391,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":
/*
@ -394,7 +408,7 @@ trait helperfunctions {
break;
default:
if (!empty($value['data'])) {
$this->sccp_conf_init['general'][$key] = $value['data'];
$conf_init['general'][$key] = $value['data'];
}
}
}
@ -404,7 +418,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 ;",
@ -413,7 +427,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() {

View file

@ -2,11 +2,11 @@
"rawname": "sccp_manager",
"repo": "stable",
"name": "Sccp Manager",
"version": "14.5.0.3",
"version": "14.5.0.4",
"publisher": "Steve Lad",
"license": "GPL",
"licenselink": "http://www.gnu.org/licenses/gpl.txt",
"changelog": "*14.5.0.3* Fix issue 32\n*14.4.0.5* Fix issue 59\n*14.4.0.1* Fix regression in SQL not compatible with MariaDb 5\n*14.4.0.1* Upgrade installer to prevent data loss when run\n*14.3.0.30* Fix issue returning after save\n*14.3.0.28* Fix issue with RNav\n*14.3.0.27* Improve handling of SIP devices\n*14.3.0.15* Install master files list via installer\n*14.2.0.3* Fix module database definition\n*14.2.0.3* Fix module database definition\n*14.2.0.2* First release of new version without old interface\n*13.0.0.1* Packaging of ver 1.0.0.1\n*12.0.0.1* Packaging of ver 1.0.0.1",
"changelog": "*14.5.0.4* Preserve softkeys across installs. Fix truncated values\n*14.5.0.3* Fix issue 32\n*14.4.0.5* Fix issue 59\n*14.4.0.1* Fix regression in SQL not compatible with MariaDb 5\n*14.4.0.1* Upgrade installer to prevent data loss when run\n*14.3.0.30* Fix issue returning after save\n*14.3.0.28* Fix issue with RNav\n*14.3.0.27* Improve handling of SIP devices\n*14.3.0.15* Install master files list via installer\n*14.2.0.3* Fix module database definition\n*14.2.0.3* Fix module database definition\n*14.2.0.2* First release of new version without old interface\n*13.0.0.1* Packaging of ver 1.0.0.1\n*12.0.0.1* Packaging of ver 1.0.0.1",
"category": "Sccp Connectivity",
"description": "The Sccp Manager module lets you manage the chan-sccp driver.",
"depends": {
@ -15,7 +15,7 @@
"supported": {
"version": "15.0"
},
"location": "https://github.com/chan-sccp/sccp_manager/archive/refs/tags/v14.5.0.3.tar.gz",
"location": "https://github.com/chan-sccp/sccp_manager/archive/refs/tags/v14.5.0.4.tar.gz",
"md5sum": "3dd88a76b58db66f7c86eaf718596d7e",
"packaged": "1643306708"
"packaged": "1643364518"
}