mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-11-07 21:23:02 -05:00
Add a CreatedBy column to the Reports table and a canEdit() method on the Report class so $report->canEdit() (already called from web/ajax/reports.php) resolves to a real check. canEdit() permits the report owner (CreatedBy == user) or any user/role with System=Edit. Wire actions/report.php to stamp CreatedBy on first save and refuse save/delete on existing reports the current user cannot edit. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
19 lines
465 B
SQL
19 lines
465 B
SQL
--
|
|
-- Add CreatedBy to Reports so canEdit() can check ownership
|
|
--
|
|
|
|
SELECT 'Checking for CreatedBy in Reports';
|
|
SET @s = (SELECT IF(
|
|
(SELECT COUNT(*)
|
|
FROM INFORMATION_SCHEMA.COLUMNS
|
|
WHERE table_name = 'Reports'
|
|
AND table_schema = DATABASE()
|
|
AND column_name = 'CreatedBy'
|
|
) > 0,
|
|
"SELECT 'CreatedBy column already exists in Reports'",
|
|
"ALTER TABLE Reports ADD COLUMN `CreatedBy` int(10) unsigned AFTER `Interval`"
|
|
));
|
|
|
|
PREPARE stmt FROM @s;
|
|
EXECUTE stmt;
|