zoneminder/web/api/app/Model/Zone.php

84 lines
1.6 KiB
PHP
Raw Normal View History

2014-04-23 11:14:25 +08:00
<?php
App::uses('AppModel', 'Model');
/**
* Zone Model
*
* @property Monitor $Monitor
*/
class Zone extends AppModel {
/**
* Use table
*
* @var mixed False or table name
*/
public $useTable = 'Zones';
/**
* Primary key field
*
* @var string
*/
public $primaryKey = 'Id';
/**
* Display field
*
* @var string
*/
public $displayField = 'Name';
2015-06-11 10:58:58 +08:00
public $recursive = -1;
2014-04-23 11:14:25 +08:00
2020-07-21 04:25:08 +08:00
/**
* Validation rules
*
* @var array
*/
public $validate = array(
'MonitorId' => array(
'rule' => 'checkMonitorId',
//array('naturalNumber'),
'message' => 'Zones must have a valid MonitorId',
'allowEmpty' => false,
'required' => true,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
'Name' => array(
'required' => array(
//'on' => 'create',
'rule' => 'notBlank',
'message' => 'Zone Name must be specified for creation',
'required' => true,
),
)
);
2014-04-23 11:14:25 +08:00
//The Associations below have been created with all possible keys, those that are not needed can be removed
/**
* belongsTo associations
*
* @var array
*/
public $belongsTo = array(
'Monitor' => array(
'className' => 'Monitor',
'foreignKey' => 'MonitorId',
2020-07-21 04:25:08 +08:00
//'conditions' => '',
//'fields' => '',
//'order' => ''
2014-04-23 11:14:25 +08:00
)
);
2020-07-21 04:25:08 +08:00
public function checkMonitorId($data) {
if ( !$this->Monitor->find('first', array('conditions'=>array('Id'=>$data['MonitorId']))) ) {
//$this->invalidate('MonitorId', 'Invalid Monitor Id');
return false;
}
return true;
}
2014-04-23 11:14:25 +08:00
}