mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-09-13 13:49:22 -04:00
Neither checked anything, so any enabled, API-enabled account could read them.
Control definitions describe how to drive a camera and are edited under Options,
which requires System. Manufacturers, CameraModels and EncoderTemplates already
gate their reference data that way; Controls was left open.
getLoad returns the system load average, which getSysLoadHTML() in the web ui
declines to render without canView('System'), so the API no longer hands the
same figure to an account without it.
getDiskPercent reported usage per monitor, keyed by monitor name, telling an
account which monitors exist and how much disk each uses even when it was not
permitted to view any of them. It now reports only on monitors the caller can
view, and asking about one specific monitor requires view on that monitor.
daemonCheck is deliberately left alone: it reports only whether ZoneMinder is
running, which the web ui's navbar shows to every logged-in user, and gating it
here would make the API stricter than the interface it serves.
74 lines
1.8 KiB
PHP
74 lines
1.8 KiB
PHP
<?php
|
|
App::uses('AppController', 'Controller');
|
|
/**
|
|
* Controls Controller
|
|
*
|
|
* @property Control $Control
|
|
* @property PaginatorComponent $Paginator
|
|
*/
|
|
|
|
/*
|
|
We need a control API to get the PTZ parameters associated with a monitor
|
|
The monitor API returns a control ID which we then need to use to construct
|
|
an appropriate PTZ command to control PTZ operations
|
|
https://github.com/ZoneMinder/ZoneMinder/issues/799#issuecomment-105233112
|
|
*/
|
|
class ControlsController extends AppController {
|
|
|
|
|
|
/**
|
|
* Components
|
|
*
|
|
* @var array
|
|
*/
|
|
public $components = array('Paginator', 'RequestHandler');
|
|
|
|
# Control definitions describe how to drive a camera and are edited under
|
|
# Options, which requires System. Manufacturers, CameraModels and
|
|
# EncoderTemplates all gate their reference data the same way; this one was
|
|
# left open.
|
|
public function beforeFilter() {
|
|
parent::beforeFilter();
|
|
global $user;
|
|
$canView = (!$user) || ($user->System() != 'None');
|
|
if (!$canView) {
|
|
throw new UnauthorizedException(__('Insufficient Privileges'));
|
|
return;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* index method
|
|
*
|
|
* @return void
|
|
*/
|
|
public function index() {
|
|
$this->Control->recursive = 0;
|
|
$controls = $this->Control->find('all');
|
|
$this->set(array(
|
|
'controls' => $controls,
|
|
'_serialize' => array('controls')
|
|
));
|
|
}
|
|
|
|
/**
|
|
* view method
|
|
*
|
|
* @throws NotFoundException
|
|
* @param string $id
|
|
* @return void
|
|
*/
|
|
public function view($id = null) {
|
|
if (!$this->Control->exists($id)) {
|
|
throw new NotFoundException(__('Invalid control'));
|
|
}
|
|
$options = array('conditions' => array('Control.' . $this->Control->primaryKey => $id));
|
|
$control = $this->Control->find('first', $options);
|
|
$this->set(array(
|
|
'control' => $control,
|
|
'_serialize' => array('control')
|
|
));
|
|
}
|
|
}
|
|
|