Should be $COURSE not $course
[moodle-linuxchix.git] / admin / user_bulk.php
blobf7fcece4dce1ff3609f898469b70d917659e95a7
1 <?php //$Id$
2 require_once('../config.php');
3 require_once($CFG->libdir.'/adminlib.php');
4 require_once($CFG->libdir.'/dmllib.php');
6 require_once($CFG->dirroot.'/user/filters/text.php');
7 require_once($CFG->dirroot.'/user/filters/select.php');
8 require_once($CFG->dirroot.'/user/filters/courserole.php');
9 require_once($CFG->dirroot.'/user/filters/globalrole.php');
10 require_once($CFG->dirroot.'/user/filters/profilefield.php');
11 require_once($CFG->dirroot.'/user/filters/yesno.php');
13 require_once($CFG->dirroot.'/admin/user_bulk_form.php');
14 define("MAX_USERS_PER_PAGE", 5000);
16 $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
18 // array of bulk operations
19 $actions = array();
20 $actions[1] = get_string('confirm');
21 if (has_capability('moodle/site:readallmessages', $sitecontext) && !empty($CFG->messaging)) {
22 $actions[2] = get_string('messageselectadd');
24 $actions[3] = get_string('delete');
26 // create the bulk operations form
27 $user_bulk_form =& new user_bulk_form(null, $actions);
28 // check if an action should be performed and do so
29 switch ($user_bulk_form->getAction()) {
30 case 1:
31 include($CFG->dirroot . '/admin/user_bulk_confirm.php');
32 return;
33 case 2:
34 include($CFG->dirroot . '/admin/user_bulk_message.php');
35 return;
36 case 3:
37 include($CFG->dirroot . '/admin/user_bulk_delete.php');
38 return;
41 // prepare user filter types
42 $filters[] = new user_filter_text('username', get_string('username'), 'username');
43 $filters[] = new user_filter_text('realname', get_string('fullname'), sql_fullname());
44 $filters[] = new user_filter_text('email', get_string('email'), 'email');
45 $filters[] = new user_filter_text('city', get_string('city'), 'city');
46 $filters[] = new user_filter_select('country', get_string('country'), 'country', get_list_of_countries());
47 $filters[] = new user_filter_yesno('confirmed', get_string('confirm'), 'confirmed');
48 $filters[] = new user_filter_profilefield('profile', get_string('profile'));
49 $filters[] = new user_filter_courserole('course', get_string('courserole', 'filters'));
50 $filters[] = new user_filter_globalrole('system', get_string('globalrole', 'role'));
52 // create the user filter form
53 $user_filter_form =& new user_filter_form(null, $filters);
55 // do output
56 admin_externalpage_setup('editusers');
57 admin_externalpage_print_header();
59 // put the user filter form first
60 $user_filter_form->display();
61 // get the SQL filter
62 $where =& $user_filter_form->getSQLFilter('id<>1 AND NOT deleted');
63 $ausercount = count_records_select('user', $where);
64 // limit the number of options
65 if($ausercount <= MAX_USERS_PER_PAGE) {
66 $user_bulk_form->setAvailableUsersSQL($where);
67 } else {
68 echo get_string('toomanytoshow');
70 // display the bulk user form
71 $user_bulk_form->display();
72 admin_externalpage_print_footer();