API15:JAuthorization/get group children tree
From Joomla! Documentation
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.
Description:JAuthorization/get group children tree
Contents |
Syntax
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
string|array String if html, otherwise an array
Defined in
libraries/joomla/user/authorization.php
Importing
jimport( 'joomla.user.authorization' );
Source Body
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; }
[Edit See Also] SeeAlso:JAuthorization/get group children tree
Examples
<CodeExamplesForm />
