mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-03 17:14:46 +00:00
65 lines
1.3 KiB
PHP
65 lines
1.3 KiB
PHP
|
<?php
|
||
|
trait CSRDispatcher {
|
||
|
function grantNode($path,$player) {
|
||
|
if(is_numeric($path)) {
|
||
|
//it's me (id == numeric)
|
||
|
if($this->getID() == $path) {
|
||
|
$this->grant($player);
|
||
|
}
|
||
|
}
|
||
|
else {
|
||
|
//get child with the next level id and dispatch
|
||
|
$tmp = explode(";",$path);
|
||
|
|
||
|
$c = $this->getChildDataByID($tmp[1]);
|
||
|
|
||
|
if($c != null) { // check if it's really own child
|
||
|
unset($tmp[0]);
|
||
|
$c->grantNode(implode(";",$tmp),$player);
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
function denyNode($path,$player) {
|
||
|
if(is_numeric($path)) {
|
||
|
//it's me (id == numeric)
|
||
|
if($this->getID() == $path) {
|
||
|
$this->deny($player);
|
||
|
}
|
||
|
}
|
||
|
else {
|
||
|
//get child with the next level id and dispatch
|
||
|
$tmp = explode(";",$path);
|
||
|
|
||
|
if($tmp[0] == $this->getID()) { // it's my id!
|
||
|
|
||
|
$c = $this->getChildDataByID($tmp[1]);
|
||
|
if($c != null) { // check if it's really own child
|
||
|
unset($tmp[0]);
|
||
|
$c->denyNode(implode(";",$tmp),$player);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function getPath($path = "") {
|
||
|
if($path != "") {
|
||
|
$path = ";".$path;
|
||
|
}
|
||
|
|
||
|
$path = $this->getID().$path;
|
||
|
|
||
|
if($this->hasParent()) {
|
||
|
$path = $this->parent->getPath($path);
|
||
|
}
|
||
|
|
||
|
return $path;
|
||
|
}
|
||
|
|
||
|
private function hasParent() {
|
||
|
return ($this->parent != null);
|
||
|
}
|
||
|
}
|
||
|
?>
|