aboutsummaryrefslogtreecommitdiff
path: root/mod/bulk_user_admin/views/default/admin/user.php
blob: c63f091ec0ac5cd0cc8f0ad23cbfd4d77a4ab69a (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
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
/**
 * Display a list of users to delete in bulk.
 *
 * Also used to show the search by domain results
 */

// Are we performing a search
$limit = get_input('limit', 10);
$offset = get_input('offset', 0);
$domain = get_input('domain');

$context = elgg_get_context();

if (!$domain) {
	$title = elgg_echo('admin:user');
} else {
	$title = "Users in the domain $domain";
}

elgg_set_context('search');

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

if ($domain) {
	$users = bulk_user_admin_get_users_by_email_domain($domain, $options);
	$options['count'] = true;
	$users_count = bulk_user_admin_get_users_by_email_domain($domain, $options);
} else {
	$users = elgg_get_entities($options);
	$options['count'] = true;
	$users_count = elgg_get_entities($options);
}

$pagination = elgg_view('navigation/pagination', array(
	'baseurl' => current_page_url(),
	'offset' => $offset,
	'count' => $users_count
));

$form_body = '';
foreach ($users as $user) {
	$form_body .= elgg_view('bulk_user_admin/user', array('entity' => $user));
}

$delete_button = elgg_view('input/submit', array(
	'value' => 'Delete checked',
));

$form_body .= $delete_button;

$site = elgg_get_config('site');

$checked_form = elgg_view('input/form', array(
	'action' =>  $site->url . 'action/bulk_user_admin/delete',
	'body' => $form_body
));


$domain_form = '';

if ($domain) {
	$delete_button = "<br /><br />" . elgg_view('input/submit', array(
		'value' => 'Delete all in domain',
	));

	$hidden = elgg_view('input/hidden', array(
		'name' => 'domain',
		'value' => $domain
	));

	$form_body = $delete_button . $hidden;

	$domain_form = elgg_view('input/form', array(
		'action' =>  $site->url . 'action/bulk_user_admin/delete_by_domain',
		'body' => $form_body
	));

}

$summary = "<div>$users_count user(s) found</div>";

if ($domain) {
	$summary .= '<br />';
	$summary .= elgg_view('output/url', array(
		'href' => elgg_http_remove_url_query_element(current_page_url(), 'domain'),
		'text' => 'All users'
	));
}

elgg_set_context('admin');

echo $title . $summary . $pagination . $checked_form . $domain_form . $pagination;