74 lines
1.7 KiB
PHP
74 lines
1.7 KiB
PHP
<?php
|
|
|
|
class Voiceplandestination extends mfBaseModel {
|
|
protected $forcestr = ["name", "destination", "prefix"];
|
|
|
|
private $voiceplan;
|
|
private $voiceplanzone;
|
|
|
|
protected function beforeUpdate($data) {
|
|
if(!array_key_exists("edit_by", $data)) {
|
|
$me = new User();
|
|
$me->loadMe();
|
|
$data["edit_by"] = $me->id;
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
|
|
public function getProperty($name) {
|
|
if($this->$name == null) {
|
|
|
|
if(!$this->id) {
|
|
return null;
|
|
}
|
|
|
|
if($name == "voiceplan") {
|
|
$zone = $this->getProperty("voiceplanzone");
|
|
if($zone->voiceplan_id) {
|
|
$voiceplan = new Voiceplan($zone->voiceplan_id);
|
|
if($voiceplan->id) {
|
|
$this->voiceplan = $voiceplan;
|
|
}
|
|
}
|
|
return $this->voiceplan;
|
|
}
|
|
|
|
$classname = ucfirst($name);
|
|
$idfield = $name."_id";
|
|
$this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield);
|
|
if(!$this->$name) {
|
|
$this->$name = new $classname($this->$idfield);
|
|
}
|
|
|
|
if($this->$name->id) {
|
|
mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name);
|
|
return $this->$name;
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
return $this->$name;
|
|
}
|
|
|
|
public function __clone() {
|
|
$me = new User;
|
|
$me->loadMe();
|
|
|
|
$old_id = $this->id;
|
|
$this->id = null;
|
|
$this->voiceplan = null;
|
|
|
|
|
|
$this->create_by = $me->id;
|
|
$this->edit_by = $me->id;
|
|
|
|
$this->create = null;
|
|
$this->edit = null;
|
|
$this->saved = 0;
|
|
$this->mode = "new";
|
|
$this->_old_data = new StdClass();
|
|
|
|
}
|
|
} |