Skip to content

Commit f5e51a5

Browse files
committed
Resolve issue of softkeysets lost across installs
1 parent 4cf414e commit f5e51a5

File tree

6 files changed

+38
-37
lines changed

6 files changed

+38
-37
lines changed

Sccp_manager.class.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -692,15 +692,8 @@ function initializeSccpPath() {
692692
'tftp_countries_path' => $this->sccpvalues['tftp_countries_path']['data']
693693
);
694694

695-
$read_config = $this->cnf_read->getConfig('sccp.conf');
696-
$this->sccp_conf_init['general'] = $read_config['general'];
697-
foreach ($read_config as $key => $value) {
698-
if (isset($read_config[$key]['type'])) { // copy soft key
699-
if ($read_config[$key]['type'] == 'softkeyset') {
700-
$this->sccp_conf_init[$key] = $read_config[$key];
701-
}
702-
}
703-
}
695+
// initialise $sccp_conf_init
696+
$this->sccp_conf_init = $this->initialiseConfInit();
704697

705698
$hint = $this->aminterface->core_list_hints();
706699
foreach ($hint as $key => $value) {

install.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,13 +1024,6 @@ function addDriver($sccp_compatible) {
10241024
$file = $amp_conf['AMPWEBROOT'] . '/admin/modules/core/functions.inc/drivers/Sccp.class.php';
10251025
$contents = "<?php include '/var/www/html/admin/modules/sccp_manager/sccpManClasses/Sccp.class.php.v{$sccp_compatible}'; ?>";
10261026
file_put_contents($file, $contents);
1027-
1028-
$dir = $cnf_int->get('ASTETCDIR');
1029-
if (!file_exists("{$dir}/sccp.conf")) { // System re Config
1030-
outn("<li>" . _("Adding default configuration file ...") . "</li>");
1031-
$sccpfile = file_get_contents($amp_conf['AMPWEBROOT'] . '/admin/modules/sccp_manager/conf/sccp.conf');
1032-
file_put_contents("{$dir}/sccp.conf", $sccpfile);
1033-
}
10341027
}
10351028
function checkTftpServer() {
10361029
outn("<li>" . _("Checking TFTP server path and availability ...") . "</li>");
@@ -1279,9 +1272,10 @@ function cleanUpSccpSettings() {
12791272
)";
12801273
$results = $db->query($sql);
12811274
}
1282-
1283-
// Now correct sccp.conf to replace any illegal settings
1284-
$thisInstaller->createDefaultSccpConfig($settingsFromDb, $cnf_int->get('ASTETCDIR'));
1275+
// Need to load any existing sccp.conf so that retain softkeys section if exists.
1276+
$sccp_conf_init = $thisInstaller->initialiseConfInit();
1277+
// Now correct sccp.conf to replace any illegal settings passing $sccp_conf_init
1278+
$thisInstaller->createDefaultSccpConfig($settingsFromDb, $cnf_int->get('ASTETCDIR'), $sccp_conf_init);
12851279

12861280
// have to correct prior verion sccpline lists for allow/disallow and deny permit. Prior
12871281
// versions used csl, but chan-sccp expects ; separated lists when returned by db.

module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* Version 14.4.0.3 * - Change method of selecting phonecodepage depending on if is java phone.
4343
* Version 14.4.0.5 * - Fix issue #59.
4444
* Version 14.5.0.2 * - Fix issue #32.
45-
* Version 14.5.0.4 * - Fix issue where values with spaces are truncated.
45+
* Version 14.5.0.4 * - Fix issue where values with spaces are truncated. Preserve softkeys accross installs
4646
</changelog>
4747
<location>https://github.com/chan-sccp/sccp_manager</location>
4848
<depends>

sccpManTraits/ajaxHelper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ public function ajaxHandler() {
243243
if (!empty($request['softkey'])) {
244244
$id_name = $request['softkey'];
245245
unset($this->sccp_conf_init[$id_name]);
246-
$this->createDefaultSccpConfig($this->sccpvalues, $this->sccppath["asterisk"]);
246+
$this->createDefaultSccpConfig($this->sccpvalues, $this->sccppath["asterisk"], $this->sccp_conf_init);
247247
$msg = print_r($this->aminterface->core_sccp_reload(), 1);
248248
return array('status' => true, 'table_reload' => true);
249249
}
@@ -257,7 +257,7 @@ public function ajaxHandler() {
257257
$this->sccp_conf_init[$id_name][$keyl] = $request[$keyl];
258258
}
259259
}
260-
$this->createDefaultSccpConfig($this->sccpvalues, $this->sccppath["asterisk"]);
260+
$this->createDefaultSccpConfig($this->sccpvalues, $this->sccppath["asterisk"], $this->sccp_conf_init);
261261

262262
// !TODO!: -TODO-: Check SIP Support Enabled
263263
$this->createSccpXmlSoftkey();
@@ -521,7 +521,7 @@ function handleSubmit($request, $validateonly = false) {
521521
$this->dbinterface->updateTableDefaults($rowToSave['table'], $rowToSave['field'], $rowToSave['Default']);
522522
}
523523
// rewrite sccp.conf
524-
$this->createDefaultSccpConfig($this->sccpvalues, $this->sccppath["asterisk"]);
524+
$this->createDefaultSccpConfig($this->sccpvalues, $this->sccppath["asterisk"], $this->sccp_conf_init);
525525
$this->createDefaultSccpXml();
526526
}
527527

sccpManTraits/helperFunctions.php

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,20 @@ function tftpReadTestFile($remoteFileName, $host = "127.0.0.1")
275275
return false;
276276
}
277277

278+
public function initialiseConfInit(){
279+
$read_config = \FreePBX::LoadConfig()->getConfig('sccp.conf');
280+
$sccp_conf_init['general'] = $read_config['general'];
281+
foreach ($read_config as $key => $value) {
282+
if (isset($read_config[$key]['type'])) { // copy soft key
283+
if ($read_config[$key]['type'] == 'softkeyset') {
284+
$sccp_conf_init[$key] = $read_config[$key];
285+
}
286+
}
287+
}
288+
return $sccp_conf_init;
289+
}
290+
291+
278292
public function checkTftpMapping(){
279293
exec('in.tftpd -V', $tftpInfo);
280294
$info['TFTP Server'] = array('Version' => 'Not Found', 'about' => 'Mapping not available');
@@ -342,18 +356,18 @@ public function getChanSccpSettings() {
342356
unset($sysConfig);
343357
}
344358

345-
public function createDefaultSccpConfig(array $sccpvalues, string $asteriskPath) {
359+
public function createDefaultSccpConfig(array $sccpvalues, string $asteriskPath, $conf_init) {
346360
global $cnf_wr;
347361
// Make sccp.conf data
348362
// [general] section
349363
// TODO: Need to review sccpsettings seq numbering, as will speed this up, and remove the need for $permittedSettings.
350364
$cnf_wr = \FreePBX::WriteConfig();
351365
//clear old general settings, and initiate with allow/disallow and permit/deny keys in correct order
352-
$this->sccp_conf_init['general'] = array();
353-
$this->sccp_conf_init['general']['disallow'] = 'all';
354-
$this->sccp_conf_init['general']['allow'] = '';
355-
$this->sccp_conf_init['general']['deny'] = '0.0.0.0/0.0.0.0';
356-
$this->sccp_conf_init['general']['permit'] = '0.0.0.0/0.0.0.0';
366+
$conf_init['general'] = array();
367+
$conf_init['general']['disallow'] = 'all';
368+
$conf_init['general']['allow'] = '';
369+
$conf_init['general']['deny'] = '0.0.0.0/0.0.0.0';
370+
$conf_init['general']['permit'] = '0.0.0.0/0.0.0.0';
357371
// permitted chan-sccp settings array
358372
$permittedSettings = array(
359373
'debug', 'servername', 'keepalive', 'context', 'dateformat', 'bindaddr', 'port', 'secbindaddr', 'secport', 'disallow', 'allow', 'deny', 'permit',
@@ -377,7 +391,7 @@ public function createDefaultSccpConfig(array $sccpvalues, string $asteriskPath)
377391
case "deny":
378392
case "localnet":
379393
case "permit":
380-
$this->sccp_conf_init['general'][$key] = explode(';', $value['data']);
394+
$conf_init['general'][$key] = explode(';', $value['data']);
381395
break;
382396
case "devlang":
383397
/*
@@ -394,7 +408,7 @@ public function createDefaultSccpConfig(array $sccpvalues, string $asteriskPath)
394408
break;
395409
default:
396410
if (!empty($value['data'])) {
397-
$this->sccp_conf_init['general'][$key] = $value['data'];
411+
$conf_init['general'][$key] = $value['data'];
398412
}
399413
}
400414
}
@@ -404,7 +418,7 @@ public function createDefaultSccpConfig(array $sccpvalues, string $asteriskPath)
404418
// This will complicate solving problems caused by unexpected solutions from users.
405419
//
406420
if (file_exists($asteriskPath . "/sccp_custom.conf")) {
407-
$this->sccp_conf_init['HEADER'] = array(
421+
$conf_init['HEADER'] = array(
408422
"; ;",
409423
"; It is a very bad idea to add an external configuration file !!!! ;",
410424
"; This will complicate solving problems caused by unexpected solutions ;",
@@ -413,7 +427,7 @@ public function createDefaultSccpConfig(array $sccpvalues, string $asteriskPath)
413427
"#include sccp_custom.conf"
414428
);
415429
}
416-
$cnf_wr->WriteConfig('sccp.conf', $this->sccp_conf_init);
430+
$cnf_wr->WriteConfig('sccp.conf', $conf_init);
417431
}
418432

419433
public function initVarfromXml() {

sccpManagerUpdater.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
"rawname": "sccp_manager",
33
"repo": "stable",
44
"name": "Sccp Manager",
5-
"version": "14.5.0.3",
5+
"version": "14.5.0.4",
66
"publisher": "Steve Lad",
77
"license": "GPL",
88
"licenselink": "http://www.gnu.org/licenses/gpl.txt",
9-
"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",
9+
"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",
1010
"category": "Sccp Connectivity",
1111
"description": "The Sccp Manager module lets you manage the chan-sccp driver.",
1212
"depends": {
@@ -15,7 +15,7 @@
1515
"supported": {
1616
"version": "15.0"
1717
},
18-
"location": "https://github.com/chan-sccp/sccp_manager/archive/refs/tags/v14.5.0.3.tar.gz",
18+
"location": "https://github.com/chan-sccp/sccp_manager/archive/refs/tags/v14.5.0.4.tar.gz",
1919
"md5sum": "3dd88a76b58db66f7c86eaf718596d7e",
20-
"packaged": "1643306708"
20+
"packaged": "1643364518"
2121
}

0 commit comments

Comments
 (0)