From fd954ad01b2f317751ab2eca9ee88d62fb0beccf Mon Sep 17 00:00:00 2001 From: Mark Ward Date: Thu, 26 Mar 2015 16:21:00 +0000 Subject: [PATCH] MDL-49022 auth_ldap: trigger event when required. When calling update_user_record() for auth_ldap the method now has option to trigger event core\event\user_updated when syncing with domain controller. This means that the event will be triggered by sync_users() but not by user_signup(). --- auth/ldap/auth.php | 10 +++++++--- auth/ldap/upgrade.txt | 4 ++++ 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 auth/ldap/upgrade.txt diff --git a/auth/ldap/auth.php b/auth/ldap/auth.php index 5e20dbf688c..3244c7669c8 100644 --- a/auth/ldap/auth.php +++ b/auth/ldap/auth.php @@ -534,6 +534,7 @@ class auth_plugin_ldap extends auth_plugin_base { * * @param object $user new user object * @param boolean $notify print notice with link and terminate + * @return boolean success */ function user_signup($user, $notify=true) { global $CFG, $DB, $PAGE, $OUTPUT; @@ -889,7 +890,7 @@ 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)) { + if (!$this->update_user_record($user->username, $updatekeys, true)) { echo ' - '.get_string('skipped'); } echo "\n"; @@ -987,8 +988,11 @@ class auth_plugin_ldap extends auth_plugin_base { * * @param string $username username * @param boolean $updatekeys true to update the local record with the external LDAP values. + * @param bool $triggerevent set false if user_updated event should not be triggered. + * This will not affect user_password_updated event triggering. + * @return stdClass|bool updated user record or false if there is no new info to update. */ - function update_user_record($username, $updatekeys = false) { + protected function update_user_record($username, $updatekeys = false, $triggerevent = false) { global $CFG, $DB; // Just in case check text case @@ -1030,7 +1034,7 @@ class auth_plugin_ldap extends auth_plugin_base { } } } - user_update_user($newuser, false, false); + user_update_user($newuser, false, $triggerevent); } } else { return false; diff --git a/auth/ldap/upgrade.txt b/auth/ldap/upgrade.txt new file mode 100644 index 00000000000..8ac90734518 --- /dev/null +++ b/auth/ldap/upgrade.txt @@ -0,0 +1,4 @@ +This files describes API changes in the auth_ldap code. +=== 2.9.1 === +* auth_plugin_ldap::update_user_record() accepts an additional (optional) param + to trigger update event.