[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * script for bulk user force password change 4 */ 5 6 require_once('../../config.php'); 7 require_once ('lib.php'); 8 require_once($CFG->libdir.'/adminlib.php'); 9 10 $confirm = optional_param('confirm', 0, PARAM_BOOL); 11 12 require_login(); 13 admin_externalpage_setup('userbulk'); 14 require_capability('moodle/user:update', context_system::instance()); 15 16 $return = $CFG->wwwroot.'/'.$CFG->admin.'/user/user_bulk.php'; 17 18 if (empty($SESSION->bulk_users)) { 19 redirect($return); 20 } 21 22 echo $OUTPUT->header(); 23 24 if ($confirm and confirm_sesskey()) { 25 // only force password change if user may actually change the password 26 $authsavailable = get_enabled_auth_plugins(); 27 $changeable = array(); 28 29 foreach($authsavailable as $authplugin) { 30 if (!$auth = get_auth_plugin($authplugin)) { 31 continue; 32 } 33 if ($auth->is_internal() and $auth->can_change_password()) { 34 $changeable[$authplugin] = true; 35 } 36 } 37 38 $parts = array_chunk($SESSION->bulk_users, 300); 39 foreach ($parts as $users) { 40 list($in, $params) = $DB->get_in_or_equal($users); 41 $rs = $DB->get_recordset_select('user', "id $in", $params); 42 foreach ($rs as $user) { 43 if (!empty($changeable[$user->auth])) { 44 set_user_preference('auth_forcepasswordchange', 1, $user->id); 45 unset($SESSION->bulk_users[$user->id]); 46 } else { 47 echo $OUTPUT->notification(get_string('forcepasswordchangenot', '', fullname($user, true))); 48 } 49 } 50 $rs->close(); 51 } 52 echo $OUTPUT->notification(get_string('changessaved'), 'notifysuccess'); 53 echo $OUTPUT->continue_button($return); 54 55 } else { 56 list($in, $params) = $DB->get_in_or_equal($SESSION->bulk_users); 57 $userlist = $DB->get_records_select_menu('user', "id $in", $params, 'fullname', 'id,'.$DB->sql_fullname().' AS fullname', 0, MAX_BULK_USERS); 58 $usernames = implode(', ', $userlist); 59 if (count($SESSION->bulk_users) > MAX_BULK_USERS) { 60 $usernames .= ', ...'; 61 } 62 echo $OUTPUT->heading(get_string('confirmation', 'admin')); 63 $formcontinue = new single_button(new moodle_url('/admin/user/user_bulk_forcepasswordchange.php', array('confirm' => 1)), get_string('yes')); 64 $formcancel = new single_button(new moodle_url('/admin/user/user_bulk.php'), get_string('no'), 'get'); 65 echo $OUTPUT->confirm(get_string('forcepasswordchangecheckfull', '', $usernames), $formcontinue, $formcancel); 66 } 67 68 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |