From 31a1ca623660d0242ca8cc1838665e19053ba605 Mon Sep 17 00:00:00 2001 From: Edward Hibbert Date: Tue, 19 Dec 2023 09:48:26 +0000 Subject: [PATCH] Test fixes. --- app/Helpers/Fixometer.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/app/Helpers/Fixometer.php b/app/Helpers/Fixometer.php index 02cffd66e..dd1c055c9 100644 --- a/app/Helpers/Fixometer.php +++ b/app/Helpers/Fixometer.php @@ -179,6 +179,34 @@ public static function userHasDeletePartyPermission($partyId, $userId = null) return false; } + public static function userCanApproveEvent($eventId, $userId = null, $groupId = null) + { + if (is_null($userId)) { + $userId = Auth::user()->id; + } + $user = User::find($userId); + + if (self::hasRole($user, 'Administrator')) { + return true; + } + + if (self::hasRole($user, 'NetworkCoordinator')) { + if ($groupId) { + $group = Group::find($groupId); + } else { + $group = Party::find($eventId)->theGroup; + } + + foreach ($group->networks as $network) { + if ($network->coordinators->contains($user)) { + return true; + } + } + } + + return false; + } + public static function userHasEditEventsDevicesPermission($partyId, $userId = null) { if (is_null($userId)) {