user.php
1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/**
* @package Joomla.Libraries
* @subpackage HTML
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
/**
* Utility class working with users
*
* @since 2.5
*/
abstract class JHtmlUser
{
/**
* Displays a list of user groups.
*
* @param boolean $includeSuperAdmin true to include super admin groups, false to exclude them
*
* @return array An array containing a list of user groups.
*
* @since 2.5
*/
public static function groups($includeSuperAdmin = false)
{
$options = array_values(JHelperUsergroups::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;
$groups[] = JHtml::_('select.option', $options[$i]->value, $options[$i]->text);
}
// Exclude super admin groups if requested
if (!$includeSuperAdmin)
{
$filteredGroups = array();
foreach ($groups as $group)
{
if (!JAccess::checkGroup($group->value, 'core.admin'))
{
$filteredGroups[] = $group;
}
}
$groups = $filteredGroups;
}
return $groups;
}
/**
* Get a list of users.
*
* @return string
*
* @since 2.5
*/
public static function userlist()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('a.id AS value, a.name AS text')
->from('#__users AS a')
->where('a.block = 0')
->order('a.name');
$db->setQuery($query);
return $db->loadObjectList();
}
}