JHtmlRules/ getUserGroups
From Joomla! Documentation
< JHtmlRules(Difference between revisions)
Current revision
Contents |
Syntax
static JHtmlRules::_getUserGroups()
Defined in
libraries/joomla/html/html/rules.php
Importing
jimport( 'joomla.html.html.rules' );
Source Body
protected static function _getUserGroups()
{
// Get a database object.
$db = JFactory::getDBO();
// Get the user groups from the database.
$db->setQuery(
'SELECT a.id AS value, a.title AS text, COUNT(DISTINCT b.id) AS level' .
' , GROUP_CONCAT(b.id SEPARATOR \',\') AS parents' .
' FROM #__usergroups AS a' .
' LEFT JOIN `#__usergroups` AS b ON a.lft > b.lft AND a.rgt < b.rgt' .
' GROUP BY a.id' .
' ORDER BY a.lft ASC'
);
$options = $db->loadObjectList();
// Pre-compute additional values.
foreach ($options as &$option)
{
// Pad the option text with spaces using depth level as a multiplier.
//$option->text = str_repeat(' ',$option->level).$option->text;
$option->identities = ($option->parents) ? explode(',', $option->parents.','.$option->value) : array($option->value);
}
return $options;
}
