public static function getUsersByGroup($groupId, $recursive = false)
	{
		$test = $recursive ? '>=' : '=';

		// First find the users contained in the group
		$db = App::get('db');
		$query = $db->getQuery()
			->select('DISTINCT(user_id)')
			->from('#__usergroups', 'ug1')
			->joinRaw('#__usergroups AS ug2', 'ug2.lft' . $test . 'ug1.lft AND ug1.rgt' . $test . 'ug2.rgt', 'inner')
			->join('#__user_usergroup_map AS m', 'm.group_id', 'ug2.id', 'inner')
			->whereEquals('ug1.id', $groupId);

		$db->setQuery($query->toString());

		$result = $db->loadColumn();

		// Clean up any NULL values, just in case
		Arr::toInteger($result);

		return $result;
	}
public static function getUsersByGroup($groupId, $recursive = false)
	{
		$test = $recursive ? '>=' : '=';

		// First find the users contained in the group
		$db = App::get('db');
		$query = $db->getQuery()
			->select('DISTINCT(user_id)')
			->from('#__usergroups', 'ug1')
			->joinRaw('#__usergroups AS ug2', 'ug2.lft' . $test . 'ug1.lft AND ug1.rgt' . $test . 'ug2.rgt', 'inner')
			->join('#__user_usergroup_map AS m', 'm.group_id', 'ug2.id', 'inner')
			->whereEquals('ug1.id', $groupId);

		$db->setQuery($query->toString());

		$result = $db->loadColumn();

		// Clean up any NULL values, just in case
		Arr::toInteger($result);

		return $result;
	}
public static function getUsersByGroup ( $ groupId , $ recursive = false ) { $ test = $ recursive ? '>=' : '=' ; // First find the users contained in the group $ db = App :: get ( 'db' ) ; $ query = $ db -> getQuery ( ) -> select ( 'DISTINCT(user_id)' ) -> from ( '#__usergroups' , 'ug1' ) -> joinRaw ( '#__usergroups AS ug2' , 'ug2.lft' . $ test . 'ug1.lft AND ug1.rgt' . $ test . 'ug2.rgt' , 'inner' ) -> join ( '#__user_usergroup_map AS m' , 'm.group_id' , 'ug2.id' , 'inner' ) -> whereEquals ( 'ug1.id' , $ groupId ) ; $ db -> setQuery ( $ query -> toString ( ) ) ; $ result = $ db -> loadColumn ( ) ; // Clean up any NULL values, just in case Arr :: toInteger ( $ result ) ; return $ result ; }
Method to return a list of user Ids contained in a Group

@param   integer  $groupId    The group Id
@param   boolean  $recursive  Recursively include all child groups (optional)
@return  array
@todo    This method should move somewhere else
Method to return a list of user Ids contained in a Group