Files
thetool/application/PreordercampaignOperator/PreordercampaignOperator.php
2025-03-17 12:22:03 +01:00

62 lines
1.6 KiB
PHP

<?php
class PreordercampaignOperator extends mfBaseModel
{
private $operator;
private $preordercampaign;
private $isps;
protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
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 = new Address($this->operator_id);
if(!$operator->id) {
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;
}
}