or the class was instantiated. This class must remain abstract. Please refer to the Cake docs for ACL configuration.", E_USER_ERROR);
return null;
}
extract ($this->__dataVars());
if ($id == null && $this->id == false) {
return false;
} elseif ($id == null) {
$id = $this->id;
}
$object = $this->find($this->_resolveID($id), null, null, 0);
if ($object == null || count($object) == 0) {
return false;
}
$object = $object[$class];
$parent = $this->getParent($id);
if (($parent == null && $parentId == null) || ($parentId == $parent[$class][$secondary_id] && $parentId != null) || ($parentId == $parent[$class]['alias'] && $parentId != null)) {
return false;
}
if ($parentId == null) {
$newParent = $this->find(null, 'MAX(rght) as lft', null, -1);
$newParent = $newParent[0];
$newParent['rght'] = $newParent['lft'];
} else {
$newParent = $this->find($this->_resolveID($parentId), null, null, 0);
$newParent = $newParent[$class];
}
if ($parentId != null && $newParent['lft'] <= $object['lft'] && $newParent['rght'] >= $object['rght']) {
return false;
}
$this->_syncTable(0, $object['lft'], $object['lft']);
if ($object['lft'] < $newParent['lft']) {
$newParent['lft'] = $newParent['lft'] - 2;
$newParent['rght'] = $newParent['rght'] - 2;
}
if ($parentId != null) {
$this->_syncTable(1, $newParent['lft'], $newParent['lft']);
}
$object['lft'] = $newParent['lft'] + 1;
$object['rght'] = $newParent['lft'] + 2;
$this->save(array($class => $object));
if ($newParent['lft'] == 0) {
$this->_syncTable(2, $newParent['lft'], $newParent['lft']);
}
return true;
}
/**
* Get the parent node of the given Aro or Aco
*
* @param moxed $id
* @return array
* @access public
*/
function getParent($id) {
$path = $this->getPath($id);
if ($path == null || count($path) < 2) {
return null;
} else {
return $path[count($path) - 2];
}
}
/**
* Gets the path to the given Aro or Aco
*
* @param mixed $id
* @return array
* @access public
*/
function getPath($id) {
if (strtolower(get_class($this)) == "aclnode") {
trigger_error("[acl_base] The AclBase class constructor has been called, or the class was instantiated. This class must remain abstract. Please refer to the Cake docs for ACL configuration.", E_USER_ERROR);
return null;
}
extract ($this->__dataVars());
$item = $this->find($this->_resolveID($id), null, null, 0);
if ($item == null || count($item) == 0) {
return null;
}
return $this->findAll(array($class . '.lft' => '<= ' . $item[$class]['lft'], $class . '.rght' => '>= ' . $item[$class]['rght']), null, array($class . '.lft' => 'ASC'), null, null, 0);
}
/**
* Get the child nodes of the given Aro or Aco
*
* @param mixed $id
* @return array
* @access public
*/
function getChildren($id) {
if (strtolower(get_class($this)) == "aclnode") {
trigger_error("[acl_base] The AclBase class constructor has been called, or the class was instantiated. This class must remain abstract. Please refer to the Cake docs for ACL configuration.", E_USER_ERROR);
return null;
}
extract ($this->__dataVars());
$item = $this->find($this->_resolveID($id), null, null, 0);
return $this->findAll(array($class . '.lft' => '> ' . $item[$class]['lft'], $class . '.rght' => '< ' . $item[$class]['rght']), null, null, null, null, null, 0);
}
/**
* Gets a conditions array to find an Aro or Aco, based on the given id or alias
*
* @param mixed $id
* @return array Conditions array for