diff options
author | Michael Gapczynski <mtgap@owncloud.com> | 2012-08-01 17:17:28 -0400 |
---|---|---|
committer | Michael Gapczynski <mtgap@owncloud.com> | 2012-08-01 17:17:28 -0400 |
commit | 2201074e1f1e4ec3c2f60cac74d8168738d83650 (patch) | |
tree | c8409702fb43bbafd17428e29253c682817fb8e5 /lib/public | |
parent | 83b935a1c2cd827610a3980ed559ff286ef41431 (diff) | |
download | nextcloud-server-2201074e1f1e4ec3c2f60cac74d8168738d83650.tar.gz nextcloud-server-2201074e1f1e4ec3c2f60cac74d8168738d83650.zip |
Basic setup for sharing with contacts
Diffstat (limited to 'lib/public')
-rw-r--r-- | lib/public/share.php | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/public/share.php b/lib/public/share.php index 47181c8c1f9..d9bcb8df81f 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -187,6 +187,24 @@ class Share { case self::SHARE_TYPE_PRIVATE_LINK: $shareWith = md5(uniqid($item, true)); return self::put($itemType, $item, $shareType, $shareWith, $uidOwner, $permissions); + case self::SHARE_TYPE_CONTACT: + if (!\OC_App::isEnabled('contacts')) { + \OC_Log::write('OCP\Share', 'Sharing '.$item.' failed, because the contacts app is not enabled', \OC_Log::ERROR); + return false; + } + $vcard = \OC_Contacts_App::getContactVCard($shareWith); + if (!isset($vcard)) { + \OC_Log::write('OCP\Share', 'Sharing '.$item.' failed, because the contact does not exist', \OC_Log::ERROR); + return false; + } + $details = OC_Contacts_VCard::structureContact($vcard); + // TODO Add ownCloud user to contacts vcard + if (!isset($details['EMAIL'])) { + \OC_Log::write('OCP\Share', 'Sharing '.$item.' failed, because no email address is associated with the contact', \OC_Log::ERROR); + return false; + } + return self::share($itemType, $item, self::SHARE_TYPE_EMAIL, $permissions); + break; // Future share types need to include their own conditions default: \OC_Log::write('OCP\Share', 'Share type '.$shareType.' is not valid for '.$item, \OC_Log::ERROR); |