mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-11-30 04:04:03 -05:00
46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
if ( !canEdit('Control') ) {
|
|
ZM\Warning('Need Control permissions to edit control capabilities');
|
|
ajaxError('Insufficient permissions');
|
|
return;
|
|
}
|
|
|
|
if ( empty($_REQUEST['action']) ) {
|
|
ajaxError('Action Not Provided');
|
|
return;
|
|
} else {
|
|
$action = $_REQUEST['action'];
|
|
}
|
|
|
|
if ( isset($_REQUEST['cids']) ) {
|
|
$cids = (array)$_REQUEST['cids'];
|
|
} else {
|
|
ajaxError('At least one Control Id must be Provided.');
|
|
return;
|
|
}
|
|
|
|
if ( $action == 'delete' ) {
|
|
$failed = false;
|
|
foreach ( $cids as $cid ) {
|
|
// validCardinal() would turn '-3', '1.5' or '1e1' into another capability's id.
|
|
if ( !(is_string($cid) || is_int($cid)) || !ctype_digit((string)$cid) )
|
|
continue;
|
|
$cid = (string)$cid;
|
|
if ( dbQuery('UPDATE Monitors SET Controllable = 0, ControlId = 0 WHERE ControlId = ?', array($cid)) === null )
|
|
$failed = true;
|
|
if ( dbQuery('DELETE FROM Controls WHERE Id = ?', array($cid)) === null )
|
|
$failed = true;
|
|
}
|
|
if ( $failed ) {
|
|
ajaxError('Failed to delete control capability: '.dbLastError());
|
|
return;
|
|
}
|
|
} else {
|
|
ajaxError('Unrecognised action ' .$_REQUEST['action']);
|
|
return;
|
|
}
|
|
|
|
ajaxResponse();
|
|
return;
|
|
?>
|