public static function usergroup($name, $selected, $attribs = '', $allowAll = true)
	{
		$db = App::get('db');
		$query = $db->getQuery()
			->select('a.id', 'value')
			->select('a.title', 'text')
			->select('COUNT(DISTINCT b.id)', 'level')
			->from('#__usergroups', 'a')
			->joinRaw('#__usergroups AS b', 'a.lft > b.lft AND a.rgt < b.rgt', 'left')
			->group('a.id')
			->group('a.title')
			->group('a.lft')
			->group('a.rgt')
			->order('a.lft', 'asc');
		$db->setQuery($query->toString());
		$options = $db->loadObjectList();

		// Check for a database error.
		if ($db->getErrorNum())
		{
			throw new Exception($db->getErrorMsg(), 500, E_WARNING);
			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, Select::option('', Lang::txt('JOPTION_ACCESS_SHOW_ALL_GROUPS')));
		}

		return Select::genericlist($options, $name, array('list.attr' => $attribs, 'list.select' => $selected));
	}
public static function usergroup($name, $selected, $attribs = '', $allowAll = true)
	{
		$db = App::get('db');
		$query = $db->getQuery()
			->select('a.id', 'value')
			->select('a.title', 'text')
			->select('COUNT(DISTINCT b.id)', 'level')
			->from('#__usergroups', 'a')
			->joinRaw('#__usergroups AS b', 'a.lft > b.lft AND a.rgt < b.rgt', 'left')
			->group('a.id')
			->group('a.title')
			->group('a.lft')
			->group('a.rgt')
			->order('a.lft', 'asc');
		$db->setQuery($query->toString());
		$options = $db->loadObjectList();

		// Check for a database error.
		if ($db->getErrorNum())
		{
			throw new Exception($db->getErrorMsg(), 500, E_WARNING);
			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, Select::option('', Lang::txt('JOPTION_ACCESS_SHOW_ALL_GROUPS')));
		}

		return Select::genericlist($options, $name, array('list.attr' => $attribs, 'list.select' => $selected));
	}
public static function usergroup ( $ name , $ selected , $ attribs = '' , $ allowAll = true ) { $ db = App :: get ( 'db' ) ; $ query = $ db -> getQuery ( ) -> select ( 'a.id' , 'value' ) -> select ( 'a.title' , 'text' ) -> select ( 'COUNT(DISTINCT b.id)' , 'level' ) -> from ( '#__usergroups' , 'a' ) -> joinRaw ( '#__usergroups AS b' , 'a.lft > b.lft AND a.rgt < b.rgt' , 'left' ) -> group ( 'a.id' ) -> group ( 'a.title' ) -> group ( 'a.lft' ) -> group ( 'a.rgt' ) -> order ( 'a.lft' , 'asc' ) ; $ db -> setQuery ( $ query -> toString ( ) ) ; $ options = $ db -> loadObjectList ( ) ; // Check for a database error. if ( $ db -> getErrorNum ( ) ) { throw new Exception ( $ db -> getErrorMsg ( ) , 500 , E_WARNING ) ; 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 , Select :: option ( '' , Lang :: txt ( 'JOPTION_ACCESS_SHOW_ALL_GROUPS' ) ) ) ; } return Select :: genericlist ( $ options , $ name , array ( 'list.attr' => $ attribs , 'list.select' => $ selected ) ) ; }
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.
@return  string   The required HTML for the SELECT tag.
Displays a list of the available user groups .