Merge pull request #17165 from owncloud/federated_cloud_sharing_search_address_book

Search address book for federated cloud id
This commit is contained in:
Thomas Müller 2015-06-26 10:53:02 +02:00
commit 6c3a4282e5
2 changed files with 28 additions and 3 deletions

View File

@ -359,7 +359,23 @@ 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',

View File

@ -1703,11 +1703,20 @@ class Share extends Constants {
$row['permissions'] &= ~\OCP\Constants::PERMISSION_SHARE;
}
// Add display names to result
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'];
if ( isset($row['share_with']) && $row['share_with'] != '' &&
$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) {
$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']);