mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-40613 auth: avoid undefined property 'suspended_attribute'
Re-introduce MDL-53580.
This commit is contained in:
parent
220ca688c1
commit
4e133e775c
@ -381,7 +381,7 @@ class auth_plugin_db extends auth_plugin_base {
|
||||
list($in_sql, $params) = $DB->get_in_or_equal($userlistchunk, SQL_PARAMS_NAMED, 'u', true);
|
||||
$params['authtype'] = $this->authtype;
|
||||
$params['mnethostid'] = $CFG->mnet_localhost_id;
|
||||
$sql = "SELECT u.id, u.username
|
||||
$sql = "SELECT u.id, u.username, u.suspended
|
||||
FROM {user} u
|
||||
WHERE u.auth = :authtype AND u.deleted = 0 AND u.mnethostid = :mnethostid AND u.username {$in_sql}";
|
||||
$update_users = $update_users + $DB->get_records_sql($sql, $params);
|
||||
@ -391,7 +391,7 @@ class auth_plugin_db extends auth_plugin_base {
|
||||
$trace->output("User entries to update: ".count($update_users));
|
||||
|
||||
foreach ($update_users as $user) {
|
||||
if ($this->update_user_record($user->username, $updatekeys)) {
|
||||
if ($this->update_user_record($user->username, $updatekeys, false, (bool) $user->suspended)) {
|
||||
$trace->output(get_string('auth_dbupdatinguser', 'auth_db', array('name'=>$user->username, 'id'=>$user->id)), 1);
|
||||
} else {
|
||||
$trace->output(get_string('auth_dbupdatinguser', 'auth_db', array('name'=>$user->username, 'id'=>$user->id))." - ".get_string('skipped'), 1);
|
||||
|
@ -547,7 +547,9 @@ class auth_plugin_ldap extends auth_plugin_base {
|
||||
// Save any custom profile field information
|
||||
profile_save_data($user);
|
||||
|
||||
$this->update_user_record($user->username);
|
||||
$userinfo = $this->get_userinfo($user->username);
|
||||
$this->update_user_record($user->username, false, false, $this->is_user_suspended((object) $userinfo));
|
||||
|
||||
// This will also update the stored hash to the latest algorithm
|
||||
// if the existing hash is using an out-of-date algorithm (or the
|
||||
// legacy md5 algorithm).
|
||||
@ -874,7 +876,9 @@ class auth_plugin_ldap extends auth_plugin_base {
|
||||
|
||||
foreach ($users as $user) {
|
||||
echo "\t"; print_string('auth_dbupdatinguser', 'auth_db', array('name'=>$user->username, 'id'=>$user->id));
|
||||
if (!$this->update_user_record($user->username, $updatekeys, true)) {
|
||||
$userinfo = $this->get_userinfo($user->username);
|
||||
if (!$this->update_user_record($user->username, $updatekeys, true,
|
||||
$this->is_user_suspended((object) $userinfo))) {
|
||||
echo ' - '.get_string('skipped');
|
||||
}
|
||||
echo "\n";
|
||||
|
@ -627,9 +627,10 @@ class auth_plugin_base {
|
||||
* @param array $updatekeys fields to update, false updates all fields.
|
||||
* @param bool $triggerevent set false if user_updated event should not be triggered.
|
||||
* This will not affect user_password_updated event triggering.
|
||||
* @param bool $suspenduser Should the user be suspended?
|
||||
* @return stdClass|bool updated user record or false if there is no new info to update.
|
||||
*/
|
||||
protected function update_user_record($username, $updatekeys = false, $triggerevent = false) {
|
||||
protected function update_user_record($username, $updatekeys = false, $triggerevent = false, $suspenduser = false) {
|
||||
global $CFG, $DB;
|
||||
|
||||
require_once($CFG->dirroot.'/user/profile/lib.php');
|
||||
@ -663,6 +664,8 @@ class auth_plugin_base {
|
||||
if (!empty($updatekeys)) {
|
||||
$newuser = new stdClass();
|
||||
$newuser->id = $userid;
|
||||
// The cast to int is a workaround for MDL-53959.
|
||||
$newuser->suspended = (int) $suspenduser;
|
||||
$newuser->profile = array();
|
||||
|
||||
foreach ($updatekeys as $key) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user