Merge branch 'master' into storageareas

pull/2618/head
Isaac Connor 2019-05-24 09:37:03 -04:00
commit f9004443cf
2 changed files with 32 additions and 3 deletions

View File

@ -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
?>

View File

@ -132,8 +132,8 @@ if ( ! $Event->Id() ) {
<span id="dataCause" title="<?php echo $Event->Notes()?validHtmlStr($Event->Notes()):translate('AttrCause') ?>"><?php echo validHtmlStr($Event->Cause()) ?></span>
<span id="dataTime" title="<?php echo translate('Time') ?>"><?php echo strftime( STRF_FMT_DATETIME_SHORT, strtotime($Event->StartTime() ) ) ?></span>
<span id="dataDuration" title="<?php echo translate('Duration') ?>"><?php echo $Event->Length().'s' ?></span>
<span id="dataFrames" title="<?php echo translate('AttrFrames')."/".translate('AttrAlarmFrames') ?>"><?php echo $Event->Frames() ?>/<?php echo $Event->AlarmFrames() ?></span>
<span id="dataScore" title="<?php echo translate('AttrTotalScore')."/".translate('AttrAvgScore')."/".translate('AttrMaxScore') ?>"><?php echo $Event->TotScore() ?>/<?php echo $Event->AvgScore() ?>/<?php echo $Event->MaxScore() ?></span>
<span id="dataFrames" title="<?php echo translate('AttrFrames').'/'.translate('AttrAlarmFrames') ?>"><?php echo $Event->Frames() ?>/<?php echo $Event->AlarmFrames() ?></span>
<span id="dataScore" title="<?php echo translate('AttrTotalScore').'/'.translate('AttrAvgScore').'/'.translate('AttrMaxScore') ?>"><?php echo $Event->TotScore() ?>/<?php echo $Event->AvgScore() ?>/<?php echo $Event->MaxScore() ?></span>
<span id="Storage"> <?php echo human_filesize($Event->DiskSpace(null)) . ' on ' . $Event->Storage()->Name() ?></span>
<div id="closeWindow"><a href="#" onclick="<?php echo $popup ? 'window.close()' : 'window.history.back();return false;' ?>"><?php echo $popup ? translate('Close') : translate('Back') ?></a></div>
</div>
@ -146,7 +146,7 @@ if ( ! $Event->Id() ) {
<?php
if ( canEdit('Events') ) {
?>
<div id="deleteEvent"><button type="button" data-on-click="deleteEvent" <?php echo $Event->Archived == 1 ? ' disabled="disabled" title="You cannot delete an archived event. Unarchive it first."' : '' ?>><?php echo translate('Delete') ?></button></div>
<div id="deleteEvent"><button type="button" data-on-click="deleteEvent" <?php echo $Event->can_delete() ? '' : ' disabled="disabled" title="'.$Event->cant_delete_reason().'"' ?>><?php echo translate('Delete') ?></button></div>
<div id="editEvent"><button type="button" data-on-click="editEvent"><?php echo translate('Edit') ?></button></div>
<div id="archiveEvent"<?php echo $Event->Archived == 1 ? ' class="hidden"' : '' ?>><button type="button" data-on-click="archiveEvent"><?php echo translate('Archive') ?></button></div>
<div id="unarchiveEvent"<?php echo $Event->Archived == 0 ? ' class="hidden"' : '' ?>><button type="button" data-on-click="unarchiveEvent"><?php echo translate('Unarchive') ?></button></div>