Menu [Class]: Updates for PHP 8.1

This commit is contained in:
fusionate
2023-06-06 22:27:16 +00:00
parent 992a7e6f62
commit 8d51e9d948

View File

@@ -17,7 +17,7 @@
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>
Copyright (C) 2010 - 2022 Copyright (C) 2010 - 2023
All Rights Reserved. All Rights Reserved.
Contributor(s): Contributor(s):
@@ -191,7 +191,7 @@ if (!class_exists('menu')) {
} }
//delete the checked rows //delete the checked rows
if (is_array($array) && @sizeof($array) != 0) { if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions //grant temporary permissions
$p = new permissions; $p = new permissions;
@@ -249,7 +249,7 @@ if (!class_exists('menu')) {
$uuids[] = "'".$record['uuid']."'"; $uuids[] = "'".$record['uuid']."'";
} }
} }
if (is_array($uuids) && @sizeof($uuids) != 0) { if (!empty($uuids) && is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." "; $sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") "; $sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$database = new database; $database = new database;
@@ -265,17 +265,19 @@ if (!class_exists('menu')) {
//build update array //build update array
$x = 0; $x = 0;
foreach ($states as $uuid => $state) { if (!empty($states) && is_array($states) && @sizeof($states) != 0) {
//create the array foreach ($states as $uuid => $state) {
$array[$this->table][$x][$this->name.'_uuid'] = $uuid; //create the array
$array[$this->table][$x][$this->toggle_field] = $state == $this->toggle_values[0] ? $this->toggle_values[1] : $this->toggle_values[0]; $array[$this->table][$x][$this->name.'_uuid'] = $uuid;
$array[$this->table][$x][$this->toggle_field] = $state == $this->toggle_values[0] ? $this->toggle_values[1] : $this->toggle_values[0];
//increment //increment
$x++; $x++;
}
} }
//save the changes //save the changes
if (is_array($array) && @sizeof($array) != 0) { if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//save the array //save the array
$database = new database; $database = new database;
$database->app_name = $this->app_name; $database->app_name = $this->app_name;
@@ -534,7 +536,7 @@ if (!class_exists('menu')) {
$parameters['menu_item_uuid'] = $uuid_array[$sub_row['uuid']]; $parameters['menu_item_uuid'] = $uuid_array[$sub_row['uuid']];
$parameters['menu_uuid'] = $this->menu_uuid; $parameters['menu_uuid'] = $this->menu_uuid;
$parameters['group_name'] = $group; $parameters['group_name'] = $group;
$parameters['group_uuid'] = $group_uuids[$group]; $parameters['group_uuid'] = $group_uuids[$group] ?? null;
$database = new database; $database = new database;
$num_rows = $database->select($sql, $parameters, 'column'); $num_rows = $database->select($sql, $parameters, 'column');
if ($num_rows == 0) { if ($num_rows == 0) {
@@ -543,7 +545,7 @@ if (!class_exists('menu')) {
$array['menu_item_groups'][$x]['menu_uuid'] = $this->menu_uuid; $array['menu_item_groups'][$x]['menu_uuid'] = $this->menu_uuid;
$array['menu_item_groups'][$x]['menu_item_uuid'] = $uuid_array[$sub_row['uuid']]; $array['menu_item_groups'][$x]['menu_item_uuid'] = $uuid_array[$sub_row['uuid']];
$array['menu_item_groups'][$x]['group_name'] = $group; $array['menu_item_groups'][$x]['group_name'] = $group;
$array['menu_item_groups'][$x]['group_uuid'] = $group_uuids[$group]; $array['menu_item_groups'][$x]['group_uuid'] = $group_uuids[$group] ?? null;
$x++; $x++;
} }
unset($sql, $parameters, $num_rows); unset($sql, $parameters, $num_rows);