Actions

API16

Difference between revisions of "JAccess/getUsersByGroup"

From Joomla! Documentation

< API16:JAccess
(New page: ===Description=== Method to return a list of user Ids contained in a Group <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>[[Description:JAccess/getUsersByGroup|Ed...)
 
m (removing red link to edit, no existant pages)
 
Line 3: Line 3:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JAccess/getUsersByGroup|Edit Descripton]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
  
{{Description:JAccess/getUsersByGroup}}
+
<! removed transcluded page call, red link never existed >
  
 
===Syntax===
 
===Syntax===
Line 63: Line 63:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[SeeAlso:JAccess/getUsersByGroup|Edit See Also]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
{{SeeAlso:JAccess/getUsersByGroup}}
+
<! removed transcluded page call, red link never existed >
  
 
===Examples===
 
===Examples===
Line 78: Line 78:
 
  format= ,,,
 
  format= ,,,
 
</dpl>
 
</dpl>
 +
[[Category:Archived pages API16]]

Latest revision as of 20:56, 12 May 2013

Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Method to return a list of user Ids contained in a Group

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax

getUsersByGroup($groupId, $recursive=false)
Parameter Name Default Value Description
$groupId The group Id
$recursive false Recursively include all child groups (optional)

Returns

array

Defined in

libraries/joomla/access/access.php

Importing

jimport( 'joomla.access.access' );

Source Body

public function getUsersByGroup($groupId, $recursive = false)
{
        // Get a database object.
        $db     = JFactory::getDbo();
 
        $test = $recursive ? '>=' : '=';
 
        // First find the users contained in the group
        $query  = $db->getQuery(true);
        $query->select('DISTINCT(user_id)');
        $query->from('#__usergroups as ug1');
        $query->join('INNER','#__usergroups AS ug2 ON ug2.lft'.$test.'ug1.lft AND ug1.rgt'.$test.'ug2.rgt');
        $query->join('INNER','#__user_usergroup_map AS m ON ug2.id=m.group_id');
        $query->where('ug1.id='.$db->Quote($groupId));
 
        $db->setQuery($query);
 
        $result = $db->loadResultArray();
 
        // Clean up any NULL values, just in case
        JArrayHelper::toInteger($result);
 
        return $result;
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

<CodeExamplesForm />