From 17010892115e2fce369e1932bfeec3fa5ebf063a Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 17 Sep 2020 20:56:21 -0400 Subject: [PATCH] Add MonitorId to Zone fields and add Monitor() method --- web/includes/Zone.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/web/includes/Zone.php b/web/includes/Zone.php index 7a19df9d2..9f3850bb1 100644 --- a/web/includes/Zone.php +++ b/web/includes/Zone.php @@ -8,8 +8,9 @@ class Zone extends ZM_Object { protected static $table = 'Zones'; protected $defaults = array( - 'Id' => null, - 'Name' => '', + 'Id' => null, + 'MonitorId' => null, + 'Name' => '', 'Type' => 'Active', 'Units' => 'Pixels', 'CheckMethod' => 'Blobs', @@ -36,6 +37,14 @@ class Zone extends ZM_Object { public static function find_one( $parameters = array(), $options = array() ) { return ZM_Object::_find_one(get_class(), $parameters, $options); } + public function Monitor() { + if ( isset($this->{'MonitorId'}) ) { + $Monitor = Monitor::find_one(array('Id'=>$this->{'MonitorId'})); + if ( $Monitor ) + return $Monitor; + } + return new Monitor(); + } } # end class Zone ?>