diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 104b263..06a18ba 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -725,51 +725,21 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return $save_settings; } - public function getMyConfig($var = null, $id = "noid") { - switch ($var) { - case "voicecodecs": - $val = explode(",", explode("|", $this->sccpvalues['disallow|allow']['data'])[1]); - $final = array(); - $i = 1; - foreach ($val as $value) { - $final[$value] = $i; - $i++; - } - break; - case "softkeyset": - $final = array(); - $i = 0; - if ($id == "noid") { - foreach ($this->sccp_conf_init as $key => $value) { - if ($this->sccp_conf_init[$key]['type'] == 'softkeyset') { - $final[$i] = $value; - $i++; - } - } - } else { - if (!empty($this->sccp_conf_init[$id])) { - if ($this->sccp_conf_init[$id]['type'] == 'softkeyset') { - $final = $this->sccp_conf_init[$id]; - } - } - } - - break; - } - return $final; - } - public function getCodecs($type, $showDefaults = false) { $allSupported = array(); $Sccp_Codec = array('alaw', 'ulaw', 'g722', 'g723', 'g726', 'g729', 'gsm', 'h264', 'h263', 'h261'); + // First see if have any site defaults + $val = $this->sccpvalues['allow']['data']; + if (empty($val)) { + // No site defaults so return chan-sccp defaults + $val = $this->sccpvalues['allow']['systemdefault']; + } + $lcodecs = explode(',',$val); switch ($type) { case 'audio': - $lcodecs = $this->getMyConfig('voicecodecs'); $allCodecs = $this->FreePBX->Codecs->getAudio(); - dbug('FPBX audio', $allCodecs); break; case 'video': - $lcodecs = $this->getMyConfig('voicecodecs'); $allCodecs = $this->FreePBX->Codecs->getVideo(); break; case 'text': @@ -780,23 +750,20 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $lcodecs = $this->getConfig('imagecodecs'); $allCodecs = $this->FreePBX->Codecs->getImage(true); break; - default: - throw new Exception(_('Unknown Type')); - break; } foreach ($allCodecs as $c => $v) { if (in_array($c, $Sccp_Codec)) { $allSupported[$c] = $v; } } - if (empty($lcodecs) || (!is_array($lcodecs))) { + if (empty($lcodecs)) { if (empty($allSupported)) { $lcodecs = $allCodecs; } else { $lcodecs = $allSupported; } } else { - foreach ($lcodecs as $c => $v) { + foreach ($lcodecs as $c) { if (isset($allSupported[$c])) { $codecs[$c] = true; } @@ -812,7 +779,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } else { //Remove non digits $final = array(); - dbug('codecs', $codecs); foreach ($codecs as $codec => $order) { $order = trim($order); if (ctype_digit($order)) { @@ -824,37 +790,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } } - /** - * Update or Set Codecs - * @param {string} $type Codec Type - * @param {array} $codecs=array() The codecs with order, if blank set defaults - */ - public function setCodecs($type, $codecs = array()) { - $default = empty($codecs) ? true : false; - switch ($type) { - case 'audio': - $codecs = $default ? $this->FreePBX->Codecs->getAudio(true) : $codecs; - $this->setConfig("voicecodecs", $codecs); - break; - case 'video': - $codecs = $default ? $this->FreePBX->Codecs->getVideo(true) : $codecs; - $this->setConfig("videocodecs", $codecs); - break; - case 'text': - $codecs = $default ? $this->FreePBX->Codecs->getText(true) : $codecs; - $this->setConfig("textcodecs", $codecs); - break; - case 'image': - $codecs = $default ? $this->FreePBX->Codecs->getImage(true) : $codecs; - $this->setConfig("imagecodecs", $codecs); - break; - default: - throw new Exception(_('Unknown Type')); - break; - } - return true; - } - /** * Retrieve Active Codecs * return fiends Lag pack diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index bb40b95..e690f78 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -387,7 +387,6 @@ trait ajaxHelper { } function handleSubmit($request, $validateonly = false) { - dbug('request is:', $request); $hdr_prefix = 'sccp_'; $hdr_arprefix = 'sccp-ar_'; $save_settings = array(); @@ -495,30 +494,6 @@ trait ajaxHelper { } } switch ($key) { - case 'disallow': - if (is_array($value)) { - foreach ($value as $keycodeс => $valcodeс) { - $save_codec[$i] = $keycodeс; - $i++; - }; - $tmpv = implode(",", $save_codec); - } else { - $tmpv = $value; - } - - if (empty($save_settings['disallow|allow']['data'])) { - $save_settings['disallow|allow']['data'] = $tmpv . "|"; - } else { - $save_settings[] = array( - 'keyword' => 'disallow|allow', - 'data' => $tmpv . "|" .$save_settings['disallow|allow']['data'], - 'seq' => $this->sccpvalues['disallow|allow']['seq'], - 'type' => $this->sccpvalues['disallow|allow']['type'], - 'systemdefault' => $this->sccpvalues['disallow|allow']['systemdefault'] - ); - unset($save_settings['disallow|allow']['data']); - } - break; case 'voicecodecs': case 'vcodec': foreach ($value as $keycodeс => $valcodeс) { @@ -526,17 +501,14 @@ trait ajaxHelper { $i++; }; $tmpv = implode(",", $save_codec); - if (empty($save_settings['disallow|allow']['data'])) { - $save_settings['disallow|allow']['data'] = $tmpv; - } else { + if (!($this->sccpvalues['allow']['data'] == $tmpv)) { $save_settings[] = array( - 'keyword' => 'disallow|allow', - 'data' => $save_settings['disallow|allow']['data'] . $tmpv, - 'seq' => $this->sccpvalues['disallow|allow']['seq'], - 'type' => $this->sccpvalues['disallow|allow']['type'], - 'systemdefault' => $this->sccpvalues['disallow|allow']['systemdefault'] - ); - unset($save_settings['disallow|allow']['data']); + 'keyword' => 'allow', + 'data' => $tmpv, + 'seq' => $this->sccpvalues['allow']['seq'], + 'type' => $this->sccpvalues['allow']['type'], + 'systemdefault' => $this->sccpvalues['allow']['systemdefault'] + ); } break; @@ -571,6 +543,32 @@ trait ajaxHelper { $this->createDefaultSccpXml(); return $save_settings; } + + public function getMyConfig($var = null, $id = "noid") { + // TODO: this function has little purpose - need to integrate into AjaxHelper + switch ($var) { + case "softkeyset": + $final = array(); + $i = 0; + if ($id == "noid") { + foreach ($this->sccp_conf_init as $key => $value) { + if ($this->sccp_conf_init[$key]['type'] == 'softkeyset') { + $final[$i] = $value; + $i++; + } + } + } else { + if (!empty($this->sccp_conf_init[$id])) { + if ($this->sccp_conf_init[$id]['type'] == 'softkeyset') { + $final = $this->sccp_conf_init[$id]; + } + } + } + + break; + } + return $final; + } } ?> diff --git a/views/server.codec.php b/views/server.codec.php index d802973..489a53c 100644 --- a/views/server.codec.php +++ b/views/server.codec.php @@ -6,37 +6,16 @@ * and open the template in the editor. */ - $def_val = null; $dev_id = null; $audio_codecs = $this->getCodecs('audio', true); $video_codecs = $this->getCodecs('video', true); -$sccp_disallow_def = $this->sccpvalues['disallow|allow']['data']; -$sccp_disallow_def = explode("|",$sccp_disallow_def)[0]; -$sccp_disallow = $sccp_disallow_def; +$sccp_disallow_def = $this->sccpvalues['disallow']['data']; +$sys_disallow_def = $this->sccpvalues['disallow']['systemdefault']; -if (!empty($_REQUEST['id'])) { - $dev_id = $_REQUEST['id']; - $db_res = $this->dbinterface->getSccpDeviceTableData('get_sccpdevice_byid', array("id" => $dev_id)); - if (!empty($db_res['allow'])) { - $i = 1; - foreach (explode(';', $db_res['allow']) as $c) { - $codec_list[$c] = $i; - $i ++; - } - foreach ($audio_codecs as $c => $v) { - if (!isset($codec_list[$c])) { - $codec_list[$c] = false; - } - } - } - if (!empty($db_res['disallow'])) { - $sccp_disallow = $db_res['disallow']; - } -} else { - $codec_list = $audio_codecs; +if (empty($sccp_disallow_def)) { + $sccp_disallow_def = $sys_disallow_def; } - ?> @@ -56,8 +35,8 @@ if (!empty($_REQUEST['id'])) {
- - + +
@@ -65,7 +44,7 @@ if (!empty($_REQUEST['id'])) {
- +
@@ -90,13 +69,17 @@ if (!empty($_REQUEST['id'])) {
- + 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) ?>
'; - foreach ($codec_list as $codec => $codec_state) { + foreach ($audio_codecs as $codec => $codec_state) { $codec_trans = _($codec); $codec_checked = $codec_state ? 'checked' : ''; echo '
  • ' @@ -141,7 +124,7 @@ if (!empty($_REQUEST['id'])) {
  • - +
    ' . '' . '