diff --git a/web/api/app/Config/routes.php b/web/api/app/Config/routes.php index d41c2fd9e..0f9343644 100755 --- a/web/api/app/Config/routes.php +++ b/web/api/app/Config/routes.php @@ -32,6 +32,10 @@ Router::mapResources('logs'); Router::mapResources('states'); Router::mapResources('zonepresets'); + + /* Add new API to retrieve camera controls - for PTZ */ + /* refer to https://github.com/ZoneMinder/ZoneMinder/issues/799#issuecomment-105233112 */ + Router::mapResources('controls'); Router::parseExtensions(); /** diff --git a/web/api/app/Controller/ControlsController.php b/web/api/app/Controller/ControlsController.php new file mode 100644 index 000000000..879142f75 --- /dev/null +++ b/web/api/app/Controller/ControlsController.php @@ -0,0 +1,59 @@ +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') + )); + } +} + diff --git a/web/api/app/Model/Control.php b/web/api/app/Model/Control.php new file mode 100644 index 000000000..d5716cc66 --- /dev/null +++ b/web/api/app/Model/Control.php @@ -0,0 +1,54 @@ + array( + 'numeric' => array( + 'rule' => array('numeric'), + //'message' => 'Your custom message here', + //'allowEmpty' => false, + //'required' => false, + //'last' => false, // Stop validation after this rule + //'on' => 'create', // Limit validation to 'create' or 'update' operations + ), + ), + ); + +} diff --git a/web/api/app/Plugin/Crud b/web/api/app/Plugin/Crud index 813857bb2..0e7910cfc 160000 --- a/web/api/app/Plugin/Crud +++ b/web/api/app/Plugin/Crud @@ -1 +1 @@ -Subproject commit 813857bb220ac8858c1dd89f11b086a7d06e70d5 +Subproject commit 0e7910cfcc19f97ca05fec97afcdb4701d4e76c9