Added permission checks for Buildings and terminations
This commit is contained in:
@@ -2,8 +2,11 @@
|
||||
|
||||
class Address extends mfBaseModel {
|
||||
protected $forcestr = ['street','company','zip','phone','fax','mobile','note'];
|
||||
private $parent;
|
||||
private $types;
|
||||
private $attributes;
|
||||
private $permissions;
|
||||
|
||||
|
||||
public function getFullName() {
|
||||
// Assumes "Firma1 Firma2" or "firstname lastname" as readable form
|
||||
@@ -28,17 +31,33 @@ class Address extends mfBaseModel {
|
||||
return $this->getFullName();
|
||||
}
|
||||
|
||||
private function loadAddresstypes() {
|
||||
|
||||
public function loadAddresstypes() {
|
||||
if(!$this->id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->types = AddresstypeModel::search(['address_id' => $this->id], true);
|
||||
if(!$this->parent_id) {
|
||||
$this->types = AddresstypeModel::search(['address_id' => $this->id], true);
|
||||
} else {
|
||||
// get types from parent
|
||||
|
||||
$parent = $this->getProperty("parent");
|
||||
$types = $parent->getProperty("types");
|
||||
$this->types = $types;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if(!$this->id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if($name == "types") {
|
||||
$this->loadAddresstypes();
|
||||
return $this->types;
|
||||
@@ -55,6 +74,16 @@ class Address extends mfBaseModel {
|
||||
return $this->attributes;
|
||||
}
|
||||
|
||||
if($name == "permissions") {
|
||||
$this->permissions = NetworkAddressModel::search(['address_id' => $this->id]);
|
||||
return $permissions;
|
||||
}
|
||||
|
||||
if($name == "parent") {
|
||||
$this->parent = new Address($this->parent_id);
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
|
||||
Reference in New Issue
Block a user