Skip to content

Commit

Permalink
MDL-49022 auth_ldap: trigger event when required.
Browse files Browse the repository at this point in the history
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().
  • Loading branch information
markward authored and Rajesh Taneja committed Jun 23, 2015
1 parent f4bfbd5 commit 7b9643b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 7 additions & 3 deletions auth/ldap/auth.php
Expand Up @@ -534,6 +534,7 @@ function can_signup() {
*
* @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;
Expand Down Expand Up @@ -889,7 +890,7 @@ function sync_users($do_updates=true) {

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";
Expand Down Expand Up @@ -987,8 +988,11 @@ function sync_users($do_updates=true) {
*
* @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
Expand Down Expand Up @@ -1030,7 +1034,7 @@ function update_user_record($username, $updatekeys = false) {
}
}
}
user_update_user($newuser, false, false);
user_update_user($newuser, false, $triggerevent);
}
} else {
return false;
Expand Down
4 changes: 4 additions & 0 deletions 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.

0 comments on commit 7b9643b

Please sign in to comment.