3 require_once('../../config.php');
4 require_once($CFG->libdir
.'/adminlib.php');
5 require_once($CFG->dirroot
.'/'.$CFG->admin
.'/user/lib.php');
6 require_once($CFG->dirroot
.'/'.$CFG->admin
.'/user/user_bulk_forms.php');
8 admin_externalpage_setup('userbulk');
10 if (!isset($SESSION->bulk_users
)) {
11 $SESSION->bulk_users
= array();
13 // create the user filter form
14 $ufiltering = new user_filtering();
16 // array of bulk operations
17 // create the bulk operations form
18 $action_form = new user_bulk_action_form();
19 if ($data = $action_form->get_data()) {
20 // check if an action should be performed and do so
21 switch ($data->action
) {
22 case 1: redirect($CFG->wwwroot
.'/'.$CFG->admin
.'/user/user_bulk_confirm.php');
23 case 2: redirect($CFG->wwwroot
.'/'.$CFG->admin
.'/user/user_bulk_message.php');
24 case 3: redirect($CFG->wwwroot
.'/'.$CFG->admin
.'/user/user_bulk_delete.php');
25 case 4: redirect($CFG->wwwroot
.'/'.$CFG->admin
.'/user/user_bulk_display.php');
26 case 5: redirect($CFG->wwwroot
.'/'.$CFG->admin
.'/user/user_bulk_download.php');
27 case 7: redirect($CFG->wwwroot
.'/'.$CFG->admin
.'/user/user_bulk_forcepasswordchange.php');
28 case 8: redirect($CFG->wwwroot
.'/'.$CFG->admin
.'/user/user_bulk_cohortadd.php');
32 $user_bulk_form = new user_bulk_form(null, get_selection_data($ufiltering));
34 if ($data = $user_bulk_form->get_data()) {
35 if (!empty($data->addall
)) {
36 add_selection_all($ufiltering);
38 } else if (!empty($data->addsel
)) {
39 if (!empty($data->ausers
)) {
40 if (in_array(0, $data->ausers
)) {
41 add_selection_all($ufiltering);
43 foreach($data->ausers
as $userid) {
47 if (!isset($SESSION->bulk_users
[$userid])) {
48 $SESSION->bulk_users
[$userid] = $userid;
54 } else if (!empty($data->removeall
)) {
55 $SESSION->bulk_users
= array();
57 } else if (!empty($data->removesel
)) {
58 if (!empty($data->susers
)) {
59 if (in_array(0, $data->susers
)) {
60 $SESSION->bulk_users
= array();
62 foreach($data->susers
as $userid) {
66 unset($SESSION->bulk_users
[$userid]);
72 // reset the form selections
74 $user_bulk_form = new user_bulk_form(null, get_selection_data($ufiltering));
77 echo $OUTPUT->header();
79 $ufiltering->display_add();
80 $ufiltering->display_active();
82 $user_bulk_form->display();
84 $action_form->display();
86 echo $OUTPUT->footer();