From 2fc7b3cf4d69e25fa68d190dd6b052d7fef94077 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 24 May 2019 09:31:48 -0400 Subject: [PATCH] Don't allow deleting of in-progress recording --- web/includes/Event.php | 29 +++++++++++++++++++++++++++++ web/skins/classic/views/event.php | 6 +++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/web/includes/Event.php b/web/includes/Event.php index ba4f04e8c..07460a7ec 100644 --- a/web/includes/Event.php +++ b/web/includes/Event.php @@ -664,6 +664,35 @@ class Event { return 0; } # end public function file_size() + public function can_delete() { + if ( $this->Archived() ) { + Logger::Debug("Am archived, can't delete"); + return false; + } + if ( !$this->EndTime() ) { + Logger::Debug("No EndTime can't delete"); + return false; + } + if ( !canEdit('Events') ) { + Logger::Debug("No permission to edit events, can't delete"); + return false; + } + Logger::Debug("Can delete: archived: " . $this->Archived() . " endtime: " . $this->EndTime() ); + + return true; + } + + public function cant_delete_reason() { + if ( $this->Archived() ) { + return 'You cannot delete an archived event. Unarchive it first.'; + } else if ( ! $this->EndTime() ) { + return 'You cannot delete an event while it is being recorded. Wait for it to finish.'; + } else if ( ! canEdit('Events') ) { + return 'You do not have rights to edit Events.'; + } + return 'Unknown reason'; + } + } # end class ?> diff --git a/web/skins/classic/views/event.php b/web/skins/classic/views/event.php index 7feed10df..b09f88acc 100644 --- a/web/skins/classic/views/event.php +++ b/web/skins/classic/views/event.php @@ -132,8 +132,8 @@ if ( ! $Event->Id() ) { Cause()) ?> StartTime() ) ) ?> Length().'s' ?> - ">Frames() ?>/AlarmFrames() ?> - ">TotScore() ?>/AvgScore() ?>/MaxScore() ?> + Frames() ?>/AlarmFrames() ?> + TotScore() ?>/AvgScore() ?>/MaxScore() ?> DiskSpace(null)) . ' on ' . $Event->Storage()->Name() ?>
@@ -146,7 +146,7 @@ if ( ! $Event->Id() ) { -
+
Archived == 1 ? ' class="hidden"' : '' ?>>
Archived == 0 ? ' class="hidden"' : '' ?>>