Finalise Codecs tab for site defaults
Partially revert changes to sccpvalues keys Remove obsolete code Improve help and set as open by default Move getMyConfig to AjaxHelper as only used there
This commit is contained in:
parent
acdf777bcc
commit
2e5028f438
|
@ -725,51 +725,21 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
||||||
return $save_settings;
|
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) {
|
public function getCodecs($type, $showDefaults = false) {
|
||||||
$allSupported = array();
|
$allSupported = array();
|
||||||
$Sccp_Codec = array('alaw', 'ulaw', 'g722', 'g723', 'g726', 'g729', 'gsm', 'h264', 'h263', 'h261');
|
$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) {
|
switch ($type) {
|
||||||
case 'audio':
|
case 'audio':
|
||||||
$lcodecs = $this->getMyConfig('voicecodecs');
|
|
||||||
$allCodecs = $this->FreePBX->Codecs->getAudio();
|
$allCodecs = $this->FreePBX->Codecs->getAudio();
|
||||||
dbug('FPBX audio', $allCodecs);
|
|
||||||
break;
|
break;
|
||||||
case 'video':
|
case 'video':
|
||||||
$lcodecs = $this->getMyConfig('voicecodecs');
|
|
||||||
$allCodecs = $this->FreePBX->Codecs->getVideo();
|
$allCodecs = $this->FreePBX->Codecs->getVideo();
|
||||||
break;
|
break;
|
||||||
case 'text':
|
case 'text':
|
||||||
|
@ -780,23 +750,20 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
||||||
$lcodecs = $this->getConfig('imagecodecs');
|
$lcodecs = $this->getConfig('imagecodecs');
|
||||||
$allCodecs = $this->FreePBX->Codecs->getImage(true);
|
$allCodecs = $this->FreePBX->Codecs->getImage(true);
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
throw new Exception(_('Unknown Type'));
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
foreach ($allCodecs as $c => $v) {
|
foreach ($allCodecs as $c => $v) {
|
||||||
if (in_array($c, $Sccp_Codec)) {
|
if (in_array($c, $Sccp_Codec)) {
|
||||||
$allSupported[$c] = $v;
|
$allSupported[$c] = $v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (empty($lcodecs) || (!is_array($lcodecs))) {
|
if (empty($lcodecs)) {
|
||||||
if (empty($allSupported)) {
|
if (empty($allSupported)) {
|
||||||
$lcodecs = $allCodecs;
|
$lcodecs = $allCodecs;
|
||||||
} else {
|
} else {
|
||||||
$lcodecs = $allSupported;
|
$lcodecs = $allSupported;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
foreach ($lcodecs as $c => $v) {
|
foreach ($lcodecs as $c) {
|
||||||
if (isset($allSupported[$c])) {
|
if (isset($allSupported[$c])) {
|
||||||
$codecs[$c] = true;
|
$codecs[$c] = true;
|
||||||
}
|
}
|
||||||
|
@ -812,7 +779,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
||||||
} else {
|
} else {
|
||||||
//Remove non digits
|
//Remove non digits
|
||||||
$final = array();
|
$final = array();
|
||||||
dbug('codecs', $codecs);
|
|
||||||
foreach ($codecs as $codec => $order) {
|
foreach ($codecs as $codec => $order) {
|
||||||
$order = trim($order);
|
$order = trim($order);
|
||||||
if (ctype_digit($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
|
* Retrieve Active Codecs
|
||||||
* return fiends Lag pack
|
* return fiends Lag pack
|
||||||
|
|
|
@ -387,7 +387,6 @@ trait ajaxHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSubmit($request, $validateonly = false) {
|
function handleSubmit($request, $validateonly = false) {
|
||||||
dbug('request is:', $request);
|
|
||||||
$hdr_prefix = 'sccp_';
|
$hdr_prefix = 'sccp_';
|
||||||
$hdr_arprefix = 'sccp-ar_';
|
$hdr_arprefix = 'sccp-ar_';
|
||||||
$save_settings = array();
|
$save_settings = array();
|
||||||
|
@ -495,30 +494,6 @@ trait ajaxHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch ($key) {
|
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 'voicecodecs':
|
||||||
case 'vcodec':
|
case 'vcodec':
|
||||||
foreach ($value as $keycodeс => $valcodeс) {
|
foreach ($value as $keycodeс => $valcodeс) {
|
||||||
|
@ -526,17 +501,14 @@ trait ajaxHelper {
|
||||||
$i++;
|
$i++;
|
||||||
};
|
};
|
||||||
$tmpv = implode(",", $save_codec);
|
$tmpv = implode(",", $save_codec);
|
||||||
if (empty($save_settings['disallow|allow']['data'])) {
|
if (!($this->sccpvalues['allow']['data'] == $tmpv)) {
|
||||||
$save_settings['disallow|allow']['data'] = $tmpv;
|
|
||||||
} else {
|
|
||||||
$save_settings[] = array(
|
$save_settings[] = array(
|
||||||
'keyword' => 'disallow|allow',
|
'keyword' => 'allow',
|
||||||
'data' => $save_settings['disallow|allow']['data'] . $tmpv,
|
'data' => $tmpv,
|
||||||
'seq' => $this->sccpvalues['disallow|allow']['seq'],
|
'seq' => $this->sccpvalues['allow']['seq'],
|
||||||
'type' => $this->sccpvalues['disallow|allow']['type'],
|
'type' => $this->sccpvalues['allow']['type'],
|
||||||
'systemdefault' => $this->sccpvalues['disallow|allow']['systemdefault']
|
'systemdefault' => $this->sccpvalues['allow']['systemdefault']
|
||||||
);
|
);
|
||||||
unset($save_settings['disallow|allow']['data']);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -571,6 +543,32 @@ trait ajaxHelper {
|
||||||
$this->createDefaultSccpXml();
|
$this->createDefaultSccpXml();
|
||||||
return $save_settings;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -6,37 +6,16 @@
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
$def_val = null;
|
$def_val = null;
|
||||||
$dev_id = null;
|
$dev_id = null;
|
||||||
$audio_codecs = $this->getCodecs('audio', true);
|
$audio_codecs = $this->getCodecs('audio', true);
|
||||||
$video_codecs = $this->getCodecs('video', true);
|
$video_codecs = $this->getCodecs('video', true);
|
||||||
$sccp_disallow_def = $this->sccpvalues['disallow|allow']['data'];
|
$sccp_disallow_def = $this->sccpvalues['disallow']['data'];
|
||||||
$sccp_disallow_def = explode("|",$sccp_disallow_def)[0];
|
$sys_disallow_def = $this->sccpvalues['disallow']['systemdefault'];
|
||||||
$sccp_disallow = $sccp_disallow_def;
|
|
||||||
|
|
||||||
if (!empty($_REQUEST['id'])) {
|
if (empty($sccp_disallow_def)) {
|
||||||
$dev_id = $_REQUEST['id'];
|
$sccp_disallow_def = $sys_disallow_def;
|
||||||
$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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!-- Codec selection is at the line level - this page sets site defaults based on chan-sccp defaults -->
|
<!-- Codec selection is at the line level - this page sets site defaults based on chan-sccp defaults -->
|
||||||
|
@ -56,8 +35,8 @@ if (!empty($_REQUEST['id'])) {
|
||||||
<i class="fa fa-question-circle fpbx-help-icon" data-for="sccp_disallow"></i>
|
<i class="fa fa-question-circle fpbx-help-icon" data-for="sccp_disallow"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-9 radioset">
|
<div class="col-md-9 radioset">
|
||||||
<input id="sccp_disallow" type="text" name="sccp_disallow" value="<?php echo $sccp_disallow ?>">
|
<input id="sccp_disallow" type="text" name="sccp_disallow" value="<?php echo $sccp_disallow_def ?>">
|
||||||
<label for="sccp_disallow"><?php echo _("Current value : " . $sccp_disallow_def . "<br>Recomended default: all") ?></label>
|
<label for="sccp_disallow"><?php echo _("Recomended default: all") ?></label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -65,7 +44,7 @@ if (!empty($_REQUEST['id'])) {
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<span id="sccp_disallow-help" class="help-block fpbx-help-block"><?php echo _("Default : all. Please enter format: alaw,ulaw,...") ?></span>
|
<span id="sccp_disallow-help" class="help-block fpbx-help-block"><?php echo _("Default : all. If you wish to change (Not Recommended) please enter a comma separated list for example: alaw,ulaw,...") ?></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -90,13 +69,17 @@ if (!empty($_REQUEST['id'])) {
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<div>
|
<div>
|
||||||
<?php echo show_help(_("This is the default Codec setting for SCCP Device.")) ?>
|
<?php echo show_help(_("These are the default audio codec settings for this site. Unchecked codecs cannot be assigned to extensions.
|
||||||
|
<br>Order can be changed by dragging and dropping to indicate priority. This priority applies for all extensions
|
||||||
|
<br>Higher priority enabled codecs are at the top
|
||||||
|
<br>Precedence for ulaw and alaw, if used, should be set according to your region
|
||||||
|
<br>If your region uses alaw, it is important that alaw has the highest priority"),"Helpful information",true) ?>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
$seq = 1;
|
$seq = 1;
|
||||||
|
|
||||||
echo '<ul class="sortable">';
|
echo '<ul class="sortable">';
|
||||||
foreach ($codec_list as $codec => $codec_state) {
|
foreach ($audio_codecs as $codec => $codec_state) {
|
||||||
$codec_trans = _($codec);
|
$codec_trans = _($codec);
|
||||||
$codec_checked = $codec_state ? 'checked' : '';
|
$codec_checked = $codec_state ? 'checked' : '';
|
||||||
echo '<li><a href="#">'
|
echo '<li><a href="#">'
|
||||||
|
@ -141,7 +124,7 @@ if (!empty($_REQUEST['id'])) {
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<div>
|
<div>
|
||||||
<?php echo show_help(_("This is the default Codec setting for SCCP Device.")) ?>
|
<?php echo show_help(_("These are the default video codec settings for this site.")) ?>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
$seq = 1;
|
$seq = 1;
|
||||||
|
@ -154,9 +137,9 @@ if (!empty($_REQUEST['id'])) {
|
||||||
. '<img src="assets/sipsettings/images/arrow_up_down.png" height="16" width="16" border="0" alt="move" style="float:none; margin-left:-6px; margin-bottom:-3px;cursor:move" /> '
|
. '<img src="assets/sipsettings/images/arrow_up_down.png" height="16" width="16" border="0" alt="move" style="float:none; margin-left:-6px; margin-bottom:-3px;cursor:move" /> '
|
||||||
. '<input type="checkbox" '
|
. '<input type="checkbox" '
|
||||||
. ($codec_checked ? 'value="' . $seq++ . '" ' : '')
|
. ($codec_checked ? 'value="' . $seq++ . '" ' : '')
|
||||||
. 'name="voicecodecs[' . $codec . ']" '
|
. 'name="videocodecs[' . $codec . ']" '
|
||||||
. 'id="' . $codec . '" '
|
. 'id="' . $codec . '" '
|
||||||
. 'class="audio-codecs" '
|
. 'class="video-codecs" '
|
||||||
. $codec_checked
|
. $codec_checked
|
||||||
. ' />'
|
. ' />'
|
||||||
. ' <label for="' . $codec . '"> '
|
. ' <label for="' . $codec . '"> '
|
||||||
|
|
Loading…
Reference in a new issue