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>[<! removed edit link to red link >]</nowiki> |
</span> | </span> | ||
− | + | <! 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>[<! removed edit link to red link >]</nowiki> |
</span> | </span> | ||
− | + | <! removed transcluded page call, red link never existed > | |
===Examples=== | ===Examples=== | ||
Line 78: | Line 78: | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
+ | [[Category:Archived pages API16]] |
Revision as of 20:56, 12 May 2013
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]
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[edit]
getUsersByGroup($groupId, $recursive=false)
Parameter Name | Default Value | Description |
---|---|---|
$groupId | The group Id | |
$recursive | false | Recursively include all child groups (optional) |
Returns[edit]
array
Defined in[edit]
libraries/joomla/access/access.php
Importing[edit]
jimport( 'joomla.access.access' );
Source Body[edit]
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[edit]
<CodeExamplesForm />