diff options
author | Julius Härtl <jus@bitgrid.net> | 2018-10-29 17:00:09 +0100 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2018-10-30 10:19:35 +0100 |
commit | 61af60752555bb0c7f0a30cb7b7f35e7ca45fa45 (patch) | |
tree | f9597f423477fef10fa687d7ba98ed8dcc3866b9 /lib | |
parent | 192324e4decc850d5def1394581a0dce2f2402d6 (diff) | |
download | nextcloud-server-61af60752555bb0c7f0a30cb7b7f35e7ca45fa45.tar.gz nextcloud-server-61af60752555bb0c7f0a30cb7b7f35e7ca45fa45.zip |
Make enhancing entries with type property optional
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Collaboration/Collaborators/MailPlugin.php | 11 | ||||
-rw-r--r-- | lib/private/Collaboration/Collaborators/RemotePlugin.php | 19 | ||||
-rw-r--r-- | lib/public/IAddressBook.php | 14 |
3 files changed, 30 insertions, 14 deletions
diff --git a/lib/private/Collaboration/Collaborators/MailPlugin.php b/lib/private/Collaboration/Collaborators/MailPlugin.php index e89e22d012e..1d0738677bb 100644 --- a/lib/private/Collaboration/Collaborators/MailPlugin.php +++ b/lib/private/Collaboration/Collaborators/MailPlugin.php @@ -84,11 +84,16 @@ class MailPlugin implements ISearchPlugin { foreach ($addressBookContacts as $contact) { if (isset($contact['EMAIL'])) { $emailAddresses = $contact['EMAIL']; - if (!is_array($emailAddresses)) { + if (\is_string($emailAddresses)) { $emailAddresses = [$emailAddresses]; } foreach ($emailAddresses as $type => $emailAddress) { $displayName = $emailAddress; + if (\is_array($emailAddress)) { + $emailAddressData = $emailAddress; + $emailAddress = $emailAddressData['value']; + $emailAddressType = $emailAddressData['type']; + } if (isset($contact['FN'])) { $displayName = $contact['FN'] . ' (' . $emailAddress . ')'; } @@ -163,7 +168,7 @@ class MailPlugin implements ISearchPlugin { $result['exact'][] = [ 'label' => $displayName, 'uuid' => $contact['UID'], - 'type' => $type, + 'type' => $emailAddressType, 'value' => [ 'shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => $emailAddress, @@ -173,7 +178,7 @@ class MailPlugin implements ISearchPlugin { $result['wide'][] = [ 'label' => $displayName, 'uuid' => $contact['UID'], - 'type' => $type, + 'type' => $emailAddressType, 'value' => [ 'shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => $emailAddress, diff --git a/lib/private/Collaboration/Collaborators/RemotePlugin.php b/lib/private/Collaboration/Collaborators/RemotePlugin.php index bde6d15b7b6..3da6bdeb637 100644 --- a/lib/private/Collaboration/Collaborators/RemotePlugin.php +++ b/lib/private/Collaboration/Collaborators/RemotePlugin.php @@ -44,12 +44,15 @@ class RemotePlugin implements ISearchPlugin { private $config; /** @var IUserManager */ private $userManager; + /** @var string */ + private $userId; - public function __construct(IManager $contactsManager, ICloudIdManager $cloudIdManager, IConfig $config, IUserManager $userManager) { + public function __construct(IManager $contactsManager, ICloudIdManager $cloudIdManager, IConfig $config, IUserManager $userManager, $userId) { $this->contactsManager = $contactsManager; $this->cloudIdManager = $cloudIdManager; $this->config = $config; $this->userManager = $userManager; + $this->userId = $userId; $this->shareeEnumeration = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes'; } @@ -67,11 +70,17 @@ class RemotePlugin implements ISearchPlugin { } if (isset($contact['CLOUD'])) { $cloudIds = $contact['CLOUD']; - if (!is_array($cloudIds)) { + if (is_string($cloudIds)) { $cloudIds = [$cloudIds]; } $lowerSearch = strtolower($search); - foreach ($cloudIds as $type => $cloudId) { + foreach ($cloudIds as $cloudId) { + $cloudIdType = ''; + if (\is_array($cloudId)) { + $cloudIdData = $cloudId; + $cloudId = $cloudIdData['value']; + $cloudIdType = $cloudIdData['type']; + } try { list($remoteUser, $serverUrl) = $this->splitUserRemote($cloudId); } catch (\InvalidArgumentException $e) { @@ -90,7 +99,7 @@ class RemotePlugin implements ISearchPlugin { $result['exact'][] = [ 'label' => $contact['FN'] . " ($cloudId)", 'uuid' => $contact['UID'], - 'type' => $type, + 'type' => $cloudIdType, 'value' => [ 'shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => $cloudId, @@ -101,7 +110,7 @@ class RemotePlugin implements ISearchPlugin { $result['wide'][] = [ 'label' => $contact['FN'] . " ($cloudId)", 'uuid' => $contact['UID'], - 'type' => $type, + 'type' => $cloudIdType, 'value' => [ 'shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => $cloudId, diff --git a/lib/public/IAddressBook.php b/lib/public/IAddressBook.php index 67c34c9e8c9..4739e6f0c5b 100644 --- a/lib/public/IAddressBook.php +++ b/lib/public/IAddressBook.php @@ -55,16 +55,18 @@ namespace OCP { /** * @param string $pattern which should match within the $searchProperties * @param array $searchProperties defines the properties within the query pattern should match - * @param array $options - for future use. One should always have options! + * @param array $options Options to define the output format + * - types boolean (since 15.0.0) If set to true, fields that come with a TYPE property will be an array + * example: ['id' => 5, 'FN' => 'Thomas Tanghus', 'EMAIL' => ['type => 'HOME', 'value' => 'g@h.i']] * @return array an array of contacts which are arrays of key-value-pairs + * example result: + * [ + * ['id' => 0, 'FN' => 'Thomas Müller', 'EMAIL' => 'a@b.c', 'GEO' => '37.386013;-122.082932'], + * ['id' => 5, 'FN' => 'Thomas Tanghus', 'EMAIL' => ['d@e.f', 'g@h.i']] + * ] * @since 5.0.0 */ public function search($pattern, $searchProperties, $options); - // // dummy results - // return array( - // array('id' => 0, 'FN' => 'Thomas Müller', 'EMAIL' => 'a@b.c', 'GEO' => '37.386013;-122.082932'), - // array('id' => 5, 'FN' => 'Thomas Tanghus', 'EMAIL' => array('d@e.f', 'g@h.i')), - // ); /** * @param array $properties this array if key-value-pairs defines a contact |