From ac876402b398f11de530b761d3654faed3e5ae8e Mon Sep 17 00:00:00 2001 From: Antonio Fernandez Date: Thu, 13 Jun 2024 16:53:30 -0400 Subject: [PATCH] add function to return the config object used to create the database object (#6998) (#7006) Co-authored-by: Tim Fry --- app/devices/app_config.php | 6 +++++ app/devices/device_edit.php | 27 +++++++++++++++++++ app/provision/app_config.php | 9 ++++++- .../acrobits/default/qr_template.txt | 1 + 4 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 resources/templates/provision/acrobits/default/qr_template.txt diff --git a/app/devices/app_config.php b/app/devices/app_config.php index 55d42ee324..b05476654a 100644 --- a/app/devices/app_config.php +++ b/app/devices/app_config.php @@ -4313,4 +4313,10 @@ $vendors[$y]['name'] = "sipnetic"; $z=0; + //acrobits details + $y++; + $vendors[$y]['uuid'] = "9c616373-99fb-4f7d-8713-d5b1da9aaef3"; + $vendors[$y]['name'] = "acrobits"; + $z=0; + ?> diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index dcdef7e80e..62dd19ef27 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -783,6 +783,9 @@ else if ($device_template == "sipnetic/default") { $qr_code_enabled = true; } + else if ($device_template == "acrobits/default") { + $qr_code_enabled = true; + } else { $qr_code_enabled = false; } @@ -863,6 +866,30 @@ unset($template); } } + //build content for acrobits + else if ($device_template == 'acrobits/default') { + //check custom template provision location + if (is_file('/usr/share/fusionpbx/templates/provision/'.$device_template.'/qr_template.txt')) { + $template = file_get_contents('/usr/share/fusionpbx/templates/provision/'.$device_template.'/qr_template.txt'); + } + else if (is_file('/var/www/fusionpbx/resources/templates/provision/'.$device_template.'/qr_template.txt')) { + $template = file_get_contents('/var/www/fusionpbx/resources/templates/provision/'.$device_template.'/qr_template.txt'); + } + + //get the provision settings + $provision = new settings(["category" => "provision"]); + $acrobits_code = $provision->get('provision', 'acrobits_code'); + + if (!empty($template) && isset($acrobits_code)) { + $template = str_replace('{$server_address}', $row['server_address'], $template); + $template = str_replace('{$user_id}', urlencode($row['user_id']), $template); + $template = str_replace('{$password}', urlencode(str_replace(';',';;',$row['password'])), $template); + $template = str_replace('{$code}', $acrobits_code, $template); + $content = trim($template, "\r\n"); + unset($template); + unset($acrobits_code); + } + } } diff --git a/app/provision/app_config.php b/app/provision/app_config.php index 100f0998b8..6befc9bbe4 100644 --- a/app/provision/app_config.php +++ b/app/provision/app_config.php @@ -390,5 +390,12 @@ $apps[$x]['default_settings'][$y]['default_setting_value'] = ""; $apps[$x]['default_settings'][$y]['default_setting_enabled'] = "false"; $apps[$x]['default_settings'][$y]['default_setting_description'] = "User level password for endpoint embedded web server."; - + $y++; + $apps[$x]['default_settings'][$y]['default_setting_uuid'] = "e039d204-3682-4774-9b83-1603854ec05e"; + $apps[$x]['default_settings'][$y]['default_setting_category'] = "provision"; + $apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "acrobits_code"; + $apps[$x]['default_settings'][$y]['default_setting_name'] = "text"; + $apps[$x]['default_settings'][$y]['default_setting_value'] = ""; + $apps[$x]['default_settings'][$y]['default_setting_enabled'] = "false"; + $apps[$x]['default_settings'][$y]['default_setting_description'] = "Enter your Acrobits application code here. This can be found in your Acrobits portal."; ?> diff --git a/resources/templates/provision/acrobits/default/qr_template.txt b/resources/templates/provision/acrobits/default/qr_template.txt new file mode 100644 index 0000000000..bf7032dd45 --- /dev/null +++ b/resources/templates/provision/acrobits/default/qr_template.txt @@ -0,0 +1 @@ +csc:{$user_id}@{$server_address}:{$password}@{$code} \ No newline at end of file