Correct getExtConfig method

sccp_lang did not accept index arg
This commit is contained in:
steve-lad 2021-06-22 10:17:57 +02:00
parent c271dbf3c2
commit 95cd7b4d9b
7 changed files with 39 additions and 32 deletions

View file

@ -174,24 +174,23 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
*/
public function showGroup($group_name, $show_Header, $form_prefix = 'sccp', $form_values = array()) {
$htmlret = "";
if (empty($form_values)) {
$form_values = $this->sccpvalues;
}
if ((array) $this->xml_data) {
foreach ($this->xml_data->xpath('//page_group[@name="' . $group_name . '"]') as $item) {
$htmlret .= load_view(__DIR__ . '/views/formShow.php', array(
$htmlret = load_view(__DIR__ . '/views/formShow.php', array(
'itm' => $item,
'h_show' => $show_Header,
'form_prefix' => $form_prefix,
'fvalues' => $form_values,
'tftp_lang' => $this->tftpLang,
'metainfo' => $this->sccp_metainfo,
'metainfo' => $this->sccp_metainfo
)
);
}
} else {
$htmlret .= load_view(__DIR__ . '/views/formShowError.php');
$htmlret = load_view(__DIR__ . '/views/formShowError.php');
}
return $htmlret;
}
@ -201,7 +200,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
*/
public function initVarfromDefs() {
foreach ($this->extconfigs->getextConfig('sccpDefaults') as $key => $value) {
foreach ($this->extconfigs->getExtConfig('sccpDefaults') as $key => $value) {
if (empty($this->sccpvalues[$key])) {
$this->sccpvalues[$key] = array('keyword' => $key, 'data' => $value, 'type' => '0', 'seq' => '0');
}
@ -593,7 +592,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
case 'name':
if (!empty($get_settings[$hdr_prefix . 'mac'])) {
$value = $get_settings[$hdr_prefix . 'mac'];
$value = strtoupper(str_replace(array('.', '-', ':'), '', $value)); // Delete mac Seporated from string
$value = strtoupper(str_replace(array('.', '-', ':'), '', $value)); // Delete mac separators from string
$value = sprintf("%012s", $value);
if ($hw_prefix == 'VG') {
$value = $hw_prefix . $value . '0';
@ -605,8 +604,9 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
break;
case 'phonecodepage':
$value = 'null';
// TODO: getExtConfig(sccp_lang ....) does not accept any additional arguments and will return an array
if (!empty($get_settings[$hdr_prefix . 'devlang'])) {
$lang_data = $this->extconfigs->getextConfig('sccp_lang', $get_settings[$hdr_prefix . 'devlang']);
$lang_data = $this->extconfigs->getExtConfig('sccp_lang', $get_settings[$hdr_prefix . 'devlang']);
if (!empty($lang_data)) {
$value = $lang_data['codepage'];
}
@ -922,7 +922,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
$filename = $dir . DIRECTORY_SEPARATOR . $value . DIRECTORY_SEPARATOR . $this->SCCP_LANG_DICTIONARY;
if (file_exists($filename)) {
$lang_ar = $this->extconfigs->getextConfig('sccp_lang');
$lang_ar = $this->extconfigs->getExtConfig('sccp_lang');
foreach ($lang_ar as $lang_key => $lang_value) {
if ($lang_value['locale'] == $value) {
$result[$lang_key] = $value;
@ -942,11 +942,11 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
private function initializeTFtpLanguagePath() {
$dir = $this->sccppath["tftp_lang_path"];
foreach ($this->extconfigs->getextConfig('sccp_lang') as $lang_key => $lang_value) {
foreach ($this->extconfigs->getExtConfig('sccp_lang') as $lang_key => $lang_value) {
$filename = $dir . DIRECTORY_SEPARATOR . $lang_value['locale'];
if (!file_exists($filename)) {
if (!mkdir($filename, 0777, true)) {
die('Error create lang dir');
die('Error creating tftp language directory');
}
}
}
@ -1131,7 +1131,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
$model_information = $this->getSccpModelInformation($get = "all", $validate = false); // Get All
}
$lang_data = $this->extconfigs->getextConfig('sccp_lang');
$lang_data = $this->extconfigs->getExtConfig('sccp_lang');
$data_value['tftp_path'] = $this->sccppath["tftp_path"];
$this->xmlinterface->create_default_XML($this->sccppath["tftp_path_store"], $data_value, $model_information, $lang_data);
@ -1195,7 +1195,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
$data_value[$key] = $value['data'];
}
//Get Cisco Code only Old Device
$data_value['ntp_timezone_id'] = $this->extconfigs->getextConfig('sccp_timezone', $data_value['ntp_timezone']); // Old Cisco Device
$data_value['ntp_timezone_id'] = $this->extconfigs->getExtConfig('sccp_timezone', $data_value['ntp_timezone']); // Old Cisco Device
// $data_value['ntp_timezone_id'] = $data_value['ntp_timezone']; // New Cisco Device !
// $data_value['ntp_timezone_id'] = // SPA Cisco Device !
$data_value['server_if_list'] = $this->getIpInformation('ip4');
@ -1210,7 +1210,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
}
}
$lang_data = $this->extconfigs->getextConfig('sccp_lang');
$lang_data = $this->extconfigs->getExtConfig('sccp_lang');
if (!$sccp_native) {
return $this->xmlinterface->create_SEP_SIP_XML($this->sccppath["tftp_path_store"], $data_value, $dev_config, $dev_id, $lang_data);
}
@ -1310,8 +1310,11 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
$this->sccp_conf_init['general'][$key] = explode(';', $content);
break;
case "devlang":
$lang_data = $this->extconfigs->getextConfig('sccp_lang', $value['data']);
$lang_data = $this->extconfigs->getExtConfig('sccp_lang', $value['data']);
if (!empty($lang_data)) {
// TODO: getExtConfig(sccp_lang ....) does not accept any additional arguments and will return an array
// TODO: will always get here, but lang_data['codepage'] will be empty as not a valid key
$this->sccp_conf_init['general']['phonecodepage'] = $lang_data['codepage'];
}
break;
@ -1343,7 +1346,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
);
}
// ----- It is a very bad idea to add an external configuration file "sccp_custom.conf" !!!!
// TODO: Should only rewrite the general section - if users have extensions, this may overwrite
// Should read first and then rewrite all existing sections.
$this->cnf_wr->writeConfig('sccp.conf', $this->sccp_conf_init);
}

View file

@ -20,13 +20,18 @@ class extconfigs
'about' => 'Default Settings and Enums ver: ' . $Ver);
}
public function getextConfig($id = '', $index = '') {
public function getExtConfig($id = '', $index = '') {
$result = array();
switch ($id) {
case 'keyset':
$result = $this->keysetdefault;
break;
case 'sccp_lang':
$result = $this->cisco_language;
if (empty($index)) {
return $this->cisco_language; // return language array
} elseif (!empty($this->cisco_language[$index])) {
return $this->cisco_language[$index]; // return the matched value
}
break;
case 'sccpDefaults':
$result = $this->sccpDefaults;
@ -268,8 +273,8 @@ class extconfigs
}
}
if (empty($base_config["tftp_path"])) {
if (file_exists($this->getextConfig('sccpDefaults', "tftp_path"))) {
$base_config["tftp_path"] = $this->getextConfig('sccpDefaults', "tftp_path");
if (file_exists($this->getExtConfig('sccpDefaults', "tftp_path"))) {
$base_config["tftp_path"] = $this->getExtConfig('sccpDefaults', "tftp_path");
}
}
if (empty($base_config["tftp_path"])) {

View file

@ -255,7 +255,7 @@ trait ajaxHelper {
if (!empty($request['id'])) {
$id_name = preg_replace('/[^A-Za-z0-9]/', '', $request['id']);
$this->sccp_conf_init[$id_name]['type'] = "softkeyset";
foreach ($this->extconfigs->getextConfig('keyset') as $keyl => $vall) {
foreach ($this->extconfigs->getExtConfig('keyset') as $keyl => $vall) {
if (!empty($request[$keyl])) {
$this->sccp_conf_init[$id_name][$keyl] = $request[$keyl];
}
@ -275,7 +275,7 @@ trait ajaxHelper {
foreach ($this->aminterface->sccp_list_keysets() as $keyl => $vall) {
$result[$i]['softkeys'] = $keyl;
if ($keyl == 'default') {
foreach ($this->extconfigs->getextConfig('keyset') as $key => $value) {
foreach ($this->extconfigs->getExtConfig('keyset') as $key => $value) {
$result[$i][$key] = str_replace(',', '<br>', $value);
}
} else {
@ -509,7 +509,7 @@ trait ajaxHelper {
case 'ntp_timezone':
$tz_id = $value;
$TZdata = $this->extconfigs->getextConfig('sccp_timezone', $tz_id);
$TZdata = $this->extconfigs->getExtConfig('sccp_timezone', $tz_id);
if (!empty($TZdata)) {
$value = $TZdata['offset']/60;
if (!($this->sccpvalues['tzoffset']['data'] == $value)) {

View file

@ -8,7 +8,7 @@
$keymultiselect = array('AllRight' =>'>>', 'Right' => '>', 'AllLeft' => '<<', 'Left' => '<');
// ------------------------------------- Key Set Value ---------------------------------------------------------
$keysetarray = $this->extconfigs->getextConfig('keyset');
$keysetarray = $this->extconfigs->getExtConfig('keyset');
/*$keysetarray1 = array('onhook' => array('redial','newcall','cfwdall','dnd','pickup','gpickup','private'),
'connected' => array('hold','endcall','park','vidmode','select','cfwdall','cfwdbusy','idivert'),

View file

@ -31,16 +31,14 @@ if (empty($form_prefix)) {
$day_format = array("D.M.Y", "D.M.YA", "Y.M.D", "YA.M.D", "M-D-Y", "M-D-YA", "D-M-Y", "D-M-YA", "Y-M-D", "YA-M-D", "M/D/Y", "M/D/YA",
"D/M/Y", "D/M/YA", "Y/M/D", "YA/M/D", "M/D/Y", "M/D/YA");
$mysql_table = array("sccpdevice","sccpdeviceconfig");
//$time_zone_name = timezone_identifiers_list();
$time_zone = array('-12' => 'GMT -12', '-11' => 'GMT -11', '-10' => 'GMT -10', '-09' => 'GMT -9',
$timeZoneOffsetList = array('-12' => 'GMT -12', '-11' => 'GMT -11', '-10' => 'GMT -10', '-09' => 'GMT -9',
'-08' => 'GMT -8', '-07' => 'GMT -7', '-06' => 'GMT -6', '-05' => 'GMT -5',
'-04' => 'GMT -4', '-03' => 'GMT -3', '-02' => 'GMT -2', '-01' => 'GMT -1',
'00' => 'GMT', '01' => 'GMT +1', '02' => 'GMT +2', '03' => 'GMT +3',
'04' => 'GMT +4', '05' => 'GMT +5', '06' => 'GMT +6', '07' => 'GMT +7',
'08' => 'GMT +8', '09' => 'GMT +9', '10' => 'GMT +10', '11'=> 'GMT +11', '12' => 'GMT +12');
$time_zone_name = array();
$extension_list = array();
$sofkey_list = array();
$model_list = array();
@ -440,7 +438,7 @@ foreach ($items as $child) {
$select_opt= $dialplan_list;
}
// if ($child['type'] == 'SLZ') {
// $select_opt= $time_zone;
// $select_opt= $timeZoneOffsetList;
// }
echo '<!-- Begin '.$child->label.' -->';
@ -500,7 +498,7 @@ foreach ($items as $child) {
$select_opt= $tftp_lang;
}
if ($child['type'] == 'SLZ') {
$select_opt= $time_zone;
$select_opt= $timeZoneOffsetList;
// $child->value = ($system_time_zone[offset]/60);
}

View file

@ -11,7 +11,7 @@ $def_val = null;
$dev_id = null;
$sccp_codec = $this->getCodecs('audio', true);
$video_codecs = $this->getCodecs('video', true);
$sccp_disalow_def = $this->extconfigs->getextConfig('sccpDefaults', 'disallow');
$sccp_disalow_def = $this->extconfigs->getExtConfig('sccpDefaults', 'disallow');
$sccp_disalow = $sccp_disalow_def;
if (!empty($_REQUEST['id'])) {

View file

@ -119,7 +119,7 @@ if ($mysql_info['Value'] <= '2000') {
// Check Time Zone compatibility
$conf_tz = $this->sccpvalues['ntp_timezone']['data'];
$cisco_tz = $this->extconfigs->getextConfig('sccp_timezone', $conf_tz);
$cisco_tz = $this->extconfigs->getExtConfig('sccp_timezone', $conf_tz);
if ($cisco_tz['offset'] == 0) {
if (!empty($conf_tz)) {
$tmp_dt = new DateTime(null, new DateTimeZone($conf_tz));