52 lines
1.4 KiB
PHP
52 lines
1.4 KiB
PHP
<?php
|
|
|
|
class PreordercampaignOperator extends mfBaseModel
|
|
{
|
|
private $operator;
|
|
private $preordercampaign;
|
|
private $isps;
|
|
|
|
protected function beforeDelete() {
|
|
// delete all ISPs
|
|
foreach(PreordercampaignOperatorIspModel::search(["campaignoperator_id" => $this->id]) as $isp) {
|
|
$isp->delete();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public function getProperty($name) {
|
|
if($this->$name == null) {
|
|
|
|
if($name == "isps") {
|
|
$isps = PreordercampaignOperatorIspModel::search(["campaignoperator_id" => $this->id]);
|
|
if(!$isps) {
|
|
return [];
|
|
}
|
|
foreach($isps as $isp) {
|
|
$this->isps[$isp->isp_id] = $isp;
|
|
}
|
|
|
|
return $this->isps;
|
|
}
|
|
|
|
if($name == "operator") {
|
|
$operator = mfValuecache::singleton()->getMfObject("Address", $this->operator_id);
|
|
if(!$operator) {
|
|
return null;
|
|
}
|
|
|
|
$this->operator = $operator;
|
|
return $this->operator;
|
|
}
|
|
|
|
$classname = ucfirst($name);
|
|
$idfield = $name."_id";
|
|
$this->$name = mfValuecache::singleton()->getMfObject($classname, $this->$idfield);
|
|
if(!$this->$name) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
return $this->$name;
|
|
}
|
|
} |