From 444477d8a5263490124d64910122ccdc0f56ac38 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Mon, 8 Jun 2015 17:49:51 +0000 Subject: [PATCH 1/7] New Control API to retrieve PTZ controls definitions. Refer https://github.com/ZoneMinder/ZoneMinder/issues/799#issuecomment-105233112 --- web/api/app/Model/Control.php | 90 +++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 web/api/app/Model/Control.php diff --git a/web/api/app/Model/Control.php b/web/api/app/Model/Control.php new file mode 100644 index 000000000..8788086dc --- /dev/null +++ b/web/api/app/Model/Control.php @@ -0,0 +1,90 @@ + 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 + ), + ), + ); + + //The Associations below have been created with all possible keys, those that are not needed can be removed + +/** + * hasMany associations + * + * @var array + */ + public $hasMany = array( + 'Event' => array( + 'className' => 'Event', + 'foreignKey' => 'ControlId', + 'dependent' => false, + 'conditions' => '', + 'fields' => '', + 'order' => '', + 'limit' => '', + 'offset' => '', + 'exclusive' => '', + 'finderQuery' => '', + 'counterQuery' => '' + ), + 'Zone' => array( + 'className' => 'Zone', + 'foreignKey' => 'ControlId', + 'dependent' => true, + 'conditions' => '', + 'fields' => '', + 'order' => '', + 'limit' => '', + 'offset' => '', + 'exclusive' => '', + 'finderQuery' => '', + 'counterQuery' => '' + ) + ); + +} From f723fc58b22b2016203871e53187f7ad4dc1fa31 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Mon, 8 Jun 2015 17:50:36 +0000 Subject: [PATCH 2/7] New Control API to retrieve PTZ controls definitions. Refer https://github.com/ZoneMinder/ZoneMinder/issues/799#issuecomment-105233112 --- web/api/app/Controller/ControlsController.php | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 web/api/app/Controller/ControlsController.php 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') + )); + } +} + From 30aefe1097ce6194543b9d4fc982dad878f02e03 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Mon, 8 Jun 2015 17:51:59 +0000 Subject: [PATCH 3/7] Addnew route for new control API. Ref: https://github.com/ZoneMinder/ZoneM^Cder/issues/799#issuecomment-105233112 --- web/api/app/Config/routes.php | 4 ++++ 1 file changed, 4 insertions(+) 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(); /** From 812efdb14cddc001d8ea3dd9e9ad1cc653f38efd Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Tue, 9 Jun 2015 12:22:28 +0000 Subject: [PATCH 4/7] Removed hasmany relationship from Control - it should not be mapped into any other controller --- web/api/app/Model/Control.php | 36 ----------------------------------- 1 file changed, 36 deletions(-) diff --git a/web/api/app/Model/Control.php b/web/api/app/Model/Control.php index 8788086dc..d5716cc66 100644 --- a/web/api/app/Model/Control.php +++ b/web/api/app/Model/Control.php @@ -51,40 +51,4 @@ class Control extends AppModel { ), ); - //The Associations below have been created with all possible keys, those that are not needed can be removed - -/** - * hasMany associations - * - * @var array - */ - public $hasMany = array( - 'Event' => array( - 'className' => 'Event', - 'foreignKey' => 'ControlId', - 'dependent' => false, - 'conditions' => '', - 'fields' => '', - 'order' => '', - 'limit' => '', - 'offset' => '', - 'exclusive' => '', - 'finderQuery' => '', - 'counterQuery' => '' - ), - 'Zone' => array( - 'className' => 'Zone', - 'foreignKey' => 'ControlId', - 'dependent' => true, - 'conditions' => '', - 'fields' => '', - 'order' => '', - 'limit' => '', - 'offset' => '', - 'exclusive' => '', - 'finderQuery' => '', - 'counterQuery' => '' - ) - ); - } From 1f7cd3111bfaa763f4f514b9a6dd7639f2e2098f Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Wed, 10 Jun 2015 15:42:48 +0000 Subject: [PATCH 5/7] Added CRUD plugin --- scripts/ZoneMinder/MYMETA.json | 39 ++++++++++++++++++++++++++++++++ web/api/app/Config/bootstrap.php | 4 ++-- web/api/app/Plugin/Crud | 2 +- 3 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 scripts/ZoneMinder/MYMETA.json diff --git a/scripts/ZoneMinder/MYMETA.json b/scripts/ZoneMinder/MYMETA.json new file mode 100644 index 000000000..8e349594e --- /dev/null +++ b/scripts/ZoneMinder/MYMETA.json @@ -0,0 +1,39 @@ +{ + "abstract" : "Container module for common ZoneMinder modules", + "author" : [ + "Philip Coombes " + ], + "dynamic_config" : 0, + "generated_by" : "ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.120921", + "license" : [ + "unknown" + ], + "meta-spec" : { + "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", + "version" : "2" + }, + "name" : "ZoneMinder", + "no_index" : { + "directory" : [ + "t", + "inc" + ] + }, + "prereqs" : { + "build" : { + "requires" : { + "ExtUtils::MakeMaker" : "0" + } + }, + "configure" : { + "requires" : { + "ExtUtils::MakeMaker" : "0" + } + }, + "runtime" : { + "requires" : {} + } + }, + "release_status" : "stable", + "version" : "v1.28.0" +} diff --git a/web/api/app/Config/bootstrap.php b/web/api/app/Config/bootstrap.php index 3a0981dd3..e86c35fd7 100644 --- a/web/api/app/Config/bootstrap.php +++ b/web/api/app/Config/bootstrap.php @@ -107,8 +107,8 @@ CakeLog::config('error', array( 'file' => 'error', )); -Configure::write('ZM_CONFIG', '@ZM_CONFIG@'); -Configure::write('ZM_VERSION', '@VERSION@'); +Configure::write('ZM_CONFIG', '/etc/zm.conf'); +Configure::write('ZM_VERSION', '1.28.0'); loadConfigFile(); 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 From 6aa722d5a9fc4282bb47f11ea20ecc12c11886a4 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Wed, 10 Jun 2015 15:51:38 +0000 Subject: [PATCH 6/7] removed MYMETA.json, its a post build generated file --- scripts/ZoneMinder/MYMETA.json | 39 ---------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 scripts/ZoneMinder/MYMETA.json diff --git a/scripts/ZoneMinder/MYMETA.json b/scripts/ZoneMinder/MYMETA.json deleted file mode 100644 index 8e349594e..000000000 --- a/scripts/ZoneMinder/MYMETA.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "abstract" : "Container module for common ZoneMinder modules", - "author" : [ - "Philip Coombes " - ], - "dynamic_config" : 0, - "generated_by" : "ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.120921", - "license" : [ - "unknown" - ], - "meta-spec" : { - "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", - "version" : "2" - }, - "name" : "ZoneMinder", - "no_index" : { - "directory" : [ - "t", - "inc" - ] - }, - "prereqs" : { - "build" : { - "requires" : { - "ExtUtils::MakeMaker" : "0" - } - }, - "configure" : { - "requires" : { - "ExtUtils::MakeMaker" : "0" - } - }, - "runtime" : { - "requires" : {} - } - }, - "release_status" : "stable", - "version" : "v1.28.0" -} From 8677e600a4bc2129edbaf8e0a9db9bb2cd44be02 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Wed, 10 Jun 2015 15:53:21 +0000 Subject: [PATCH 7/7] Reset bootstrap to use config/version variables --- web/api/app/Config/bootstrap.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/api/app/Config/bootstrap.php b/web/api/app/Config/bootstrap.php index e86c35fd7..3a0981dd3 100644 --- a/web/api/app/Config/bootstrap.php +++ b/web/api/app/Config/bootstrap.php @@ -107,8 +107,8 @@ CakeLog::config('error', array( 'file' => 'error', )); -Configure::write('ZM_CONFIG', '/etc/zm.conf'); -Configure::write('ZM_VERSION', '1.28.0'); +Configure::write('ZM_CONFIG', '@ZM_CONFIG@'); +Configure::write('ZM_VERSION', '@VERSION@'); loadConfigFile();