diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2012-11-12 14:44:00 +0100 |
---|---|---|
committer | Jörn Friedrich Dreyer <jfd@butonic.de> | 2012-11-20 15:03:12 +0100 |
commit | d8a171df26a33710ad162b6acc9f46d00976b986 (patch) | |
tree | 958a8024bd6bf2d6ef9b1f6f80b01ec99763df87 /core | |
parent | 568def2b61e45d51d4506ad08723c3e2173481b4 (diff) | |
download | nextcloud-server-d8a171df26a33710ad162b6acc9f46d00976b986.tar.gz nextcloud-server-d8a171df26a33710ad162b6acc9f46d00976b986.zip |
implement share via link token
Diffstat (limited to 'core')
-rw-r--r-- | core/ajax/share.php | 14 | ||||
-rw-r--r-- | core/js/share.js | 18 |
2 files changed, 15 insertions, 17 deletions
diff --git a/core/ajax/share.php b/core/ajax/share.php index efe01dff886..41832a3c659 100644 --- a/core/ajax/share.php +++ b/core/ajax/share.php @@ -28,13 +28,19 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo case 'share': if (isset($_POST['shareType']) && isset($_POST['shareWith']) && isset($_POST['permissions'])) { try { - if ((int)$_POST['shareType'] === OCP\Share::SHARE_TYPE_LINK && $_POST['shareWith'] == '') { + $shareType = (int)$_POST['shareType']; + $shareWith = $_POST['shareWith']; + if ($shareType === OCP\Share::SHARE_TYPE_LINK && $shareWith == '') { $shareWith = null; + } + + $token = OCP\Share::shareItem($_POST['itemType'], $_POST['itemSource'], $shareType, $shareWith, $_POST['permissions']); + + if (is_string($token)) { + OC_JSON::success(array('data' => array('token' => $token))); } else { - $shareWith = $_POST['shareWith']; + OC_JSON::success(); } - OCP\Share::shareItem($_POST['itemType'], $_POST['itemSource'], (int)$_POST['shareType'], $shareWith, $_POST['permissions']); - OC_JSON::success(); } catch (Exception $exception) { OC_JSON::error(array('data' => array('message' => $exception->getMessage()))); } diff --git a/core/js/share.js b/core/js/share.js index 8fcea84af88..879befd95ba 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -179,7 +179,7 @@ OC.Share={ if (data.shares) { $.each(data.shares, function(index, share) { if (share.share_type == OC.Share.SHARE_TYPE_LINK) { - OC.Share.showLink(itemSource, share.share_with); + OC.Share.showLink(share.token, share.share_with); } else { if (share.collection) { OC.Share.addShareWith(share.share_type, share.share_with, share.permissions, possiblePermissions, share.collection); @@ -323,18 +323,10 @@ OC.Share={ $('#expiration').show(); } }, - showLink:function(itemSource, password) { + showLink:function(token, password) { OC.Share.itemShares[OC.Share.SHARE_TYPE_LINK] = true; $('#linkCheckbox').attr('checked', true); - var filename = $('tr').filterAttr('data-id', String(itemSource)).data('file'); - var type = $('tr').filterAttr('data-id', String(itemSource)).data('type'); - if ($('#dir').val() == '/') { - var file = $('#dir').val() + filename; - } else { - var file = $('#dir').val() + '/' + filename; - } - file = '/'+OC.currentUser+'/files'+file; - var link = parent.location.protocol+'//'+location.host+OC.linkTo('', 'public.php')+'?service=files&'+type+'='+encodeURIComponent(file); + var link = parent.location.protocol+'//'+location.host+OC.linkTo('', 'public.php')+'?service=files&t='+token; $('#linkText').val(link); $('#linkText').show('blind'); $('#showPassword').show(); @@ -480,8 +472,8 @@ $(document).ready(function() { var itemSource = $('#dropdown').data('item-source'); if (this.checked) { // Create a link - OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', OC.PERMISSION_READ, function() { - OC.Share.showLink(itemSource); + OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', OC.PERMISSION_READ, function(data) { + OC.Share.showLink(data.token); OC.Share.updateIcon(itemType, itemSource); }); } else { |