mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
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().
This commit is contained in:
parent
f4bfbd5aa2
commit
7b9643b59c
@ -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;
|
||||
|
4
auth/ldap/upgrade.txt
Normal file
4
auth/ldap/upgrade.txt
Normal file
@ -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.
|
Loading…
x
Reference in New Issue
Block a user