Code in domain_settings evolving

This commit is contained in:
FusionPBX 2023-05-13 11:28:12 -06:00 committed by GitHub
parent f6a48235d2
commit 0a37d8c8d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 45 additions and 40 deletions

View File

@ -1,27 +1,27 @@
<?php <?php
/* /*
FusionPBX FusionPBX
Version: MPL 1.1 Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with 1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis, Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the for the specific language governing rights and limitations under the
License. License.
The Original Code is FusionPBX The Original Code is FusionPBX
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2020 Portions created by the Initial Developer are Copyright (C) 2008 - 2022
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
*/ */
//set the include path //set the include path
@ -46,19 +46,26 @@
$text = $language->get(); $text = $language->get();
//get the domain_uuid //get the domain_uuid
if (is_uuid($_GET['id'])) { if (!empty($_GET['id']) && is_uuid($_GET['id'])) {
$domain_uuid = $_GET['id']; $domain_uuid = $_GET['id'];
} }
//set additional variables
//$search = !empty($_GET["search"]) ? $_GET["search"] : '';
$show = !empty($_GET["show"]) ? $_GET["show"] : '';
//set from session variables
$list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false';
//get the http post data //get the http post data
if ($_POST['action'] != '') { if (!empty($_POST['action'])) {
$action = $_POST['action']; $action = $_POST['action'] ?? '';
$domain_uuid = $_POST['domain_uuid']; $domain_uuid = $_POST['domain_uuid'] ?? '';
$domain_settings = $_POST['domain_settings']; $domain_settings = $_POST['domain_settings'] ?? '';
$domain_uuid_target = $_POST['domain_uuid_target']; $domain_uuid_target = $_POST['domain_uuid_target'] ?? '';
//process the http post data by action //process the http post data by action
if (is_array($domain_settings) && @sizeof($domain_settings) != 0) { if (!empty($domain_settings)) {
switch ($action) { switch ($action) {
case 'copy': case 'copy':
if (permission_exists('domain_setting_add') && permission_exists('domain_select') && count($_SESSION['domains']) > 1) { if (permission_exists('domain_setting_add') && permission_exists('domain_select') && count($_SESSION['domains']) > 1) {
@ -90,9 +97,9 @@
exit; exit;
} }
//get the variables //get order and order by and sanitize the values
$order_by = $_GET["order_by"]; $order_by = $_GET["order_by"] ?? '';
$order = $_GET["order"]; $order = $_GET["order"] ?? '';
//get the domain_name //get the domain_name
$sql = "select domain_name from v_domains "; $sql = "select domain_name from v_domains ";
@ -121,7 +128,7 @@
} }
$parameters['domain_uuid'] = $domain_uuid; $parameters['domain_uuid'] = $domain_uuid;
$database = new database; $database = new database;
$domain_settings = $database->select($sql, $parameters, 'all'); $domain_settings = $database->select($sql, $parameters ?? null, 'all');
unset($sql, $parameters); unset($sql, $parameters);
//create token //create token
@ -133,12 +140,7 @@
require_once "resources/header.php"; require_once "resources/header.php";
//copy settings javascript //copy settings javascript
if ( if (permission_exists("domain_select") && permission_exists("domain_setting_add") && !empty($_SESSION['domains'])) {
permission_exists("domain_select") &&
permission_exists("domain_setting_add") &&
is_array($_SESSION['domains']) &&
@sizeof($_SESSION['domains']) > 1
) {
echo "<script language='javascript' type='text/javascript'>\n"; echo "<script language='javascript' type='text/javascript'>\n";
echo " var fade_speed = 400;\n"; echo " var fade_speed = 400;\n";
echo " function show_domains() {\n"; echo " function show_domains() {\n";
@ -217,7 +219,10 @@
echo "<input type='hidden' name='domain_uuid_target' id='domain_uuid_target' value=''>\n"; echo "<input type='hidden' name='domain_uuid_target' id='domain_uuid_target' value=''>\n";
echo "<table class='list'>\n"; echo "<table class='list'>\n";
if (is_array($domain_settings) && @sizeof($domain_settings) != 0) { if (!empty($domain_settings)) {
//define the variable
$previous_domain_setting_category = '';
$x = 0; $x = 0;
foreach ($domain_settings as $row) { foreach ($domain_settings as $row) {
$domain_setting_category = strtolower($row['domain_setting_category']); $domain_setting_category = strtolower($row['domain_setting_category']);
@ -235,7 +240,7 @@
} }
if ($previous_domain_setting_category != $row['domain_setting_category']) { if ($previous_domain_setting_category != $row['domain_setting_category']) {
if ($previous_domain_setting_category != '') { if (!empty($previous_domain_setting_category)) {
echo "</table>\n"; echo "</table>\n";
echo "<br>\n"; echo "<br>\n";
@ -249,7 +254,7 @@
echo " <input type='checkbox' id='checkbox_all_".$domain_setting_category."' name='checkbox_all' onclick=\"list_all_toggle('".$domain_setting_category."');\">\n"; echo " <input type='checkbox' id='checkbox_all_".$domain_setting_category."' name='checkbox_all' onclick=\"list_all_toggle('".$domain_setting_category."');\">\n";
echo " </th>\n"; echo " </th>\n";
} }
if ($_GET['show'] == 'all' && permission_exists('domain_setting_all')) { if ($show == 'all' && permission_exists('domain_setting_all')) {
echo th_order_by('domain_name', $text['label-domain'], $order_by, $order); echo th_order_by('domain_name', $text['label-domain'], $order_by, $order);
} }
echo th_order_by('domain_setting_subcategory', $text['label-subcategory'], $order_by, $order, null, "class='pct-35'"); echo th_order_by('domain_setting_subcategory', $text['label-subcategory'], $order_by, $order, null, "class='pct-35'");
@ -257,7 +262,7 @@
echo th_order_by('domain_setting_value', $text['label-value'], $order_by, $order, null, "class='pct-30'"); echo th_order_by('domain_setting_value', $text['label-value'], $order_by, $order, null, "class='pct-30'");
echo th_order_by('domain_setting_enabled', $text['label-enabled'], $order_by, $order, null, "class='center'"); echo th_order_by('domain_setting_enabled', $text['label-enabled'], $order_by, $order, null, "class='center'");
echo " <th class='pct-25 hide-sm-dn'>".$text['label-description']."</th>\n"; echo " <th class='pct-25 hide-sm-dn'>".$text['label-description']."</th>\n";
if (permission_exists('domain_setting_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { if (permission_exists('domain_setting_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n"; echo " <td class='action-button'>&nbsp;</td>\n";
} }
echo "</tr>\n"; echo "</tr>\n";
@ -292,7 +297,7 @@
$parameters['menu_uuid'] = $row['domain_setting_value']; $parameters['menu_uuid'] = $row['domain_setting_value'];
$database = new database; $database = new database;
$sub_result = $database->select($sql, $parameters, 'all'); $sub_result = $database->select($sql, $parameters, 'all');
if (is_array($sub_result) && sizeof($sub_result) != 0) { if (!empty($sub_result)) {
foreach ($sub_result as &$sub_row) { foreach ($sub_result as &$sub_row) {
echo escape($sub_row["menu_language"])." - ".escape($sub_row["menu_name"])."\n"; echo escape($sub_row["menu_language"])." - ".escape($sub_row["menu_name"])."\n";
} }
@ -376,7 +381,7 @@
} }
echo " </td>\n"; echo " </td>\n";
echo " <td class='description overflow hide-sm-dn' title=\"".escape($row['domain_setting_description'])."\">".escape($row['domain_setting_description'])."&nbsp;</td>\n"; echo " <td class='description overflow hide-sm-dn' title=\"".escape($row['domain_setting_description'])."\">".escape($row['domain_setting_description'])."&nbsp;</td>\n";
if (permission_exists('domain_setting_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { if (permission_exists('domain_setting_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>\n"; echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]); echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n"; echo " </td>\n";