ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilTree Class Reference

Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco. More...

+ Inheritance diagram for ilTree:
+ Collaboration diagram for ilTree:

Public Member Functions

 ilTree ($a_tree_id, $a_root_id=0)
 Constructor public.
 initTreeImplementation ()
 Init tree implementation.
 getTreeImplementation ()
 Get tree implementation.
 useCache ($a_use=true)
 Use Cache (usually activated)
 isCacheUsed ()
 Check if cache is active.
 getDepthCache ()
 Get depth cache.
 getParentCache ()
 Get parent cache.
 initLangCode ()
 Store user language.
 getTreeTable ()
 Get tree table name.
 getObjectDataTable ()
 Get object data table.
 getTreePk ()
 Get tree primary key.
 getTableReference ()
 Get reference table if available.
 getGap ()
 Get default gap *.
 resetInTreeCache ()
 setTableNames ($a_table_tree, $a_table_obj_data, $a_table_obj_reference="")
 set table names The primary key of the table containing your object_data must be 'obj_id' You may use a reference table.
 setReferenceTablePK ($a_column_name)
 set column containing primary key in reference table public
 setObjectTablePK ($a_column_name)
 set column containing primary key in object table public
 setTreeTablePK ($a_column_name)
 set column containing primary key in tree table public
 buildJoin ()
 build join depending on table settings private
 getRelation ($a_node_a, $a_node_b)
 Get relation of two nodes.
 getRelationOfNodes ($a_node_a_arr, $a_node_b_arr)
 get relation of two nodes by node data
 getChilds ($a_node_id, $a_order="", $a_direction="ASC")
 get child nodes of given node public
 getFilteredChilds ($a_filter, $a_node, $a_order="", $a_direction="ASC")
 get child nodes of given node (exclude filtered obj_types) public
 getChildsByType ($a_node_id, $a_type)
 get child nodes of given node by object type public
 getChildsByTypeFilter ($a_node_id, $a_types, $a_order="", $a_direction="ASC")
 get child nodes of given node by object type public
 insertNode ($a_node_id, $a_parent_id, $a_pos=IL_LAST_NODE, $a_reset_deletion_date=false)
 insert new node with node_id under parent node with parent_id public
 getFilteredSubTree ($a_node_id, $a_filter=array())
 get filtered subtree
 getSubTreeIds ($a_ref_id)
 Get all ids of subnodes.
 getSubTree ($a_node, $a_with_data=true, $a_type="")
 get all nodes in the subtree under specified node
 getSubTreeTypes ($a_node, $a_filter=0)
 get types of nodes in the subtree under specified node
 deleteTree ($a_node)
 delete node and the whole subtree under this node public
 getPathFull ($a_endnode_id, $a_startnode_id=0)
 get path from a given startnode to a given endnode if startnode is not given the rootnode is startnode.
 preloadDepthParent ($a_node_ids)
 Preload depth/parent.
 getPathId ($a_endnode_id, $a_startnode_id=0)
 get path from a given startnode to a given endnode if startnode is not given the rootnode is startnode public
 getNodePathForTitlePath ($titlePath, $a_startnode_id=null)
 Converts a path consisting of object titles into a path consisting of tree nodes.
 getNodePath ($a_endnode_id, $a_startnode_id=0)
 Returns the node path for the specified object reference.
 checkTree ()
 check consistence of tree all left & right values are checked if they are exists only once public
 checkTreeChilds ($a_no_zero_child=true)
 check, if all childs of tree nodes exist in object table
 getMaximumDepth ()
 Return the current maximum depth in the tree public.
 getDepth ($a_node_id)
 return depth of a node in tree private
 getNodeTreeData ($a_node_id)
 return all columns of tabel tree
 getNodeData ($a_node_id, $a_tree_pk=null)
 get all information of a node.
 fetchNodeData ($a_row)
 get data of parent node from tree and object_data private
 isInTree ($a_node_id)
 get all information of a node.
 getParentNodeData ($a_node_id)
 get data of parent node from tree and object_data public
 isGrandChild ($a_startnode_id, $a_querynode_id)
 checks if a node is in the path of an other node public
 addTree ($a_tree_id, $a_node_id=-1)
 create a new tree to do: ???
 getNodeDataByType ($a_type)
 get nodes by type
 removeTree ($a_tree_id)
 remove an existing tree
 moveToTrash ($a_node_id, $a_set_deleted=false)
 Wrapper for saveSubTree.
 saveSubTree ($a_node_id, $a_set_deleted=false)
 Use the wrapper moveToTrash save subtree: delete a subtree (defined by node_id) to a new tree with $this->tree_id -node_id.
 isDeleted ($a_node_id)
 This is a wrapper for isSaved() with a more useful name.
 isSaved ($a_node_id)
 Use method isDeleted check if node is saved.
 preloadDeleted ($a_node_ids)
 Preload deleted information.
 getSavedNodeData ($a_parent_id)
 get data saved/deleted nodes
 getSavedNodeObjIds (array $a_obj_ids)
 get object id of saved/deleted nodes
 getParentId ($a_node_id)
 get parent id of given node public
 getLeftValue ($a_node_id)
 get left value of given node public
 getChildSequenceNumber ($a_node, $type="")
 get sequence number of node in sibling sequence public
 readRootId ()
 read root id from database
 getRootId ()
 get the root id of tree public
 setRootId ($a_root_id)
 getTreeId ()
 get tree id public
 setTreeId ($a_tree_id)
 set tree id public
 fetchSuccessorNode ($a_node_id, $a_type="")
 get node data of successor node
 fetchPredecessorNode ($a_node_id, $a_type="")
 get node data of predecessor node
 renumber ($node_id=1, $i=1)
 Wrapper for renumber.
 __renumber ($node_id=1, $i=1)
 This method is private.
 checkForParentType ($a_ref_id, $a_type, $a_exclude_source_check=false)
 Check for parent type e.g check if a folder (ref_id 3) is in a parent course obj => checkForParentType(3,'crs');.
 _removeEntry ($a_tree, $a_child, $a_db_table="tree")
 STATIC METHOD Removes a single entry from a tree.
 __isMainTree ()
 Check if operations are done on main tree.
 __checkDelete ($a_node)
 Check for deleteTree() compares a subtree of a given node by checking lft, rgt against parent relation.
 __getSubTreeByParentRelation ($a_node_id, &$parent_childs)
 type $ilDB
 __validateSubtrees (&$lft_childs, $parent_childs)
 moveTree ($a_source_id, $a_target_id, $a_location=self::POS_LAST_NODE)
 Move Tree Implementation.
 getRbacSubtreeInfo ($a_endnode_id)
 This method is used for change existing objects and returns all necessary information for this action.
 getSubTreeQuery ($a_node_id, $a_fields=array(), $a_types= '', $a_force_join_reference=false)
 Get tree subtree query.

Data Fields

const POS_LAST_NODE = -2
const POS_FIRST_NODE = -1
const RELATION_CHILD = 1
const RELATION_PARENT = 2
const RELATION_SIBLING = 3
const RELATION_EQUALS = 4
const RELATION_NONE = 5
 $ilias
 $log
 $root_id
 $tree_id
 $table_tree
 $table_obj_data
 $table_obj_reference
 $ref_pk
 $obj_pk
 $tree_pk
 $gap

Protected Member Functions

 fetchTranslationFromObjectDataCache ($a_obj_ids)
 Get translation data from object cache (trigger in object cache on preload)

Protected Attributes

 $depth_cache = array()
 $parent_cache = array()
 $in_tree_cache = array()

Private Attributes

 $tree_impl = NULL

Detailed Description

Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco.

Author
Sascha Hofmann sasch.nosp@m.ahof.nosp@m.mann@.nosp@m.gmx..nosp@m.de
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
Id:
class.ilTree.php 57727 2015-02-02 09:34:44Z smeyer

Definition at line 24 of file class.ilTree.php.

Member Function Documentation

ilTree::__checkDelete (   $a_node)

Check for deleteTree() compares a subtree of a given node by checking lft, rgt against parent relation.

private

Parameters
arraynode data from ilTree::getNodeData()
Returns
boolean
Deprecated:
since 4.4.0

Definition at line 2481 of file class.ilTree.php.

References $GLOBALS, $query, $res, $row, __getSubTreeByParentRelation(), __validateSubtrees(), and getTreeImplementation().

Referenced by deleteTree().

{
global $ilDB;
$query = $this->getTreeImplementation()->getSubTreeQuery($a_node, array(),false);
$GLOBALS['ilLog']->write(__METHOD__.': '.$query);
$res = $ilDB->query($query);
$counter = (int) $lft_childs = array();
while($row = $ilDB->fetchObject($res))
{
$lft_childs[$row->child] = $row->parent;
++$counter;
}
// CHECK FOR DUPLICATE CHILD IDS
if($counter != count($lft_childs))
{
$message = sprintf('%s::__checkTree(): Duplicate entries for "child" in maintree! $a_node_id: %s',
get_class($this),
$a_node['child']);
$this->log->write($message,$this->log->FATAL);
$this->ilErr->raiseError($message,$this->ilErr->WARNING);
}
// GET SUBTREE BY PARENT RELATION
$parent_childs = array();
$this->__getSubTreeByParentRelation($a_node['child'],$parent_childs);
$this->__validateSubtrees($lft_childs,$parent_childs);
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTree::__getSubTreeByParentRelation (   $a_node_id,
$parent_childs 
)

type $ilDB

Parameters
type$a_node_id
type$parent_childs
Returns
boolean
Deprecated:
since 4.4.0

Definition at line 2523 of file class.ilTree.php.

References $query, $res, and $row.

Referenced by __checkDelete().

{
global $ilDB;
// GET PARENT ID
$query = 'SELECT * FROM '.$this->table_tree.' '.
'WHERE child = %s '.
'AND tree = %s ';
$res = $ilDB->queryF($query,array('integer','integer'),array(
$a_node_id,
$this->tree_id));
$counter = 0;
while($row = $ilDB->fetchObject($res))
{
$parent_childs[$a_node_id] = $row->parent;
++$counter;
}
// MULTIPLE ENTRIES
if($counter > 1)
{
$message = sprintf('%s::__getSubTreeByParentRelation(): Multiple entries in maintree! $a_node_id: %s',
get_class($this),
$a_node_id);
$this->log->write($message,$this->log->FATAL);
$this->ilErr->raiseError($message,$this->ilErr->WARNING);
}
// GET ALL CHILDS
$query = 'SELECT * FROM '.$this->table_tree.' '.
'WHERE parent = %s ';
$res = $ilDB->queryF($query,array('integer'),array($a_node_id));
while($row = $ilDB->fetchObject($res))
{
// RECURSION
$this->__getSubTreeByParentRelation($row->child,$parent_childs);
}
return true;
}

+ Here is the caller graph for this function:

ilTree::__isMainTree ( )

Check if operations are done on main tree.

private

Returns
boolean

Definition at line 2466 of file class.ilTree.php.

Referenced by addTree(), checkForParentType(), deleteTree(), getChilds(), getNodeData(), getPathFull(), getPathId(), getSubTree(), initTreeImplementation(), insertNode(), isCacheUsed(), isInTree(), isSaved(), preloadDeleted(), preloadDepthParent(), removeTree(), renumber(), and saveSubTree().

{
return $this->table_tree === 'tree';
}

+ Here is the caller graph for this function:

ilTree::__renumber (   $node_id = 1,
  $i = 1 
)

This method is private.

Always call ilTree->renumber() since it locks the tree table renumber left/right values and close the gaps in numbers (recursive) private

Parameters
integernode_id where to start (usually the root node)
integerfirst left value of start node (usually 1)
Returns
integer current left value of recursive call

Definition at line 2330 of file class.ilTree.php.

References $query, $res, and getChilds().

Referenced by renumber().

{
global $ilDB;
$query = 'UPDATE '.$this->table_tree.' SET lft = %s WHERE child = %s';
$res = $ilDB->manipulateF($query,array('integer','integer'),array(
$i,
$node_id));
$childs = $this->getChilds($node_id);
foreach ($childs as $child)
{
$i = $this->__renumber($child["child"],$i+1);
}
$i++;
// Insert a gap at the end of node, if the node has children
if (count($childs) > 0)
{
$i += $this->gap * 2;
}
$query = 'UPDATE '.$this->table_tree.' SET rgt = %s WHERE child = %s';
$res = $ilDB->manipulateF($query,array('integer','integer'),array(
$i,
$node_id));
return $i;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTree::__validateSubtrees ( $lft_childs,
  $parent_childs 
)

Definition at line 2564 of file class.ilTree.php.

References $GLOBALS.

Referenced by __checkDelete().

{
// SORT BY KEY
ksort($lft_childs);
ksort($parent_childs);
$GLOBALS['ilLog']->write(__METHOD__.': left childs '. print_r($lft_childs,true));
$GLOBALS['ilLog']->write(__METHOD__.': parent childs '. print_r($parent_childs,true));
if(count($lft_childs) != count($parent_childs))
{
$message = sprintf('%s::__validateSubtrees(): (COUNT) Tree is corrupted! Left/Right subtree does not comply .'.
'with parent relation',
get_class($this));
$this->log->write($message,$this->log->FATAL);
$this->ilErr->raiseError($message,$this->ilErr->WARNING);
}
foreach($lft_childs as $key => $value)
{
if($parent_childs[$key] != $value)
{
$message = sprintf('%s::__validateSubtrees(): (COMPARE) Tree is corrupted! Left/Right subtree does not comply '.
'with parent relation',
get_class($this));
$this->log->write($message,$this->log->FATAL);
$this->ilErr->raiseError($message,$this->ilErr->WARNING);
}
if($key == ROOT_FOLDER_ID)
{
$message = sprintf('%s::__validateSubtrees(): (ROOT_FOLDER) Tree is corrupted! Tried to delete root folder',
get_class($this));
$this->log->write($message,$this->log->FATAL);
$this->ilErr->raiseError($message,$this->ilErr->WARNING);
}
}
return true;
}

+ Here is the caller graph for this function:

ilTree::_removeEntry (   $a_tree,
  $a_child,
  $a_db_table = "tree" 
)

STATIC METHOD Removes a single entry from a tree.

The tree structure is NOT updated!

public

Parameters
integertree id
integerchild id
stringdb_table name. default is 'tree' (optional)

Definition at line 2434 of file class.ilTree.php.

References $ilErr, $ilLog, $query, and $res.

Referenced by ilValidator\purgeObjects().

{
global $ilDB,$ilLog,$ilErr;
if($a_db_table === 'tree')
{
if($a_tree == 1 and $a_child == ROOT_FOLDER_ID)
{
$message = sprintf('%s::_removeEntry(): Tried to delete root node! $a_tree: %s $a_child: %s',
get_class($this),
$a_tree,
$a_child);
$ilLog->write($message,$ilLog->FATAL);
$ilErr->raiseError($message,$ilErr->WARNING);
}
}
$query = 'DELETE FROM '.$a_db_table.' '.
'WHERE tree = %s '.
'AND child = %s ';
$res = $ilDB->manipulateF($query,array('integer','integer'),array(
$a_tree,
$a_child));
}

+ Here is the caller graph for this function:

ilTree::addTree (   $a_tree_id,
  $a_node_id = -1 
)

create a new tree to do: ???

Parameters
integera_tree_id: obj_id of object where tree belongs to
integera_node_id: root node of tree (optional; default is tree_id itself)
Returns
boolean true on success public

Definition at line 1676 of file class.ilTree.php.

References $query, $res, and __isMainTree().

Referenced by ilWorkspaceExplorer\__construct(), ilWorkspaceTree\createTreeForUser(), and ilSCORMPackageParser\handlerBeginTag().

{
global $ilDB;
// FOR SECURITY addTree() IS NOT ALLOWED ON MAIN TREE
if($this->__isMainTree())
{
$message = sprintf('%s::addTree(): Operation not allowed on main tree! $a_tree_if: %s $a_node_id: %s',
get_class($this),
$a_tree_id,
$a_node_id);
$this->log->write($message,$this->log->FATAL);
$this->ilErr->raiseError($message,$this->ilErr->WARNING);
}
if (!isset($a_tree_id))
{
$this->ilErr->raiseError(get_class($this)."::addTree(): No tree_id given! ",$this->ilErr->WARNING);
}
if ($a_node_id <= 0)
{
$a_node_id = $a_tree_id;
}
$query = 'INSERT INTO '.$this->table_tree.' ('.
$this->tree_pk.', child,parent,lft,rgt,depth) '.
'VALUES '.
'(%s,%s,%s,%s,%s,%s)';
$res = $ilDB->manipulateF($query,array('integer','integer','integer','integer','integer','integer'),array(
$a_tree_id,
$a_node_id,
0,
1,
2,
1));
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTree::buildJoin ( )

build join depending on table settings private

Returns
string

Definition at line 451 of file class.ilTree.php.

Referenced by fetchPredecessorNode(), fetchSuccessorNode(), getChildsByTypeFilter(), getChildSequenceNumber(), getNodeData(), getNodeDataByType(), getPathFull(), getSavedNodeData(), and getSavedNodeObjIds().

{
if ($this->table_obj_reference)
{
// Use inner join instead of left join to improve performance
return "JOIN ".$this->table_obj_reference." ON ".$this->table_tree.".child=".$this->table_obj_reference.".".$this->ref_pk." ".
"JOIN ".$this->table_obj_data." ON ".$this->table_obj_reference.".".$this->obj_pk."=".$this->table_obj_data.".".$this->obj_pk." ";
}
else
{
// Use inner join instead of left join to improve performance
return "JOIN ".$this->table_obj_data." ON ".$this->table_tree.".child=".$this->table_obj_data.".".$this->obj_pk." ";
}
}

+ Here is the caller graph for this function:

ilTree::checkForParentType (   $a_ref_id,
  $a_type,
  $a_exclude_source_check = false 
)

Check for parent type e.g check if a folder (ref_id 3) is in a parent course obj => checkForParentType(3,'crs');.

public

Parameters
integerref_id
stringtype
Returns
mixed false if item is not in tree, int (object ref_id) > 0 if path container course, int 0 if pathc does not contain the object type

Definition at line 2372 of file class.ilTree.php.

References $path, __isMainTree(), getPathFull(), isCacheUsed(), and isInTree().

{
// #12577
$cache_key = $a_ref_id.'.'.$a_type.'.'.((int)$a_exclude_source_check);
// Try to return a cached result
if($this->isCacheUsed() &&
array_key_exists($cache_key, $this->parent_type_cache))
{
return $this->parent_type_cache[$cache_key];
}
// Store up to 1000 results in cache
$do_cache = ($this->__isMainTree() && count($this->parent_type_cache) < 1000);
// ref_id is not in tree
if(!$this->isInTree($a_ref_id))
{
if($do_cache)
{
$this->parent_type_cache[$cache_key] = false;
}
return false;
}
$path = array_reverse($this->getPathFull($a_ref_id));
// remove first path entry as it is requested node
if($a_exclude_source_check)
{
array_shift($path);
}
foreach($path as $node)
{
// found matching parent
if($node["type"] == $a_type)
{
if($do_cache)
{
$this->parent_type_cache[$cache_key] = $node["child"];
}
return $node["child"];
}
}
if($do_cache)
{
$this->parent_type_cache[$cache_key] = false;
}
return 0;
}

+ Here is the call graph for this function:

ilTree::checkTree ( )

check consistence of tree all left & right values are checked if they are exists only once public

Returns
boolean true if tree is ok; otherwise throws error object

Definition at line 1216 of file class.ilTree.php.

References $query, $res, and $row.

{
global $ilDB;
$types = array('integer');
$query = 'SELECT lft,rgt FROM '.$this->table_tree.' '.
'WHERE '.$this->tree_pk.' = %s ';
$res = $ilDB->queryF($query,$types,array($this->tree_id));
while ($row = $ilDB->fetchObject($res))
{
$lft[] = $row->lft;
$rgt[] = $row->rgt;
}
$all = array_merge($lft,$rgt);
$uni = array_unique($all);
if (count($all) != count($uni))
{
$message = sprintf('%s::checkTree(): Tree is corrupted!',
get_class($this));
$this->log->write($message,$this->log->FATAL);
$this->ilErr->raiseError($message,$this->ilErr->WARNING);
}
return true;
}
ilTree::checkTreeChilds (   $a_no_zero_child = true)

check, if all childs of tree nodes exist in object table

Definition at line 1249 of file class.ilTree.php.

References $query, and $row.

{
global $ilDB;
$query = 'SELECT * FROM '.$this->table_tree.' '.
'WHERE '.$this->tree_pk.' = %s '.
'ORDER BY lft';
$r1 = $ilDB->queryF($query,array('integer'),array($this->tree_id));
while ($row = $ilDB->fetchAssoc($r1))
{
//echo "tree:".$row[$this->tree_pk].":lft:".$row["lft"].":rgt:".$row["rgt"].":child:".$row["child"].":<br>";
if (($row["child"] == 0) && $a_no_zero_child)
{
$this->ilErr->raiseError(get_class($this)."::checkTreeChilds(): Tree contains child with ID 0!",$this->ilErr->WARNING);
}
if ($this->table_obj_reference)
{
// get object reference data
$query = 'SELECT * FROM '.$this->table_obj_reference.' WHERE '.$this->ref_pk.' = %s ';
$r2 = $ilDB->queryF($query,array('integer'),array($row['child']));
//echo "num_childs:".$r2->numRows().":<br>";
if ($r2->numRows() == 0)
{
$this->ilErr->raiseError(get_class($this)."::checkTree(): No Object-to-Reference entry found for ID ".
$row["child"]."!",$this->ilErr->WARNING);
}
if ($r2->numRows() > 1)
{
$this->ilErr->raiseError(get_class($this)."::checkTree(): More Object-to-Reference entries found for ID ".
$row["child"]."!",$this->ilErr->WARNING);
}
// get object data
$obj_ref = $ilDB->fetchAssoc($r2);
$query = 'SELECT * FROM '.$this->table_obj_data.' WHERE '.$this->obj_pk.' = %s';
$r3 = $ilDB->queryF($query,array('integer'),array($obj_ref[$this->obj_pk]));
if ($r3->numRows() == 0)
{
$this->ilErr->raiseError(get_class($this)."::checkTree(): No child found for ID ".
$obj_ref[$this->obj_pk]."!",$this->ilErr->WARNING);
}
if ($r3->numRows() > 1)
{
$this->ilErr->raiseError(get_class($this)."::checkTree(): More childs found for ID ".
$obj_ref[$this->obj_pk]."!",$this->ilErr->WARNING);
}
}
else
{
// get only object data
$query = 'SELECT * FROM '.$this->table_obj_data.' WHERE '.$this->obj_pk.' = %s';
$r2 = $ilDB->queryF($query,array('integer'),array($row['child']));
//echo "num_childs:".$r2->numRows().":<br>";
if ($r2->numRows() == 0)
{
$this->ilErr->raiseError(get_class($this)."::checkTree(): No child found for ID ".
$row["child"]."!",$this->ilErr->WARNING);
}
if ($r2->numRows() > 1)
{
$this->ilErr->raiseError(get_class($this)."::checkTree(): More childs found for ID ".
$row["child"]."!",$this->ilErr->WARNING);
}
}
}
return true;
}
ilTree::deleteTree (   $a_node)

delete node and the whole subtree under this node public

Parameters
arraynode_data of a node
Exceptions
InvalidArgumentException,InvalidTreeStructureException

Definition at line 884 of file class.ilTree.php.

References $GLOBALS, __checkDelete(), __isMainTree(), getTreeImplementation(), and resetInTreeCache().

Referenced by ilWorkspaceTree\cascadingDelete().

{
global $ilDB;
$GLOBALS['ilLog']->write(__METHOD__.': Delete tree with node '. $a_node);
if (!is_array($a_node))
{
$GLOBALS['ilLog']->logStack();
throw new InvalidArgumentException(__METHOD__.': Wrong datatype for node data!');
}
$GLOBALS['ilLog']->write(__METHOD__.': '. $this->tree_pk);
if($this->__isMainTree() )
{
// @todo normally this part is not executed, since the subtree is first
// moved to trash and then deleted.
if(!$this->__checkDelete($a_node))
{
$GLOBALS['ilLog']->logStack();
throw new ilInvalidTreeStructureException('Deletion canceled due to invalid tree structure.' . print_r($a_node,true));
}
}
$this->getTreeImplementation()->deleteTree($a_node['child']);
$this->resetInTreeCache();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTree::fetchNodeData (   $a_row)

get data of parent node from tree and object_data private

Parameters
objectdb db result object containing node_data
Returns
array 2-dim (int/str) node_data TODO: select description twice for compability. Please use 'desc' in future only

Definition at line 1447 of file class.ilTree.php.

References $ilBench, $lng, $query, $res, $row, ilContainerReference\_lookupTargetTitle(), ilObject\DESC_LENGTH, isCacheUsed(), and ilUtil\shortenText().

Referenced by fetchPredecessorNode(), fetchSuccessorNode(), ilSCORMTree\getChilds(), getChilds(), getChildsByType(), getChildsByTypeFilter(), getNodeData(), getNodeDataByType(), getParentNodeData(), getPathFull(), getSavedNodeData(), and getSubTree().

{
global $objDefinition, $lng, $ilBench,$ilDB;
//$ilBench->start("Tree", "fetchNodeData_getRow");
$data = $a_row;
$data["desc"] = $a_row["description"]; // for compability
//$ilBench->stop("Tree", "fetchNodeData_getRow");
// multilingual support systemobjects (sys) & categories (db)
//$ilBench->start("Tree", "fetchNodeData_readDefinition");
if (is_object($objDefinition))
{
$translation_type = $objDefinition->getTranslationType($data["type"]);
}
//$ilBench->stop("Tree", "fetchNodeData_readDefinition");
if ($translation_type == "sys")
{
//$ilBench->start("Tree", "fetchNodeData_getLangData");
if ($data["type"] == "rolf" and $data["obj_id"] != ROLE_FOLDER_ID)
{
$data["description"] = $lng->txt("obj_".$data["type"]."_local_desc").$data["title"].$data["desc"];
$data["desc"] = $lng->txt("obj_".$data["type"]."_local_desc").$data["title"].$data["desc"];
$data["title"] = $lng->txt("obj_".$data["type"]."_local");
}
else
{
$data["title"] = $lng->txt("obj_".$data["type"]);
$data["description"] = $lng->txt("obj_".$data["type"]."_desc");
$data["desc"] = $lng->txt("obj_".$data["type"]."_desc");
}
//$ilBench->stop("Tree", "fetchNodeData_getLangData");
}
elseif ($translation_type == "db")
{
// Try to retrieve object translation from cache
if ($this->isCacheUsed() &&
array_key_exists($data["obj_id"].'.'.$lang_code, $this->translation_cache)) {
$key = $data["obj_id"].'.'.$lang_code;
$data["title"] = $this->translation_cache[$key]['title'];
$data["description"] = $this->translation_cache[$key]['description'];
$data["desc"] = $this->translation_cache[$key]['desc'];
}
else
{
// Object translation is not in cache, read it from database
//$ilBench->start("Tree", "fetchNodeData_getTranslation");
$query = 'SELECT title,description FROM object_translation '.
'WHERE obj_id = %s '.
'AND lang_code = %s '.
'AND NOT lang_default = %s';
$res = $ilDB->queryF($query,array('integer','text','integer'),array(
$data['obj_id'],
$this->lang_code,
1));
$row = $ilDB->fetchObject($res);
if ($row)
{
$data["title"] = $row->title;
$data["description"] = ilUtil::shortenText($row->description,ilObject::DESC_LENGTH,true);
$data["desc"] = $row->description;
}
//$ilBench->stop("Tree", "fetchNodeData_getTranslation");
// Store up to 1000 object translations in cache
if ($this->isCacheUsed() && count($this->translation_cache) < 1000)
{
$key = $data["obj_id"].'.'.$lang_code;
$this->translation_cache[$key] = array();
$this->translation_cache[$key]['title'] = $data["title"] ;
$this->translation_cache[$key]['description'] = $data["description"];
$this->translation_cache[$key]['desc'] = $data["desc"];
}
}
}
// TODO: Handle this switch by module.xml definitions
if($data['type'] == 'crsr' or $data['type'] == 'catr')
{
include_once('./Services/ContainerReference/classes/class.ilContainerReference.php');
$data['title'] = ilContainerReference::_lookupTargetTitle($data['obj_id']);
}
return $data ? $data : array();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTree::fetchPredecessorNode (   $a_node_id,
  $a_type = "" 
)

get node data of predecessor node

public

Parameters
integernode id
Returns
array node data array

Definition at line 2221 of file class.ilTree.php.

References $query, $res, $row, buildJoin(), and fetchNodeData().

{
global $ilDB;
if (!isset($a_node_id))
{
$this->ilErr->raiseError(get_class($this)."::getNodeData(): No node_id given! ",$this->ilErr->WARNING);
}
// get lft value for current node
$query = 'SELECT lft FROM '.$this->table_tree.' '.
'WHERE '.$this->table_tree.'.child = %s '.
'AND '.$this->table_tree.'.'.$this->tree_pk.' = %s ';
$res = $ilDB->queryF($query,array('integer','integer'),array(
$a_node_id,
$this->tree_id));
$curr_node = $ilDB->fetchAssoc($res);
if($a_type)
{
$query = 'SELECT * FROM '.$this->table_tree.' '.
$this->buildJoin().
'WHERE lft < %s '.
'AND '.$this->table_obj_data.'.type = %s '.
'AND '.$this->table_tree.'.'.$this->tree_pk.' = %s '.
'ORDER BY lft DESC';
$ilDB->setLimit(1);
$res = $ilDB->queryF($query,array('integer','text','integer'),array(
$curr_node['lft'],
$a_type,
$this->tree_id));
}
else
{
$query = 'SELECT * FROM '.$this->table_tree.' '.
$this->buildJoin().
'WHERE lft < %s '.
'AND '.$this->table_tree.'.'.$this->tree_pk.' = %s '.
'ORDER BY lft DESC';
$ilDB->setLimit(1);
$res = $ilDB->queryF($query,array('integer','integer'),array(
$curr_node['lft'],
$this->tree_id));
}
if ($res->numRows() < 1)
{
return false;
}
else
{
$row = $ilDB->fetchAssoc($res);
return $this->fetchNodeData($row);
}
}

+ Here is the call graph for this function:

ilTree::fetchSuccessorNode (   $a_node_id,
  $a_type = "" 
)

get node data of successor node

public

Parameters
integernode id
Returns
array node data array

Definition at line 2158 of file class.ilTree.php.

References $query, $res, $row, buildJoin(), and fetchNodeData().

Referenced by ilSCORMPresentationGUI\finishSahs().

{
global $ilDB;
if (!isset($a_node_id))
{
$this->ilErr->raiseError(get_class($this)."::getNodeData(): No node_id given! ",$this->ilErr->WARNING);
}
// get lft value for current node
$query = 'SELECT lft FROM '.$this->table_tree.' '.
'WHERE '.$this->table_tree.'.child = %s '.
'AND '.$this->table_tree.'.'.$this->tree_pk.' = %s ';
$res = $ilDB->queryF($query,array('integer','integer'),array(
$a_node_id,
$this->tree_id));
$curr_node = $ilDB->fetchAssoc($res);
if($a_type)
{
$query = 'SELECT * FROM '.$this->table_tree.' '.
$this->buildJoin().
'WHERE lft > %s '.
'AND '.$this->table_obj_data.'.type = %s '.
'AND '.$this->table_tree.'.'.$this->tree_pk.' = %s '.
'ORDER BY lft ';
$ilDB->setLimit(1);
$res = $ilDB->queryF($query,array('integer','text','integer'),array(
$curr_node['lft'],
$a_type,
$this->tree_id));
}
else
{
$query = 'SELECT * FROM '.$this->table_tree.' '.
$this->buildJoin().
'WHERE lft > %s '.
'AND '.$this->table_tree.'.'.$this->tree_pk.' = %s '.
'ORDER BY lft ';
$ilDB->setLimit(1);
$res = $ilDB->queryF($query,array('integer','integer'),array(
$curr_node['lft'],
$this->tree_id));
}
if ($res->numRows() < 1)
{
return false;
}
else
{
$row = $ilDB->fetchAssoc($res);
return $this->fetchNodeData($row);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTree::fetchTranslationFromObjectDataCache (   $a_obj_ids)
protected

Get translation data from object cache (trigger in object cache on preload)

Parameters
array$a_obj_idsobject ids

Definition at line 1543 of file class.ilTree.php.

References isCacheUsed().

Referenced by getChilds().

{
global $ilObjDataCache;
if ($this->isCacheUsed() && is_array($a_obj_ids) && is_object($ilObjDataCache))
{
foreach ($a_obj_ids as $id)
{
$this->translation_cache[$id.'.']['title'] = $ilObjDataCache->lookupTitle($id);
$this->translation_cache[$id.'.']['description'] = $ilObjDataCache->lookupDescription($id);;
$this->translation_cache[$id.'.']['desc'] =
$this->translation_cache[$id.'.']['description'];
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTree::getChilds (   $a_node_id,
  $a_order = "",
  $a_direction = "ASC" 
)

get child nodes of given node public

Parameters
integernode_id
stringsort order of returned childs, optional (possible values: 'title','desc','last_update' or 'type')
stringsort direction, optional (possible values: 'DESC' or 'ASC'; defalut is 'ASC')
Returns
array with node data of all childs or empty array

Reimplemented in ilSCORMTree.

Definition at line 498 of file class.ilTree.php.

References $ilBench, $ilUser, $query, $res, $row, __isMainTree(), fetchNodeData(), fetchTranslationFromObjectDataCache(), and isCacheUsed().

Referenced by __renumber(), getFilteredChilds(), and ilObjWorkspaceFolderTableGUI\getItems().

{
global $ilBench,$ilDB, $ilObjDataCache, $ilUser;
if (!isset($a_node_id))
{
$message = get_class($this)."::getChilds(): No node_id given!";
$this->ilErr->raiseError($message,$this->ilErr->WARNING);
}
// init childs
$childs = array();
// number of childs
$count = 0;
// init order_clause
$order_clause = "";
// set order_clause if sort order parameter is given
if (!empty($a_order))
{
$order_clause = "ORDER BY ".$a_order." ".$a_direction;
}
else
{
$order_clause = "ORDER BY ".$this->table_tree.".lft";
}
$query = sprintf('SELECT * FROM '.$this->table_tree.' '.
$this->buildJoin().
"WHERE parent = %s " .
"AND ".$this->table_tree.".".$this->tree_pk." = %s ".
$order_clause,
$ilDB->quote($a_node_id,'integer'),
$ilDB->quote($this->tree_id,'integer'));
$res = $ilDB->query($query);
if(!$count = $res->numRows())
{
return array();
}
// get rows and object ids
$rows = array();
while($r = $ilDB->fetchAssoc($res))
{
$rows[] = $r;
$obj_ids[] = $r["obj_id"];
}
// preload object translation information
if ($this->__isMainTree() && $this->isCacheUsed() && is_object($ilObjDataCache) &&
is_object($ilUser) && $this->lang_code == $ilUser->getLanguage() && !$this->oc_preloaded[$a_node_id])
{
// $ilObjDataCache->preloadTranslations($obj_ids, $this->lang_code);
$ilObjDataCache->preloadObjectCache($obj_ids, $this->lang_code);
$this->oc_preloaded[$a_node_id] = true;
}
foreach ($rows as $row)
{
$childs[] = $this->fetchNodeData($row);
// Update cache of main tree
if ($this->__isMainTree())
{
#$GLOBALS['ilLog']->write(__METHOD__.': Storing in tree cache '.$row['child'].' = true');
$this->in_tree_cache[$row['child']] = $row['tree'] == 1;
}
}
$childs[$count - 1]["last"] = true;
return $childs;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTree::getChildsByType (   $a_node_id,
  $a_type 
)

get child nodes of given node by object type public

Parameters
integernode_id
stringobject type
Returns
array with node data of all childs or empty array

Definition at line 607 of file class.ilTree.php.

References $query, $res, $row, and fetchNodeData().

{
global $ilDB;
if (!isset($a_node_id) or !isset($a_type))
{
$message = get_class($this)."::getChildsByType(): Missing parameter! node_id:".$a_node_id." type:".$a_type;
$this->ilErr->raiseError($message,$this->ilErr->WARNING);
}
if ($a_type=='rolf' && $this->table_obj_reference) {
// Performance optimization: A node can only have exactly one
// role folder as its child. Therefore we don't need to sort the
// results, and we can let the database know about the expected limit.
$ilDB->setLimit(1,0);
$query = sprintf("SELECT * FROM ".$this->table_tree." ".
$this->buildJoin().
"WHERE parent = %s ".
"AND ".$this->table_tree.".".$this->tree_pk." = %s ".
"AND ".$this->table_obj_data.".type = %s ",
$ilDB->quote($a_node_id,'integer'),
$ilDB->quote($this->tree_id,'integer'),
$ilDB->quote($a_type,'text'));
} else {
$query = sprintf("SELECT * FROM ".$this->table_tree." ".
$this->buildJoin().
"WHERE parent = %s ".
"AND ".$this->table_tree.".".$this->tree_pk." = %s ".
"AND ".$this->table_obj_data.".type = %s ".
"ORDER BY ".$this->table_tree.".lft",
$ilDB->quote($a_node_id,'integer'),
$ilDB->quote($this->tree_id,'integer'),
$ilDB->quote($a_type,'text'));
}
$res = $ilDB->query($query);
// init childs
$childs = array();
while($row = $ilDB->fetchAssoc($res))
{
$childs[] = $this->fetchNodeData($row);
}
return $childs ? $childs : array();
}

+ Here is the call graph for this function:

ilTree::getChildsByTypeFilter (   $a_node_id,
  $a_types,
  $a_order = "",
  $a_direction = "ASC" 
)

get child nodes of given node by object type public

Parameters
integernode_id
arrayarray of object type
Returns
array with node data of all childs or empty array

Definition at line 661 of file class.ilTree.php.

References $query, $res, $row, buildJoin(), fetchNodeData(), and ilUtil\quoteArray().

{
global $ilDB;
if (!isset($a_node_id) or !$a_types)
{
$message = get_class($this)."::getChildsByType(): Missing parameter! node_id:".$a_node_id." type:".$a_types;
$this->ilErr->raiseError($message,$this->ilErr->WARNING);
}
$filter = ' ';
if($a_types)
{
$filter = 'AND '.$this->table_obj_data.'.type IN('.implode(',',ilUtil::quoteArray($a_types)).') ';
}
// set order_clause if sort order parameter is given
if (!empty($a_order))
{
$order_clause = "ORDER BY ".$a_order." ".$a_direction;
}
else
{
$order_clause = "ORDER BY ".$this->table_tree.".lft";
}
$query = 'SELECT * FROM '.$this->table_tree.' '.
$this->buildJoin().
'WHERE parent = '.$ilDB->quote($a_node_id,'integer').' '.
'AND '.$this->table_tree.'.'.$this->tree_pk.' = '.$ilDB->quote($this->tree_id,'integer').' '.
$filter.
$order_clause;
$res = $ilDB->query($query);
while($row = $ilDB->fetchAssoc($res))
{
$childs[] = $this->fetchNodeData($row);
}
return $childs ? $childs : array();
}

+ Here is the call graph for this function:

ilTree::getChildSequenceNumber (   $a_node,
  $type = "" 
)

get sequence number of node in sibling sequence public

Parameters
arraynode
Returns
integer sequence number

Definition at line 2054 of file class.ilTree.php.

References $query, $res, $row, and buildJoin().

{
global $ilDB;
if (!isset($a_node))
{
$this->ilErr->raiseError(get_class($this)."::getChildSequenceNumber(): No node_id given! ",$this->ilErr->WARNING);
}
if($type)
{
$query = 'SELECT count(*) cnt FROM '.$this->table_tree.' '.
$this->buildJoin().
'WHERE lft <= %s '.
'AND type = %s '.
'AND parent = %s '.
'AND '.$this->table_tree.'.'.$this->tree_pk.' = %s ';
$res = $ilDB->queryF($query,array('integer','text','integer','integer'),array(
$a_node['lft'],
$type,
$a_node['parent'],
$this->tree_id));
}
else
{
$query = 'SELECT count(*) cnt FROM '.$this->table_tree.' '.
$this->buildJoin().
'WHERE lft <= %s '.
'AND parent = %s '.
'AND '.$this->table_tree.'.'.$this->tree_pk.' = %s ';
$res = $ilDB->queryF($query,array('integer','integer','integer'),array(
$a_node['lft'],
$a_node['parent'],
$this->tree_id));
}
$row = $ilDB->fetchAssoc($res);
return $row["cnt"];
}

+ Here is the call graph for this function:

ilTree::getDepth (   $a_node_id)

return depth of a node in tree private

Parameters
integernode_id of parent's node_id
Returns
integer depth of node in tree

Definition at line 1345 of file class.ilTree.php.

References $query, $res, and $row.

{
global $ilDB;
if ($a_node_id)
{
$query = 'SELECT depth FROM '.$this->table_tree.' '.
'WHERE child = %s '.
'AND '.$this->tree_pk.' = %s ';
$res = $ilDB->queryF($query,array('integer','integer'),array($a_node_id,$this->tree_id));
$row = $ilDB->fetchObject($res);
return $row->depth;
}
else
{
return 1;
}
}
ilTree::getDepthCache ( )

Get depth cache.

Returns
type

Definition at line 279 of file class.ilTree.php.

References $depth_cache.

{
return (array) $this->depth_cache;
}
ilTree::getFilteredChilds (   $a_filter,
  $a_node,
  $a_order = "",
  $a_direction = "ASC" 
)

get child nodes of given node (exclude filtered obj_types) public

Parameters
arrayobjects to filter (e.g array('rolf'))
integernode_id
stringsort order of returned childs, optional (possible values: 'title','desc','last_update' or 'type')
stringsort direction, optional (possible values: 'DESC' or 'ASC'; defalut is 'ASC')
Returns
array with node data of all childs or empty array

Definition at line 585 of file class.ilTree.php.

References getChilds().

{
$childs = $this->getChilds($a_node,$a_order,$a_direction);
foreach($childs as $child)
{
if(!in_array($child["type"],$a_filter))
{
$filtered[] = $child;
}
}
return $filtered ? $filtered : array();
}

+ Here is the call graph for this function:

ilTree::getFilteredSubTree (   $a_node_id,
  $a_filter = array() 
)

get filtered subtree

get all subtree nodes beginning at a specific node excluding specific object types and their child nodes.

E.g getFilteredSubTreeNodes()

public

Parameters
@return

Definition at line 766 of file class.ilTree.php.

References getNodeData(), and getSubTree().

{
$node = $this->getNodeData($a_node_id);
$first = true;
$depth = 0;
foreach($this->getSubTree($node) as $subnode)
{
if($depth and $subnode['depth'] > $depth)
{
continue;
}
if(!$first and in_array($subnode['type'],$a_filter))
{
$depth = $subnode['depth'];
$first = false;
continue;
}
$depth = 0;
$first = false;
$filtered[] = $subnode;
}
return $filtered ? $filtered : array();
}

+ Here is the call graph for this function:

ilTree::getGap ( )

Get default gap *.

Returns
int

Definition at line 350 of file class.ilTree.php.

References $gap.

{
return $this->gap;
}
ilTree::getLeftValue (   $a_node_id)

get left value of given node public

Parameters
integernode id
Returns
integer left value

Definition at line 2029 of file class.ilTree.php.

References $query, $res, and $row.

{
global $ilDB;
if (!isset($a_node_id))
{
$this->ilErr->raiseError(get_class($this)."::getLeftValued(): No node_id given! ",$this->ilErr->WARNING);
}
$query = 'SELECT lft FROM '.$this->table_tree.' '.
'WHERE child = %s '.
'AND '.$this->tree_pk.' = %s ';
$res = $ilDB->queryF($query,array('integer','integer'),array(
$a_node_id,
$this->tree_id));
$row = $ilDB->fetchObject($res);
return $row->lft;
}
ilTree::getMaximumDepth ( )

Return the current maximum depth in the tree public.

Returns
integer max depth level of tree

Definition at line 1328 of file class.ilTree.php.

References $query, $res, and $row.

{
global $ilDB;
$query = 'SELECT MAX(depth) depth FROM '.$this->table_tree;
$res = $ilDB->query($query);
$row = $ilDB->fetchAssoc($res);
return $row['depth'];
}
ilTree::getNodeData (   $a_node_id,
  $a_tree_pk = null 
)

get all information of a node.

get data of a specific node from tree and object_data public

Parameters
integernode id
Returns
array 2-dim (int/str) node_data

Definition at line 1402 of file class.ilTree.php.

References $GLOBALS, $query, $res, $row, $tree_id, $tree_pk, __isMainTree(), buildJoin(), and fetchNodeData().

Referenced by ilWorkspaceTree\cascadingDelete(), getFilteredSubTree(), ilPortfolioPageTableGUI\getItems(), ilWorkspaceTree\getObjectsFromType(), ilOrgUnitTree\getRecursiveOrgUnitTree(), getSubTreeTypes(), ilPCFileListGUI\initEditForm(), ilPCVerificationGUI\initForm(), ilPCFileListGUI\insertNewFileItem(), ilPCFileItemGUI\insertNewItemAfter(), and ilPCFileItemGUI\insertNewItemBefore().

{
global $ilDB;
if (!isset($a_node_id))
{
$GLOBALS['ilLog']->logStack();
$this->ilErr->raiseError(get_class($this)."::getNodeData(): No node_id given! ",$this->ilErr->WARNING);
}
if($this->__isMainTree())
{
if($a_node_id < 1)
{
$message = sprintf('%s::getNodeData(): No valid parameter given! $a_node_id: %s',
get_class($this),
$a_node_id);
$this->log->write($message,$this->log->FATAL);
$this->ilErr->raiseError($message,$this->ilErr->WARNING);
}
}
// BEGIN WebDAV: Pass tree id to this method
$query = 'SELECT * FROM '.$this->table_tree.' '.
$this->buildJoin().
'WHERE '.$this->table_tree.'.child = %s '.
'AND '.$this->table_tree.'.'.$this->tree_pk.' = %s ';
$res = $ilDB->queryF($query,array('integer','integer'),array(
$a_node_id,
$a_tree_pk === null ? $this->tree_id : $a_tree_pk));
// END WebDAV: Pass tree id to this method
$row = $ilDB->fetchAssoc($res);
return $this->fetchNodeData($row);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTree::getNodeDataByType (   $a_type)

get nodes by type

Parameters
integera_tree_id: obj_id of object where tree belongs to
integera_type_id: type of object public
Exceptions
InvalidArgumentException
Deprecated:
since 4.4.0

Definition at line 1724 of file class.ilTree.php.

References $GLOBALS, $query, $res, $row, buildJoin(), fetchNodeData(), and ilDB\quote().

{
global $ilDB;
if(!isset($a_type) or (!is_string($a_type)))
{
$GLOBALS['ilLog']->logStack();
throw new InvalidArgumentException('Type not given or wrong datatype');
}
$query = 'SELECT * FROM ' . $this->table_tree . ' ' .
$this->buildJoin().
'WHERE ' . $this->table_obj_data . '.type = ' . $this->ilDB->quote($a_type, 'text').
'AND ' . $this->table_tree . '.' . $this->tree_pk . ' = ' . $this->ilDB->quote($this->tree_id, 'integer');
$res = $ilDB->query($query);
$data = array();
while($row = $ilDB->fetchAssoc($res))
{
$data[] = $this->fetchNodeData($row);
}
return $data;
}

+ Here is the call graph for this function:

ilTree::getNodePath (   $a_endnode_id,
  $a_startnode_id = 0 
)

Returns the node path for the specified object reference.

Note: this function returns the same result as getNodePathForTitlePath, but takes ref-id's as parameters.

This function differs from getPathFull, in the following aspects:

  • The title of an object is not translated into the language of the user
  • This function is significantly faster than getPathFull.

public

Parameters
integernode_id of endnode
integernode_id of startnode (optional)
Returns
array ordered path info (depth,parent,child,obj_id,type,title) or null, if the node_id can not be converted into a node path.

Definition at line 1171 of file class.ilTree.php.

References $query, $res, $row, and getPathId().

Referenced by getNodePathForTitlePath().

{
global $ilDB;
$pathIds = $this->getPathId($a_endnode_id, $a_startnode_id);
// Abort if no path ids were found
if (count($pathIds) == 0)
{
return null;
}
$types = array();
$data = array();
for ($i = 0; $i < count($pathIds); $i++)
{
$types[] = 'integer';
$data[] = $pathIds[$i];
}
$query = 'SELECT t.depth,t.parent,t.child,d.obj_id,d.type,d.title '.
'FROM '.$this->table_tree.' t '.
'JOIN '.$this->table_obj_reference.' r ON r.ref_id = t.child '.
'JOIN '.$this->table_obj_data.' d ON d.obj_id = r.obj_id '.
'WHERE '.$ilDB->in('t.child',$data,false,'integer').' '.
'ORDER BY t.depth ';
$res = $ilDB->queryF($query,$types,$data);
$titlePath = array();
while ($row = $ilDB->fetchAssoc($res))
{
$titlePath[] = $row;
}
return $titlePath;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTree::getNodePathForTitlePath (   $titlePath,
  $a_startnode_id = null 
)

Converts a path consisting of object titles into a path consisting of tree nodes.

The comparison is non-case sensitive.

Note: this function returns the same result as getNodePath, but takes a title path as parameter.

public

Parameters
ArrayPath array with object titles. e.g. array('ILIAS','English','Course A')
ref_idStartnode of the relative path. Specify null, if the title path is an absolute path. Specify a ref id, if the title path is a relative path starting at this ref id.
Returns
array ordered path info (depth,parent,child,obj_id,type,title) or null, if the title path can not be converted into a node path.

Definition at line 1048 of file class.ilTree.php.

References $log, $obj_pk, $row, DB_FETCHMODE_ASSOC, getNodePath(), ilStr\strToLower(), and UtfNormal\toNFC().

{
global $ilDB, $log;
//$log->write('getNodePathForTitlePath('.implode('/',$titlePath));
// handle empty title path
if ($titlePath == null || count($titlePath) == 0)
{
if ($a_startnode_id == 0)
{
return null;
}
else
{
return $this->getNodePath($a_startnode_id);
}
}
// fetch the node path up to the startnode
if ($a_startnode_id != null && $a_startnode_id != 0)
{
// Start using the node path to the root of the relative path
$nodePath = $this->getNodePath($a_startnode_id);
$parent = $a_startnode_id;
}
else
{
// Start using the root of the tree
$nodePath = array();
$parent = 0;
}
// Convert title path into Unicode Normal Form C
// This is needed to ensure that we can compare title path strings with
// strings from the database.
require_once('include/Unicode/UtfNormal.php');
include_once './Services/Utilities/classes/class.ilStr.php';
$inClause = 'd.title IN (';
for ($i=0; $i < count($titlePath); $i++)
{
$titlePath[$i] = ilStr::strToLower(UtfNormal::toNFC($titlePath[$i]));
if ($i > 0) $inClause .= ',';
$inClause .= $ilDB->quote($titlePath[$i],'text');
}
$inClause .= ')';
// Fetch all rows that are potential path elements
if ($this->table_obj_reference)
{
$joinClause = 'JOIN '.$this->table_obj_reference.' r ON t.child = r.'.$this->ref_pk.' '.
'JOIN '.$this->table_obj_data.' d ON r.'.$this->obj_pk.' = d.'.$this->obj_pk;
}
else
{
$joinClause = 'JOIN '.$this->table_obj_data.' d ON t.child = d.'.$this->obj_pk;
}
// The ORDER BY clause in the following SQL statement ensures that,
// in case of a multiple objects with the same title, always the Object
// with the oldest ref_id is chosen.
// This ensure, that, if a new object with the same title is added,
// WebDAV clients can still work with the older object.
$q = 'SELECT t.depth, t.parent, t.child, d.'.$this->obj_pk.' obj_id, d.type, d.title '.
'FROM '.$this->table_tree.' t '.
$joinClause.' '.
'WHERE '.$inClause.' '.
'AND t.depth <= '.(count($titlePath)+count($nodePath)).' '.
'AND t.tree = 1 '.
'ORDER BY t.depth, t.child ASC';
$r = $ilDB->query($q);
$rows = array();
while ($row = $r->fetchRow(DB_FETCHMODE_ASSOC))
{
$row['title'] = UtfNormal::toNFC($row['title']);
$row['ref_id'] = $row['child'];
$rows[] = $row;
}
// Extract the path elements from the fetched rows
for ($i = 0; $i < count($titlePath); $i++) {
$pathElementFound = false;
foreach ($rows as $row) {
if ($row['parent'] == $parent &&
ilStr::strToLower($row['title']) == $titlePath[$i])
{
// FIXME - We should test here, if the user has
// 'visible' permission for the object.
$nodePath[] = $row;
$parent = $row['child'];
$pathElementFound = true;
break;
}
}
// Abort if we haven't found a path element for the current depth
if (! $pathElementFound)
{
//$log->write('ilTree.getNodePathForTitlePath('.var_export($titlePath,true).','.$a_startnode_id.'):null');
return null;
}
}
// Return the node path
//$log->write('ilTree.getNodePathForTitlePath('.var_export($titlePath,true).','.$a_startnode_id.'):'.var_export($nodePath,true));
return $nodePath;
}

+ Here is the call graph for this function:

ilTree::getNodeTreeData (   $a_node_id)

return all columns of tabel tree

Parameters
type$a_node_id
Returns
array of table column => values
Exceptions
InvalidArgumentException

Definition at line 1372 of file class.ilTree.php.

References $GLOBALS, $query, $res, $row, and DB_FETCHMODE_ASSOC.

Referenced by getRelation(), getSubTreeQuery(), and saveSubTree().

{
global $ilDB;
if(!$a_node_id)
{
$GLOBALS['ilLog']->logStack();
throw new InvalidArgumentException('Missing or empty parameter $a_node_id: '. $a_node_id);
}
$query = 'SELECT * FROM '.$this->table_tree.' '.
'WHERE child = '.$ilDB->quote($a_node_id,'integer');
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_ASSOC))
{
return $row;
}
return array();
}

+ Here is the caller graph for this function:

ilTree::getObjectDataTable ( )

Get object data table.

Returns
type

Definition at line 325 of file class.ilTree.php.

References $table_obj_data.

{
}
ilTree::getParentCache ( )

Get parent cache.

Returns
type

Definition at line 288 of file class.ilTree.php.

References $parent_cache.

{
return (array) $this->parent_cache;
}
ilTree::getParentId (   $a_node_id)

get parent id of given node public

Parameters
integernode id
Returns
integer parent id

Definition at line 2003 of file class.ilTree.php.

References $query, $res, and $row.

{
global $ilDB;
if (!isset($a_node_id))
{
$this->ilErr->raiseError(get_class($this)."::getParentId(): No node_id given! ",$this->ilErr->WARNING);
}
$query = 'SELECT parent FROM '.$this->table_tree.' '.
'WHERE child = %s '.
'AND '.$this->tree_pk.' = %s ';
$res = $ilDB->queryF($query,array('integer','integer'),array(
$a_node_id,
$this->tree_id));
$row = $ilDB->fetchObject($res);
return $row->parent;
}
ilTree::getParentNodeData (   $a_node_id)

get data of parent node from tree and object_data public

Parameters
integernode id
Returns
array
Exceptions
InvalidArgumentException

Definition at line 1619 of file class.ilTree.php.

References $ilLog, $query, $res, $row, and fetchNodeData().

{
global $ilDB;
global $ilLog;
if (!isset($a_node_id))
{
$ilLog->logStack();
throw new InvalidArgumentException(__METHOD__.': No node_id given!');
}
if ($this->table_obj_reference)
{
// Use inner join instead of left join to improve performance
$innerjoin = "JOIN ".$this->table_obj_reference." ON v.child=".$this->table_obj_reference.".".$this->ref_pk." ".
"JOIN ".$this->table_obj_data." ON ".$this->table_obj_reference.".".$this->obj_pk."=".$this->table_obj_data.".".$this->obj_pk." ";
}
else
{
// Use inner join instead of left join to improve performance
$innerjoin = "JOIN ".$this->table_obj_data." ON v.child=".$this->table_obj_data.".".$this->obj_pk." ";
}
$query = 'SELECT * FROM '.$this->table_tree.' s, '.$this->table_tree.' v '.
$innerjoin.
'WHERE s.child = %s '.
'AND s.parent = v.child '.
'AND s.'.$this->tree_pk.' = %s '.
'AND v.'.$this->tree_pk.' = %s';
$res = $ilDB->queryF($query,array('integer','integer','integer'),array(
$a_node_id,
$this->tree_id,
$this->tree_id));
$row = $ilDB->fetchAssoc($res);
return $this->fetchNodeData($row);
}

+ Here is the call graph for this function:

ilTree::getPathFull (   $a_endnode_id,
  $a_startnode_id = 0 
)

get path from a given startnode to a given endnode if startnode is not given the rootnode is startnode.

This function chooses the algorithm to be used.

public

Parameters
integernode_id of endnode
integernode_id of startnode (optional)
Returns
array ordered path info (id,title,parent) from start to end

Definition at line 925 of file class.ilTree.php.

References $row, __isMainTree(), buildJoin(), DB_FETCHMODE_ASSOC, fetchNodeData(), getPathId(), and ilDB\quote().

Referenced by checkForParentType(), and ilSkillTree\getSkillTreePath().

{
$pathIds =& $this->getPathId($a_endnode_id, $a_startnode_id);
// We retrieve the full path in a single query to improve performance
global $ilDB;
// Abort if no path ids were found
if (count($pathIds) == 0)
{
return null;
}
$inClause = 'child IN (';
for ($i=0; $i < count($pathIds); $i++)
{
if ($i > 0) $inClause .= ',';
$inClause .= $ilDB->quote($pathIds[$i],'integer');
}
$inClause .= ')';
$q = 'SELECT * '.
'FROM '.$this->table_tree.' '.
$this->buildJoin().' '.
'WHERE '.$inClause.' '.
'AND '.$this->table_tree.'.'.$this->tree_pk.' = '.$this->ilDB->quote($this->tree_id,'integer').' '.
'ORDER BY depth';
$r = $ilDB->query($q);
$pathFull = array();
while ($row = $r->fetchRow(DB_FETCHMODE_ASSOC))
{
$pathFull[] = $this->fetchNodeData($row);
// Update cache
if ($this->__isMainTree())
{
#$GLOBALS['ilLog']->write(__METHOD__.': Storing in tree cache '.$row['child']);
$this->in_tree_cache[$row['child']] = $row['tree'] == 1;
}
}
return $pathFull;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTree::getPathId (   $a_endnode_id,
  $a_startnode_id = 0 
)

get path from a given startnode to a given endnode if startnode is not given the rootnode is startnode public

Parameters
integernode_id of endnode
integernode_id of startnode (optional)
Returns
array all path ids from startnode to endnode
Exceptions
InvalidArgumentException

Definition at line 1005 of file class.ilTree.php.

References $GLOBALS, __isMainTree(), getTreeImplementation(), and isCacheUsed().

Referenced by getNodePath(), getPathFull(), and ilSkillTree\getTopParentNodeId().

{
if(!$a_endnode_id)
{
$GLOBALS['ilLog']->logStack();
throw new InvalidArgumentException(__METHOD__.': No endnode given!');
}
// path id cache
if ($this->isCacheUsed() && isset($this->path_id_cache[$a_endnode_id][$a_startnode_id]))
{
//echo "<br>getPathIdhit";
return $this->path_id_cache[$a_endnode_id][$a_startnode_id];
}
//echo "<br>miss";
$pathIds = $this->getTreeImplementation()->getPathIds($a_endnode_id, $a_startnode_id);
if($this->__isMainTree())
{
$this->path_id_cache[$a_endnode_id][$a_startnode_id] = $pathIds;
}
return $pathIds;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTree::getRbacSubtreeInfo (   $a_endnode_id)

This method is used for change existing objects and returns all necessary information for this action.

The former use of ilTree::getSubtree needs to much memory.

Parameters
ref_idref_id of source node
Returns

Definition at line 2637 of file class.ilTree.php.

References getTreeImplementation().

{
return $this->getTreeImplementation()->getSubtreeInfo($a_endnode_id);
}

+ Here is the call graph for this function:

ilTree::getRelation (   $a_node_a,
  $a_node_b 
)

Get relation of two nodes.

Parameters
int$a_node_a
int$a_node_b

Definition at line 471 of file class.ilTree.php.

References getNodeTreeData(), and getRelationOfNodes().

Referenced by isGrandChild().

{
return $this->getRelationOfNodes(
$this->getNodeTreeData($a_node_a),
$this->getNodeTreeData($a_node_b)
);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTree::getRelationOfNodes (   $a_node_a_arr,
  $a_node_b_arr 
)

get relation of two nodes by node data

Parameters
array$a_node_a_arr
array$a_node_b_arr

Definition at line 485 of file class.ilTree.php.

References getTreeImplementation().

Referenced by getRelation().

{
return $this->getTreeImplementation()->getRelation($a_node_a_arr, $a_node_b_arr);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTree::getRootId ( )

get the root id of tree public

Returns
integer root node id

Definition at line 2122 of file class.ilTree.php.

References $root_id.

Referenced by ilWorkspaceTree\getObjectsFromType(), and ilPCVerificationGUI\initForm().

{
}

+ Here is the caller graph for this function:

ilTree::getSavedNodeData (   $a_parent_id)

get data saved/deleted nodes

Returns
array data
Parameters
integerid of parent object of saved object public

Definition at line 1949 of file class.ilTree.php.

References $query, $res, $row, buildJoin(), and fetchNodeData().

{
global $ilDB;
if (!isset($a_parent_id))
{
$this->ilErr->raiseError(get_class($this)."::getSavedNodeData(): No node_id given!",$this->ilErr->WARNING);
}
$query = 'SELECT * FROM '.$this->table_tree.' '.
$this->buildJoin().
'WHERE '.$this->table_tree.'.'.$this->tree_pk.' < %s '.
'AND '.$this->table_tree.'.parent = %s';
$res = $ilDB->queryF($query,array('integer','integer'),array(
0,
$a_parent_id));
while($row = $ilDB->fetchAssoc($res))
{
$saved[] = $this->fetchNodeData($row);
}
return $saved ? $saved : array();
}

+ Here is the call graph for this function:

ilTree::getSavedNodeObjIds ( array  $a_obj_ids)

get object id of saved/deleted nodes

Returns
array data
Parameters
arrayobject ids to check public

Definition at line 1980 of file class.ilTree.php.

References $query, $res, $row, and buildJoin().

{
global $ilDB;
$query = 'SELECT '.$this->table_obj_data.'.obj_id FROM '.$this->table_tree.' '.
$this->buildJoin().
'WHERE '.$this->table_tree.'.'.$this->tree_pk.' < '.$ilDB->quote(0, 'integer').' '.
'AND '.$ilDB->in($this->table_obj_data.'.obj_id', $a_obj_ids, '', 'integer');
$res = $ilDB->query($query);
while($row = $ilDB->fetchAssoc($res))
{
$saved[] = $row['obj_id'];
}
return $saved ? $saved : array();
}

+ Here is the call graph for this function:

ilTree::getSubTree (   $a_node,
  $a_with_data = true,
  $a_type = "" 
)

get all nodes in the subtree under specified node

public

Parameters
arraynode_data
booleanwith data: default is true otherwise this function return only a ref_id array
Returns
array 2-dim (int/array) key, node_data of each subtree node including the specified node
Exceptions
InvalidArgumentException

Definition at line 811 of file class.ilTree.php.

References $GLOBALS, $query, $res, $row, __isMainTree(), fetchNodeData(), and getTreeImplementation().

Referenced by ilWorkspaceTree\cascadingDelete(), getFilteredSubTree(), ilWorkspaceTree\getObjectsFromType(), and ilOrgUnitTree\getRecursiveOrgUnitTree().

{
global $ilDB;
if (!is_array($a_node))
{
$GLOBALS['ilLog']->logStack();
throw new InvalidArgumentException(__METHOD__.': wrong datatype for node data given');
}
/*
if($a_node['lft'] < 1 or $a_node['rgt'] < 2)
{
$GLOBALS['ilLog']->logStack();
$message = sprintf('%s: Invalid node given! $a_node["lft"]: %s $a_node["rgt"]: %s',
__METHOD__,
$a_node['lft'],
$a_node['rgt']);
throw new InvalidArgumentException($message);
}
*/
$query = $this->getTreeImplementation()->getSubTreeQuery($a_node, $a_type);
$res = $ilDB->query($query);
while($row = $ilDB->fetchAssoc($res))
{
if($a_with_data)
{
$subtree[] = $this->fetchNodeData($row);
}
else
{
$subtree[] = $row['child'];
}
// the lm_data "hack" should be removed in the trunk during an alpha
if($this->__isMainTree() || $this->table_tree == "lm_tree")
{
$this->in_tree_cache[$row['child']] = true;
}
}
return $subtree ? $subtree : array();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTree::getSubTreeIds (   $a_ref_id)

Get all ids of subnodes.

Returns
Parameters
object$a_ref_id

Definition at line 796 of file class.ilTree.php.

References getTreeImplementation().

{
return $this->getTreeImplementation()->getSubTreeIds($a_ref_id);
}

+ Here is the call graph for this function:

ilTree::getSubTreeQuery (   $a_node_id,
  $a_fields = array(),
  $a_types = '',
  $a_force_join_reference = false 
)

Get tree subtree query.

Parameters
type$a_node_id
type$a_types
type$a_force_join_reference
Returns
type

Definition at line 2650 of file class.ilTree.php.

References getNodeTreeData(), and getTreeImplementation().

{
return $this->getTreeImplementation()->getSubTreeQuery(
$this->getNodeTreeData($a_node_id),
$a_types,
$a_force_join_reference,
$a_fields);
}

+ Here is the call graph for this function:

ilTree::getSubTreeTypes (   $a_node,
  $a_filter = 0 
)

get types of nodes in the subtree under specified node

public

Parameters
arraynode_id
arrayobject types to filter e.g array('rolf')
Returns
array 2-dim (int/array) key, node_data of each subtree node including the specified node

Definition at line 863 of file class.ilTree.php.

References getNodeData().

{
$a_filter = $a_filter ? $a_filter : array();
foreach($this->getSubtree($this->getNodeData($a_node)) as $node)
{
if(in_array($node["type"],$a_filter))
{
continue;
}
$types["$node[type]"] = $node["type"];
}
return $types ? $types : array();
}

+ Here is the call graph for this function:

ilTree::getTableReference ( )

Get reference table if available.

Definition at line 342 of file class.ilTree.php.

References $table_obj_reference.

ilTree::getTreeId ( )

get tree id public

Returns
integer tree id

Definition at line 2136 of file class.ilTree.php.

References $tree_id.

Referenced by ilWorkspaceExplorer\__construct().

{
}

+ Here is the caller graph for this function:

ilTree::getTreeImplementation ( )

Get tree implementation.

Returns
ilTreeImplementation $impl

Definition at line 253 of file class.ilTree.php.

References $tree_impl.

Referenced by __checkDelete(), deleteTree(), getPathId(), getRbacSubtreeInfo(), getRelationOfNodes(), getSubTree(), getSubTreeIds(), getSubTreeQuery(), insertNode(), moveTree(), and saveSubTree().

{
}

+ Here is the caller graph for this function:

ilTree::getTreePk ( )

Get tree primary key.

Returns
string column of pk

Definition at line 334 of file class.ilTree.php.

References $tree_pk.

{
}
ilTree::getTreeTable ( )

Get tree table name.

Returns
string tree table name

Definition at line 316 of file class.ilTree.php.

References $table_tree.

{
}
ilTree::ilTree (   $a_tree_id,
  $a_root_id = 0 
)

Constructor public.

Parameters
integer$a_tree_idtree_id
integer$a_root_idroot_id (optional)

Definition at line 147 of file class.ilTree.php.

References $ilErr, $ilias, $ilLog, initTreeImplementation(), and PEAR_ERROR_CALLBACK.

Referenced by ilLMTree\__construct(), ilAICCTree\ilAICCTree(), and ilSCORMTree\ilSCORMTree().

{
global $ilDB,$ilErr,$ilias,$ilLog;
// set db & error handler
$this->ilDB = $ilDB;
if (!isset($ilErr))
{
$ilErr = new ilErrorHandling();
$ilErr->setErrorHandling(PEAR_ERROR_CALLBACK,array($ilErr,'errorHandler'));
}
else
{
$this->ilErr = $ilErr;
}
$this->lang_code = "en";
if (!isset($a_tree_id) or (func_num_args() == 0) )
{
$this->ilErr->raiseError(get_class($this)."::Constructor(): No tree_id given!",$this->ilErr->WARNING);
}
if (func_num_args() > 2)
{
$this->ilErr->raiseError(get_class($this)."::Constructor(): Wrong parameter count!",$this->ilErr->WARNING);
}
// CREATE LOGGER INSTANCE
$this->log = $ilLog;
//init variables
if (empty($a_root_id))
{
$a_root_id = ROOT_FOLDER_ID;
}
$this->tree_id = $a_tree_id;
$this->root_id = $a_root_id;
$this->table_tree = 'tree';
$this->table_obj_data = 'object_data';
$this->table_obj_reference = 'object_reference';
$this->ref_pk = 'ref_id';
$this->obj_pk = 'obj_id';
$this->tree_pk = 'tree';
$this->use_cache = true;
// If cache is activated, cache object translations to improve performance
$this->translation_cache = array();
$this->parent_type_cache = array();
// By default, we create gaps in the tree sequence numbering for 50 nodes
$this->gap = 50;
// init tree implementation
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTree::initLangCode ( )

Store user language.

This function is used by the "main" tree only (during initialisation).

Definition at line 297 of file class.ilTree.php.

References $ilUser.

{
global $ilUser;
// lang_code is only required in $this->fetchnodedata
if (!is_object($ilUser))
{
$this->lang_code = "en";
}
else
{
$this->lang_code = $ilUser->getCurrentLanguage();
}
}
ilTree::initTreeImplementation ( )

Init tree implementation.

Definition at line 211 of file class.ilTree.php.

References $GLOBALS, and __isMainTree().

Referenced by ilTree(), and setTableNames().

{
global $ilDB;
if(!is_object($GLOBALS['ilSetting']) or $GLOBALS['ilSetting']->getModule() != 'common')
{
include_once './Services/Administration/classes/class.ilSetting.php';
$setting = new ilSetting('common');
}
else
{
$setting = $GLOBALS['ilSetting'];
}
if($this->__isMainTree())
{
if($setting->get('main_tree_impl','ns') == 'ns')
{
#$GLOBALS['ilLog']->write(__METHOD__.': Using nested set.');
include_once './Services/Tree/classes/class.ilNestedSetTree.php';
$this->tree_impl = new ilNestedSetTree($this);
}
else
{
#$GLOBALS['ilLog']->write(__METHOD__.': Using materialized path.');
include_once './Services/Tree/classes/class.ilMaterializedPathTree.php';
$this->tree_impl = new ilMaterializedPathTree($this);
}
}
else
{
#$GLOBALS['ilLog']->write(__METHOD__.': Using netsted set for non main tree.');
include_once './Services/Tree/classes/class.ilNestedSetTree.php';
$this->tree_impl = new ilNestedSetTree($this);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTree::insertNode (   $a_node_id,
  $a_parent_id,
  $a_pos = IL_LAST_NODE,
  $a_reset_deletion_date = false 
)

insert new node with node_id under parent node with parent_id public

Parameters
integernode_id
integerparent_id
integerIL_LAST_NODE | IL_FIRST_NODE | node id of preceding child

Definition at line 710 of file class.ilTree.php.

References $GLOBALS, __isMainTree(), ilObject\_resetDeletedDate(), getTreeImplementation(), and isInTree().

Referenced by ilWorkspaceTree\insertObject().

{
global $ilDB;
//echo "+$a_node_id+$a_parent_id+";
// CHECK node_id and parent_id > 0 if in main tree
if($this->__isMainTree())
{
if($a_node_id <= 1 or $a_parent_id <= 0)
{
$GLOBALS['ilLog']->logStack();
$message = sprintf('%s::insertNode(): Invalid parameters! $a_node_id: %s $a_parent_id: %s',
get_class($this),
$a_node_id,
$a_parent_id);
$this->log->write($message,$this->log->FATAL);
$this->ilErr->raiseError($message,$this->ilErr->WARNING);
}
}
if (!isset($a_node_id) or !isset($a_parent_id))
{
$GLOBALS['ilLog']->logStack();
$this->ilErr->raiseError(get_class($this)."::insertNode(): Missing parameter! ".
"node_id: ".$a_node_id." parent_id: ".$a_parent_id,$this->ilErr->WARNING);
}
if ($this->isInTree($a_node_id))
{
$this->ilErr->raiseError(get_class($this)."::insertNode(): Node ".$a_node_id." already in tree ".
$this->table_tree."!",$this->ilErr->WARNING);
}
$this->getTreeImplementation()->insertNode($a_node_id, $a_parent_id, $a_pos);
$this->in_tree_cache[$a_node_id] = true;
// reset deletion date
if ($a_reset_deletion_date)
{
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTree::isCacheUsed ( )

Check if cache is active.

Returns
bool

Reimplemented in ilLMTree.

Definition at line 270 of file class.ilTree.php.

References __isMainTree().

Referenced by checkForParentType(), fetchNodeData(), fetchTranslationFromObjectDataCache(), getChilds(), getPathId(), isInTree(), isSaved(), preloadDeleted(), and preloadDepthParent().

{
return $this->__isMainTree() and $this->use_cache;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTree::isDeleted (   $a_node_id)

This is a wrapper for isSaved() with a more useful name.

Parameters
int$a_node_id

Definition at line 1860 of file class.ilTree.php.

References isSaved().

{
return $this->isSaved($a_node_id);
}

+ Here is the call graph for this function:

ilTree::isGrandChild (   $a_startnode_id,
  $a_querynode_id 
)

checks if a node is in the path of an other node public

Parameters
integerobject id of start node
integerobject id of query node
Returns
integer number of entries

Definition at line 1663 of file class.ilTree.php.

References getRelation(), and RELATION_PARENT.

{
return $this->getRelation($a_startnode_id, $a_querynode_id) == self::RELATION_PARENT;
}

+ Here is the call graph for this function:

ilTree::isInTree (   $a_node_id)

get all information of a node.

get data of a specific node from tree and object_data public

Parameters
integernode id
Returns
boolean true, if node id is in tree

Definition at line 1567 of file class.ilTree.php.

References $query, $res, __isMainTree(), and isCacheUsed().

Referenced by checkForParentType(), and insertNode().

{
global $ilDB;
if (!isset($a_node_id))
{
return false;
#$this->ilErr->raiseError(get_class($this)."::getNodeData(): No node_id given! ",$this->ilErr->WARNING);
}
// is in tree cache
if ($this->isCacheUsed() && isset($this->in_tree_cache[$a_node_id]))
{
#$GLOBALS['ilLog']->write(__METHOD__.': Using in tree cache '.$a_node_id);
//echo "<br>in_tree_hit";
return $this->in_tree_cache[$a_node_id];
}
$query = 'SELECT * FROM '.$this->table_tree.' '.
'WHERE '.$this->table_tree.'.child = %s '.
'AND '.$this->table_tree.'.'.$this->tree_pk.' = %s';
$res = $ilDB->queryF($query,array('integer','integer'),array(
$a_node_id,
$this->tree_id));
if ($res->numRows() > 0)
{
if($this->__isMainTree())
{
#$GLOBALS['ilLog']->write(__METHOD__.': Storing in tree cache '.$a_node_id.' = true');
$this->in_tree_cache[$a_node_id] = true;
}
return true;
}
else
{
if($this->__isMainTree())
{
#$GLOBALS['ilLog']->write(__METHOD__.': Storing in tree cache '.$a_node_id.' = false');
$this->in_tree_cache[$a_node_id] = false;
}
return false;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTree::isSaved (   $a_node_id)

Use method isDeleted check if node is saved.

Deprecated:
since 4.4.0

Definition at line 1870 of file class.ilTree.php.

References $query, $res, $row, __isMainTree(), and isCacheUsed().

Referenced by isDeleted().

{
global $ilDB;
// is saved cache
if ($this->isCacheUsed() && isset($this->is_saved_cache[$a_node_id]))
{
//echo "<br>issavedhit";
return $this->is_saved_cache[$a_node_id];
}
$query = 'SELECT '.$this->tree_pk.' FROM '.$this->table_tree.' '.
'WHERE child = %s ';
$res = $ilDB->queryF($query,array('integer'),array($a_node_id));
$row = $ilDB->fetchAssoc($res);
if ($row[$this->tree_pk] < 0)
{
if($this->__isMainTree())
{
$this->is_saved_cache[$a_node_id] = true;
}
return true;
}
else
{
if($this->__isMainTree())
{
$this->is_saved_cache[$a_node_id] = false;
}
return false;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTree::moveToTrash (   $a_node_id,
  $a_set_deleted = false 
)

Wrapper for saveSubTree.

Parameters
type$a_node_id
type$a_set_deleted
Exceptions
InvalidArgumentException

Definition at line 1784 of file class.ilTree.php.

References saveSubTree().

{
return $this->saveSubTree($a_node_id, $a_set_deleted);
}

+ Here is the call graph for this function:

ilTree::moveTree (   $a_source_id,
  $a_target_id,
  $a_location = self::POS_LAST_NODE 
)

Move Tree Implementation.

public

Parameters
intsource ref_id
inttarget ref_id
intlocation IL_LAST_NODE or IL_FIRST_NODE (IL_FIRST_NODE not implemented yet)

Definition at line 2613 of file class.ilTree.php.

References $GLOBALS, and getTreeImplementation().

{
$this->getTreeImplementation()->moveTree($a_source_id,$a_target_id,$a_location);
$GLOBALS['ilAppEventHandler']->raise(
"Services/Tree",
"moveTree",
array(
'tree' => $this->table_tree,
'source_id' => $a_source_id,
'target_id' => $a_target_id)
);
return true;
}

+ Here is the call graph for this function:

ilTree::preloadDeleted (   $a_node_ids)

Preload deleted information.

Parameters
arraynodfe ids
Returns
bool

Definition at line 1910 of file class.ilTree.php.

References $query, $res, $row, __isMainTree(), and isCacheUsed().

{
global $ilDB;
if (!is_array($a_node_ids) || !$this->isCacheUsed())
{
return;
}
$query = 'SELECT '.$this->tree_pk.', child FROM '.$this->table_tree.' '.
'WHERE '.$ilDB->in("child", $a_node_ids, false, "integer");
$res = $ilDB->query($query);
while ($row = $ilDB->fetchAssoc($res))
{
if ($row[$this->tree_pk] < 0)
{
if($this->__isMainTree())
{
$this->is_saved_cache[$row["child"]] = true;
}
}
else
{
if($this->__isMainTree())
{
$this->is_saved_cache[$row["child"]] = false;
}
}
}
}

+ Here is the call graph for this function:

ilTree::preloadDepthParent (   $a_node_ids)

Preload depth/parent.

Parameters
@return

Definition at line 976 of file class.ilTree.php.

References $res, $row, __isMainTree(), and isCacheUsed().

{
global $ilDB;
if (!$this->__isMainTree() || !is_array($a_node_ids) || !$this->isCacheUsed())
{
return;
}
$res = $ilDB->query('SELECT t.depth, t.parent, t.child '.
'FROM '.$this->table_tree.' t '.
'WHERE '.$ilDB->in("child", $a_node_ids, false, "integer").
'AND '.$this->tree_pk.' = '.$ilDB->quote($this->tree_id, "integer"));
while ($row = $ilDB->fetchAssoc($res))
{
$this->depth_cache[$row["child"]] = $row["depth"];
$this->parent_cache[$row["child"]] = $row["parent"];
}
}

+ Here is the call graph for this function:

ilTree::readRootId ( )

read root id from database

Parameters
root_idpublic
Returns
int new root id

Definition at line 2102 of file class.ilTree.php.

References $query, $res, $root_id, and $row.

Referenced by ilWorkspaceTree\__construct(), ilWorkspaceExplorer\__construct(), ilWorkspaceTree\cascadingDelete(), ilWorkspaceAccessHandler\checkAccessOfUser(), ilHACPPresentationGUI\explorer(), ilAICCPresentationGUI\explorer(), ilSAHSPresentationGUI\explorer(), ilSCORMPresentationGUI\explorer(), ilPortfolioPageTableGUI\getItems(), ilAICCExplorer\ilAICCExplorer(), ilHACPExplorer\ilHACPExplorer(), and ilSCORMExplorer\ilSCORMExplorer().

{
global $ilDB;
$query = 'SELECT child FROM '.$this->table_tree.' '.
'WHERE parent = %s '.
'AND '.$this->tree_pk.' = %s ';
$res = $ilDB->queryF($query,array('integer','integer'),array(
0,
$this->tree_id));
$row = $ilDB->fetchObject($res);
$this->root_id = $row->child;
}

+ Here is the caller graph for this function:

ilTree::removeTree (   $a_tree_id)

remove an existing tree

Parameters
integera_tree_id: tree to be removed
Returns
boolean true on success public

Definition at line 1756 of file class.ilTree.php.

References $GLOBALS, $query, and __isMainTree().

{
global $ilDB;
// OPERATION NOT ALLOWED ON MAIN TREE
if($this->__isMainTree())
{
$GLOBALS['ilLog']->logStack();
throw new InvalidArgumentException('Operation not allowed on main tree');
}
if (!$a_tree_id)
{
$GLOBALS['ilLog']->logStack();
throw new InvalidArgumentException('Missing parameter tree id');
}
$query = 'DELETE FROM '.$this->table_tree.
' WHERE '.$this->tree_pk.' = %s ';
$ilDB->manipulateF($query,array('integer'),array($a_tree_id));
return true;
}

+ Here is the call graph for this function:

ilTree::renumber (   $node_id = 1,
  $i = 1 
)

Wrapper for renumber.

This method locks the table tree (recursive) public

Parameters
integernode_id where to start (usually the root node)
integerfirst left value of start node (usually 1)
Returns
integer current left value of recursive call

Definition at line 2286 of file class.ilTree.php.

References __isMainTree(), __renumber(), and ilDB\LOCK_WRITE.

{
global $ilDB;
// LOCKED ###################################
if($this->__isMainTree())
{
/*
ilDB::_lockTables(array($this->table_tree => 'WRITE',
$this->table_obj_data => 'WRITE',
$this->table_obj_reference => 'WRITE',
'object_translation' => 'WRITE',
'object_data od' => 'WRITE',
'container_reference cr' => 'WRITE'));
*/
$ilDB->lockTables(
array(
0 => array('name' => $this->table_tree, 'type' => ilDB::LOCK_WRITE),
1 => array('name' => $this->table_obj_data, 'type' => ilDB::LOCK_WRITE),
2 => array('name' => $this->table_obj_reference, 'type' => ilDB::LOCK_WRITE),
3 => array('name' => 'object_translation', 'type' => ilDB::LOCK_WRITE),
4 => array('name' => 'object_data', 'type' => ilDB::LOCK_WRITE, 'alias' => 'od'),
5 => array('name' => 'container_reference', 'type' => ilDB::LOCK_WRITE, 'alias' => 'cr')
));
}
$return = $this->__renumber($node_id,$i);
if($this->__isMainTree())
{
$ilDB->unlockTables();
}
// LOCKED ###################################
return $return;
}

+ Here is the call graph for this function:

ilTree::resetInTreeCache ( )

Definition at line 358 of file class.ilTree.php.

Referenced by deleteTree().

{
$this->in_tree_cache = array();
}

+ Here is the caller graph for this function:

ilTree::saveSubTree (   $a_node_id,
  $a_set_deleted = false 
)

Use the wrapper moveToTrash save subtree: delete a subtree (defined by node_id) to a new tree with $this->tree_id -node_id.

This is neccessary for undelete functionality

Parameters
integernode_id
Returns
integer public
Exceptions
InvalidArgumentException
Deprecated:
since 4.4.0

Definition at line 1799 of file class.ilTree.php.

References $GLOBALS, $query, $res, $row, __isMainTree(), DB_FETCHMODE_ASSOC, getNodeTreeData(), getTreeImplementation(), ilDB\LOCK_WRITE, and ilObject\setDeletedDates().

Referenced by moveToTrash().

{
global $ilDB;
if(!$a_node_id)
{
$GLOBALS['ilLog']->logStack();
throw new InvalidArgumentException('No valid parameter given! $a_node_id: '.$a_node_id);
}
// LOCKED ###############################################
if($this->__isMainTree())
{
$ilDB->lockTables(
array(
0 => array('name' => 'tree', 'type' => ilDB::LOCK_WRITE),
1 => array('name' => 'object_reference', 'type' => ilDB::LOCK_WRITE)));
}
$query = $this->getTreeImplementation()->getSubTreeQuery($this->getNodeTreeData($a_node_id),'',false);
$res = $ilDB->query($query);
$subnodes = array();
while($row = $res->fetchRow(DB_FETCHMODE_ASSOC))
{
$subnodes[] = $row['child'];
}
if(!count($subnodes))
{
// Possibly already deleted
// Unlock locked tables before returning
if($this->__isMainTree())
{
$ilDB->unlockTables();
}
return false;
}
if($a_set_deleted)
{
include_once './Services/Object/classes/class.ilObject.php';
}
// netsted set <=> mp
$this->getTreeImplementation()->moveToTrash($a_node_id);
if($this->__isMainTree())
{
$ilDB->unlockTables();
}
// LOCKED ###############################################
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTree::setObjectTablePK (   $a_column_name)

set column containing primary key in object table public

Parameters
stringcolumn name
Returns
boolean true, when successfully set

Definition at line 418 of file class.ilTree.php.

Referenced by ilECSCmsTree\__construct(), and ilWorkspaceTree\__construct().

{
if (!isset($a_column_name))
{
$this->ilErr->raiseError(get_class($this)."::setObjectTablePK(): No column name given!",$this->ilErr->WARNING);
}
$this->obj_pk = $a_column_name;
return true;
}

+ Here is the caller graph for this function:

ilTree::setReferenceTablePK (   $a_column_name)

set column containing primary key in reference table public

Parameters
stringcolumn name
Returns
boolean true, when successfully set

Definition at line 401 of file class.ilTree.php.

Referenced by ilWorkspaceTree\__construct().

{
if (!isset($a_column_name))
{
$this->ilErr->raiseError(get_class($this)."::setReferenceTablePK(): No column name given!",$this->ilErr->WARNING);
}
$this->ref_pk = $a_column_name;
return true;
}

+ Here is the caller graph for this function:

ilTree::setRootId (   $a_root_id)

Definition at line 2126 of file class.ilTree.php.

Referenced by ilWorkspaceExplorer\__construct(), and ilWorkspaceTree\createTreeForUser().

{
$this->root_id = $a_root_id;
}

+ Here is the caller graph for this function:

ilTree::setTableNames (   $a_table_tree,
  $a_table_obj_data,
  $a_table_obj_reference = "" 
)

set table names The primary key of the table containing your object_data must be 'obj_id' You may use a reference table.

If no reference table is specified the given tree table is directly joined with the given object_data table. The primary key in object_data table and its foreign key in reference table must have the same name!

Parameters
stringtable name of tree table
stringtable name of object_data table
stringtable name of object_reference table (optional) public
Returns
boolean

Definition at line 378 of file class.ilTree.php.

References initTreeImplementation().

Referenced by ilECSCmsTree\__construct(), ilWorkspaceTree\__construct(), ilSkillTree\__construct(), ilTaxonomyTree\__construct(), ilSCORM2004Tree\__construct(), ilBookmarkTree\__construct(), ilLMTree\__construct(), ilLMPageObject\_splitPage(), ilLMPageObject\_splitPageNext(), ilObjContentObjectGUI\explorer(), ilSCORM2004ScoGUI\getExportResources(), ilAICCTree\ilAICCTree(), ilLMEditorGUI\ilLMEditorGUI(), ilLMExplorer\ilLMExplorer(), ilSCORMTree\ilSCORMTree(), ilMailFolderTableGUI\prepareHTML(), ilSCORM2004NodeGUI\putInTree(), ilLMObjectGUI\putInTree(), ilLMObject\putInTree(), ilSCORM2004ScoGUI\sahs_questions(), ilSCORM2004ScoGUI\sco_preview(), ilSCORM2004NodeGUI\setLocator(), and ilObjSCORM2004LearningModuleGUI\showTree().

{
if (!isset($a_table_tree) or !isset($a_table_obj_data))
{
$this->ilErr->raiseError(get_class($this)."::setTableNames(): Missing parameter! ".
"tree table: ".$a_table_tree." object data table: ".$a_table_obj_data,$this->ilErr->WARNING);
}
$this->table_tree = $a_table_tree;
$this->table_obj_data = $a_table_obj_data;
$this->table_obj_reference = $a_table_obj_reference;
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTree::setTreeId (   $a_tree_id)

set tree id public

Returns
integer tree id

Definition at line 2146 of file class.ilTree.php.

{
$this->tree_id = $a_tree_id;
}
ilTree::setTreeTablePK (   $a_column_name)

set column containing primary key in tree table public

Parameters
stringcolumn name
Returns
boolean true, when successfully set

Definition at line 435 of file class.ilTree.php.

Referenced by ilWorkspaceTree\__construct(), ilSkillTree\__construct(), ilTaxonomyTree\__construct(), ilSCORM2004Tree\__construct(), ilLMTree\__construct(), ilSCORM13Package\dbImportLM(), ilSCORM2004ScoGUI\getEditTree(), ilObjSCORM2004LearningModuleGUI\getEditTree(), ilAICCTree\ilAICCTree(), ilContObjParser\ilContObjParser(), ilSCORMTree\ilSCORMTree(), ilObjSCORM2004LearningModuleGUI\insertAsset(), ilObjSCORM2004LearningModuleGUI\insertChapter(), ilObjSCORM2004LearningModuleGUI\insertPage(), ilObjSCORM2004LearningModuleGUI\insertScenario(), ilObjSCORM2004LearningModuleGUI\insertSco(), ilObjSCORM2004LearningModuleGUI\insertTemplate(), and ilSCORM2004Node\putInTree().

{
if (!isset($a_column_name))
{
$this->ilErr->raiseError(get_class($this)."::setTreeTablePK(): No column name given!",$this->ilErr->WARNING);
}
$this->tree_pk = $a_column_name;
return true;
}

+ Here is the caller graph for this function:

ilTree::useCache (   $a_use = true)

Use Cache (usually activated)

Definition at line 261 of file class.ilTree.php.

Referenced by ilECSCmsTree\__construct(), and ilLMTree\__construct().

{
$this->use_cache = $a_use;
}

+ Here is the caller graph for this function:

Field Documentation

ilTree::$depth_cache = array()
protected

Definition at line 134 of file class.ilTree.php.

Referenced by getDepthCache().

ilTree::$gap

Definition at line 132 of file class.ilTree.php.

Referenced by getGap().

ilTree::$ilias

Definition at line 42 of file class.ilTree.php.

Referenced by ilTree().

ilTree::$in_tree_cache = array()
protected

Definition at line 136 of file class.ilTree.php.

ilTree::$log

Definition at line 50 of file class.ilTree.php.

Referenced by getNodePathForTitlePath().

ilTree::$obj_pk

Definition at line 99 of file class.ilTree.php.

Referenced by getNodePathForTitlePath(), and ilWorkspaceTree\lookupObjectId().

ilTree::$parent_cache = array()
protected

Definition at line 135 of file class.ilTree.php.

Referenced by getParentCache().

ilTree::$ref_pk

Definition at line 92 of file class.ilTree.php.

Referenced by ilWorkspaceTree\lookupNodeId().

ilTree::$root_id
ilTree::$table_obj_data

Definition at line 78 of file class.ilTree.php.

Referenced by getObjectDataTable().

ilTree::$table_obj_reference

Definition at line 85 of file class.ilTree.php.

Referenced by getTableReference().

ilTree::$table_tree

Definition at line 71 of file class.ilTree.php.

Referenced by getTreeTable().

ilTree::$tree_id

Definition at line 64 of file class.ilTree.php.

Referenced by getNodeData(), and getTreeId().

ilTree::$tree_impl = NULL
private

Definition at line 138 of file class.ilTree.php.

Referenced by getTreeImplementation().

ilTree::$tree_pk

Definition at line 106 of file class.ilTree.php.

Referenced by getNodeData(), and getTreePk().

const ilTree::POS_FIRST_NODE = -1

Definition at line 27 of file class.ilTree.php.

Referenced by ilNestedSetTree\insertNode().

const ilTree::POS_LAST_NODE = -2

Definition at line 26 of file class.ilTree.php.

const ilTree::RELATION_CHILD = 1
const ilTree::RELATION_EQUALS = 4
const ilTree::RELATION_NONE = 5
const ilTree::RELATION_PARENT = 2
const ilTree::RELATION_SIBLING = 3

The documentation for this class was generated from the following file: