JAuthorization/get group children tree
From Joomla! Documentation
< API15:JAuthorization
The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.
<! removed transcluded page call, red link never existed >
Syntax[edit]
get_group_children_tree($root_id=null, $root_name=null, $inclusive=true, $html=true)
Parameter Name | Default Value | Description |
---|---|---|
$root_id | null | |
$root_name | null | |
$inclusive | true | |
$html | true | Returns the complete html if true |
Returns[edit]
string|array String if html, otherwise an array
Defined in[edit]
libraries/joomla/user/authorization.php
Importing[edit]
jimport( 'joomla.user.authorization' );
Source Body[edit]
function get_group_children_tree( $root_id=null, $root_name=null, $inclusive=true, $html=true )
{
$db =& JFactory::getDBO();
$tree = $this->_getBelow( '#__core_acl_aro_groups',
'g1.id, g1.name, COUNT(g2.name) AS level',
'g1.name',
$root_id, $root_name, $inclusive );
// first pass get level limits
$n = count( $tree );
$min = $tree[0]->level;
$max = $tree[0]->level;
for ($i=0; $i < $n; $i++) {
$min = min( $min, $tree[$i]->level );
$max = max( $max, $tree[$i]->level );
}
$indents = array();
foreach (range( $min, $max ) as $i) {
$indents[$i] = ' ';
}
// correction for first indent
$indents[$min] = '';
$list = array();
for ($i=$n-1; $i >= 0; $i--) {
$shim = '';
foreach (range( $min, $tree[$i]->level ) as $j) {
$shim .= $indents[$j];
}
if (@$indents[$tree[$i]->level+1] == '. ') {
$twist = ' ';
} else {
$twist = "- ";
}
$groupName = JText::_( $tree[$i]->name );
//$list[$i] = $tree[$i]->level.$shim.$twist.$tree[$i]->name;
if ($html) {
$list[$i] = JHTML::_('select.option', $tree[$i]->id, $shim.$twist.$groupName );
} else {
$list[$i] = array( 'value'=>$tree[$i]->id, 'text'=>$shim.$twist.$groupName );
}
if ($tree[$i]->level < @$tree[$i-1]->level) {
$indents[$tree[$i]->level+1] = '. ';
}
}
ksort($list);
return $list;
}
<! removed transcluded page call, red link never existed >
Examples[edit]
Code Examples[edit]