Fix bug codecs storage
codecs were stored as a ',' separated list while chan-sccp expects a ';' separated list Correct all existing db values when running installer make sure that disallow is not unset in installer (set to all) make sure that disallow is not empty correct help text
This commit is contained in:
parent
b3b3858965
commit
2898f5e3c9
|
@ -718,7 +718,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
||||||
// No site defaults so return chan-sccp defaults
|
// No site defaults so return chan-sccp defaults
|
||||||
$val = $this->sccpvalues['allow']['systemdefault'];
|
$val = $this->sccpvalues['allow']['systemdefault'];
|
||||||
}
|
}
|
||||||
$siteCodecs = array_fill_keys(explode(',',$val), 1);
|
$siteCodecs = array_fill_keys(explode(';',$val), 1);
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'audio':
|
case 'audio':
|
||||||
$fpbxCodecs = $this->FreePBX->Codecs->getAudio();
|
$fpbxCodecs = $this->FreePBX->Codecs->getAudio();
|
||||||
|
|
15
install.php
15
install.php
|
@ -165,7 +165,7 @@ function Get_DB_config($sccp_compatible)
|
||||||
'transfer' => array('create' => "enum('yes','no') NOT NULL default 'yes'", 'modify' => "enum('yes','no')"),
|
'transfer' => array('create' => "enum('yes','no') NOT NULL default 'yes'", 'modify' => "enum('yes','no')"),
|
||||||
'vmnum' => array('def_modify' => "*97"),
|
'vmnum' => array('def_modify' => "*97"),
|
||||||
'musicclass' => array('def_modify' => "default"),
|
'musicclass' => array('def_modify' => "default"),
|
||||||
'disallow' => array('create' => "VARCHAR(255) NULL DEFAULT NULL"),
|
'disallow' => array('create' => "VARCHAR(255) NULL DEFAULT 'all'", 'modify' => 'VARCHAR(255)'),
|
||||||
'allow' => array('create' => "VARCHAR(255) NULL DEFAULT NULL"),
|
'allow' => array('create' => "VARCHAR(255) NULL DEFAULT NULL"),
|
||||||
'id' => array('create' => 'MEDIUMINT(9) NOT NULL AUTO_INCREMENT, ADD UNIQUE(id);', 'modify' => "MEDIUMINT(9)", 'index' => 'id'),
|
'id' => array('create' => 'MEDIUMINT(9) NOT NULL AUTO_INCREMENT, ADD UNIQUE(id);', 'modify' => "MEDIUMINT(9)", 'index' => 'id'),
|
||||||
'echocancel' => array('create' => "enum('yes','no') NOT NULL default 'yes'", 'modify' => "enum('yes','no')"),
|
'echocancel' => array('create' => "enum('yes','no') NOT NULL default 'yes'", 'modify' => "enum('yes','no')"),
|
||||||
|
@ -983,7 +983,10 @@ function cleanUpSccpSettings() {
|
||||||
// 2 special cases deny|permit & disallow|allow where need to parse on |.
|
// 2 special cases deny|permit & disallow|allow where need to parse on |.
|
||||||
$newKeyword = explode("|", $valueArray['Name'], 2);
|
$newKeyword = explode("|", $valueArray['Name'], 2);
|
||||||
if (isset($newKeyword[1])) {
|
if (isset($newKeyword[1])) {
|
||||||
|
// chan-sccp sets sysdef as comma separated list for sccp.conf, but expects ; separated list
|
||||||
|
// when returned from db
|
||||||
$newSysDef = explode("|", $valueArray['DefaultValue'], 2);
|
$newSysDef = explode("|", $valueArray['DefaultValue'], 2);
|
||||||
|
$newSysDef = str_replace(',',';', $newSysDef);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($newKeyword as $dummy) {
|
foreach ($newKeyword as $dummy) {
|
||||||
if (array_key_exists($newKeyword[$i],$settingsFromDb)) {
|
if (array_key_exists($newKeyword[$i],$settingsFromDb)) {
|
||||||
|
@ -1032,5 +1035,15 @@ function cleanUpSccpSettings() {
|
||||||
)";
|
)";
|
||||||
$results = $db->query($sql);
|
$results = $db->query($sql);
|
||||||
}
|
}
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
outn("<li>" . _("Replacing invalid values in sccpline") . "</li>");
|
||||||
|
$db->query("UPDATE sccpline SET allow = REPLACE(allow, ',',';') WHERE allow like '%,%'");
|
||||||
|
$db->query("UPDATE sccpline SET disallow = REPLACE(disallow, ',',';') WHERE disallow like '%,%'");
|
||||||
|
|
||||||
|
// Ensure that disallow is set to all if unset (and not NULL)
|
||||||
|
$db->query("UPDATE sccpline SET disallow = 'all' WHERE disallow like ''");
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -85,6 +85,13 @@ class Sccp extends \FreePBX\modules\Core\Driver {
|
||||||
}
|
}
|
||||||
// This will produce an array where site defaults take precedence over system defaults
|
// This will produce an array where site defaults take precedence over system defaults
|
||||||
$this->line_defaults = array_intersect_key($siteDefaults,$sccpDefaults);
|
$this->line_defaults = array_intersect_key($siteDefaults,$sccpDefaults);
|
||||||
|
// If have no site codecs, use system defaults - must have a codec!
|
||||||
|
if (empty($this->line_defaults['allow'])) {
|
||||||
|
$this->line_defaults['allow'] = $sccpDefaults['allow'];
|
||||||
|
}
|
||||||
|
if (empty($this->line_defaults['disallow'])) {
|
||||||
|
$this->line_defaults['disallow'] = $sccpDefaults['disallow'];
|
||||||
|
}
|
||||||
unset($raw_settings, $siteDefaults, $sccpDefaults);
|
unset($raw_settings, $siteDefaults, $sccpDefaults);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +128,7 @@ class Sccp extends \FreePBX\modules\Core\Driver {
|
||||||
$allow_codec[] = str_replace('codec_','',$key);
|
$allow_codec[] = str_replace('codec_','',$key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$settings['allow']['value'] = implode(",", $allow_codec);
|
$settings['allow']['value'] = implode(";", $allow_codec);
|
||||||
// Reset to line defaults if no value selected
|
// Reset to line defaults if no value selected
|
||||||
if (empty($settings['allow']['value'])) {
|
if (empty($settings['allow']['value'])) {
|
||||||
$settings['allow']['value'] = $this->line_defaults['allow'];
|
$settings['allow']['value'] = $this->line_defaults['allow'];
|
||||||
|
@ -238,7 +245,7 @@ class Sccp extends \FreePBX\modules\Core\Driver {
|
||||||
$currentComponent->addTabTranslation('sccp',_('SCCP'));
|
$currentComponent->addTabTranslation('sccp',_('SCCP'));
|
||||||
|
|
||||||
// get site and system defaults
|
// get site and system defaults
|
||||||
$systemCodecs = array_fill_keys(explode(',',$this->line_defaults['allow']),true);
|
$systemCodecs = array_fill_keys(explode(';',$this->line_defaults['allow']),true);
|
||||||
$siteAudioCodecs = array_intersect_key($systemCodecs, $this->freepbx->Codecs->getAudio());
|
$siteAudioCodecs = array_intersect_key($systemCodecs, $this->freepbx->Codecs->getAudio());
|
||||||
$siteVideoCodecs = array_intersect_key($systemCodecs, $this->freepbx->Codecs->getVideo());
|
$siteVideoCodecs = array_intersect_key($systemCodecs, $this->freepbx->Codecs->getVideo());
|
||||||
|
|
||||||
|
@ -249,7 +256,7 @@ class Sccp extends \FreePBX\modules\Core\Driver {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// have allowed codecs for this line
|
// have allowed codecs for this line
|
||||||
foreach (explode(',',$deviceInfo['allow']) as $lineCodec) {
|
foreach (explode(';',$deviceInfo['allow']) as $lineCodec) {
|
||||||
$activeCodecs[] = "devinfo_codec_{$lineCodec}";
|
$activeCodecs[] = "devinfo_codec_{$lineCodec}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -264,7 +271,7 @@ class Sccp extends \FreePBX\modules\Core\Driver {
|
||||||
}
|
}
|
||||||
|
|
||||||
$tmparr['disallow'] = array('prompttext' => _('Disallowed Codecs'),
|
$tmparr['disallow'] = array('prompttext' => _('Disallowed Codecs'),
|
||||||
'value' => $this->line_defaults[(string)$child->name],
|
'value' => $this->line_defaults['disallow'],
|
||||||
'tt' => 'Codecs that are disallowed. Default and recommended value is all',
|
'tt' => 'Codecs that are disallowed. Default and recommended value is all',
|
||||||
'level' => 1,
|
'level' => 1,
|
||||||
'section' => $section_с,
|
'section' => $section_с,
|
||||||
|
|
|
@ -101,7 +101,7 @@ class SCCPShowDevice_Event extends Event
|
||||||
public function getCapabilities()
|
public function getCapabilities()
|
||||||
{
|
{
|
||||||
$ret = array();
|
$ret = array();
|
||||||
$codecs = explode(", ", substr($this->getKey('Capabilities'), 1, -1));
|
$codecs = explode(';', substr($this->getKey('Capabilities'), 1, -1));
|
||||||
foreach ($codecs as $codec) {
|
foreach ($codecs as $codec) {
|
||||||
$codec_parts = explode(" ", $codec);
|
$codec_parts = explode(" ", $codec);
|
||||||
$ret[] = array("name" => $codec_parts[0], "value" => substr($codec_parts[1], 1, -1));
|
$ret[] = array("name" => $codec_parts[0], "value" => substr($codec_parts[1], 1, -1));
|
||||||
|
@ -112,7 +112,7 @@ class SCCPShowDevice_Event extends Event
|
||||||
public function getCodecsPreference()
|
public function getCodecsPreference()
|
||||||
{
|
{
|
||||||
$ret = array();
|
$ret = array();
|
||||||
$codecs = explode(", ", substr($this->getKey('CodecsPreference'), 1, -1));
|
$codecs = explode(';', substr($this->getKey('CodecsPreference'), 1, -1));
|
||||||
foreach ($codecs as $codec) {
|
foreach ($codecs as $codec) {
|
||||||
$codec_parts = explode(" ", $codec);
|
$codec_parts = explode(" ", $codec);
|
||||||
$ret[] = array("name" => $codec_parts[0], "value" => substr($codec_parts[1], 1, -1));
|
$ret[] = array("name" => $codec_parts[0], "value" => substr($codec_parts[1], 1, -1));
|
||||||
|
|
|
@ -405,7 +405,7 @@ trait ajaxHelper {
|
||||||
// if uncheck all codecs, audiocodecs key is missing so nothing changes in db.
|
// if uncheck all codecs, audiocodecs key is missing so nothing changes in db.
|
||||||
// Unsetting all codecs will now return to chan-sccp defaults.
|
// Unsetting all codecs will now return to chan-sccp defaults.
|
||||||
if (!isset($request['audiocodecs'])) {
|
if (!isset($request['audiocodecs'])) {
|
||||||
$request['audiocodecs'] = array_fill_keys(explode(',',$this->sccpvalues['allow']['systemdefault']),true);
|
$request['audiocodecs'] = array_fill_keys(explode(';',$this->sccpvalues['allow']['systemdefault']),true);
|
||||||
}
|
}
|
||||||
foreach ($request as $key => $value) {
|
foreach ($request as $key => $value) {
|
||||||
// Originally saved all to sccpvalues. Now will save to db defaults if appropriate
|
// Originally saved all to sccpvalues. Now will save to db defaults if appropriate
|
||||||
|
@ -506,7 +506,7 @@ trait ajaxHelper {
|
||||||
$save_codec[$i] = $keycodeс;
|
$save_codec[$i] = $keycodeс;
|
||||||
$i++;
|
$i++;
|
||||||
};
|
};
|
||||||
$tmpv = implode(",", $save_codec);
|
$tmpv = implode(";", $save_codec);
|
||||||
if (!($this->sccpvalues['allow']['data'] == $tmpv)) {
|
if (!($this->sccpvalues['allow']['data'] == $tmpv)) {
|
||||||
$save_settings['allow'] = array(
|
$save_settings['allow'] = array(
|
||||||
'keyword' => 'allow',
|
'keyword' => 'allow',
|
||||||
|
|
|
@ -44,7 +44,7 @@ if (empty($sccp_disallow_def)) {
|
||||||
</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. If you wish to change (Not Recommended) please enter a comma separated list for example: 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 semicolon separated list for example: alaw;ulaw;...") ?></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue