diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2018-10-30 13:38:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-30 13:38:16 +0100 |
commit | 8b2b238d86f9a1e1846328317f0c0b1cb6c86357 (patch) | |
tree | c66ee0be98ee62f964542d3d484b471eb651ed8e /apps/user_ldap/lib | |
parent | dccfe4bf8410b2c24c2568c249e76270ed050eb1 (diff) | |
parent | 49456e42f958bec9b0fc9d07c5ec37ff51cc9351 (diff) | |
download | nextcloud-server-8b2b238d86f9a1e1846328317f0c0b1cb6c86357.tar.gz nextcloud-server-8b2b238d86f9a1e1846328317f0c0b1cb6c86357.zip |
Merge pull request #12054 from nextcloud/fix/5212/interact-with-userobject
LDAP: announce display name changes so that addressbook picks it up
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r-- | apps/user_ldap/lib/User/User.php | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/apps/user_ldap/lib/User/User.php b/apps/user_ldap/lib/User/User.php index 02764a72eca..f4be19a7ad5 100644 --- a/apps/user_ldap/lib/User/User.php +++ b/apps/user_ldap/lib/User/User.php @@ -414,14 +414,23 @@ class User { * * @param string $displayName * @param string $displayName2 - * @returns string the effective display name + * @return string the effective display name */ public function composeAndStoreDisplayName($displayName, $displayName2 = '') { $displayName2 = (string)$displayName2; if($displayName2 !== '') { $displayName .= ' (' . $displayName2 . ')'; } - $this->store('displayName', $displayName); + $oldName = $this->config->getUserValue($this->uid, 'user_ldap', 'displayName', null); + if ($oldName !== $displayName) { + $this->store('displayName', $displayName); + $user = $this->userManager->get($this->getUsername()); + if (!empty($oldName) && $user instanceof \OC\User\User) { + // if it was empty, it would be a new record, not a change emitting the trigger could + // potentially cause a UniqueConstraintViolationException, depending on some factors. + $user->triggerChange('displayName', $displayName); + } + } return $displayName; } |