{
if ($this->oldParentId != $this->parent_id) {
$acoClass = new CGroup();
$aco = $acoClass->loadObject($this);
if($aco === NULL)
throw new RuntimeException('Aco-object does not exist');
if($this->oldParentId !== NULL){
if (!$aco->leave(array('model' => get_class($this), 'foreign_key' => $this->oldParentId)))
throw new RuntimeException('Unable to leave old parent-aco-object');
}
if($this->parent_id !== NULL){
$aco2 = $acoClass->loadObject(
array('model' => get_class($this), 'foreign_key' => $this->parent_id));
if (!$aco->join($aco2))
throw new RuntimeException('Unable to choose new parent-aco');
}
$this->oldParentId = $this->parent_id;
}
return true;
}