From b9efe627f30842a2e7ac8957dcfa6922c65a8207 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 18 Aug 2021 10:37:56 -0400 Subject: [PATCH] implement Event->canView --- web/includes/Event.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/web/includes/Event.php b/web/includes/Event.php index 7b0807728..328b06f66 100644 --- a/web/includes/Event.php +++ b/web/includes/Event.php @@ -627,6 +627,29 @@ class Event extends ZM_Object { return 'Unknown reason'; } + function canView($u=null) { + global $user; + if (!$u) $u=$user; + if (!$u) { + # auth turned on and not logged in + return false; + } + if (!empty($u['MonitorIds']) ) { + if (in_array($this->{'MonitorId'}, explode(',', $u['MonitorIds']))) { + return true; + } + return false; + } + if ($u['Events'] != 'None') { + return true; + } + if ($u['Snapshots'] != 'None') { + # If the event is contained in a snapshot, then we can still view it. + if (dbFetchOne('SELECT * FROM Snapshot_Events WHERE EventId=?', $this->Id())) + return true; + } + return false; + } } # end class ?>