Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added getChildIds #3

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 30 additions & 7 deletions Services/Tree/classes/class.ilTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down