From: Petr Skoda Date: Tue, 17 Nov 2009 11:36:51 +0000 (+0000) Subject: MDL-19608 do not force changing of passwords if users may not actually change them X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=154acd7aa32bd970ec8521c7c4665d30bb4c669f;p=moodle.git MDL-19608 do not force changing of passwords if users may not actually change them --- diff --git a/admin/user/user_bulk_forcepasswordchange.php b/admin/user/user_bulk_forcepasswordchange.php index 4d75218c50..d47a7fff26 100644 --- a/admin/user/user_bulk_forcepasswordchange.php +++ b/admin/user/user_bulk_forcepasswordchange.php @@ -22,14 +22,29 @@ if (empty($SESSION->bulk_users)) { admin_externalpage_print_header(); if ($confirm and confirm_sesskey()) { - $primaryadmin = get_admin(); + // only force password change if user may actually change the password + $authsavailable = get_plugin_list('auth'); + $changeable = array(); + foreach($authsavailable as $authname=>$path) { + if (!$auth = get_auth_plugin($authname)) { + continue; + } + if (@$auth->can_change_password()) { // plugins may not be configured yet, not nice :-( + $changeable[$authname] = true; + } + } $parts = array_chunk($SESSION->bulk_users, 300); foreach ($parts as $users) { list($in, $params) = $DB->get_in_or_equal($users); if ($rs = $DB->get_recordset_select('user', "id $in", $params)) { foreach ($rs as $user) { - set_user_preference('auth_forcepasswordchange', 1, $user->id); + 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(); }