87 lines
2.4 KiB
PHP
87 lines
2.4 KiB
PHP
<?php
|
|
|
|
class PreorderHistory extends mfBaseModel {
|
|
private $preorder;
|
|
private $creator;
|
|
private $editor;
|
|
|
|
private $old;
|
|
private $new;
|
|
|
|
public function getValue($type = "new", $raw = false) {
|
|
if($type != "old" && $type != "new") return null;
|
|
|
|
if($type == "new") {
|
|
$value = $this->new_value;
|
|
} else {
|
|
$value = $this->old_value;
|
|
}
|
|
|
|
if($raw) {
|
|
return $value;
|
|
}
|
|
|
|
$m = [];
|
|
if(preg_match('/(.+)_id/', $this->key, $m)) {
|
|
if(array_key_exists(1, $m)) {
|
|
$object = ucfirst($m[1]);
|
|
|
|
$value = new $object($value);
|
|
if(!$value->id) return null;
|
|
}
|
|
}
|
|
|
|
return $value;
|
|
|
|
}
|
|
|
|
public function getProperty($name) {
|
|
if($this->$name == null) {
|
|
|
|
if($name == "old" || $name == "new") {
|
|
return $this->getValue($name, false);
|
|
}
|
|
|
|
if($name == "old_raw") {
|
|
return $this->getValue("old", true);
|
|
}
|
|
if($name == "new_raw") {
|
|
return $this->getValue("new", true);
|
|
}
|
|
|
|
if($name == "creator") {
|
|
$this->creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
|
|
if($this->creator === null) {
|
|
$this->creator = new User($this->create_by);
|
|
if($this->creator->id) {
|
|
mfValuecache::singleton()->set("Worker-id-".$this->create_by, $this->creator);
|
|
}
|
|
}
|
|
return $this->creator;
|
|
}
|
|
|
|
if($name == "editor") {
|
|
$this->editor = mfValuecache::singleton()->get("Worker-id-".$this->edit_by);
|
|
if($this->editor === null) {
|
|
$this->editor = new User($this->edit_by);
|
|
if($this->editor->id) {
|
|
mfValuecache::singleton()->set("Worker-id-".$this->edit_by, $this->editor);
|
|
}
|
|
}
|
|
return $this->editor;
|
|
}
|
|
|
|
$classname = ucfirst($name);
|
|
$idfield = $name."_id";
|
|
$this->$name = new $classname($this->$idfield);
|
|
|
|
if($this->$name->id) {
|
|
return $this->$name;
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
return $this->$name;
|
|
}
|
|
} |