mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-11-30 04:04:03 -05:00
78 lines
3.3 KiB
PHP
78 lines
3.3 KiB
PHP
<?php
|
|
//
|
|
// ZoneMinder web action
|
|
// Copyright (C) 2019 ZoneMinder LLC
|
|
//
|
|
// This program is free software; you can redistribute it and/or
|
|
// modify it under the terms of the GNU General Public License
|
|
// as published by the Free Software Foundation; either version 2
|
|
// of the License, or (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program; if not, write to the Free Software
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
//
|
|
|
|
// If there is an action on an event, then we must have an id.
|
|
if ( empty($_REQUEST['eid']) ) {
|
|
ZM\Warning('No eid in action on event view');
|
|
return;
|
|
}
|
|
|
|
// Event scope actions. Require edit on this event, which includes access to its monitor.
|
|
global $error_message;
|
|
$event = new ZM\Event(validCardinal($_REQUEST['eid']));
|
|
if ( $event->Id() and $event->canEdit() ) {
|
|
$_REQUEST['eid'] = $event->Id();
|
|
$failMessage = '';
|
|
|
|
if ( ($action == 'rename') && isset($_REQUEST['eventName']) ) {
|
|
if ( !is_scalar($_REQUEST['eventName']) ) {
|
|
$failMessage = 'Error renaming event '.$_REQUEST['eid'].': the name must be text<br/>';
|
|
} else if ( dbQuery('UPDATE Events SET Name=? WHERE Id=?', array($_REQUEST['eventName'], $_REQUEST['eid'])) === null ) {
|
|
$failMessage = 'Error renaming event '.$_REQUEST['eid'].': '.htmlspecialchars(dbLastError()).'<br/>';
|
|
} else {
|
|
ZM\AuditAction('rename', 'event', $_REQUEST['eid'], 'Name: '.$_REQUEST['eventName']);
|
|
}
|
|
} else if ( $action == 'eventdetail' ) {
|
|
$newEvent = isset($_REQUEST['newEvent']) ? $_REQUEST['newEvent'] : array();
|
|
if ( !is_array($newEvent) or (isset($newEvent['Cause']) and !is_scalar($newEvent['Cause']))
|
|
or (isset($newEvent['Notes']) and !is_scalar($newEvent['Notes'])) ) {
|
|
$failMessage = 'Error updating event '.$_REQUEST['eid'].': the cause and notes must be text<br/>';
|
|
} else if ( dbQuery('UPDATE Events SET Cause=?, Notes=? WHERE Id=?',
|
|
array(
|
|
$_REQUEST['newEvent']['Cause'],
|
|
$_REQUEST['newEvent']['Notes'],
|
|
$_REQUEST['eid']
|
|
)
|
|
) === null ) {
|
|
$failMessage = 'Error updating event '.$_REQUEST['eid'].': '.htmlspecialchars(dbLastError()).'<br/>';
|
|
} else {
|
|
ZM\AuditAction('update', 'event', $_REQUEST['eid'], 'Detail update');
|
|
$refreshParent = true;
|
|
$closePopup = true;
|
|
}
|
|
} else if ( $action == 'archive' or $action == 'unarchive' ) {
|
|
if ( dbQuery('UPDATE Events SET Archived=? WHERE Id=?', array(($action == 'archive') ? 1 : 0, $_REQUEST['eid'])) === null ) {
|
|
$failMessage = 'Error updating event '.$_REQUEST['eid'].': '.htmlspecialchars(dbLastError()).'<br/>';
|
|
}
|
|
} else if ( $action == 'delete' ) {
|
|
if ( deleteEvent($_REQUEST['eid']) ) {
|
|
ZM\AuditAction('delete', 'event', $_REQUEST['eid'], '');
|
|
$refreshParent = true;
|
|
} else {
|
|
$failMessage = 'Error deleting event '.$_REQUEST['eid'].'<br/>';
|
|
}
|
|
}
|
|
if ( $failMessage !== '' ) {
|
|
ZM\Warning(strip_tags($failMessage));
|
|
$error_message .= $failMessage;
|
|
}
|
|
} // end if event canEdit
|
|
?>
|