Add defaults for ModelId and ManufacturerId. Fixes the methods for loading them

This commit is contained in:
Isaac Connor 2021-09-25 10:32:04 -04:00
parent 15adc47c61
commit 7ca7d40b6f
1 changed files with 18 additions and 6 deletions

View File

@ -49,6 +49,8 @@ class Monitor extends ZM_Object {
'Notes' => '',
'ServerId' => 0,
'StorageId' => 0,
'ManufacturerId' => null,
'ModelId' => null,
'Type' => 'Ffmpeg',
'Function' => 'Mocord',
'Enabled' => array('type'=>'boolean','default'=>1),
@ -685,16 +687,26 @@ class Monitor extends ZM_Object {
$output = $this->AlarmCommand('disable');
}
function Model() {
if (!$this->{'Model'}) {
if (!property_exists($this, 'Model')) {
if ($this->{'ModelId'}) {
$this->{'Model'} = Model::find_one(array('Id'=>$this->ModelId()));
if (!$this->{'Model'}) $this->{'Model'} = new Model();
if (!$this->{'Model'})
$this->{'Model'} = new Model();
} else {
$this->{'Model'} = new Model();
}
}
return $this->{'Model'};
}
function Manufacturer() {
if (!$this->{'Manufacturer'}) {
if (!property_exists($this, 'Manufacturer')) {
if ($this->{'ManufacturerId'}) {
$this->{'Manufacturer'} = Manufacturer::find_one(array('Id'=>$this->ManufacturerId()));
if (!$this->{'Manufacturer'}) $this->{'Manufacturer'} = new Manufacturer();
if (!$this->{'Manufacturer'})
$this->{'Manufacturer'} = new Manufacturer();
} else {
$this->{'Manufacturer'} = new Manufacturer();
}
}
return $this->{'Manufacturer'};
}