diff options
author | René Gieling <github@dartcafe.de> | 2022-02-15 10:52:44 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-15 10:52:44 +0300 |
commit | 81ab2375ad37815bf9cd969adb155a4bb55a0b89 (patch) | |
tree | 55bec873519a984343cfcfa0198f8c2889d0c421 | |
parent | 55fa0ccd53a6e2c683122cdbda91120cc5cf292f (diff) | |
parent | 041b0a2233d8a8e781dd5ed2f9b246bd37deba39 (diff) |
Merge pull request #2268 from nextcloud/enh/user-search
return email address in user search for users and contacts resolve #2264
-rw-r--r-- | lib/Model/UserGroup/Contact.php | 16 | ||||
-rw-r--r-- | lib/Model/UserGroup/User.php | 8 |
2 files changed, 20 insertions, 4 deletions
diff --git a/lib/Model/UserGroup/Contact.php b/lib/Model/UserGroup/Contact.php index dbc6a283..6c7d52e2 100644 --- a/lib/Model/UserGroup/Contact.php +++ b/lib/Model/UserGroup/Contact.php @@ -107,14 +107,24 @@ class Contact extends UserBase { $this->emailAddress = $this->contact['EMAIL'][0] ?? $this->emailAddress; $this->organisation = $this->contact['ORG'] ?? ''; $this->categories = isset($this->contact['CATEGORIES']) ? explode(',', $this->contact['CATEGORIES']) : []; - $description = $this->categories; + } + + public function getDescription(): string { + $description = $this->getCategories(); if (isset($this->contact['ORG'])) { - array_unshift($description, $this->organisation); + array_unshift($description, $this->getOrganisation()); + } + + if ($this->getEmailAddress()) { + array_unshift($description, $this->getEmailAddress()); } - $this->description = count($description) ? implode(", ", $description) : Container::getL10N()->t('Contact'); + + return count($description) ? implode(", ", $description) : Container::getL10N()->t('Contact'); } + + public static function isEnabled(): bool { return Container::isAppEnabled('contacts'); } diff --git a/lib/Model/UserGroup/User.php b/lib/Model/UserGroup/User.php index 9973fa68..522b5619 100644 --- a/lib/Model/UserGroup/User.php +++ b/lib/Model/UserGroup/User.php @@ -45,8 +45,8 @@ class User extends UserBase { ) { parent::__construct($id, $type); $this->icon = self::ICON; - $this->description = Container::getL10N()->t('User'); $this->isNoUser = false; + $this->description = Container::getL10N()->t('User'); $this->config = Container::queryClass(IConfig::class); $this->user = Container::queryClass(IUserManager::class)->get($this->id); @@ -68,6 +68,12 @@ class User extends UserBase { return new DateTimeZone($this->timezone->getTimeZone()->getName()); } + public function getDescription(): string { + if ($this->getEmailAddress()) { + return $this->getEmailAddress(); + } + return $this->description; + } /** * @return User[] |