aboutsummaryrefslogtreecommitdiff
path: root/mod/ecml/views/default/ecml/keywords/user_list.php
blob: 2f2f09c49039975b558341be609c1a377b503686 (plain)
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
<?php
/**
 * Lists users
 *
 * @package SitePages
 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
 * @author Curverider Ltd
 * @copyright Curverider Ltd 2008-2010
 * @link http://elgg.org/
 */

$only_with_avatars = (isset($vars['only_with_avatars'])) ? $vars['only_with_avatars'] : TRUE;
$list_type = (isset($vars['list_type'])) ? $vars['list_type'] : 'newest';
$limit = (isset($vars['limit'])) ? $vars['limit'] : 10;

$options = array(
	'type' => 'user',
	'limit' => $limit
);

if ($only_with_avatars == TRUE) {
	$options['metadata_name_value_pairs'] = array('name' => 'icontime', 'operand' => '!=', 'value' => 0);
}

switch ($list_type) {
	case 'newest':
		$options['order_by'] = 'e.time_created DESC';
		break;

	case 'online':
		// show people with a last action of < 10 minutes.
		$last_action = time() - 10 * 60;
		$options['joins'] = array("JOIN {$vars['config']->dbprefix}users_entity ue on ue.guid = e.guid");
		$options['wheres'] = array("ue.last_action > $last_action");
		break;

	case 'random':
		$options['order_by'] = 'RAND()';
		break;

	default:
		break;
}

$users = elgg_get_entities_from_metadata($options);

echo elgg_view_entity_list($users, count($users), 0, $limit, FALSE, FALSE, FALSE);