From a439127b757a0dd746228b1379a99b3ed6f1d077 Mon Sep 17 00:00:00 2001 From: Fabian Schmid Date: Wed, 5 Aug 2015 09:41:19 +0200 Subject: [PATCH] added getChildIds --- Services/Tree/classes/class.ilTree.php | 37 +++++++++++++++++++++----- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/Services/Tree/classes/class.ilTree.php b/Services/Tree/classes/class.ilTree.php index eb11f16235ce..2bb650f1f66d 100755 --- a/Services/Tree/classes/class.ilTree.php +++ b/Services/Tree/classes/class.ilTree.php @@ -488,13 +488,36 @@ public function getRelationOfNodes($a_node_a_arr, $a_node_b_arr) } /** - * get child nodes of given node - * @access public - * @param integer node_id - * @param string sort order of returned childs, optional (possible values: 'title','desc','last_update' or 'type') - * @param string sort direction, optional (possible values: 'DESC' or 'ASC'; defalut is 'ASC') - * @return array with node data of all childs or empty array - */ + * Get node child ids + * @global type $ilDB + * @param type $a_node + * @return type + */ + public function getChildIds($a_node) + { + global $ilDB; + + $query = 'SELECT * FROM tree '. + 'WHERE parent = '.$ilDB->quote($a_node,'integer').' '. + 'AND tree > '.$ilDB->quote(0,'integer'); + $res = $ilDB->query($query); + + $childs = array(); + while($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) + { + $childs[] = $row->child; + } + return $childs; + } + + /** + * get child nodes of given node + * @access public + * @param integer node_id + * @param string sort order of returned childs, optional (possible values: 'title','desc','last_update' or 'type') + * @param string sort direction, optional (possible values: 'DESC' or 'ASC'; defalut is 'ASC') + * @return array with node data of all childs or empty array + */ function getChilds($a_node_id, $a_order = "", $a_direction = "ASC") { global $ilBench,$ilDB, $ilObjDataCache, $ilUser;