JHtmlAccess/usergroup
From Joomla! Documentation
< API16:JHtmlAccessRevision as of 21:56, 13 May 2013 by JoomlaWikiBot (talk | contribs) (removing red link to edit, no existant pages)
Revision as of 21:56, 13 May 2013 by JoomlaWikiBot (talk | contribs) (removing red link to edit, no existant pages)
The "API16" 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.
Description[edit]
Displays a list of the available user groups.
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
Syntax[edit]
static usergroup($name, $selected, $attribs= '', $allowAll=true)
Parameter Name | Default Value | Description |
---|---|---|
$name | The form field name. | |
$selected | The name of the selected section. | |
$attribs | Additional attributes to add to the select field. | |
$allowAll | true | True to add "All Groups" option. |
Returns[edit]
string The required HTML for the SELECT tag.
Defined in[edit]
libraries/joomla/html/html/access.php
Importing[edit]
jimport( 'joomla.html.html.access' );
Source Body[edit]
public static function usergroup($name, $selected, $attribs = '', $allowAll = true)
{
$db = &JFactory::getDbo();
$db->setQuery(
'SELECT a.id AS value, a.title AS text, COUNT(DISTINCT b.id) AS level' .
' 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();
// Check for a database error.
if ($db->getErrorNum()) {
JError::raiseNotice(500, $db->getErrorMsg());
return null;
}
for ($i=0,$n=count($options); $i < $n; $i++) {
$options[$i]->text = str_repeat('- ',$options[$i]->level).$options[$i]->text;
}
// If all usergroups is allowed, push it into the array.
if ($allowAll) {
array_unshift($options, JHtml::_('select.option', '', JText::_('JOption_Access_Show_All_Groups')));
}
return JHtml::_('select.genericlist', $options, $name,
array(
'list.attr' => $attribs,
'list.select' => $selected
)
);
}
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples[edit]
<CodeExamplesForm />