Cast GET parameters to int and update SQL query

GET parameters 'id' and 'group_id' are now explicitly cast to integers in NotificationGroupController for improved type safety. Also, the SQL query in NotificationGroup model now includes GROUP BY and ORDER BY clauses when filtering by user_id, ensuring results are grouped and sorted by group name.
This commit is contained in:
Hosteroid
2025-10-20 17:48:35 +03:00
parent c59a4e2c5b
commit 111698cfed
2 changed files with 7 additions and 7 deletions

View File

@@ -29,7 +29,7 @@ class NotificationGroup extends Model
LEFT JOIN domains d ON ng.id = d.notification_group_id";
if ($userId && !$this->getUserModel()->isAdmin($userId)) {
$sql .= " WHERE ng.user_id = ?";
$sql .= " WHERE ng.user_id = ? GROUP BY ng.id ORDER BY ng.name ASC";
$stmt = $this->db->prepare($sql);
$stmt->execute([$userId]);
} else {