Commit Graph
5 Commits
Author SHA1 Message Date
Nic Boet 012063d3e1 fix: change or delete only events on monitors the user can view
The ajax/event.php actions rename, eventdetail, archive, unarchive and
delete checked Events edit only, and took any event id: a user with
Events edit restricted to some monitors could rename, annotate,
archive, unarchive or delete events of monitors they can't see. The
web event action and the API already check the event's monitor.

Load the event once for every Edit-level action in ajax/event.php and
require visibleMonitor() on its monitor, as addtag/removetag do; a
missing and a hidden event get the same answer (delete keeps its "Event
not found." reply). getselectedtags lists no tags of an event on a
hidden monitor.

includes/actions/eventdetail.php checks each event's monitor since
13138a0af, but passes markEids entries through validInt(), which keeps
an array an array, and new ZM\Event() takes an array as the row itself
without loading it: markEids[0][Id]=<hidden event>&markEids[0][MonitorId]=
<visible monitor> passes canEdit() and updates the hidden event. Take
only scalar ids there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit afe6452e421b10a9738d243bb5092cbbb2c4d0a6)
2026-10-30 18:10:30 -04:00
Nic Boet 321796dc4e fix(web): let Events view users delete the videos they generate
The video view generates videos (Events view, ajax/event.php action
video) and lists them under Existing Video Files with a Delete link.
Requiring Events edit for every delete also took that from viewers,
although only the event's recording needs protecting: a generated
video can be made again from it.

Treat as the recording the event's DefaultVideo, incomplete.<ext> (zmc's
name while recording) and <Id>-video.* (its final name), and require
Events edit for those only. Show the Delete link per file by the same
rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit a7c4b01a254bf006eec40cf1c9aa8bc82c92e6f3)
2026-10-30 18:10:07 -04:00
Nic Boet 123b36d43c fix(web): video view links address the file in their row
The file list numbered its rows with a counter that skipped empty
files, while deleteIndex, downloadIndex and showIndex look the number up
as the key in $videoFiles. With an empty file earlier in the directory
(for example a video generation that failed) every later row's Download,
Show and Delete acted on another file, Delete included. Use the array
key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit ca1b9311edab1a6eca6d61864a0e03f2796f3b77)
2026-10-30 18:10:07 -04:00
Nic Boet 7f09a39c88 fix: tag only events on monitors the user can view
addtag and removetag took any event id: a user with Events edit
restricted to some monitors could tag or untag events on monitors they
can't see. Filters select events by tag (a purge filter can keep tagged
events, or delete them), so that reaches events the user has no access
to. Load the event and require visibleMonitor() on its monitor; a
missing and a hidden event get the same error. removetag now validates
its ids like addtag.

ajax/tags.php listed tags only for Events view since the previous
commit, but the event view also serves Snapshots view users and loads
the tag list; accept either, as ajax/event.php does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 5b9df458d55d3491086dbbe25dbac2d3f3db1264)
2026-10-30 18:10:07 -04:00
Nic Boet 7bae8d61bb fix: require Events edit to tag events or delete event videos
Three event write paths were reachable with Events view only:

- ajax/event.php handled addtag and removetag in its canView('Events')
  block. removetag also deletes the Tag row once no event uses it.
- ajax/tags.php had no permission check, so createtag inserted Tags for
  any logged-in user, and getavailabletags listed them.
- views/video.php opens with canView('Events') and unlinks
  $videoFiles[deleteIndex]. ZM_FFMPEG_FORMATS defaults to "mp4* ...", so
  that list includes the event's own recording: a viewer could delete
  the recorded video of every event on the monitors they can see.

Move addtag and removetag into the canEdit('Events') block next to
rename and archive. In tags.php require canView('Events') for the file
and canEdit('Events') for createtag. In video.php require
canEdit('Events') for deleteIndex, skip indexes that are not in the
list, and only show the Delete link to users who can use it. The event
view disables the tag input and the tag-and-step buttons for users
without Events edit.

tests/php/test_event_writes_require_events_edit.php drives the three
files with Events None, View and Edit and checks the SQL they send and
whether the video file survives.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit d935293c527c4543a3afbdad1afdddc774c63ea2)
2026-10-30 18:10:07 -04:00