file check_defaults.class.php was added on branch MOODLE_19_STABLE on 2008-05-15...
[moodle-linuxchix.git] / admin / user / user_bulk_confirm.php
blobfe0a8bfbaa7b60f0d3a0732fe1047a89ac0673ba
1 <?php //$Id$
2 /**
3 * script for bulk user delete operations
4 */
6 require_once('../../config.php');
7 require_once($CFG->libdir.'/adminlib.php');
9 $confirm = optional_param('confirm', 0, PARAM_BOOL);
11 admin_externalpage_setup('userbulk');
12 require_capability('moodle/user:update', get_context_instance(CONTEXT_SYSTEM));
14 $return = $CFG->wwwroot.'/'.$CFG->admin.'/user/user_bulk.php';
16 if (empty($SESSION->bulk_users)) {
17 redirect($return);
20 admin_externalpage_print_header();
22 //TODO: add support for large number of users
24 if ($confirm and confirm_sesskey()) {
25 $in = implode(',', $SESSION->bulk_users);
26 if ($rs = get_recordset_select('user', "id IN ($in)", '', 'id, username, secret, confirmed, auth, firstname, lastname')) {
27 while ($user = rs_fetch_next_record($rs)) {
28 if ($user->confirmed) {
29 continue;
31 $auth = get_auth_plugin($user->auth);
32 $result = $auth->user_confirm(addslashes($user->username), addslashes($user->secret));
33 if ($result != AUTH_CONFIRM_OK && $result != AUTH_CONFIRM_ALREADY) {
34 notify(get_string('usernotconfirmed', '', fullname($user, true)));
37 rs_close($rs);
39 redirect($return, get_string('changessaved'));
41 } else {
42 $in = implode(',', $SESSION->bulk_users);
43 $userlist = get_records_select_menu('user', "id IN ($in)", 'fullname', 'id,'.sql_fullname().' AS fullname');
44 $usernames = implode(', ', $userlist);
45 $optionsyes = array();
46 $optionsyes['confirm'] = 1;
47 $optionsyes['sesskey'] = sesskey();
48 print_heading(get_string('confirmation', 'admin'));
49 notice_yesno(get_string('confirmcheckfull', '', $usernames), 'user_bulk_confirm.php', 'user_bulk.php', $optionsyes, NULL, 'post', 'get');
52 admin_externalpage_print_footer();