public static string
usergroup
(mixed $name, mixed $selected, mixed $attribs = '', mixed $allowAll = true, mixed $id = false)
/**
* Displays a list of the available user groups.
*
* @param string $name The form field name.
* @param string $selected The name of the selected section.
* @param string $attribs Additional attributes to add to the select field.
* @param boolean $allowAll True to add "All Groups" option.
* @param mixed $id The form field id
*
* @return string The required HTML for the SELECT tag.
*
* @see \Joomla\CMS\Form\Field\UsergrouplistField
* @since 1.6
*/
public static function usergroup($name, $selected, $attribs = '', $allowAll = true, $id = false)
{
$options = array_values(UserGroupsHelper::getInstance()->getAll());
for ($i = 0, $n = count($options); $i < $n; $i++) {
$options[$i]->value = $options[$i]->id;
$options[$i]->text = str_repeat('- ', $options[$i]->level) . $options[$i]->title;
}
// If all usergroups is allowed, push it into the array.
if ($allowAll) {
array_unshift($options, HTMLHelper::_('select.option', '', Text::_('JOPTION_ACCESS_SHOW_ALL_GROUPS')));
}
return HTMLHelper::_('select.genericlist', $options, $name, array('list.attr' => $attribs, 'list.select' => $selected, 'id' => $id));
}