ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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

 __construct (int $a_tree_id, int $a_root_id=0, ?ilDBInterface $db=null)
 
 initTreeImplementation ()
 Init tree implementation. More...
 
 getTreeImplementation ()
 Get tree implementation. More...
 
 useCache (bool $a_use=true)
 Use Cache (usually activated) More...
 
 getDepthCache ()
 Get depth cache. More...
 
 getParentCache ()
 Get parent cache. More...
 
 initLangCode ()
 Do not use it Store user language. More...
 
 getTreeTable ()
 Get tree table name. More...
 
 getObjectDataTable ()
 Get object data table. More...
 
 getTreePk ()
 Get tree primary key. More...
 
 getTableReference ()
 Get reference table if available. More...
 
 getGap ()
 Get default gap. More...
 
 setTableNames (string $a_table_tree, string $a_table_obj_data, string $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. More...
 
 setReferenceTablePK (string $a_column_name)
 set column containing primary key in reference table More...
 
 setObjectTablePK (string $a_column_name)
 set column containing primary key in object table More...
 
 setTreeTablePK (string $a_column_name)
 set column containing primary key in tree table More...
 
 buildJoin ()
 build join depending on table settings @access private More...
 
 getRelation (int $a_node_a, int $a_node_b)
 Get relation of two nodes. More...
 
 getRelationOfNodes (array $a_node_a_arr, array $a_node_b_arr)
 get relation of two nodes by node data More...
 
 getChildIds (int $a_node)
 
 getChilds (int $a_node_id, string $a_order="", string $a_direction="ASC")
 get child nodes of given node More...
 
 getFilteredChilds (array $a_filter, int $a_node, string $a_order="", string $a_direction="ASC")
 get child nodes of given node (exclude filtered obj_types) More...
 
 getChildsByType (int $a_node_id, string $a_type)
 get child nodes of given node by object type More...
 
 getChildsByTypeFilter (int $a_node_id, array $a_types, string $a_order="", string $a_direction="ASC")
 get child nodes of given node by object type More...
 
 insertNodeFromTrash (int $a_source_id, int $a_target_id, int $a_tree_id, int $a_pos=self::POS_LAST_NODE, bool $a_reset_deleted_date=false)
 Insert node from trash deletes trash entry. More...
 
 insertNode (int $a_node_id, int $a_parent_id, int $a_pos=self::POS_LAST_NODE, bool $a_reset_deletion_date=false)
 insert new node with node_id under parent node with parent_id More...
 
 getFilteredSubTree (int $a_node_id, array $a_filter=[])
 get filtered subtree get all subtree nodes beginning at a specific node excluding specific object types and their child nodes. More...
 
 getSubTreeIds (int $a_ref_id)
 Get all ids of subnodes. More...
 
 getSubTree (array $a_node, bool $a_with_data=true, array $a_type=[])
 get all nodes in the subtree under specified node More...
 
 deleteTree (array $a_node)
 delete node and the whole subtree under this node More...
 
 validateParentRelations ()
 Validate parent relations of tree. More...
 
 getPathFull (int $a_endnode_id, int $a_startnode_id=0)
 get path from a given startnode to a given endnode if startnode is not given the rootnode is startnode. More...
 
 preloadDepthParent (array $a_node_ids)
 Preload depth/parent. More...
 
 getPathId (int $a_endnode_id, int $a_startnode_id=0)
 get path from a given startnode to a given endnode if startnode is not given the rootnode is startnode More...
 
 getNodePath (int $a_endnode_id, int $a_startnode_id=0)
 Returns the node path for the specified object reference. More...
 
 checkTree ()
 check consistence of tree all left & right values are checked if they are exists only once More...
 
 checkTreeChilds (bool $a_no_zero_child=true)
 check, if all childs of tree nodes exist in object table More...
 
 getMaximumDepth ()
 Return the current maximum depth in the tree. More...
 
 getDepth (int $a_node_id)
 return depth of a node in tree More...
 
 getNodeTreeData (int $a_node_id)
 return all columns of tabel tree More...
 
 getNodeData (int $a_node_id, ?int $a_tree_pk=null)
 get all information of a node. More...
 
 fetchNodeData (array $a_row)
 get data of parent node from tree and object_data More...
 
 isInTree (?int $a_node_id)
 get all information of a node. More...
 
 getParentNodeData (int $a_node_id)
 get data of parent node from tree and object_data More...
 
 isGrandChild (int $a_startnode_id, int $a_querynode_id)
 checks if a node is in the path of an other node More...
 
 addTree (int $a_tree_id, int $a_node_id=-1)
 create a new tree to do: ??? More...
 
 removeTree (int $a_tree_id)
 remove an existing tree More...
 
 moveToTrash (int $a_node_id, bool $a_set_deleted=false, int $a_deleted_by=0)
 Move node to trash bin. More...
 
 isDeleted (int $a_node_id)
 This is a wrapper for isSaved() with a more useful name. More...
 
 preloadDeleted (array $a_node_ids)
 Preload deleted information. More...
 
 getSavedNodeData (int $a_parent_id)
 get data saved/deleted nodes More...
 
 getSavedNodeObjIds (array $a_obj_ids)
 get object id of saved/deleted nodes More...
 
 getParentId (int $a_node_id)
 get parent id of given node More...
 
 getChildSequenceNumber (array $a_node, string $type="")
 get sequence number of node in sibling sequence More...
 
 readRootId ()
 
 getRootId ()
 
 setRootId (int $a_root_id)
 
 getTreeId ()
 
 fetchSuccessorNode (int $a_node_id, string $a_type="")
 get node data of successor node More...
 
 fetchPredecessorNode (int $a_node_id, string $a_type="")
 get node data of predecessor node More...
 
 renumber (int $node_id=1, int $i=1)
 Wrapper for renumber. More...
 
 checkForParentType (int $a_ref_id, string $a_type, bool $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');. More...
 
 __isMainTree ()
 Check if operations are done on main tree. More...
 
 moveTree (int $a_source_id, int $a_target_id, int $a_location=self::POS_LAST_NODE)
 Move Tree Implementation @access public. More...
 
 getRbacSubtreeInfo (int $a_endnode_id)
 This method is used for change existing objects and returns all necessary information for this action. More...
 
 getSubTreeQuery (int $a_node_id, array $a_fields=[], array $a_types=[], bool $a_force_join_reference=false)
 Get tree subtree query. More...
 
 getTrashSubTreeQuery (int $a_node_id, array $a_fields=[], array $a_types=[], bool $a_force_join_reference=false)
 
 getSubTreeFilteredByObjIds (int $a_node_id, array $a_obj_ids, array $a_fields=[])
 get all node ids in the subtree under specified node id, filter by object ids More...
 
 deleteNode (int $a_tree_id, int $a_node_id)
 
 lookupTrashedObjectTypes ()
 Lookup object types in trash. More...
 

Static Public Member Functions

static lookupTreesForNode (int $node_id)
 
static _removeEntry (int $a_tree, int $a_child, string $a_db_table="tree")
 STATIC METHOD Removes a single entry from a tree. More...
 

Data Fields

const TREE_TYPE_MATERIALIZED_PATH = 'mp'
 
const TREE_TYPE_NESTED_SET = 'ns'
 
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
 

Protected Member Functions

 isCacheUsed ()
 Check if cache is active. More...
 
 resetInTreeCache ()
 reset in tree cache More...
 
 fetchTranslationFromObjectDataCache (array $a_obj_ids)
 Get translation data from object cache (trigger in object cache on preload) More...
 
 __renumber (int $node_id=1, int $i=1)
 This method is private. More...
 
 __checkDelete (array $a_node)
 Check for deleteTree() compares a subtree of a given node by checking lft, rgt against parent relation. More...
 
 __getSubTreeByParentRelation (int $a_node_id, array &$parent_childs)
 
 __validateSubtrees (array &$lft_childs, array $parent_childs)
 
 isRepositoryTree ()
 check if current tree instance operates on repository tree table More...
 

Protected Attributes

const DEFAULT_LANGUAGE = 'en'
 
const DEFAULT_GAP = 50
 
ilLogger $logger
 
ilDBInterface $db
 
ilAppEventHandler $eventHandler
 
int $root_id
 points to root node (may be a subtree) More...
 
int $tree_id
 to use different trees in one db-table More...
 
string $table_tree
 table name of tree table More...
 
string $table_obj_data
 table name of object_data table More...
 
string $table_obj_reference
 table name of object_reference table More...
 
string $ref_pk
 column name containing primary key in reference table More...
 
string $obj_pk
 column name containing primary key in object table More...
 
string $tree_pk
 column name containing tree id in tree table More...
 
bool $use_cache
 
array $oc_preloaded = []
 
array $depth_cache = []
 
array $parent_cache = []
 
array $in_tree_cache = []
 
array $translation_cache = []
 
array $parent_type_cache = []
 
array $is_saved_cache = []
 

Private Attributes

string $lang_code
 
int $gap
 Size of the gaps to be created in the nested sets sequence numbering of the tree nodes. More...
 
ilTreeImplementation $tree_impl = null
 
array $path_id_cache = []
 

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

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

Constructor & Destructor Documentation

◆ __construct()

ilTree::__construct ( int  $a_tree_id,
int  $a_root_id = 0,
?ilDBInterface  $db = null 
)
Exceptions
InvalidArgumentException

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

137 {
138 global $DIC;
139
140 $this->db = $db ?? $DIC->database();
141 $this->logger = ilLoggerFactory::getLogger('tree');
142 //$this->logger = $DIC->logger()->tree();
143 if (isset($DIC['ilAppEventHandler'])) {
144 $this->eventHandler = $DIC['ilAppEventHandler'];
145 }
146
147 $this->lang_code = self::DEFAULT_LANGUAGE;
148
149 if (func_num_args() > 3) {
150 $this->logger->error("Wrong parameter count!");
151 $this->logger->logStack(ilLogLevel::ERROR);
152 throw new InvalidArgumentException("Wrong parameter count!");
153 }
154
155 if ($a_root_id > 0) {
156 $this->root_id = $a_root_id;
157 } else {
158 $this->root_id = ROOT_FOLDER_ID;
159 }
160
161 $this->tree_id = $a_tree_id;
162 $this->table_tree = 'tree';
163 $this->table_obj_data = 'object_data';
164 $this->table_obj_reference = 'object_reference';
165 $this->ref_pk = 'ref_id';
166 $this->obj_pk = 'obj_id';
167 $this->tree_pk = 'tree';
168
169 $this->use_cache = true;
170
171 // By default, we create gaps in the tree sequence numbering for 50 nodes
172 $this->gap = self::DEFAULT_GAP;
173
174 // init tree implementation
175 $this->initTreeImplementation();
176 }
static getLogger(string $a_component_id)
Get component logger.
const DEFAULT_GAP
ilDBInterface $db
initTreeImplementation()
Init tree implementation.
const DEFAULT_LANGUAGE
const ROOT_FOLDER_ID
Definition: constants.php:32
global $DIC
Definition: shib_login.php:26

References $db, $DIC, DEFAULT_GAP, DEFAULT_LANGUAGE, ilLogLevel\ERROR, ilLoggerFactory\getLogger(), initTreeImplementation(), ILIAS\Repository\logger(), and ROOT_FOLDER_ID.

+ Here is the call graph for this function:

Member Function Documentation

◆ __checkDelete()

ilTree::__checkDelete ( array  $a_node)
protected

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

Exceptions
ilInvalidTreeStructureException
Deprecated:
since 4.4.0

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

1791 : bool
1792 {
1793 $query = $this->getTreeImplementation()->getSubTreeQuery($a_node, [], false);
1794 $this->logger->debug($query);
1795 $res = $this->db->query($query);
1796
1797 $counter = (int) $lft_childs = [];
1798 while ($row = $this->db->fetchObject($res)) {
1799 $lft_childs[$row->child] = (int) $row->parent;
1800 ++$counter;
1801 }
1802
1803 // CHECK FOR DUPLICATE CHILD IDS
1804 if ($counter != count($lft_childs)) {
1805 $message = 'Duplicate entries for "child" in maintree! $a_node_id: ' . $a_node['child'];
1806
1807 $this->logger->error($message);
1809 }
1810
1811 // GET SUBTREE BY PARENT RELATION
1812 $parent_childs = [];
1813 $this->__getSubTreeByParentRelation((int)$a_node['child'], $parent_childs);
1814 $this->__validateSubtrees($lft_childs, $parent_childs);
1815
1816 return true;
1817 }
Thrown if invalid tree strucutes are found.
__validateSubtrees(array &$lft_childs, array $parent_childs)
getTreeImplementation()
Get tree implementation.
__getSubTreeByParentRelation(int $a_node_id, array &$parent_childs)
$res
Definition: ltiservices.php:69
$counter
$message
Definition: xapiexit.php:31

References $counter, $message, $res, ILIAS\Repository\int(), and ILIAS\Repository\logger().

+ Here is the call graph for this function:

◆ __getSubTreeByParentRelation()

ilTree::__getSubTreeByParentRelation ( int  $a_node_id,
array &  $parent_childs 
)
protected
Exceptions
ilInvalidTreeStructureException
Deprecated:
since 4.4.0

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

1823 : bool
1824 {
1825 // GET PARENT ID
1826 $query = 'SELECT * FROM ' . $this->table_tree . ' ' .
1827 'WHERE child = %s ' .
1828 'AND tree = %s ';
1829 $res = $this->db->queryF($query, array('integer', 'integer'), array(
1830 $a_node_id,
1831 $this->tree_id
1832 ));
1833
1834 $counter = 0;
1835 while ($row = $this->db->fetchObject($res)) {
1836 $parent_childs[$a_node_id] = (int) $row->parent;
1837 ++$counter;
1838 }
1839 // MULTIPLE ENTRIES
1840 if ($counter > 1) {
1841 $message = 'Multiple entries in maintree! $a_node_id: ' . $a_node_id;
1842
1843 $this->logger->error($message);
1845 }
1846
1847 // GET ALL CHILDS
1848 $query = 'SELECT * FROM ' . $this->table_tree . ' ' .
1849 'WHERE parent = %s ';
1850 $res = $this->db->queryF($query, array('integer'), array($a_node_id));
1851
1852 while ($row = $this->db->fetchObject($res)) {
1853 // RECURSION
1854 $this->__getSubTreeByParentRelation((int) $row->child, $parent_childs);
1855 }
1856 return true;
1857 }

References $counter, $message, $res, ILIAS\Repository\int(), and ILIAS\Repository\logger().

+ Here is the call graph for this function:

◆ __isMainTree()

ilTree::__isMainTree ( )

Check if operations are done on main tree.

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

1780 : bool
1781 {
1782 return $this->table_tree === 'tree';
1783 }

Referenced by initTreeImplementation(), and isCacheUsed().

+ Here is the caller graph for this function:

◆ __renumber()

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

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)

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

1630 : int
1631 {
1632 if ($this->isRepositoryTree()) {
1633 $query = 'UPDATE ' . $this->table_tree . ' SET lft = %s WHERE child = %s';
1634 $this->db->manipulateF(
1635 $query,
1636 array('integer', 'integer'),
1637 array(
1638 $i,
1639 $node_id
1640 )
1641 );
1642 } else {
1643 $query = 'UPDATE ' . $this->table_tree . ' SET lft = %s WHERE child = %s AND tree = %s';
1644 $this->db->manipulateF(
1645 $query,
1646 array('integer', 'integer', 'integer'),
1647 array(
1648 $i,
1649 $node_id,
1650 $this->tree_id
1651 )
1652 );
1653 }
1654
1655 $query = 'SELECT * FROM ' . $this->table_tree . ' ' .
1656 'WHERE parent = ' . $this->db->quote($node_id, 'integer') . ' ' .
1657 'ORDER BY lft';
1658 $res = $this->db->query($query);
1659
1660 $childs = [];
1661 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1662 $childs[] = (int) $row->child;
1663 }
1664
1665 foreach ($childs as $child) {
1666 $i = $this->__renumber($child, $i + 1);
1667 }
1668 $i++;
1669
1670 // Insert a gap at the end of node, if the node has children
1671 if (count($childs) > 0) {
1672 $i += $this->gap * 2;
1673 }
1674
1675 if ($this->isRepositoryTree()) {
1676 $query = 'UPDATE ' . $this->table_tree . ' SET rgt = %s WHERE child = %s';
1677 $res = $this->db->manipulateF(
1678 $query,
1679 array('integer', 'integer'),
1680 array(
1681 $i,
1682 $node_id
1683 )
1684 );
1685 } else {
1686 $query = 'UPDATE ' . $this->table_tree . ' SET rgt = %s WHERE child = %s AND tree = %s';
1687 $res = $this->db->manipulateF($query, array('integer', 'integer', 'integer'), array(
1688 $i,
1689 $node_id,
1690 $this->tree_id
1691 ));
1692 }
1693 return $i;
1694 }
isRepositoryTree()
check if current tree instance operates on repository tree table
__renumber(int $node_id=1, int $i=1)
This method is private.

References $res, ilDBConstants\FETCHMODE_OBJECT, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ __validateSubtrees()

ilTree::__validateSubtrees ( array &  $lft_childs,
array  $parent_childs 
)
protected
Parameters
array$lft_childs
array$parent_childs
Returns
bool
Exceptions
ilInvalidTreeStructureException
Deprecated:
since 4.4.0

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

1866 : bool
1867 {
1868 // SORT BY KEY
1869 ksort($lft_childs);
1870 ksort($parent_childs);
1871
1872 $this->logger->debug('left childs ' . print_r($lft_childs, true));
1873 $this->logger->debug('parent childs ' . print_r($parent_childs, true));
1874
1875 if (count($lft_childs) != count($parent_childs)) {
1876 $message = '(COUNT) Tree is corrupted! Left/Right subtree does not comply with parent relation';
1877 $this->logger->error($message);
1879 }
1880
1881 foreach ($lft_childs as $key => $value) {
1882 if ($parent_childs[$key] != $value) {
1883 $message = '(COMPARE) Tree is corrupted! Left/Right subtree does not comply with parent relation';
1884 $this->logger->error($message);
1886 }
1887 if ($key == ROOT_FOLDER_ID) {
1888 $message = '(ROOT_FOLDER) Tree is corrupted! Tried to delete root folder';
1889 $this->logger->error($message);
1891 }
1892 }
1893 return true;
1894 }

References $message, ILIAS\Repository\logger(), and ROOT_FOLDER_ID.

+ Here is the call graph for this function:

◆ _removeEntry()

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

STATIC METHOD Removes a single entry from a tree.

The tree structure is NOT updated!

Exceptions
InvalidArgumentException

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

1750 : void
1751 {
1752 global $DIC;
1753
1754 $db = $DIC->database();
1755
1756 if ($a_db_table === 'tree') {
1757 if ($a_tree == 1 && $a_child == ROOT_FOLDER_ID) {
1758 $message = sprintf(
1759 'Tried to delete root node! $a_tree: %s $a_child: %s',
1760 $a_tree,
1761 $a_child
1762 );
1763 ilLoggerFactory::getLogger('tree')->error($message);
1764 throw new InvalidArgumentException($message);
1765 }
1766 }
1767
1768 $query = 'DELETE FROM ' . $a_db_table . ' ' .
1769 'WHERE tree = %s ' .
1770 'AND child = %s ';
1771 $res = $db->manipulateF($query, array('integer', 'integer'), array(
1772 $a_tree,
1773 $a_child
1774 ));
1775 }
manipulateF(string $query, array $types, array $values)

References $DIC, $message, $res, ilLoggerFactory\getLogger(), ilDBInterface\manipulateF(), and ROOT_FOLDER_ID.

Referenced by ilSystemCheckTrash\removeSelectedFromSystem().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addTree()

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

create a new tree to do: ???

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

1287 : bool
1288 {
1289 global $DIC;
1290
1291 // FOR SECURITY addTree() IS NOT ALLOWED ON MAIN TREE
1292 if ($this->__isMainTree()) {
1293 $message = sprintf(
1294 'Operation not allowed on main tree! $a_tree_if: %s $a_node_id: %s',
1295 $a_tree_id,
1296 $a_node_id
1297 );
1298 $this->logger->error($message);
1299 throw new InvalidArgumentException($message);
1300 }
1301
1302 if ($a_node_id <= 0) {
1303 $a_node_id = $a_tree_id;
1304 }
1305
1306 $query = 'INSERT INTO ' . $this->table_tree . ' (' .
1307 $this->tree_pk . ', child,parent,lft,rgt,depth) ' .
1308 'VALUES ' .
1309 '(%s,%s,%s,%s,%s,%s)';
1310 $res = $this->db->manipulateF(
1311 $query,
1312 array('integer', 'integer', 'integer', 'integer', 'integer', 'integer'),
1313 array(
1314 $a_tree_id,
1315 $a_node_id,
1316 0,
1317 1,
1318 2,
1319 1
1320 )
1321 );
1322
1323 return true;
1324 }
__isMainTree()
Check if operations are done on main tree.

References $DIC, $message, $res, and ILIAS\Repository\logger().

+ Here is the call graph for this function:

◆ buildJoin()

ilTree::buildJoin ( )

build join depending on table settings @access private

Returns
string

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

380 : string
381 {
382 if ($this->table_obj_reference) {
383 // Use inner join instead of left join to improve performance
384 return "JOIN " . $this->table_obj_reference . " ON " . $this->table_tree . ".child=" . $this->table_obj_reference . "." . $this->ref_pk . " " .
385 "JOIN " . $this->table_obj_data . " ON " . $this->table_obj_reference . "." . $this->obj_pk . "=" . $this->table_obj_data . "." . $this->obj_pk . " ";
386 } else {
387 // Use inner join instead of left join to improve performance
388 return "JOIN " . $this->table_obj_data . " ON " . $this->table_tree . ".child=" . $this->table_obj_data . "." . $this->obj_pk . " ";
389 }
390 }

Referenced by ilSCORMTree\getChilds().

+ Here is the caller graph for this function:

◆ checkForParentType()

ilTree::checkForParentType ( int  $a_ref_id,
string  $a_type,
bool  $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');.

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

1700 : int
1701 {
1702 // #12577
1703 $cache_key = $a_ref_id . '.' . $a_type . '.' . ((int) $a_exclude_source_check);
1704
1705 // Try to return a cached result
1706 if ($this->isCacheUsed() &&
1707 array_key_exists($cache_key, $this->parent_type_cache)) {
1708 return (int) $this->parent_type_cache[$cache_key];
1709 }
1710
1711 // Store up to 1000 results in cache
1712 $do_cache = ($this->__isMainTree() && count($this->parent_type_cache) < 1000);
1713
1714 // ref_id is not in tree
1715 if (!$this->isInTree($a_ref_id)) {
1716 if ($do_cache) {
1717 $this->parent_type_cache[$cache_key] = false;
1718 }
1719 return 0;
1720 }
1721
1722 $path = array_reverse($this->getPathFull($a_ref_id));
1723
1724 // remove first path entry as it is requested node
1725 if ($a_exclude_source_check) {
1726 array_shift($path);
1727 }
1728
1729 foreach ($path as $node) {
1730 // found matching parent
1731 if ($node["type"] == $a_type) {
1732 if ($do_cache) {
1733 $this->parent_type_cache[$cache_key] = (int) $node["child"];
1734 }
1735 return (int) $node["child"];
1736 }
1737 }
1738
1739 if ($do_cache) {
1740 $this->parent_type_cache[$cache_key] = false;
1741 }
1742 return 0;
1743 }
isCacheUsed()
Check if cache is active.
isInTree(?int $a_node_id)
get all information of a node.
getPathFull(int $a_endnode_id, int $a_startnode_id=0)
get path from a given startnode to a given endnode if startnode is not given the rootnode is startnod...
$path
Definition: ltiservices.php:30

References $path, and ILIAS\Repository\int().

Referenced by ilEventParticipants\__read(), ilAppointmentPresentationGUI\addContainerInfo(), ilObjSessionGUI\eventsListObject(), ilObjFolderGUI\forwardToTimingsView(), ilContainerSortingSettings\getInheritedSettings(), ilLPStatusCollection\getMembers(), ilObjFolder\getViewMode(), ilObjSessionGUI\initContainer(), ilObjectRolePermissionTableGUI\initFilter(), ilRepositoryExplorer\isVisible(), ilObjectGUI\isVisible(), ilObjFolderGUI\modifyItemGUI(), ilObjSessionGUI\modifyItemGUI(), ilObject\selfOrParentWithRatingEnabled(), and ilObjBlogGUI\setSettingsSubTabs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkTree()

ilTree::checkTree ( )

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

Todo:
remove exception for "check-method"

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

924 : bool
925 {
926 $types = array('integer');
927 $query = 'SELECT lft,rgt FROM ' . $this->table_tree . ' ' .
928 'WHERE ' . $this->tree_pk . ' = %s ';
929
930 $res = $this->db->queryF($query, $types, array($this->tree_id));
931 $lft = $rgt = [];
932 while ($row = $this->db->fetchObject($res)) {
933 $lft[] = $row->lft;
934 $rgt[] = $row->rgt;
935 }
936
937 $all = array_merge($lft, $rgt);
938 $uni = array_unique($all);
939
940 if (count($all) != count($uni)) {
941 $message = 'Tree is corrupted!';
942 $this->logger->error($message);
944 }
945 return true;
946 }

References $message, $res, and ILIAS\Repository\logger().

+ Here is the call graph for this function:

◆ checkTreeChilds()

ilTree::checkTreeChilds ( bool  $a_no_zero_child = true)

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

Exceptions
ilInvalidTreeStructureException

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

952 : bool
953 {
954 $query = 'SELECT * FROM ' . $this->table_tree . ' ' .
955 'WHERE ' . $this->tree_pk . ' = %s ' .
956 'ORDER BY lft';
957 $r1 = $this->db->queryF($query, array('integer'), array($this->tree_id));
958
959 while ($row = $this->db->fetchAssoc($r1)) {
960 //echo "tree:".$row[$this->tree_pk].":lft:".$row["lft"].":rgt:".$row["rgt"].":child:".$row["child"].":<br>";
961 if (($row["child"] == 0) && $a_no_zero_child) {
962 $message = "Tree contains child with ID 0!";
963 $this->logger->error($message);
965 }
966
967 if ($this->table_obj_reference) {
968 // get object reference data
969 $query = 'SELECT * FROM ' . $this->table_obj_reference . ' WHERE ' . $this->ref_pk . ' = %s ';
970 $r2 = $this->db->queryF($query, array('integer'), array($row['child']));
971
972 //echo "num_childs:".$r2->numRows().":<br>";
973 if ($r2->numRows() == 0) {
974 $message = "No Object-to-Reference entry found for ID " . $row["child"] . "!";
975 $this->logger->error($message);
977 }
978 if ($r2->numRows() > 1) {
979 $message = "More Object-to-Reference entries found for ID " . $row["child"] . "!";
980 $this->logger->error($message);
982 }
983
984 // get object data
985 $obj_ref = $this->db->fetchAssoc($r2);
986
987 $query = 'SELECT * FROM ' . $this->table_obj_data . ' WHERE ' . $this->obj_pk . ' = %s';
988 $r3 = $this->db->queryF($query, array('integer'), array($obj_ref[$this->obj_pk]));
989 if ($r3->numRows() == 0) {
990 $message = " No child found for ID " . $obj_ref[$this->obj_pk] . "!";
991 $this->logger->error($message);
993 }
994 if ($r3->numRows() > 1) {
995 $message = "More childs found for ID " . $obj_ref[$this->obj_pk] . "!";
996 $this->logger->error($message);
998 }
999 } else {
1000 // get only object data
1001 $query = 'SELECT * FROM ' . $this->table_obj_data . ' WHERE ' . $this->obj_pk . ' = %s';
1002 $r2 = $this->db->queryF($query, array('integer'), array($row['child']));
1003 //echo "num_childs:".$r2->numRows().":<br>";
1004 if ($r2->numRows() == 0) {
1005 $message = "No child found for ID " . $row["child"] . "!";
1006 $this->logger->error($message);
1008 }
1009 if ($r2->numRows() > 1) {
1010 $message = "More childs found for ID " . $row["child"] . "!";
1011 $this->logger->error($message);
1013 }
1014 }
1015 }
1016 return true;
1017 }
string $obj_pk
column name containing primary key in object table

References $message, and ILIAS\Repository\logger().

+ Here is the call graph for this function:

◆ deleteNode()

ilTree::deleteNode ( int  $a_tree_id,
int  $a_node_id 
)

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

1998 : void
1999 {
2000 $query = 'DELETE FROM tree where ' .
2001 'child = ' . $this->db->quote($a_node_id, 'integer') . ' ' .
2002 'AND tree = ' . $this->db->quote($a_tree_id, 'integer');
2003 $this->db->manipulate($query);
2004
2005 $this->eventHandler->raise(
2006 "components/ILIAS/Tree",
2007 "deleteNode",
2008 [
2009 'tree' => $this->table_tree,
2010 'node_id' => $a_node_id,
2011 'tree_id' => $a_tree_id
2012 ]
2013 );
2014 }

◆ deleteTree()

ilTree::deleteTree ( array  $a_node)

delete node and the whole subtree under this node

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

758 : void
759 {
760 if ($this->__isMainTree()) {
761 // moved to trash and then deleted.
762 if (!$this->__checkDelete($a_node)) {
763 $this->logger->logStack(ilLogLevel::ERROR);
764 throw new ilInvalidTreeStructureException('Deletion canceled due to invalid tree structure.' . print_r(
765 $a_node,
766 true
767 ));
768 }
769 }
770 $this->getTreeImplementation()->deleteTree((int) $a_node['child']);
771 $this->resetInTreeCache();
772 }
resetInTreeCache()
reset in tree cache
__checkDelete(array $a_node)
Check for deleteTree() compares a subtree of a given node by checking lft, rgt against parent relatio...

References ilLogLevel\ERROR, and ILIAS\Repository\logger().

Referenced by ILIAS\Skill\Node\SkillTreeNodeManager\clipboardCut(), and ilObjContentObjectGUI\confirmedDelete().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fetchNodeData()

ilTree::fetchNodeData ( array  $a_row)

get data of parent node from tree and object_data

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

1112 : array
1113 {
1114 global $DIC;
1115
1116 $objDefinition = $DIC['objDefinition'];
1117 $lng = $DIC['lng'];
1118
1119 $data = $a_row;
1120 $data["desc"] = (string) ($a_row["description"] ?? ''); // for compability
1121
1122 // multilingual support systemobjects (sys) & categories (db)
1123 $translation_type = '';
1124 if (is_object($objDefinition)) {
1125 $translation_type = $objDefinition->getTranslationType($data["type"] ?? '');
1126 }
1127
1128 if ($translation_type == "sys") {
1129 if ($data["type"] == "rolf" && $data["obj_id"] != ROLE_FOLDER_ID) {
1130 $data["description"] = (string) $lng->txt("obj_" . $data["type"] . "_local_desc") . $data["title"] . $data["desc"];
1131 $data["desc"] = $lng->txt("obj_" . $data["type"] . "_local_desc") . $data["title"] . $data["desc"];
1132 $data["title"] = $lng->txt("obj_" . $data["type"] . "_local");
1133 } else {
1134 $data["title"] = $lng->txt("obj_" . $data["type"]);
1135 $data["description"] = $lng->txt("obj_" . $data["type"] . "_desc");
1136 $data["desc"] = $lng->txt("obj_" . $data["type"] . "_desc");
1137 }
1138 } elseif ($translation_type == "db") {
1139 // Try to retrieve object translation from cache
1140 $lang_code = ''; // This did never work, because it was undefined before
1141 if ($this->isCacheUsed() &&
1142 array_key_exists($data["obj_id"] . '.' . $lang_code, $this->translation_cache)) {
1143 $key = $data["obj_id"] . '.' . $lang_code;
1144 $data["title"] = $this->translation_cache[$key]['title'];
1145 $data["description"] = $this->translation_cache[$key]['description'];
1146 $data["desc"] = $this->translation_cache[$key]['desc'];
1147 } else {
1148 // Object translation is not in cache, read it from database
1149 $query = 'SELECT title,description FROM object_translation ' .
1150 'WHERE obj_id = %s ' .
1151 'AND lang_code = %s ';
1152
1153 $res = $this->db->queryF($query, array('integer', 'text'), array(
1154 $data['obj_id'],
1155 $this->lang_code
1156 ));
1157 $row = $this->db->fetchObject($res);
1158
1159 if ($row) {
1160 $data["title"] = (string) $row->title;
1161 $data["description"] = ilStr::shortenTextExtended((string) $row->description, ilObject::DESC_LENGTH, true);
1162 $data["desc"] = (string) $row->description;
1163 }
1164
1165 // Store up to 1000 object translations in cache
1166 if ($this->isCacheUsed() && count($this->translation_cache) < 1000) {
1167 $key = $data["obj_id"] . '.' . $lang_code;
1168 $this->translation_cache[$key] = [];
1169 $this->translation_cache[$key]['title'] = $data["title"];
1170 $this->translation_cache[$key]['description'] = $data["description"];
1171 $this->translation_cache[$key]['desc'] = $data["desc"];
1172 }
1173 }
1174 }
1175
1176 // TODO: Handle this switch by module.xml definitions
1177 if (isset($data['type']) && ($data['type'] == 'crsr' || $data['type'] == 'catr' || $data['type'] == 'grpr' || $data['type'] === 'prgr')) {
1178 $data['title'] = ilContainerReference::_lookupTitle((int) $data['obj_id']);
1179 }
1180 return $data;
1181 }
static _lookupTitle(int $obj_id)
const DESC_LENGTH
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
string $lang_code
const ROLE_FOLDER_ID
Definition: constants.php:34
global $lng
Definition: privfeed.php:31

References $data, $DIC, $lng, $res, ilContainerReference\_lookupTitle(), ilObject\DESC_LENGTH, ROLE_FOLDER_ID, and ilStr\shortenTextExtended().

Referenced by ilSCORMTree\getChilds().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fetchPredecessorNode()

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

get node data of predecessor node

Exceptions
LogicException

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

1590 : ?array
1591 {
1592 $tree_implementation = $this->getTreeImplementation();
1593 if ($tree_implementation instanceof ilNestedSetTree) {
1594 return $tree_implementation->fetchPredecessorNode($a_node_id, $a_type);
1595 } else {
1596 $message = "This tree is not part of ilNestedSetTree.";
1597 $this->logger->error($message);
1598 throw new LogicException($message);
1599 }
1600 }
Base class for nested set path based trees.

References $message, and ILIAS\Repository\logger().

+ Here is the call graph for this function:

◆ fetchSuccessorNode()

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

get node data of successor node

Exceptions
LogicException

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

1574 : ?array
1575 {
1576 $tree_implementation = $this->getTreeImplementation();
1577 if ($tree_implementation instanceof ilNestedSetTree) {
1578 return $tree_implementation->fetchSuccessorNode($a_node_id, $a_type);
1579 } else {
1580 $message = "This tree is not part of ilNestedSetTree.";
1581 $this->logger->error($message);
1582 throw new LogicException($message);
1583 }
1584 }

References $message, and ILIAS\Repository\logger().

+ Here is the call graph for this function:

◆ fetchTranslationFromObjectDataCache()

ilTree::fetchTranslationFromObjectDataCache ( array  $a_obj_ids)
protected

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

Parameters
array$a_obj_idsobject ids
Todo:
handle dependency

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

1188 : void
1189 {
1190 global $DIC;
1191
1192 $ilObjDataCache = $DIC['ilObjDataCache'];
1193
1194 if ($this->isCacheUsed() && is_array($a_obj_ids) && is_object($ilObjDataCache)) {
1195 foreach ($a_obj_ids as $id) {
1196 $this->translation_cache[$id . '.']['title'] = $ilObjDataCache->lookupTitle((int) $id);
1197 $this->translation_cache[$id . '.']['description'] = $ilObjDataCache->lookupDescription((int) $id);
1198 $this->translation_cache[$id . '.']['desc'] =
1199 $this->translation_cache[$id . '.']['description'];
1200 }
1201 }
1202 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References $DIC, and $id.

◆ getChildIds()

ilTree::getChildIds ( int  $a_node)
Parameters
int$a_node
Returns
int[]

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

416 : array
417 {
418 $query = 'SELECT * FROM ' . $this->table_tree . ' ' .
419 'WHERE parent = ' . $this->db->quote($a_node, 'integer') . ' ' .
420 'AND tree = ' . $this->db->quote($this->tree_id, 'integer' . ' ' .
421 'ORDER BY lft');
422 $res = $this->db->query($query);
423
424 $childs = array();
425 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
426 $childs[] = (int) $row->child;
427 }
428 return $childs;
429 }

References $res, ilDBConstants\FETCHMODE_OBJECT, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getChilds()

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

get child nodes of given node

Todo:
remove dependency to ilObjUser and use $this->lang_code

Reimplemented in ilSCORMTree, and ilGlobalSkillTree.

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

435 : array
436 {
437 global $DIC;
438
439 $ilObjDataCache = $DIC['ilObjDataCache'];
440 $ilUser = $DIC['ilUser'];
441
442 // init childs
443 $childs = [];
444
445 // number of childs
446 $count = 0;
447
448 // init order_clause
449 $order_clause = "";
450
451 // set order_clause if sort order parameter is given
452 if (!empty($a_order)) {
453 $order_clause = "ORDER BY " . $a_order . " " . $a_direction;
454 } else {
455 $order_clause = "ORDER BY " . $this->table_tree . ".lft";
456 }
457
458 $query = sprintf(
459 'SELECT * FROM ' . $this->table_tree . ' ' .
460 $this->buildJoin() .
461 "WHERE parent = %s " .
462 "AND " . $this->table_tree . "." . $this->tree_pk . " = %s " .
463 $order_clause,
464 $this->db->quote($a_node_id, 'integer'),
465 $this->db->quote($this->tree_id, 'integer')
466 );
467
468 $res = $this->db->query($query);
469
470 if (!$count = $res->numRows()) {
471 return [];
472 }
473
474 // get rows and object ids
475 $rows = [];
476 $obj_ids = [];
477 while ($r = $this->db->fetchAssoc($res)) {
478 $rows[] = $r;
479 $obj_ids[] = (int) $r["obj_id"];
480 }
481
482 // preload object translation information
483 if ($this->__isMainTree() && $this->isCacheUsed() && is_object($ilObjDataCache) &&
484 is_object($ilUser) && $this->lang_code == $ilUser->getLanguage() && !isset($this->oc_preloaded[$a_node_id])) {
485 // $ilObjDataCache->preloadTranslations($obj_ids, $this->lang_code);
486 $ilObjDataCache->preloadObjectCache($obj_ids, $this->lang_code);
488 $this->oc_preloaded[$a_node_id] = true;
489 }
490
491 foreach ($rows as $row) {
492 $childs[] = $this->fetchNodeData($row);
493
494 // Update cache of main tree
495 if ($this->__isMainTree()) {
496 #$GLOBALS['DIC']['ilLog']->write(__METHOD__.': Storing in tree cache '.$row['child'].' = true');
497 $this->in_tree_cache[$row['child']] = $row['tree'] == 1;
498 }
499 }
500 $childs[$count - 1]["last"] = true;
501 return $childs;
502 }
fetchNodeData(array $a_row)
get data of parent node from tree and object_data
fetchTranslationFromObjectDataCache(array $a_obj_ids)
Get translation data from object cache (trigger in object cache on preload)
buildJoin()
build join depending on table settings @access private

References $DIC, $res, and ILIAS\Repository\int().

Referenced by ilAdminSubItemsTableGUI\getItems(), ilSkillTree\getMaxOrderNr(), ilClassificationBlockGUI\getSubItemIds(), ilTaggingClassificationProvider\getSubTreeTags(), ilTreeExplorerGUI\getTreeComponent(), ilObjWorkspaceFolder\gotItems(), ILIAS\Skill\Node\SkillTreeNodeManager\putIntoTree(), ilObjContentObjectGUI\showExportIDsOverview(), and ilContainerXmlWriter\writeSubitems().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getChildsByType()

ilTree::getChildsByType ( int  $a_node_id,
string  $a_type 
)

get child nodes of given node by object type

Todo:
check the perfomance optimization and remove

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

533 : array
534 {
535 if ($a_type == 'rolf' && $this->table_obj_reference) {
536 // Performance optimization: A node can only have exactly one
537 // role folder as its child. Therefore we don't need to sort the
538 // results, and we can let the database know about the expected limit.
539 $this->db->setLimit(1, 0);
540 $query = sprintf(
541 "SELECT * FROM " . $this->table_tree . " " .
542 $this->buildJoin() .
543 "WHERE parent = %s " .
544 "AND " . $this->table_tree . "." . $this->tree_pk . " = %s " .
545 "AND " . $this->table_obj_data . ".type = %s ",
546 $this->db->quote($a_node_id, 'integer'),
547 $this->db->quote($this->tree_id, 'integer'),
548 $this->db->quote($a_type, 'text')
549 );
550 } else {
551 $query = sprintf(
552 "SELECT * FROM " . $this->table_tree . " " .
553 $this->buildJoin() .
554 "WHERE parent = %s " .
555 "AND " . $this->table_tree . "." . $this->tree_pk . " = %s " .
556 "AND " . $this->table_obj_data . ".type = %s " .
557 "ORDER BY " . $this->table_tree . ".lft",
558 $this->db->quote($a_node_id, 'integer'),
559 $this->db->quote($this->tree_id, 'integer'),
560 $this->db->quote($a_type, 'text')
561 );
562 }
563 $res = $this->db->query($query);
564
565 // init childs
566 $childs = [];
567 while ($row = $this->db->fetchAssoc($res)) {
568 $childs[] = $this->fetchNodeData($row);
569 }
570 return $childs;
571 }

References $res.

Referenced by ilItemGroupItems\_getItemsOfContainer(), ilEventItems\_getItemsOfContainer(), ilSessionAppointment\lookupLastSessionByCourse(), ilSessionAppointment\lookupNextSessionByCourse(), and assQuestionGUI\outPageSelector().

+ Here is the caller graph for this function:

◆ getChildsByTypeFilter()

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

get child nodes of given node by object type

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

581 : array {
582 $filter = ' ';
583 if ($a_types) {
584 $filter = 'AND ' . $this->table_obj_data . '.type IN(' . implode(',', ilArrayUtil::quoteArray($a_types)) . ') ';
585 }
586
587 // set order_clause if sort order parameter is given
588 if (!empty($a_order)) {
589 $order_clause = "ORDER BY " . $a_order . " " . $a_direction;
590 } else {
591 $order_clause = "ORDER BY " . $this->table_tree . ".lft";
592 }
593
594 $query = 'SELECT * FROM ' . $this->table_tree . ' ' .
595 $this->buildJoin() .
596 'WHERE parent = ' . $this->db->quote($a_node_id, 'integer') . ' ' .
597 'AND ' . $this->table_tree . '.' . $this->tree_pk . ' = ' . $this->db->quote(
598 $this->tree_id,
599 'integer'
600 ) . ' ' .
601 $filter .
602 $order_clause;
603
604 $res = $this->db->query($query);
605
606 $childs = [];
607 while ($row = $this->db->fetchAssoc($res)) {
608 $childs[] = $this->fetchNodeData($row);
609 }
610
611 return $childs;
612 }
static quoteArray(array $a_array)
Quotes all members of an array for usage in DB query statement.

References ilArrayUtil\quoteArray().

Referenced by ilCheckSumOfWorkspaceFileSizesJob\calculateRecursive().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getChildSequenceNumber()

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

get sequence number of node in sibling sequence

Exceptions
LogicException

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

1527 : int
1528 {
1529 $tree_implementation = $this->getTreeImplementation();
1530 if ($tree_implementation instanceof ilNestedSetTree) {
1531 return $tree_implementation->getChildSequenceNumber($a_node, $type);
1532 } else {
1533 $message = "This tree is not part of ilNestedSetTree.";
1534 $this->logger->error($message);
1535 throw new LogicException($message);
1536 }
1537 }

References $message, and ILIAS\Repository\logger().

+ Here is the call graph for this function:

◆ getDepth()

ilTree::getDepth ( int  $a_node_id)

return depth of a node in tree

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

1036 : int
1037 {
1038 global $DIC;
1039
1040 if ($a_node_id) {
1041 if ($this->__isMainTree()) {
1042 $query = 'SELECT depth FROM ' . $this->table_tree . ' ' .
1043 'WHERE child = %s ';
1044 $res = $this->db->queryF($query, array('integer'), array($a_node_id));
1045 $row = $this->db->fetchObject($res);
1046 } else {
1047 $query = 'SELECT depth FROM ' . $this->table_tree . ' ' .
1048 'WHERE child = %s ' .
1049 'AND ' . $this->tree_pk . ' = %s ';
1050 $res = $this->db->queryF($query, array('integer', 'integer'), array($a_node_id, $this->tree_id));
1051 $row = $this->db->fetchObject($res);
1052 }
1053 return (int) ($row->depth ?? 0);
1054 }
1055 return 1;
1056 }

References $DIC, and $res.

◆ getDepthCache()

ilTree::getDepthCache ( )

Get depth cache.

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

251 : array
252 {
253 return $this->depth_cache;
254 }
array $depth_cache

References $depth_cache.

◆ getFilteredChilds()

ilTree::getFilteredChilds ( array  $a_filter,
int  $a_node,
string  $a_order = "",
string  $a_direction = "ASC" 
)

get child nodes of given node (exclude filtered obj_types)

Parameters
string[]objects to filter (e.g array('rolf'))
intnode_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 512 of file class.ilTree.php.

517 : array {
518 $childs = $this->getChilds($a_node, $a_order, $a_direction);
519
520 $filtered = [];
521 foreach ($childs as $child) {
522 if (!in_array($child["type"], $a_filter)) {
523 $filtered[] = $child;
524 }
525 }
526 return $filtered;
527 }
getChilds(int $a_node_id, string $a_order="", string $a_direction="ASC")
get child nodes of given node

◆ getFilteredSubTree()

ilTree::getFilteredSubTree ( int  $a_node_id,
array  $a_filter = [] 
)

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

E.g getFilteredSubTreeNodes()

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

697 : array
698 {
699 $node = $this->getNodeData($a_node_id);
700
701 $first = true;
702 $depth = 0;
703 $filtered = [];
704 foreach ($this->getSubTree($node) as $subnode) {
705 if ($depth && $subnode['depth'] > $depth) {
706 continue;
707 }
708 if (!$first && in_array($subnode['type'], $a_filter)) {
709 $depth = $subnode['depth'];
710 $first = false;
711 continue;
712 }
713 $depth = 0;
714 $first = false;
715 $filtered[] = $subnode;
716 }
717 return $filtered;
718 }
getNodeData(int $a_node_id, ?int $a_tree_pk=null)
get all information of a node.
getSubTree(array $a_node, bool $a_with_data=true, array $a_type=[])
get all nodes in the subtree under specified node

◆ getGap()

ilTree::getGap ( )

Get default gap.

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

317 : int
318 {
319 return $this->gap;
320 }
int $gap
Size of the gaps to be created in the nested sets sequence numbering of the tree nodes.

References $gap.

◆ getMaximumDepth()

ilTree::getMaximumDepth ( )

Return the current maximum depth in the tree.

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

1022 : int
1023 {
1024 global $DIC;
1025
1026 $query = 'SELECT MAX(depth) depth FROM ' . $this->table_tree;
1027 $res = $this->db->query($query);
1028
1029 $row = $this->db->fetchAssoc($res);
1030 return (int) $row['depth'];
1031 }
string $table_tree
table name of tree table

References $DIC, and $res.

◆ getNodeData()

ilTree::getNodeData ( int  $a_node_id,
?int  $a_tree_pk = null 
)

get all information of a node.

get data of a specific node from tree and object_data

Exceptions
InvalidArgumentException

Reimplemented in ilGlobalSkillTree.

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

1085 : array
1086 {
1087 if ($this->__isMainTree()) {
1088 if ($a_node_id < 1) {
1089 $message = 'No valid parameter given! $a_node_id: %s' . $a_node_id;
1090 $this->logger->error($message);
1091 throw new InvalidArgumentException($message);
1092 }
1093 }
1094
1095 $query = 'SELECT * FROM ' . $this->table_tree . ' ' .
1096 $this->buildJoin() .
1097 'WHERE ' . $this->table_tree . '.child = %s ' .
1098 'AND ' . $this->table_tree . '.' . $this->tree_pk . ' = %s ';
1099 $res = $this->db->queryF($query, array('integer', 'integer'), array(
1100 $a_node_id,
1101 $a_tree_pk === null ? $this->tree_id : $a_tree_pk
1102 ));
1103 $row = $this->db->fetchAssoc($res);
1105
1106 return $this->fetchNodeData($row);
1107 }
string $tree_pk
column name containing tree id in tree table
int $tree_id
to use different trees in one db-table

References $message, $res, and ILIAS\Repository\logger().

Referenced by ilPersonalSkillExplorerGUI\__construct(), ilCourseObjectiveMaterials\_getAssignableMaterials(), ilCourseObjectiveQuestion\_getAssignableTests(), ilObjSCORMLearningModule\_getTrackingItems(), ILIAS\Skill\Node\SkillTreeNodeManager\clipboardCopy(), ILIAS\Skill\Node\SkillTreeNodeManager\clipboardCut(), ilObjContentObjectGUI\confirmedDelete(), ilObjSessionGUI\eventsListObject(), ilSessionOverviewGUI\exportCSV(), ilRepositoryExplorer\formatHeader(), ilSessionOverviewTableGUI\gatherEvents(), ilGlobalVirtualSkillTree\getChildsOfNode(), ilSessionMaterialsTableGUI\getDataFromDb(), ilFavouritesDBRepository\getFavouritesOfUser(), ilTaggingClassificationProvider\getSubTreeTags(), ilTreeExplorerGUI\getTreeComponent(), ilPCFileListGUI\initEditForm(), ilTestTaxonomyTree\initOrderedTreeIndex(), ilPCFileListGUI\insertNewFileItem(), ilPCFileItemGUI\insertNewItemAfter(), ilPCFileItemGUI\insertNewItemBefore(), assQuestionGUI\outPageSelector(), ilRepositorySelectorInputGUI\render(), and ilSurveyCronNotification\run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNodePath()

ilTree::getNodePath ( int  $a_endnode_id,
int  $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.
    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 887 of file class.ilTree.php.

887 : array
888 {
889 $pathIds = $this->getPathId($a_endnode_id, $a_startnode_id);
890
891 // Abort if no path ids were found
892 if (count($pathIds) == 0) {
893 return [];
894 }
895
896 $types = [];
897 $data = [];
898 for ($i = 0; $i < count($pathIds); $i++) {
899 $types[] = 'integer';
900 $data[] = $pathIds[$i];
901 }
902
903 $query = 'SELECT t.depth,t.parent,t.child,d.obj_id,d.type,d.title ' .
904 'FROM ' . $this->table_tree . ' t ' .
905 'JOIN ' . $this->table_obj_reference . ' r ON r.ref_id = t.child ' .
906 'JOIN ' . $this->table_obj_data . ' d ON d.obj_id = r.obj_id ' .
907 'WHERE ' . $this->db->in('t.child', $data, false, 'integer') . ' ' .
908 'ORDER BY t.depth ';
909
910 $res = $this->db->queryF($query, $types, $data);
911
912 $titlePath = [];
913 while ($row = $this->db->fetchAssoc($res)) {
914 $titlePath[] = $row;
915 }
916 return $titlePath;
917 }
getPathId(int $a_endnode_id, int $a_startnode_id=0)
get path from a given startnode to a given endnode if startnode is not given the rootnode is startnod...

References $data, and $res.

◆ getNodeTreeData()

ilTree::getNodeTreeData ( int  $a_node_id)

return all columns of tabel tree

Exceptions
InvalidArgumentException

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

1062 : array
1063 {
1064 global $DIC;
1065
1066 if (!$a_node_id) {
1067 $this->logger->logStack(ilLogLevel::ERROR);
1068 throw new InvalidArgumentException('Missing or empty parameter $a_node_id: ' . $a_node_id);
1069 }
1070
1071 $query = 'SELECT * FROM ' . $this->table_tree . ' ' .
1072 'WHERE child = ' . $this->db->quote($a_node_id, 'integer');
1073 $res = $this->db->query($query);
1074 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
1075 return $row;
1076 }
1077 return [];
1078 }

References $DIC, $res, ilLogLevel\ERROR, ilDBConstants\FETCHMODE_ASSOC, and ILIAS\Repository\logger().

+ Here is the call graph for this function:

◆ getObjectDataTable()

ilTree::getObjectDataTable ( )

Get object data table.

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

293 : string
294 {
296 }
string $table_obj_data
table name of object_data table

References $table_obj_data.

◆ getParentCache()

ilTree::getParentCache ( )

Get parent cache.

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

259 : array
260 {
261 return $this->parent_cache;
262 }
array $parent_cache

References $parent_cache.

◆ getParentId()

ilTree::getParentId ( int  $a_node_id)

get parent id of given node

Exceptions
InvalidArgumentException

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

1496 : ?int
1497 {
1498 global $DIC;
1499 if ($this->__isMainTree()) {
1500 $query = 'SELECT parent FROM ' . $this->table_tree . ' ' .
1501 'WHERE child = %s ';
1502 $res = $this->db->queryF(
1503 $query,
1504 ['integer'],
1505 [$a_node_id]
1506 );
1507 } else {
1508 $query = 'SELECT parent FROM ' . $this->table_tree . ' ' .
1509 'WHERE child = %s ' .
1510 'AND ' . $this->tree_pk . ' = %s ';
1511 $res = $this->db->queryF($query, array('integer', 'integer'), array(
1512 $a_node_id,
1513 $this->tree_id
1514 ));
1515 }
1516
1517 if ($row = $this->db->fetchObject($res)) {
1518 return (int) $row->parent;
1519 }
1520 return null;
1521 }

References $DIC, and $res.

Referenced by ilOrgUnitExtension\__construct(), ilObjItemGroupGUI\_goto(), ilObjPollGUI\_goto(), ilSurveyExecutionGUI\backToRepository(), ilObjSessionGUI\cancelEditObject(), ilSurveyEditorGUI\createQuestionPool(), ilPCQuestionGUI\createQuestionPool(), ilObjSessionGUI\createRecurringSessions(), ilAdministrationCommandGUI\cut(), ilObjMediaPoolGUI\executeCommand(), ilObjSessionGUI\executeCommand(), ilFavouritesDBRepository\getFavouritesOfUser(), ilRepositorySelectorInputGUI\getHighlightedNode(), ilObjSessionGUI\getTabs(), ilObjItemGroupGUI\gotoParent(), ilObjSessionGUI\handleFileUpload(), ilConditionSelector\isNodeVisible(), ilAdministrationCommandGUI\link(), ilObjItemGroupGUI\listMaterials(), ilObjSessionGUI\redirectToParentContentPageObject(), ilObjMediaPoolGUI\returnFromItem(), ilObjItemGroupGUI\setTabs(), ilAdministrationCommandGUI\showPasteTree(), ilECSCourseCreationHandler\syncNodeToTop(), and ilObjSessionGUI\unregisterObject().

+ Here is the caller graph for this function:

◆ getParentNodeData()

ilTree::getParentNodeData ( int  $a_node_id)

get data of parent node from tree and object_data

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

1243 : array
1244 {
1245 global $DIC;
1246
1247 $ilLog = $DIC['ilLog'];
1248 if ($this->table_obj_reference) {
1249 // Use inner join instead of left join to improve performance
1250 $innerjoin = "JOIN " . $this->table_obj_reference . " ON v.child=" . $this->table_obj_reference . "." . $this->ref_pk . " " .
1251 "JOIN " . $this->table_obj_data . " ON " . $this->table_obj_reference . "." . $this->obj_pk . "=" . $this->table_obj_data . "." . $this->obj_pk . " ";
1252 } else {
1253 // Use inner join instead of left join to improve performance
1254 $innerjoin = "JOIN " . $this->table_obj_data . " ON v.child=" . $this->table_obj_data . "." . $this->obj_pk . " ";
1255 }
1256
1257 $query = 'SELECT * FROM ' . $this->table_tree . ' s, ' . $this->table_tree . ' v ' .
1258 $innerjoin .
1259 'WHERE s.child = %s ' .
1260 'AND s.parent = v.child ' .
1261 'AND s.' . $this->tree_pk . ' = %s ' .
1262 'AND v.' . $this->tree_pk . ' = %s';
1263 $res = $this->db->queryF($query, array('integer', 'integer', 'integer'), array(
1264 $a_node_id,
1265 $this->tree_id,
1266 $this->tree_id
1267 ));
1268 $row = $this->db->fetchAssoc($res);
1269 if (is_array($row)) {
1270 return $this->fetchNodeData($row);
1271 }
1272 return [];
1273 }

References $DIC, and $res.

Referenced by ilObjIndividualAssessment\getParentContainerIdByType().

+ Here is the caller graph for this function:

◆ getPathFull()

ilTree::getPathFull ( int  $a_endnode_id,
int  $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.

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

788 : array
789 {
790 $pathIds = $this->getPathId($a_endnode_id, $a_startnode_id);
791
792 // We retrieve the full path in a single query to improve performance
793 // Abort if no path ids were found
794 if (count($pathIds) == 0) {
795 return [];
796 }
797
798 $inClause = 'child IN (';
799 for ($i = 0; $i < count($pathIds); $i++) {
800 if ($i > 0) {
801 $inClause .= ',';
802 }
803 $inClause .= $this->db->quote($pathIds[$i], 'integer');
804 }
805 $inClause .= ')';
806
807 $q = 'SELECT * ' .
808 'FROM ' . $this->table_tree . ' ' .
809 $this->buildJoin() . ' ' .
810 'WHERE ' . $inClause . ' ' .
811 'AND ' . $this->table_tree . '.' . $this->tree_pk . ' = ' . $this->db->quote(
812 $this->tree_id,
813 'integer'
814 ) . ' ' .
815 'ORDER BY depth';
816 $r = $this->db->query($q);
817
818 $pathFull = [];
819 while ($row = $r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
820 $pathFull[] = $this->fetchNodeData($row);
821
822 // Update cache
823 if ($this->__isMainTree()) {
824 $this->in_tree_cache[$row['child']] = $row['tree'] == 1;
825 }
826 }
827 return $pathFull;
828 }
$q
Definition: shib_logout.php:23

References $q, and ilDBConstants\FETCHMODE_ASSOC.

Referenced by ilObjContentObject\_checkPreconditionsOfPage(), ilNewsItem\_getDefaultVisibilityForRefId(), ilObjContentObject\_getMissingPreconditionsTopChapter(), ilLocatorGUI\addAdministrationItems(), ilLocatorGUI\addContextItems(), ilObjMediaPoolGUI\addLocatorItems(), ilLocatorGUI\addRepositoryItems(), ilRepositoryTrashGUI\buildPath(), ilSurveySyncTableGUI\buildPath(), ilSurveyEvaluationGUI\cancelEvaluationAccess(), ilClassificationBlockGUI\filterContainer(), ilFeedWriter\getContextPath(), ILIAS\Awareness\User\ProviderCurrentCourse\getInitialUserSet(), ilRecommendedContentRoleTableGUI\getItems(), ilObjTaxonomyAdministration\getPath(), ilTestTaxonomyTree\getPathNodes(), ilTaxMDGUI\getSelectableTaxonomies(), and ilSkillTree\getSkillTreePath().

+ Here is the caller graph for this function:

◆ getPathId()

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

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

Returns
int[] all path ids from startnode to endnode

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

857 : array
858 {
859 if (!$a_endnode_id) {
860 $this->logger->logStack(ilLogLevel::ERROR);
861 throw new InvalidArgumentException(__METHOD__ . ': No endnode given!');
862 }
863
864 // path id cache
865 if ($this->isCacheUsed() && isset($this->path_id_cache[$a_endnode_id][$a_startnode_id])) {
866 return $this->path_id_cache[$a_endnode_id][$a_startnode_id];
867 }
868
869 $pathIds = $this->getTreeImplementation()->getPathIds($a_endnode_id, $a_startnode_id);
870
871 if ($this->__isMainTree()) {
872 $this->path_id_cache[$a_endnode_id][$a_startnode_id] = $pathIds;
873 }
874 return $pathIds;
875 }

References ilLogLevel\ERROR, and ILIAS\Repository\logger().

Referenced by ILIAS\Skill\Node\SkillTreeNodeManager\clipboardCut(), ilWorkspaceFolderUserSettings\getEffectiveSortation(), ilRepositoryExplorerGUI\getTopNodeForRefId(), ilSkillTree\getTopParentNodeId(), ilObjectLP\handleMove(), and ilSkillNotifications\sendMail().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRbacSubtreeInfo()

ilTree::getRbacSubtreeInfo ( int  $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.

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

1927 : array
1928 {
1929 return $this->getTreeImplementation()->getSubtreeInfo($a_endnode_id);
1930 }

◆ getRelation()

ilTree::getRelation ( int  $a_node_a,
int  $a_node_b 
)

Get relation of two nodes.

Todo:
add unit test

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

396 : int
397 {
398 return $this->getRelationOfNodes(
399 $this->getNodeTreeData($a_node_a),
400 $this->getNodeTreeData($a_node_b)
401 );
402 }
getNodeTreeData(int $a_node_id)
return all columns of tabel tree
getRelationOfNodes(array $a_node_a_arr, array $a_node_b_arr)
get relation of two nodes by node data

◆ getRelationOfNodes()

ilTree::getRelationOfNodes ( array  $a_node_a_arr,
array  $a_node_b_arr 
)

get relation of two nodes by node data

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

407 : int
408 {
409 return $this->getTreeImplementation()->getRelation($a_node_a_arr, $a_node_b_arr);
410 }

◆ getRootId()

ilTree::getRootId ( )

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

1555 : int
1556 {
1557 return $this->root_id;
1558 }
int $root_id
points to root node (may be a subtree)

Referenced by ilObjMediaPoolGUI\addLocatorItems(), ilTestTaxonomyTree\initOrderedTreeIndex(), ILIAS\MediaPool\Tree\MediaPoolTree\insertInMepTree(), and assQuestionGUI\outPageSelector().

+ Here is the caller graph for this function:

◆ getSavedNodeData()

ilTree::getSavedNodeData ( int  $a_parent_id)

get data saved/deleted nodes

Exceptions
InvalidArgumentException

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

1445 : array
1446 {
1447 global $DIC;
1448
1449 if (!isset($a_parent_id)) {
1450 $message = "No node_id given!";
1451 $this->logger->error($message);
1452 throw new InvalidArgumentException($message);
1453 }
1454
1455 $query = 'SELECT * FROM ' . $this->table_tree . ' ' .
1456 $this->buildJoin() .
1457 'WHERE ' . $this->table_tree . '.' . $this->tree_pk . ' < %s ' .
1458 'AND ' . $this->table_tree . '.parent = %s';
1459 $res = $this->db->queryF($query, array('integer', 'integer'), array(
1460 0,
1461 $a_parent_id
1462 ));
1463
1464 $saved = [];
1465 while ($row = $this->db->fetchAssoc($res)) {
1466 $saved[] = $this->fetchNodeData($row);
1467 }
1468
1469 return $saved;
1470 }

References $DIC, $message, $res, and ILIAS\Repository\logger().

+ Here is the call graph for this function:

◆ getSavedNodeObjIds()

ilTree::getSavedNodeObjIds ( array  $a_obj_ids)

get object id of saved/deleted nodes

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

1475 : array
1476 {
1477 global $DIC;
1478
1479 $query = 'SELECT ' . $this->table_obj_data . '.obj_id FROM ' . $this->table_tree . ' ' .
1480 $this->buildJoin() .
1481 'WHERE ' . $this->table_tree . '.' . $this->tree_pk . ' < ' . $this->db->quote(0, 'integer') . ' ' .
1482 'AND ' . $this->db->in($this->table_obj_data . '.obj_id', $a_obj_ids, false, 'integer');
1483 $res = $this->db->query($query);
1484 $saved = [];
1485 while ($row = $this->db->fetchAssoc($res)) {
1486 $saved[] = (int) $row['obj_id'];
1487 }
1488
1489 return $saved;
1490 }

References $DIC, $res, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getSubTree()

ilTree::getSubTree ( array  $a_node,
bool  $a_with_data = true,
array  $a_type = [] 
)

get all nodes in the subtree under specified node

Todo:

remove the in cache exception for lm tree

refactor $a_type to string[]

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

735 : array
736 {
737 $query = $this->getTreeImplementation()->getSubTreeQuery($a_node, $a_type);
738
739 $res = $this->db->query($query);
740 $subtree = [];
741 while ($row = $this->db->fetchAssoc($res)) {
742 if ($a_with_data) {
743 $subtree[] = $this->fetchNodeData($row);
744 } else {
745 $subtree[] = (int) $row['child'];
746 }
747 // the lm_data "hack" should be removed in the trunk during an alpha
748 if ($this->__isMainTree() || $this->table_tree == "lm_tree") {
749 $this->in_tree_cache[$row['child']] = true;
750 }
751 }
752 return $subtree;
753 }

References $res, and ILIAS\Repository\int().

Referenced by ilPersonalSkillExplorerGUI\__construct(), ilCourseObjectiveMaterials\_getAssignableMaterials(), ilCourseObjectiveQuestion\_getAssignableTests(), ilObjSCORMLearningModule\_getTrackingItems(), ILIAS\Skill\Node\SkillTreeNodeManager\clipboardCopy(), ilObjSessionGUI\eventsListObject(), ilNewsItem\getAggregatedNewsData(), ilSessionMaterialsTableGUI\getDataFromDb(), ilTaggingClassificationProvider\getSubTreeTags(), ilTestTaxonomyTree\initOrderedTreeIndex(), and ilSurveyCronNotification\run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSubTreeFilteredByObjIds()

ilTree::getSubTreeFilteredByObjIds ( int  $a_node_id,
array  $a_obj_ids,
array  $a_fields = [] 
)

get all node ids in the subtree under specified node id, filter by object ids

Parameters
int[]$a_obj_ids
string[]$a_fields

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

1969 : array
1970 {
1971 $node = $this->getNodeData($a_node_id);
1972 if (!count($node)) {
1973 return [];
1974 }
1975
1976 $res = [];
1977
1978 $query = $this->getTreeImplementation()->getSubTreeQuery($node, [], true, array($this->ref_pk));
1979
1980 $fields = '*';
1981 if (count($a_fields)) {
1982 $fields = implode(',', $a_fields);
1983 }
1984
1985 $query = "SELECT " . $fields .
1986 " FROM " . $this->getTreeTable() .
1987 " " . $this->buildJoin() .
1988 " WHERE " . $this->getTableReference() . "." . $this->ref_pk . " IN (" . $query . ")" .
1989 " AND " . $this->db->in($this->getObjectDataTable() . "." . $this->obj_pk, $a_obj_ids, false, "integer");
1990 $set = $this->db->query($query);
1991 while ($row = $this->db->fetchAssoc($set)) {
1992 $res[] = $row;
1993 }
1994
1995 return $res;
1996 }
getTreeTable()
Get tree table name.
getTableReference()
Get reference table if available.
getObjectDataTable()
Get object data table.

References $res.

Referenced by ilClassificationBlockGUI\filterContainer(), and ilClassificationBlockGUI\getSubItemIds().

+ Here is the caller graph for this function:

◆ getSubTreeIds()

ilTree::getSubTreeIds ( int  $a_ref_id)

Get all ids of subnodes.

Parameters
int$a_ref_id
Returns
int[]

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

725 : array
726 {
727 return $this->getTreeImplementation()->getSubTreeIds($a_ref_id);
728 }

Referenced by ilObjectLP\handleMove().

+ Here is the caller graph for this function:

◆ getSubTreeQuery()

ilTree::getSubTreeQuery ( int  $a_node_id,
array  $a_fields = [],
array  $a_types = [],
bool  $a_force_join_reference = false 
)

Get tree subtree query.

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

1940 : string {
1941 return $this->getTreeImplementation()->getSubTreeQuery(
1942 $this->getNodeTreeData($a_node_id),
1943 $a_types,
1944 $a_force_join_reference,
1945 $a_fields
1946 );
1947 }

◆ getTableReference()

ilTree::getTableReference ( )

Get reference table if available.

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

309 : string
310 {
312 }
string $table_obj_reference
table name of object_reference table

References $table_obj_reference.

◆ getTrashSubTreeQuery()

ilTree::getTrashSubTreeQuery ( int  $a_node_id,
array  $a_fields = [],
array  $a_types = [],
bool  $a_force_join_reference = false 
)

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

1954 : string {
1955 return $this->getTreeImplementation()->getTrashSubTreeQuery(
1956 $this->getNodeTreeData($a_node_id),
1957 $a_types,
1958 $a_force_join_reference,
1959 $a_fields
1960 );
1961 }

◆ getTreeId()

ilTree::getTreeId ( )

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

1565 : int
1566 {
1567 return $this->tree_id;
1568 }

Referenced by ilWorkspaceTree\exists(), ilSkillTree\getChildsByTypeFilter(), ilSkillTree\initChildsData(), and ILIAS\Skill\Node\SkillDeletionManager\updateProfileCompletions().

+ Here is the caller graph for this function:

◆ getTreeImplementation()

ilTree::getTreeImplementation ( )

Get tree implementation.

Returns
ilTreeImplementation $impl

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

228 {
229 return $this->tree_impl;
230 }
ilTreeImplementation $tree_impl
Interface for tree implementations Currrently nested set or materialized path.

References $tree_impl.

◆ getTreePk()

ilTree::getTreePk ( )

Get tree primary key.

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

301 : string
302 {
303 return $this->tree_pk;
304 }

References $tree_pk.

◆ getTreeTable()

ilTree::getTreeTable ( )

Get tree table name.

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

285 : string
286 {
287 return $this->table_tree;
288 }

References $table_tree.

◆ initLangCode()

ilTree::initLangCode ( )

Do not use it Store user language.

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

Todo:
remove this dependency to user language from tree class

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

270 : void
271 {
272 global $DIC;
273
274 if ($DIC->offsetExists('ilUser')) {
275 $this->lang_code = $DIC->user()->getCurrentLanguage() ?
276 $DIC->user()->getCurrentLanguage() : self::DEFAULT_LANGUAGE;
277 } else {
278 $this->lang_code = self::DEFAULT_LANGUAGE;
279 }
280 }

References $DIC, and DEFAULT_LANGUAGE.

◆ initTreeImplementation()

ilTree::initTreeImplementation ( )

Init tree implementation.

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

202 : void
203 {
204 global $DIC;
205
206 if (!$DIC->isDependencyAvailable('settings') || $DIC->settings()->getModule() != 'common') {
207 $setting = new ilSetting('common');
208 } else {
209 $setting = $DIC->settings();
210 }
211
212 if ($this->__isMainTree()) {
213 if ($setting->get('main_tree_impl', 'ns') == 'ns') {
214 $this->tree_impl = new ilNestedSetTree($this);
215 } else {
216 $this->tree_impl = new ilMaterializedPathTree($this);
217 }
218 } else {
219 $this->tree_impl = new ilNestedSetTree($this);
220 }
221 }
Base class for materialize path based trees Based on implementation of Werner Randelshofer.
ILIAS Setting Class.

References $DIC, and __isMainTree().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insertNode()

ilTree::insertNode ( int  $a_node_id,
int  $a_parent_id,
int  $a_pos = self::POS_LAST_NODE,
bool  $a_reset_deletion_date = false 
)

insert new node with node_id under parent node with parent_id

Exceptions
InvalidArgumentException

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

652 : void {
653 // CHECK node_id and parent_id > 0 if in main tree
654 if ($this->__isMainTree()) {
655 if ($a_node_id <= 1 || $a_parent_id <= 0) {
656 $message = sprintf(
657 'Invalid parameters! $a_node_id: %s $a_parent_id: %s',
658 $a_node_id,
659 $a_parent_id
660 );
661 $this->logger->logStack(ilLogLevel::ERROR, $message);
662 throw new InvalidArgumentException($message);
663 }
664 }
665 if ($this->isInTree($a_node_id)) {
666 throw new InvalidArgumentException("Node " . $a_node_id . " already in tree " .
667 $this->table_tree . "!");
668 }
669
670 $this->getTreeImplementation()->insertNode($a_node_id, $a_parent_id, $a_pos);
671
672 $this->in_tree_cache[$a_node_id] = true;
673
674 // reset deletion date
675 if ($a_reset_deletion_date) {
676 ilObject::_resetDeletedDate($a_node_id);
677 }
678 if (isset($this->eventHandler) && ($this->eventHandler instanceof ilAppEventHandler) && $this->__isMainTree()) {
679 $this->eventHandler->raise(
680 'components/ILIAS/Tree',
681 'insertNode',
682 [
683 'tree' => $this->table_tree,
684 'node_id' => $a_node_id,
685 'parent_id' => $a_parent_id
686 ]
687 );
688 }
689 }
Global event handler.
static _resetDeletedDate(int $ref_id)

References $message, ilLogLevel\ERROR, and ILIAS\Repository\logger().

Referenced by ilObjMediaPoolGUI\executeCommand(), ILIAS\MediaPool\Tree\MediaPoolTree\insertInMepTree(), ILIAS\Skill\Node\SkillTreeNodeManager\putIntoTree(), and ilObjFolder\putInTree().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insertNodeFromTrash()

ilTree::insertNodeFromTrash ( int  $a_source_id,
int  $a_target_id,
int  $a_tree_id,
int  $a_pos = self::POS_LAST_NODE,
bool  $a_reset_deleted_date = false 
)

Insert node from trash deletes trash entry.

If we have database query exceptions we could wrap insertNode in try/catch and rollback if the insert failed.

Todo:
use atom query for deletion and creating or use an update statement.

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

626 : void {
627 if ($this->__isMainTree()) {
628 if ($a_source_id <= 1 || $a_target_id <= 0) {
629 $this->logger->logStack(ilLogLevel::WARNING);
630 throw new InvalidArgumentException('Invalid parameter given for ilTree::insertNodeFromTrash');
631 }
632 }
633 if ($this->isInTree($a_source_id)) {
634 ilLoggerFactory::getLogger('tree')->error('Node already in tree');
636 throw new InvalidArgumentException('Node already in tree.');
637 }
638
639 ilTree::_removeEntry($a_tree_id, $a_source_id, 'tree');
640 $this->insertNode($a_source_id, $a_target_id, self::POS_LAST_NODE, $a_reset_deleted_date);
641 }
insertNode(int $a_node_id, int $a_parent_id, int $a_pos=self::POS_LAST_NODE, bool $a_reset_deletion_date=false)
insert new node with node_id under parent node with parent_id
static _removeEntry(int $a_tree, int $a_child, string $a_db_table="tree")
STATIC METHOD Removes a single entry from a tree.

References ILIAS\Repository\logger(), and ilLogLevel\WARNING.

+ Here is the call graph for this function:

◆ isCacheUsed()

ilTree::isCacheUsed ( )
protected

Check if cache is active.

Reimplemented in ilLMTree.

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

243 : bool
244 {
245 return $this->__isMainTree() && $this->use_cache;
246 }
bool $use_cache

References $use_cache, and __isMainTree().

+ Here is the call graph for this function:

◆ isDeleted()

ilTree::isDeleted ( int  $a_node_id)

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

Deprecated:
since 4.4.0

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

1390 : bool
1391 {
1392 if ($this->isCacheUsed() && isset($this->is_saved_cache[$a_node_id])) {
1393 return $this->is_saved_cache[$a_node_id];
1394 }
1395
1396 $query = 'SELECT ' . $this->tree_pk . ' FROM ' . $this->table_tree . ' ' .
1397 'WHERE child = %s ';
1398 $res = $this->db->queryF($query, array('integer'), array($a_node_id));
1399 $row = $this->db->fetchAssoc($res);
1400
1401 $tree_id = $row[$this->tree_pk] ?? 0;
1402 if ($tree_id < 0) {
1403 if ($this->__isMainTree()) {
1404 $this->is_saved_cache[$a_node_id] = true;
1405 }
1406 return true;
1407 } else {
1408 if ($this->__isMainTree()) {
1409 $this->is_saved_cache[$a_node_id] = false;
1410 }
1411 return false;
1412 }
1413 }

References $res.

Referenced by ilEventItems\__read(), ilObjCourseGrouping\_checkGroupingDependencies(), ilObjCourseGrouping\_getGroupingCourseIds(), ilObjCourseGrouping\_getGroupingItems(), ilClassificationBlockGUI\filterContainer(), ilObjCourse\findCoursesWithNotEnoughMembers(), ilMembershipNotifications\getActiveUsersforAllObjects(), ILIAS\Blog\Exercise\BlogExercise\getAssignmentsOfBlog(), ilPortfolioExercise\getAssignmentsOfPortfolio(), ilObjStudyProgramme\getReferencesTo(), ilObjTaxonomyAdministration\getRepositoryTaxonomies(), and ilTaggingClassificationProvider\getSubTreeTags().

+ Here is the caller graph for this function:

◆ isGrandChild()

ilTree::isGrandChild ( int  $a_startnode_id,
int  $a_querynode_id 
)

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

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

1278 : bool
1279 {
1280 return $this->getRelation($a_startnode_id, $a_querynode_id) == self::RELATION_PARENT;
1281 }
const RELATION_PARENT
getRelation(int $a_node_a, int $a_node_b)
Get relation of two nodes.

Referenced by ilObjectLP\findMembershipsByPath(), and ilObjectLP\handleMove().

+ Here is the caller graph for this function:

◆ isInTree()

ilTree::isInTree ( ?int  $a_node_id)

get all information of a node.

get data of a specific node from tree and object_data

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

1208 : bool
1209 {
1210 if (is_null($a_node_id) || !$a_node_id) {
1211 return false;
1212 }
1213 // is in tree cache
1214 if ($this->isCacheUsed() && isset($this->in_tree_cache[$a_node_id])) {
1215 return $this->in_tree_cache[$a_node_id];
1216 }
1217
1218 $query = 'SELECT * FROM ' . $this->table_tree . ' ' .
1219 'WHERE ' . $this->table_tree . '.child = %s ' .
1220 'AND ' . $this->table_tree . '.' . $this->tree_pk . ' = %s';
1221
1222 $res = $this->db->queryF($query, array('integer', 'integer'), array(
1223 $a_node_id,
1224 $this->tree_id
1225 ));
1226
1227 if ($res->numRows() > 0) {
1228 if ($this->__isMainTree()) {
1229 $this->in_tree_cache[$a_node_id] = true;
1230 }
1231 return true;
1232 } else {
1233 if ($this->__isMainTree()) {
1234 $this->in_tree_cache[$a_node_id] = false;
1235 }
1236 return false;
1237 }
1238 }

References $res.

Referenced by ilEventItems\__read(), ilNewsItem\_getDefaultVisibilityForRefId(), ILIAS\Skill\Node\SkillTreeNodeManager\clipboardCopy(), ILIAS\Skill\Node\SkillTreeNodeManager\clipboardCut(), ilObjContentObjectGUI\confirmedDelete(), ILIAS\Skill\Resource\SkillResourceDBRepository\getAll(), ilFavouritesDBRepository\getFavouritesOfUser(), ilMediaObjectUsagesTableGUI\getItems(), ilMediaPoolPageUsagesTableGUI\getItems(), ilNavigationHistory\getItems(), ilInternalLinkGUI\init(), assQuestionGUI\outPageSelector(), ILIAS\Skill\Node\SkillTreeNodeManager\putIntoTree(), ilContainerStartObjects\read(), and ilSkillNotifications\sendMail().

+ Here is the caller graph for this function:

◆ isRepositoryTree()

ilTree::isRepositoryTree ( )
protected

check if current tree instance operates on repository tree table

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

2040 : bool
2041 {
2042 return $this->table_tree == 'tree';
2043 }

◆ lookupTrashedObjectTypes()

ilTree::lookupTrashedObjectTypes ( )

Lookup object types in trash.

Returns
string[]

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

2020 : array
2021 {
2022 $query = 'SELECT DISTINCT(o.type) ' . $this->db->quoteIdentifier('type') .
2023 ' FROM tree t JOIN object_reference r ON child = r.ref_id ' .
2024 'JOIN object_data o on r.obj_id = o.obj_id ' .
2025 'WHERE tree < ' . $this->db->quote(0, 'integer') . ' ' .
2026 'AND child = -tree ' .
2027 'GROUP BY o.type';
2028 $res = $this->db->query($query);
2029
2030 $types_deleted = [];
2031 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
2032 $types_deleted[] = (string) $row->type;
2033 }
2034 return $types_deleted;
2035 }

References $res, and ilDBConstants\FETCHMODE_OBJECT.

◆ lookupTreesForNode()

static ilTree::lookupTreesForNode ( int  $node_id)
static
Parameters
int$node_id
Returns
int[]

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

182 : array
183 {
184 global $DIC;
185
186 $db = $DIC->database();
187
188 $query = 'select tree from tree ' .
189 'where child = ' . $db->quote($node_id, \ilDBConstants::T_INTEGER);
190 $res = $db->query($query);
191
192 $trees = [];
193 while ($row = $res->fetchRow(\ilDBConstants::FETCHMODE_OBJECT)) {
194 $trees[] = (int) $row->tree;
195 }
196 return $trees;
197 }
quote($value, string $type)
query(string $query)
Run a (read-only) Query on the database.

References $db, $DIC, $res, ilDBConstants\FETCHMODE_OBJECT, ILIAS\Repository\int(), ilDBInterface\query(), ilDBInterface\quote(), and ilDBConstants\T_INTEGER.

Referenced by ILIAS\Repository\Deletion\TreeStandardAdapter\getTrashTree().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ moveToTrash()

ilTree::moveToTrash ( int  $a_node_id,
bool  $a_set_deleted = false,
int  $a_deleted_by = 0 
)

Move node to trash bin.

Exceptions
InvalidArgumentException
Todo:
remove ilUser dependency

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

1351 : bool
1352 {
1353 global $DIC;
1354
1355 $user = $DIC->user();
1356 if (!$a_deleted_by) {
1357 $a_deleted_by = $user->getId();
1358 }
1359
1360 if (!$a_node_id) {
1361 $this->logger->logStack(ilLogLevel::ERROR);
1362 throw new InvalidArgumentException('No valid parameter given! $a_node_id: ' . $a_node_id);
1363 }
1364
1365 $query = $this->getTreeImplementation()->getSubTreeQuery($this->getNodeTreeData($a_node_id), [], false);
1366 $res = $this->db->query($query);
1367
1368 $subnodes = [];
1369 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
1370 $subnodes[] = (int) $row['child'];
1371 }
1372
1373 if (!count($subnodes)) {
1374 // Possibly already deleted
1375 return false;
1376 }
1377
1378 if ($a_set_deleted) {
1379 ilObject::setDeletedDates($subnodes, $a_deleted_by);
1380 }
1381 // netsted set <=> mp
1382 $this->getTreeImplementation()->moveToTrash($a_node_id);
1383 return true;
1384 }
static setDeletedDates(array $ref_ids, int $user_id)

References $DIC, $res, ilLogLevel\ERROR, ilDBConstants\FETCHMODE_ASSOC, ILIAS\Repository\int(), ILIAS\Repository\logger(), and ilObject\setDeletedDates().

+ Here is the call graph for this function:

◆ moveTree()

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

Move Tree Implementation @access public.

Parameters
intsource ref_id
inttarget ref_id
intlocation ilTree::POS_LAST_NODE or ilTree::POS_FIRST_NODE
Returns
int

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

1904 : void
1905 {
1906 $old_parent_id = $this->getParentId($a_source_id);
1907 $this->getTreeImplementation()->moveTree($a_source_id, $a_target_id, $a_location);
1908 if (isset($GLOBALS['DIC']["ilAppEventHandler"]) && $this->__isMainTree()) {
1909 $GLOBALS['DIC']['ilAppEventHandler']->raise(
1910 "components/ILIAS/Tree",
1911 "moveTree",
1912 array(
1913 'tree' => $this->table_tree,
1914 'source_id' => $a_source_id,
1915 'target_id' => $a_target_id,
1916 'old_parent_id' => $old_parent_id
1917 )
1918 );
1919 }
1920 }
getParentId(int $a_node_id)
get parent id of given node
$GLOBALS["DIC"]
Definition: wac.php:54

References $GLOBALS.

◆ preloadDeleted()

ilTree::preloadDeleted ( array  $a_node_ids)

Preload deleted information.

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

1418 : void
1419 {
1420 if (!is_array($a_node_ids) || !$this->isCacheUsed()) {
1421 return;
1422 }
1423
1424 $query = 'SELECT ' . $this->tree_pk . ', child FROM ' . $this->table_tree . ' ' .
1425 'WHERE ' . $this->db->in("child", $a_node_ids, false, "integer");
1426
1427 $res = $this->db->query($query);
1428 while ($row = $this->db->fetchAssoc($res)) {
1429 if ($row[$this->tree_pk] < 0) {
1430 if ($this->__isMainTree()) {
1431 $this->is_saved_cache[$row["child"]] = true;
1432 }
1433 } else {
1434 if ($this->__isMainTree()) {
1435 $this->is_saved_cache[$row["child"]] = false;
1436 }
1437 }
1438 }
1439 }

References $res.

◆ preloadDepthParent()

ilTree::preloadDepthParent ( array  $a_node_ids)

Preload depth/parent.

Parameters
int[]

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

834 : void
835 {
836 global $DIC;
837
838 if (!$this->__isMainTree() || !$this->isCacheUsed()) {
839 return;
840 }
841
842 $res = $this->db->query('SELECT t.depth, t.parent, t.child ' .
843 'FROM ' . $this->table_tree . ' t ' .
844 'WHERE ' . $this->db->in("child", $a_node_ids, false, "integer") .
845 'AND ' . $this->tree_pk . ' = ' . $this->db->quote($this->tree_id, "integer"));
846 while ($row = $this->db->fetchAssoc($res)) {
847 $this->depth_cache[$row["child"]] = (int) $row["depth"];
848 $this->parent_cache[$row["child"]] = (int) $row["parent"];
849 }
850 }

References $DIC, $res, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ readRootId()

ilTree::readRootId ( )

Reimplemented in ilGlobalSkillTree.

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

1539 : int
1540 {
1541 $query = 'SELECT child FROM ' . $this->table_tree . ' ' .
1542 'WHERE parent = %s ' .
1543 'AND ' . $this->tree_pk . ' = %s ';
1544 $res = $this->db->queryF($query, array('integer', 'integer'), array(
1545 0,
1546 $this->tree_id
1547 ));
1548 $this->root_id = 0;
1549 if ($row = $this->db->fetchObject($res)) {
1550 $this->root_id = (int) $row->child;
1551 }
1552 return $this->root_id;
1553 }

References $res, and ILIAS\Repository\int().

Referenced by ilLMExplorerGUI\__construct(), ilSolutionExplorer\__construct(), ilTestTaxonomyTree\__construct(), ilLMTree\__construct(), ilWorkspaceTree\__construct(), ilTaxonomyTableGUI\__construct(), ilContainerSelectionExplorer\__construct(), ilObjContentObject\_checkPreconditionsOfPage(), ilObjContentObject\_getMissingPreconditionsTopChapter(), ilObjSCORMLearningModule\_getTrackingItems(), ilObjMediaPoolGUI\afterConstructor(), ilObjSkillTreeGUI\delete(), ilGlobalVirtualSkillTree\getChildsOfNode(), ilSkillTree\getMaxOrderNr(), ilTreeExplorerGUI\getTreeComponent(), ILIAS\Skill\Node\SkillTreeNodeManager\putIntoTree(), ilContentStyleSettingsGUI\saveScope(), ilGroupAddToGroupActionGUI\selectGroup(), ilGroupAddToGroupActionGUI\selectParent(), ilObjContentObjectGUI\showExportIDsOverview(), and ilObjWorkspaceFolderGUI\showMoveIntoObjectTree().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeTree()

ilTree::removeTree ( int  $a_tree_id)

remove an existing tree

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

1329 : bool
1330 {
1331 if ($this->__isMainTree()) {
1332 $this->logger->logStack(ilLogLevel::ERROR);
1333 throw new InvalidArgumentException('Operation not allowed on main tree');
1334 }
1335 if (!$a_tree_id) {
1336 $this->logger->logStack(ilLogLevel::ERROR);
1337 throw new InvalidArgumentException('Missing parameter tree id');
1338 }
1339
1340 $query = 'DELETE FROM ' . $this->table_tree .
1341 ' WHERE ' . $this->tree_pk . ' = %s ';
1342 $this->db->manipulateF($query, array('integer'), array($a_tree_id));
1343 return true;
1344 }

References ilLogLevel\ERROR, and ILIAS\Repository\logger().

+ Here is the call graph for this function:

◆ renumber()

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

Wrapper for renumber.

This method locks the table tree (recursive)

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

1606 : int
1607 {
1608 $renumber_callable = function (ilDBInterface $db) use ($node_id, $i, &$return) {
1609 $return = $this->__renumber($node_id, $i);
1610 };
1611
1612 // LOCKED ###################################
1613 if ($this->__isMainTree()) {
1614 $ilAtomQuery = $this->db->buildAtomQuery();
1615 $ilAtomQuery->addTableLock($this->table_tree);
1616
1617 $ilAtomQuery->addQueryCallable($renumber_callable);
1618 $ilAtomQuery->run();
1619 } else {
1620 $renumber_callable($this->db);
1621 }
1622 return $return;
1623 }
Interface ilDBInterface.

◆ resetInTreeCache()

ilTree::resetInTreeCache ( )
protected

reset in tree cache

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

325 : void
326 {
327 $this->in_tree_cache = array();
328 }

◆ setObjectTablePK()

ilTree::setObjectTablePK ( string  $a_column_name)

set column containing primary key in object table

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

362 : void
363 {
364 $this->obj_pk = $a_column_name;
365 }

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

+ Here is the caller graph for this function:

◆ setReferenceTablePK()

ilTree::setReferenceTablePK ( string  $a_column_name)

set column containing primary key in reference table

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

354 : void
355 {
356 $this->ref_pk = $a_column_name;
357 }

Referenced by ilWorkspaceTree\__construct().

+ Here is the caller graph for this function:

◆ setRootId()

ilTree::setRootId ( int  $a_root_id)

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

1560 : void
1561 {
1562 $this->root_id = $a_root_id;
1563 }

◆ setTableNames()

ilTree::setTableNames ( string  $a_table_tree,
string  $a_table_obj_data,
string  $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!

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

342 : void {
343 $this->table_tree = $a_table_tree;
344 $this->table_obj_data = $a_table_obj_data;
345 $this->table_obj_reference = $a_table_obj_reference;
346
347 // reconfigure tree implementation
348 $this->initTreeImplementation();
349 }

Referenced by ilSCORM2004Tree\__construct(), ilTaxonomyTree\__construct(), ilSCORMTree\__construct(), ilECSCmsTree\__construct(), ilLMTree\__construct(), ilWorkspaceTree\__construct(), ilSkillTree\__construct(), ILIAS\MediaPool\Tree\MediaPoolTree\__construct(), and ilObjMediaPool\_getPoolTree().

+ Here is the caller graph for this function:

◆ setTreeTablePK()

ilTree::setTreeTablePK ( string  $a_column_name)

set column containing primary key in tree table

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

370 : void
371 {
372 $this->tree_pk = $a_column_name;
373 }

Referenced by ilSCORM2004Tree\__construct(), ilTaxonomyTree\__construct(), ilSCORMTree\__construct(), ilLMTree\__construct(), ilWorkspaceTree\__construct(), ilSkillTree\__construct(), ILIAS\MediaPool\Tree\MediaPoolTree\__construct(), and ilObjMediaPool\_getPoolTree().

+ Here is the caller graph for this function:

◆ useCache()

ilTree::useCache ( bool  $a_use = true)

Use Cache (usually activated)

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

235 : void
236 {
237 $this->use_cache = $a_use;
238 }

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

+ Here is the caller graph for this function:

◆ validateParentRelations()

ilTree::validateParentRelations ( )

Validate parent relations of tree.

Returns
int[] array of failure nodes

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

778 : array
779 {
780 return $this->getTreeImplementation()->validateParentRelations();
781 }

Field Documentation

◆ $db

◆ $depth_cache

array ilTree::$depth_cache = []
protected

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

Referenced by getDepthCache().

◆ $eventHandler

ilAppEventHandler ilTree::$eventHandler
protected

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

◆ $gap

int ilTree::$gap
private

Size of the gaps to be created in the nested sets sequence numbering of the tree nodes.

Having gaps in the tree greatly improves performance on all operations that add or remove tree nodes. Setting this to zero will leave no gaps in the tree. Setting this to a value larger than zero will create gaps in the tree. Each gap leaves room in the sequence numbering for the specified number of nodes. (The gap is expressed as the number of nodes. Since each node consumes two sequence numbers, specifying a gap of 1 will leave space for 2 sequence numbers.) A gap is created, when a new child is added to a node, and when not enough room between node.rgt and the child with the highest node.rgt value of the node is available. A gap is closed, when a node is removed and when (node.rgt - node.lft) is bigger than gap * 2.

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

Referenced by getGap().

◆ $in_tree_cache

array ilTree::$in_tree_cache = []
protected

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

◆ $is_saved_cache

array ilTree::$is_saved_cache = []
protected

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

◆ $lang_code

string ilTree::$lang_code
private

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

◆ $logger

ilLogger ilTree::$logger
protected

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

◆ $obj_pk

string ilTree::$obj_pk
protected

column name containing primary key in object table

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

Referenced by ilWorkspaceTree\lookupObjectId().

◆ $oc_preloaded

array ilTree::$oc_preloaded = []
protected

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

◆ $parent_cache

array ilTree::$parent_cache = []
protected

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

Referenced by getParentCache().

◆ $parent_type_cache

array ilTree::$parent_type_cache = []
protected

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

◆ $path_id_cache

array ilTree::$path_id_cache = []
private

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

◆ $ref_pk

string ilTree::$ref_pk
protected

column name containing primary key in reference table

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

Referenced by ilWorkspaceTree\lookupNodeId().

◆ $root_id

int ilTree::$root_id
protected

points to root node (may be a subtree)

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

◆ $table_obj_data

string ilTree::$table_obj_data
protected

table name of object_data table

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

Referenced by getObjectDataTable().

◆ $table_obj_reference

string ilTree::$table_obj_reference
protected

table name of object_reference table

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

Referenced by getTableReference().

◆ $table_tree

string ilTree::$table_tree
protected

table name of tree table

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

Referenced by getTreeTable().

◆ $translation_cache

array ilTree::$translation_cache = []
protected

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

◆ $tree_id

int ilTree::$tree_id
protected

to use different trees in one db-table

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

◆ $tree_impl

ilTreeImplementation ilTree::$tree_impl = null
private

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

Referenced by getTreeImplementation().

◆ $tree_pk

string ilTree::$tree_pk
protected

column name containing tree id in tree table

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

Referenced by getTreePk().

◆ $use_cache

bool ilTree::$use_cache
protected

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

Referenced by isCacheUsed().

◆ DEFAULT_GAP

const ilTree::DEFAULT_GAP = 50
protected

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

Referenced by __construct().

◆ DEFAULT_LANGUAGE

const ilTree::DEFAULT_LANGUAGE = 'en'
protected

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

Referenced by __construct(), and initLangCode().

◆ POS_FIRST_NODE

◆ POS_LAST_NODE

◆ RELATION_CHILD

const ilTree::RELATION_CHILD = 1

◆ RELATION_EQUALS

const ilTree::RELATION_EQUALS = 4

◆ RELATION_NONE

const ilTree::RELATION_NONE = 5

◆ RELATION_PARENT

const ilTree::RELATION_PARENT = 2

◆ RELATION_SIBLING

const ilTree::RELATION_SIBLING = 3

◆ TREE_TYPE_MATERIALIZED_PATH

const ilTree::TREE_TYPE_MATERIALIZED_PATH = 'mp'

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

◆ TREE_TYPE_NESTED_SET

const ilTree::TREE_TYPE_NESTED_SET = 'ns'

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


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