|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00006 require_once('../../config.php'); 00007 require_once('lib.php'); 00008 require_once($CFG->libdir.'/adminlib.php'); 00009 00010 $confirm = optional_param('confirm', 0, PARAM_BOOL); 00011 00012 require_login(); 00013 admin_externalpage_setup('userbulk'); 00014 require_capability('moodle/user:update', get_context_instance(CONTEXT_SYSTEM)); 00015 00016 $return = $CFG->wwwroot.'/'.$CFG->admin.'/user/user_bulk.php'; 00017 00018 if (empty($SESSION->bulk_users)) { 00019 redirect($return); 00020 } 00021 00022 echo $OUTPUT->header(); 00023 00024 if ($confirm and confirm_sesskey()) { 00025 // only force password change if user may actually change the password 00026 $authsavailable = get_enabled_auth_plugins(); 00027 $changeable = array(); 00028 00029 foreach($authsavailable as $authplugin) { 00030 if (!$auth = get_auth_plugin($authplugin)) { 00031 continue; 00032 } 00033 if ($auth->is_internal() and $auth->can_change_password()) { 00034 $changeable[$authplugin] = true; 00035 } 00036 } 00037 00038 $parts = array_chunk($SESSION->bulk_users, 300); 00039 foreach ($parts as $users) { 00040 list($in, $params) = $DB->get_in_or_equal($users); 00041 $rs = $DB->get_recordset_select('user', "id $in", $params); 00042 foreach ($rs as $user) { 00043 if (!empty($changeable[$user->auth])) { 00044 set_user_preference('auth_forcepasswordchange', 1, $user->id); 00045 unset($SESSION->bulk_users[$user->id]); 00046 } else { 00047 echo $OUTPUT->notification(get_string('forcepasswordchangenot', '', fullname($user, true))); 00048 } 00049 } 00050 $rs->close(); 00051 } 00052 echo $OUTPUT->notification(get_string('changessaved'), 'notifysuccess'); 00053 echo $OUTPUT->continue_button($return); 00054 00055 } else { 00056 list($in, $params) = $DB->get_in_or_equal($SESSION->bulk_users); 00057 $userlist = $DB->get_records_select_menu('user', "id $in", $params, 'fullname', 'id,'.$DB->sql_fullname().' AS fullname', 0, MAX_BULK_USERS); 00058 $usernames = implode(', ', $userlist); 00059 if (count($SESSION->bulk_users) > MAX_BULK_USERS) { 00060 $usernames .= ', ...'; 00061 } 00062 echo $OUTPUT->heading(get_string('confirmation', 'admin')); 00063 $formcontinue = new single_button(new moodle_url('/admin/user/user_bulk_forcepasswordchange.php', array('confirm' => 1)), get_string('yes')); 00064 $formcancel = new single_button(new moodle_url('/admin/user/user_bulk.php'), get_string('no'), 'get'); 00065 echo $OUTPUT->confirm(get_string('forcepasswordchangecheckfull', '', $usernames), $formcontinue, $formcancel); 00066 } 00067 00068 echo $OUTPUT->footer();