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 6: redirect($CFG->wwwroot.'/'.$CFG->admin.'/user/user_bulk_enrol.php'); //TODO: MDL-24064
28 case 7: redirect($CFG->wwwroot
.'/'.$CFG->admin
.'/user/user_bulk_forcepasswordchange.php');
29 case 8: redirect($CFG->wwwroot
.'/'.$CFG->admin
.'/user/user_bulk_cohortadd.php');
33 $user_bulk_form = new user_bulk_form(null, get_selection_data($ufiltering));
35 if ($data = $user_bulk_form->get_data()) {
36 if (!empty($data->addall
)) {
37 add_selection_all($ufiltering);
39 } else if (!empty($data->addsel
)) {
40 if (!empty($data->ausers
)) {
41 if (in_array(0, $data->ausers
)) {
42 add_selection_all($ufiltering);
44 foreach($data->ausers
as $userid) {
48 if (!isset($SESSION->bulk_users
[$userid])) {
49 $SESSION->bulk_users
[$userid] = $userid;
55 } else if (!empty($data->removeall
)) {
56 $SESSION->bulk_users
= array();
58 } else if (!empty($data->removesel
)) {
59 if (!empty($data->susers
)) {
60 if (in_array(0, $data->susers
)) {
61 $SESSION->bulk_users
= array();
63 foreach($data->susers
as $userid) {
67 unset($SESSION->bulk_users
[$userid]);
73 // reset the form selections
75 $user_bulk_form = new user_bulk_form(null, get_selection_data($ufiltering));
78 echo $OUTPUT->header();
80 $ufiltering->display_add();
81 $ufiltering->display_active();
83 $user_bulk_form->display();
85 $action_form->display();
87 echo $OUTPUT->footer();