MDL-9628 When a timestamp is selected for locktime or hiddenuntil, the grader report...
[moodle-pu.git] / admin / user_bulk_confirm.php
blob08abfa98d75cffb5c49175ddca52feb4d235e748
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);
10 $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
11 require_capability('moodle/user:update', $sitecontext);
13 // clean-up users list
14 $primaryadmin = get_admin();
15 $userlist = array();
16 foreach ($SESSION->bulk_susers as $k => $v) {
17 $user = get_record('user', 'id', $v, null, null, null, null, 'id,firstname,lastname,username,secret,confirmed,mnethostid,auth');
18 if (!empty($user) && $user->id != $primaryadmin->id && !$user->confirmed && !is_mnet_remote_user($user)) {
19 $userlist[$k] = $user;
23 if (empty($userlist)) {
24 redirect($CFG->wwwroot . '/admin/user_bulk.php');
27 admin_externalpage_setup('editusers');
28 admin_externalpage_print_header();
29 if (empty($confirm)) {
30 $usernames = array();
31 foreach ($userlist as $user) {
32 $usernames[] =& fullname($user, true);
34 $usernames = implode(', ', $usernames);
35 $optionsyes['confirm'] = 1;
36 $optionsyes['sesskey'] = sesskey();
37 print_heading(get_string('confirmation', 'admin'));
38 notice_yesno(get_string('confirmcheckfull', '', $usernames), 'user_bulk_confirm.php', 'user_bulk.php', $optionsyes, NULL, 'post', 'get');
39 } else {
40 foreach ($userlist as $k => $user) {
41 $auth = get_auth_plugin($user->auth);
42 $result = $auth->user_confirm(addslashes($user->username), addslashes($user->secret));
43 if ($result != AUTH_CONFIRM_OK && $result != AUTH_CONFIRM_ALREADY) {
44 notify(get_string('usernotconfirmed', '', fullname($user, true)));
47 redirect($CFG->wwwroot . '/admin/user_bulk.php', get_string('changessaved'));
49 admin_externalpage_print_footer();