mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-08-03 08:46:44 -04:00
Add three Options tabs (AI Datasets, AI Models, AI Classes) with full
CRUD, backed by the AI_* tables:
- List views (_options_ai_{datasets,models,classes}.php), edit modals
(ajax/modals/ai_{dataset,model,class}.php) and action handlers
(actions/ai_{dataset,model,class}.php).
- options.js loads the modals over ajax, wires the Add/edit buttons and
the AI Classes dataset filter.
- options.php dispatches the new tab includes; functions.php registers
the three tabs in the Options sub-menu with readable labels (they are
not Config categories, so they need explicit entries).
- actions/options.php routes object=ai_* deletes to the matching
handler; saves post directly to view=ai_*.
All tabs and actions are gated on System permission.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
59 lines
1.8 KiB
PHP
59 lines
1.8 KiB
PHP
<?php
|
|
//
|
|
// ZoneMinder web action file
|
|
// Copyright (C) 2024 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.
|
|
//
|
|
|
|
// AI Model edit actions
|
|
if (!canEdit('System')) {
|
|
ZM\Warning('Need System permissions to manage AI models');
|
|
return;
|
|
}
|
|
|
|
if ($action == 'save') {
|
|
if (!empty($_REQUEST['id'])) {
|
|
$dbModel = dbFetchOne('SELECT * FROM AI_Models WHERE Id=?', NULL, [$_REQUEST['id']]);
|
|
} else {
|
|
$dbModel = array();
|
|
}
|
|
|
|
$types = array();
|
|
$changes = getFormChanges($dbModel, $_REQUEST['newModel'], $types);
|
|
|
|
if (count($changes)) {
|
|
if (!empty($_REQUEST['id'])) {
|
|
dbQuery('UPDATE AI_Models SET '.implode(', ', $changes).' WHERE Id = ?',
|
|
array($_REQUEST['id']) );
|
|
} else {
|
|
dbQuery('INSERT INTO AI_Models SET '.implode(', ', $changes));
|
|
}
|
|
$refreshParent = true;
|
|
}
|
|
$redirect = '?view=options&tab=ai_models';
|
|
} else if ($action == 'delete') {
|
|
if ( !empty($_REQUEST['markIds']) ) {
|
|
foreach ($_REQUEST['markIds'] as $Id) {
|
|
dbQuery('DELETE FROM AI_Models WHERE Id=?', array($Id));
|
|
}
|
|
$refreshParent = true;
|
|
}
|
|
$redirect = '?view=options&tab=ai_models';
|
|
} else {
|
|
ZM\Error("Unknown action $action in saving AI Model");
|
|
}
|
|
?>
|