From f929267910fc1bd834f593ba0db9cc1054a65ef4 Mon Sep 17 00:00:00 2001
From: steve-lad <72376554+steve-lad@users.noreply.github.com>
Date: Tue, 6 Jul 2021 16:12:25 +0200
Subject: [PATCH] Provide mechanism to reset codecs to system defaults
Unchecking all codecs will return to chan-sccp defaults
Document this behaviour
Remove various debug code
---
Sccp_manager.class.php | 3 ---
install.php | 1 -
sccpManTraits/ajaxHelper.php | 5 +++++
views/formShowSysDefs.php | 9 ---------
views/server.codec.php | 3 ++-
5 files changed, 7 insertions(+), 14 deletions(-)
diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php
index 06a18ba..9095743 100644
--- a/Sccp_manager.class.php
+++ b/Sccp_manager.class.php
@@ -976,10 +976,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
*/
private function saveSccpSettings($save_value = array()) {
-// global $db;
-// global $amp_conf;
-// $save_settings = array();
if (empty($save_value)) {
$this->dbinterface->write('sccpsettings', $this->sccpvalues, 'replace'); //Change to replace as clearer
} else {
diff --git a/install.php b/install.php
index 5b7d177..7aa226d 100644
--- a/install.php
+++ b/install.php
@@ -982,7 +982,6 @@ function cleanUpSccpSettings() {
// 2 special cases deny|permit & disallow|allow where need to parse on |.
$newKeyword = explode("|", $valueArray['Name'], 2);
if (isset($newKeyword[1])) {
- dbug('',$newKeyword);
$newSysDef = explode("|", $valueArray['DefaultValue'], 2);
$i = 0;
foreach ($newKeyword as $dummy) {
diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php
index e690f78..2a04fd5 100644
--- a/sccpManTraits/ajaxHelper.php
+++ b/sccpManTraits/ajaxHelper.php
@@ -397,6 +397,11 @@ trait ajaxHelper {
$errors = array();
$i = 0;
$action = isset($request['sccp_createlangdir']) ? $request['sccp_createlangdir'] : '';
+ // if uncheck all codecs, voicecodecs key is missing so nothing changes in db.
+ // Unsetting all codecs will now return to chan-sccp defaults.
+ if (!isset($request['voicecodecs'])) {
+ $request['voicecodecs'] = array_fill_keys(explode(',',$this->sccpvalues['allow']['systemdefault']),true);
+ }
if ($action == 'yes') {
$this->initializeTFtpLanguagePath();
}
diff --git a/views/formShowSysDefs.php b/views/formShowSysDefs.php
index 94ceec5..4f3df26 100644
--- a/views/formShowSysDefs.php
+++ b/views/formShowSysDefs.php
@@ -578,15 +578,6 @@ $thisSccpView = new class{
}
}
$select_opt= $syslangs;
-
- foreach (array_keys($select_opt) as $k => $v) {
- if ($k !== $v) {
- dbug('sys list is an associative array');
- } else {
- dbug('sys list is a simple array');
- }
- }
-
break;
case 'SLT':
$select_opt= $tftp_lang;
diff --git a/views/server.codec.php b/views/server.codec.php
index 489a53c..b2d7bd7 100644
--- a/views/server.codec.php
+++ b/views/server.codec.php
@@ -73,7 +73,8 @@ if (empty($sccp_disallow_def)) {
Order can be changed by dragging and dropping to indicate priority. This priority applies for all extensions
Higher priority enabled codecs are at the top
Precedence for ulaw and alaw, if used, should be set according to your region
-
If your region uses alaw, it is important that alaw has the highest priority"),"Helpful information",true) ?>
+
If your region uses alaw, it is important that alaw has the highest priority
+
To return to chan-sccp defaults, uncheck all codecs."),"Helpful information",true) ?>