Эх сурвалжийг харах

Dashboard - Edit: Updates for PHP 8.1

fusionate 2 жил өмнө
parent
commit
d3c76562f5

+ 6 - 6
core/dashboard/dashboard_edit.php

@@ -61,7 +61,7 @@
 		$dashboard_column_span = $_POST["dashboard_column_span"] ?? '';
 		$dashboard_details_state = $_POST["dashboard_details_state"] ?? '';
 		$dashboard_order = $_POST["dashboard_order"] ?? '';
-		$dashboard_enabled = $_POST["dashboard_enabled"] ?: 'false';
+		$dashboard_enabled = $_POST["dashboard_enabled"] ?? 'false';
 		$dashboard_description = $_POST["dashboard_description"] ?? '';
 	}
 
@@ -370,13 +370,13 @@
 		}
 		echo "</table>\n";
 	}
-	if (is_array($groups)) {
-		echo "<br />\n";
+	if (!empty($groups) && is_array($groups)) {
+		if (!empty($dashboard_groups)) { echo "<br />\n"; }
 		echo "<select name='dashboard_groups[0][group_uuid]' class='formfld' style='width: auto; margin-right: 3px;'>\n";
 		echo "	<option value=''></option>\n";
-		foreach($groups as $row) {
-			if ($field['group_level'] <= $_SESSION['user']['group_level']) {
-				if (!in_array($row["group_uuid"], $assigned_groups)) {
+		foreach ($groups as $row) {
+			if ((!empty($field['group_level']) && $field['group_level'] <= $_SESSION['user']['group_level']) || empty($field['group_level'])) {
+				if (empty($assigned_groups) || !in_array($row["group_uuid"], $assigned_groups)) {
 					echo "	<option value='".$row['group_uuid']."'>".$row['group_name'].(!empty($row['domain_uuid']) ? "@".$_SESSION['domains'][$row['domain_uuid']]['domain_name'] : null)."</option>\n";
 				}
 			}

+ 4 - 4
core/dashboard/resources/classes/dashboard.php

@@ -85,7 +85,7 @@ if (!class_exists('dashboard')) {
 							$x = 0;
 							foreach ($records as $record) {
 								//add to the array
-									if ($record['checked'] == 'true' && is_uuid($record['dashboard_uuid'])) {
+									if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['dashboard_uuid'])) {
 										$array[$this->table][$x]['dashboard_uuid'] = $record['dashboard_uuid'];
 									}
 
@@ -200,7 +200,7 @@ if (!class_exists('dashboard')) {
 
 						//get checked records
 							foreach($records as $record) {
-								if ($record['checked'] == 'true' && is_uuid($record['dashboard_uuid'])) {
+								if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['dashboard_uuid'])) {
 									$uuids[] = "'".$record['dashboard_uuid']."'";
 								}
 							}
@@ -210,7 +210,7 @@ if (!class_exists('dashboard')) {
 								$sql = "select * from v_".$this->table." ";
 								$sql .= "where dashboard_uuid in (".implode(', ', $uuids).") ";
 								$database = new database;
-								$rows = $database->select($sql, $parameters, 'all');
+								$rows = $database->select($sql, $parameters ?? null, 'all');
 								if (is_array($rows) && @sizeof($rows) != 0) {
 									$x = 0;
 									foreach ($rows as $row) {
@@ -218,7 +218,7 @@ if (!class_exists('dashboard')) {
 											$array[$this->table][$x] = $row;
 
 										//add copy to the description
-											$array[$this->table][$x][dashboard.'_uuid'] = uuid();
+											$array[$this->table][$x]['dashboard_uuid'] = uuid();
 											$array[$this->table][$x][$this->description_field] = trim($row[$this->description_field]).' ('.$text['label-copy'].')';
 
 										//increment the id