mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
aa1c2e2382
Create or update the breadcrumbs in the site administration pages where it is required. Highlight the corresponding site adminstration tab. Highlight the primary nav to Site administration when user is navigating to any of the site administration pages. Also changed the boostnavbar so that the nodes in the secondary navigation are not shown in the breadcrumbs when user is in site administration page.
71 lines
2.5 KiB
PHP
71 lines
2.5 KiB
PHP
<?php
|
|
/**
|
|
* script for bulk user force password change
|
|
*/
|
|
|
|
require_once('../../config.php');
|
|
require_once('lib.php');
|
|
require_once($CFG->libdir.'/adminlib.php');
|
|
|
|
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
|
|
|
admin_externalpage_setup('userbulk');
|
|
require_capability('moodle/user:update', context_system::instance());
|
|
|
|
$return = $CFG->wwwroot.'/'.$CFG->admin.'/user/user_bulk.php';
|
|
|
|
if (empty($SESSION->bulk_users)) {
|
|
redirect($return);
|
|
}
|
|
|
|
$PAGE->set_primary_active_tab('siteadminnode');
|
|
$PAGE->set_secondary_active_tab('users');
|
|
|
|
echo $OUTPUT->header();
|
|
|
|
if ($confirm and confirm_sesskey()) {
|
|
// only force password change if user may actually change the password
|
|
$authsavailable = get_enabled_auth_plugins();
|
|
$changeable = array();
|
|
|
|
foreach($authsavailable as $authplugin) {
|
|
if (!$auth = get_auth_plugin($authplugin)) {
|
|
continue;
|
|
}
|
|
if ($auth->is_internal() and $auth->can_change_password()) {
|
|
$changeable[$authplugin] = true;
|
|
}
|
|
}
|
|
|
|
$parts = array_chunk($SESSION->bulk_users, 300);
|
|
foreach ($parts as $users) {
|
|
list($in, $params) = $DB->get_in_or_equal($users);
|
|
$rs = $DB->get_recordset_select('user', "id $in", $params);
|
|
foreach ($rs as $user) {
|
|
if (!empty($changeable[$user->auth])) {
|
|
set_user_preference('auth_forcepasswordchange', 1, $user->id);
|
|
unset($SESSION->bulk_users[$user->id]);
|
|
} else {
|
|
echo $OUTPUT->notification(get_string('forcepasswordchangenot', '', fullname($user, true)));
|
|
}
|
|
}
|
|
$rs->close();
|
|
}
|
|
echo $OUTPUT->notification(get_string('changessaved'), 'notifysuccess');
|
|
echo $OUTPUT->continue_button($return);
|
|
|
|
} else {
|
|
list($in, $params) = $DB->get_in_or_equal($SESSION->bulk_users);
|
|
$userlist = $DB->get_records_select_menu('user', "id $in", $params, 'fullname', 'id,'.$DB->sql_fullname().' AS fullname', 0, MAX_BULK_USERS);
|
|
$usernames = implode(', ', $userlist);
|
|
if (count($SESSION->bulk_users) > MAX_BULK_USERS) {
|
|
$usernames .= ', ...';
|
|
}
|
|
echo $OUTPUT->heading(get_string('confirmation', 'admin'));
|
|
$formcontinue = new single_button(new moodle_url('/admin/user/user_bulk_forcepasswordchange.php', array('confirm' => 1)), get_string('yes'));
|
|
$formcancel = new single_button(new moodle_url('/admin/user/user_bulk.php'), get_string('no'), 'get');
|
|
echo $OUTPUT->confirm(get_string('forcepasswordchangecheckfull', '', $usernames), $formcontinue, $formcancel);
|
|
}
|
|
|
|
echo $OUTPUT->footer();
|