forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_bulk.php
87 lines (73 loc) · 2.88 KB
/
user_bulk.php
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
<?php
require_once('../../config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->dirroot.'/'.$CFG->admin.'/user/lib.php');
require_once($CFG->dirroot.'/'.$CFG->admin.'/user/user_bulk_forms.php');
admin_externalpage_setup('userbulk');
if (!isset($SESSION->bulk_users)) {
$SESSION->bulk_users = array();
}
// create the user filter form
$ufiltering = new user_filtering();
// array of bulk operations
// create the bulk operations form
$action_form = new user_bulk_action_form();
if ($data = $action_form->get_data()) {
// check if an action should be performed and do so
switch ($data->action) {
case 1: redirect($CFG->wwwroot.'/'.$CFG->admin.'/user/user_bulk_confirm.php');
case 2: redirect($CFG->wwwroot.'/'.$CFG->admin.'/user/user_bulk_message.php');
case 3: redirect($CFG->wwwroot.'/'.$CFG->admin.'/user/user_bulk_delete.php');
case 4: redirect($CFG->wwwroot.'/'.$CFG->admin.'/user/user_bulk_display.php');
case 5: redirect($CFG->wwwroot.'/'.$CFG->admin.'/user/user_bulk_download.php');
//case 6: redirect($CFG->wwwroot.'/'.$CFG->admin.'/user/user_bulk_enrol.php'); //TODO: MDL-24064
case 7: redirect($CFG->wwwroot.'/'.$CFG->admin.'/user/user_bulk_forcepasswordchange.php');
case 8: redirect($CFG->wwwroot.'/'.$CFG->admin.'/user/user_bulk_cohortadd.php');
}
}
$user_bulk_form = new user_bulk_form(null, get_selection_data($ufiltering));
if ($data = $user_bulk_form->get_data()) {
if (!empty($data->addall)) {
add_selection_all($ufiltering);
} else if (!empty($data->addsel)) {
if (!empty($data->ausers)) {
if (in_array(0, $data->ausers)) {
add_selection_all($ufiltering);
} else {
foreach($data->ausers as $userid) {
if ($userid == -1) {
continue;
}
if (!isset($SESSION->bulk_users[$userid])) {
$SESSION->bulk_users[$userid] = $userid;
}
}
}
}
} else if (!empty($data->removeall)) {
$SESSION->bulk_users= array();
} else if (!empty($data->removesel)) {
if (!empty($data->susers)) {
if (in_array(0, $data->susers)) {
$SESSION->bulk_users= array();
} else {
foreach($data->susers as $userid) {
if ($userid == -1) {
continue;
}
unset($SESSION->bulk_users[$userid]);
}
}
}
}
// reset the form selections
unset($_POST);
$user_bulk_form = new user_bulk_form(null, get_selection_data($ufiltering));
}
// do output
echo $OUTPUT->header();
$ufiltering->display_add();
$ufiltering->display_active();
$user_bulk_form->display();
$action_form->display();
echo $OUTPUT->footer();