diff options
-rw-r--r-- | core/js/share.js | 5 | ||||
-rw-r--r-- | lib/public/share.php | 20 |
2 files changed, 16 insertions, 9 deletions
diff --git a/core/js/share.js b/core/js/share.js index 3c7d2619eb2..90da96259e7 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -253,11 +253,12 @@ $(document).ready(function() { }); $('#privateLinkCheckbox').live('change', function() { + var itemType = $('#dropdown').data('item-type'); var item = $('#dropdown').data('item'); if (this.checked) { // Create a private link - OC.Share.share(item, 'public', 0, function(token) { - OC.Share.showPrivateLink(item, token); + OC.Share.share(itemType, item, OC.Share.SHARE_TYPE_PRIVATE_LINK, 0, 0, function(token) { + OC.Share.showPrivateLink(item, 'foo'); // Change icon OC.Share.icons[item] = OC.imagePath('core', 'actions/public'); }); diff --git a/lib/public/share.php b/lib/public/share.php index c6dff4467d9..61014c6160e 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -179,11 +179,9 @@ class Share { $shareWith['group'] = $group; $shareWith['users'] = array_diff(\OC_Group::usersInGroup($group), array($uidOwner)); break; - case self::SHARETYPE_PRIVATE_LINK: - // TODO don't loop through folder conversion - $uidSharedWith = ''; - $gidSharedWith = null; - break; + case self::SHARE_TYPE_PRIVATE_LINK: + $shareWith = md5(uniqid($item, true)); + return self::put($itemType, $item, $shareType, $shareWith, $uidOwner, $permissions); // 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); @@ -630,7 +628,11 @@ class Share { return $parentFolders; } } else { - $itemTarget = $backend->generateTarget($item, $shareWith); + if ($shareType == self::SHARE_TYPE_PRIVATE_LINK) { + $itemTarget = null; + } else { + $itemTarget = $backend->generateTarget($item, $shareWith); + } if (isset($fileSource)) { if ($parentFolder) { if ($parentFolder === true) { @@ -641,7 +643,11 @@ class Share { $parent = $parentFolder['id']; } } else { - $fileTarget = self::getBackend('file')->generateTarget($source['file'], $shareWith); + if ($shareType == self::SHARE_TYPE_PRIVATE_LINK) { + $fileTarget = basename($source['file']); + } else { + $fileTarget = self::getBackend('file')->generateTarget($source['file'], $shareWith); + } } } else { $fileTarget = null; |