summaryrefslogtreecommitdiffstats
path: root/core/ajax
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2012-07-31 21:05:00 -0400
committerMichael Gapczynski <mtgap@owncloud.com>2012-07-31 21:05:00 -0400
commitb6aa5d2875bf171a7cf508102ef16f42b47b984a (patch)
tree42f8599931c37ddd083ff8f5ca25590d0a974c0e /core/ajax
parent94ce8f2168bdd9897f54ec433ad7017fb3db1cc8 (diff)
downloadnextcloud-server-b6aa5d2875bf171a7cf508102ef16f42b47b984a.tar.gz
nextcloud-server-b6aa5d2875bf171a7cf508102ef16f42b47b984a.zip
Include contacts in share with search
Diffstat (limited to 'core/ajax')
-rw-r--r--core/ajax/share.php14
1 files changed, 13 insertions, 1 deletions
diff --git a/core/ajax/share.php b/core/ajax/share.php
index c613baa7f5e..905c28a1c29 100644
--- a/core/ajax/share.php
+++ b/core/ajax/share.php
@@ -66,8 +66,20 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['item']
break;
case 'getShareWith':
if (isset($_GET['search'])) {
- // TODO Include contacts
$shareWith = array();
+ if (OC_App::isEnabled('contacts')) {
+ // TODO Add function to contacts to only get the 'fullname' column to improve performance
+ $ids = OC_Contacts_Addressbook::activeIds();
+ foreach ($ids as $id) {
+ $vcards = OC_Contacts_VCard::all($id);
+ foreach ($vcards as $vcard) {
+ $contact = $vcard['fullname'];
+ if (stripos($contact, $_GET['search']) !== false && (!isset($_GET['itemShares'][OCP\Share::SHARE_TYPE_CONTACT]) || !in_array($contact, $_GET['itemShares'][OCP\Share::SHARE_TYPE_CONTACT]))) {
+ $shareWith[] = array('label' => $contact, 'value' => array('shareType' => 5, 'shareWith' => $contact));
+ }
+ }
+ }
+ }
$count = 0;
$users = array();
$limit = 0;