Last active
January 16, 2019 23:13
-
-
Save adixon/b7338d361c08d241f11d07b7c6913ffe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/CRM/Utils/System/Drupal.php b/CRM/Utils/System/Drupal.php | |
index 4a677da..4a5e712 100644 | |
--- a/CRM/Utils/System/Drupal.php | |
+++ b/CRM/Utils/System/Drupal.php | |
@@ -94,10 +94,14 @@ class CRM_Utils_System_Drupal extends CRM_Utils_System_DrupalBase { | |
public function updateCMSName($ufID, $ufName) { | |
// CRM-5555 | |
if (function_exists('user_load')) { | |
- $user = user_load($ufID); | |
- if ($user->mail != $ufName) { | |
- user_save($user, array('mail' => $ufName)); | |
- $user = user_load($ufID); | |
+ $account = user_load($ufID); | |
+ if ($account->mail != $ufName) { | |
+ if (user_access('administer users') || $account->uid == $user->uid) { | |
+ user_save($account, array('mail' => $ufName)); | |
+ if ($account->uid == $user->uid) { | |
+ $user = user_load($ufID); | |
+ } | |
+ } | |
} | |
} | |
} |
Yes, that's an interesting question. There was no global $user in the existing code, so in theory that code shouldn't really do much. I left it in case there's some subtle cases where it does matter.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
should there be a 'global $user;' after / before the $account object is loaded?
where is the $user variable defined before it is used in line 15?