From f9dcb559e9693e7706184f4d48f20eee096b6c7f Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Thu, 25 Jun 2015 11:57:03 +0200 Subject: [PATCH 1/3] search address book for federated cloud id --- core/ajax/share.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/core/ajax/share.php b/core/ajax/share.php index e78d274815..4ce67736ab 100644 --- a/core/ajax/share.php +++ b/core/ajax/share.php @@ -352,8 +352,24 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo ) ); } + $contactManager = \OC::$server->getContactsManager(); + $addressBookContacts = $contactManager->search($_GET['search'], ['CLOUD', 'FN']); + foreach ($addressBookContacts as $contact) { + if (isset($contact['CLOUD'])) { + foreach ($contact['CLOUD'] as $cloudId) { + $shareWith[] = array( + 'label' => $contact['FN'] . ' (' . $cloudId . ')', + 'value' => array( + 'shareType' => \OCP\Share::SHARE_TYPE_REMOTE, + 'shareWith' => $cloudId + ) + ); + } + } + } } + $sorter = new \OC\Share\SearchResultSorter((string)$_GET['search'], 'label', \OC::$server->getLogger()); From dd9dfc4461ba9e484f25c81e232f00ce1873e2f0 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Thu, 25 Jun 2015 12:14:03 +0200 Subject: [PATCH 2/3] show nice display name for remote shares if possible --- lib/private/share/share.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/private/share/share.php b/lib/private/share/share.php index 027c518f9f..87000ca29a 100644 --- a/lib/private/share/share.php +++ b/lib/private/share/share.php @@ -1703,11 +1703,20 @@ class Share extends Constants { $row['permissions'] &= ~\OCP\Constants::PERMISSION_SHARE; } // Add display names to result + $row['share_with_displayname'] = $row['share_with']; if ( isset($row['share_with']) && $row['share_with'] != '' && isset($row['share_with']) && $row['share_type'] === self::SHARE_TYPE_USER) { $row['share_with_displayname'] = \OCP\User::getDisplayName($row['share_with']); - } else { - $row['share_with_displayname'] = $row['share_with']; + } else if(isset($row['share_with']) && $row['share_with'] != '' && + $row['share_type'] === self::SHARE_TYPE_REMOTE) { + $addressBookEntries = \OC::$server->getContactsManager()->search($row['share_with'], ['CLOUD']); + foreach ($addressBookEntries as $entry) { + foreach ($entry['CLOUD'] as $cloudID) { + if ($cloudID === $row['share_with']) { + $row['share_with_displayname'] = $entry['FN']; + } + } + } } if ( isset($row['uid_owner']) && $row['uid_owner'] != '') { $row['displayname_owner'] = \OCP\User::getDisplayName($row['uid_owner']); From a288d0eea36331703bf1d6e48b4bbe3e0b98e4b2 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Thu, 25 Jun 2015 12:14:46 +0200 Subject: [PATCH 3/3] ne need to check twice if $row['share_with'] is set --- lib/private/share/share.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/share/share.php b/lib/private/share/share.php index 87000ca29a..e493228835 100644 --- a/lib/private/share/share.php +++ b/lib/private/share/share.php @@ -1705,7 +1705,7 @@ class Share extends Constants { // Add display names to result $row['share_with_displayname'] = $row['share_with']; if ( isset($row['share_with']) && $row['share_with'] != '' && - isset($row['share_with']) && $row['share_type'] === self::SHARE_TYPE_USER) { + $row['share_type'] === self::SHARE_TYPE_USER) { $row['share_with_displayname'] = \OCP\User::getDisplayName($row['share_with']); } else if(isset($row['share_with']) && $row['share_with'] != '' && $row['share_type'] === self::SHARE_TYPE_REMOTE) {