From 09219263e1b989b358ef6121d78aa2078862a0fa Mon Sep 17 00:00:00 2001 From: fusionate Date: Thu, 25 May 2023 15:43:36 +0000 Subject: [PATCH] Device Vendor Function - Edit: Updates for PHP 8.1 --- app/devices/device_vendor_function_edit.php | 39 ++++++++++++--------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/app/devices/device_vendor_function_edit.php b/app/devices/device_vendor_function_edit.php index 1b464f8392..452eda8b72 100644 --- a/app/devices/device_vendor_function_edit.php +++ b/app/devices/device_vendor_function_edit.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2016-2022 + Portions created by the Initial Developer are Copyright (C) 2016-2023 the Initial Developer. All Rights Reserved. Contributor(s): @@ -31,8 +31,13 @@ //includes files require_once "resources/require.php"; + +//add multi-lingual support + $language = new text; + $text = $language->get(); + //delete the group from the menu item - if ($_REQUEST["a"] == "delete" && permission_exists("device_vendor_function_delete") && $_REQUEST["id"] != '') { + if (!empty($_REQUEST["a"]) && $_REQUEST["a"] == "delete" && permission_exists("device_vendor_function_delete") && !empty($_REQUEST["id"])) { //get the id $device_vendor_function_group_uuid = $_REQUEST["id"]; $device_vendor_function_uuid = $_REQUEST["device_vendor_function_uuid"]; @@ -53,7 +58,7 @@ $p->delete('device_vendor_function_group_delete', 'temp'); //redirect the browser - message::add($text['message-delete']); + message::add($text['message-delete'] ?? ''); header("Location: device_vendor_function_edit.php?id=".escape($device_vendor_function_uuid) ."&device_vendor_uuid=".escape($device_vendor_uuid)); exit; } @@ -69,7 +74,7 @@ } //action add or update - if (is_uuid($_REQUEST["id"])) { + if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) { $action = "update"; $device_vendor_function_uuid = $_REQUEST["id"]; } @@ -133,7 +138,7 @@ } //add or update the database - if ($_POST["persistformvar"] != "true") { + if (empty($_POST["persistformvar"]) || $_POST["persistformvar"] != "true") { //add vendor functions if ($action == "add" && permission_exists('device_vendor_function_add')) { @@ -201,8 +206,8 @@ } //pre-populate the form - if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { - $device_vendor_function_uuid = $_GET["id"]; + if (!empty($_GET) && count($_GET) > 0 && (empty($_POST["persistformvar"]) || $_POST["persistformvar"] != "true")) { + $device_vendor_function_uuid = $_GET["id"] ?? null; $sql = "select * from v_device_vendor_functions "; $sql .= "where device_vendor_function_uuid = :device_vendor_function_uuid "; $parameters['device_vendor_function_uuid'] = $device_vendor_function_uuid; @@ -249,7 +254,7 @@ //get the groups $sql = "select * from v_groups "; - if (is_array($assigned_groups) && @sizeof($assigned_groups) != 0) { + if (!empty($assigned_groups) && is_array($assigned_groups) && @sizeof($assigned_groups) != 0) { $sql .= "where "; foreach ($assigned_groups as $index => $group_uuid) { $sql_where[] = 'group_uuid <> :group_uuid_'.$index; @@ -261,7 +266,7 @@ } $sql .= "order by domain_uuid desc, group_name asc "; $database = new database; - $groups = $database->select($sql, $parameters, 'all'); + $groups = $database->select($sql, $parameters ?? null, 'all'); unset($sql, $parameters, $sql_where, $index); //create token @@ -291,7 +296,7 @@ echo " ".$text['label-type']."\n"; echo "\n"; echo "\n"; - echo " \n"; + echo " \n"; echo "
\n"; echo $text['description-type']."\n"; echo "\n"; @@ -302,9 +307,9 @@ echo " ".$text['label-subtype']."\n"; echo "\n"; echo "\n"; - echo " \n"; + echo " \n"; echo "
\n"; - echo $text['description-subtype']."\n"; + echo ($text['description-subtype'] ?? '')."\n"; echo "\n"; echo "\n"; @@ -313,7 +318,7 @@ echo " ".$text['label-value']."\n"; echo "\n"; echo "\n"; - echo " \n"; + echo " \n"; echo "
\n"; echo $text['description-value']."\n"; echo "\n"; @@ -347,7 +352,7 @@ foreach ($groups as $field) { if ($field['group_name'] == "superadmin" && !if_group("superadmin")) { continue; } //only show the superadmin group to other superadmins if ($field['group_name'] == "admin" && (!if_group("superadmin") && !if_group("admin") )) { continue; } //only show the admin group to other admins - if (!is_array($assigned_groups) || !in_array($field["group_uuid"], $assigned_groups)) { + if (empty($assigned_groups) || !is_array($assigned_groups) || !in_array($field["group_uuid"], $assigned_groups)) { echo " \n"; } } @@ -364,7 +369,7 @@ echo "\n"; echo " \n"; echo "
\n"; echo $text['description-enabled']."\n"; @@ -376,7 +381,7 @@ echo " ".$text['label-description']."\n"; echo "\n"; echo "\n"; - echo " \n"; + echo " \n"; echo "
\n"; echo $text['description-description']."\n"; echo "\n"; @@ -397,4 +402,4 @@ //include the footer require_once "resources/footer.php"; -?> +?> \ No newline at end of file