diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2012-11-26 07:42:53 -0800 |
---|---|---|
committer | Jörn Friedrich Dreyer <jfd@butonic.de> | 2012-11-26 07:42:53 -0800 |
commit | 71e8755d318eb9a415b15f5775506ecf8a8d134f (patch) | |
tree | a9778edb2956902e8211b7f556ebb6f468e39fd5 /core/js | |
parent | 588bbd2c9f36761a8bf6f0b736d3042940c6fa18 (diff) | |
parent | 995b5c073922afd5d4fae00cad7e1bfc87c0ac73 (diff) | |
download | nextcloud-server-71e8755d318eb9a415b15f5775506ecf8a8d134f.tar.gz nextcloud-server-71e8755d318eb9a415b15f5775506ecf8a8d134f.zip |
Merge pull request #380 from butonic/feature_share_link_with_token
Feature share link with token
Diffstat (limited to 'core/js')
-rw-r--r-- | core/js/share.js | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/core/js/share.js b/core/js/share.js index 8fcea84af88..0f71ae22419 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, itemSource); } else { if (share.collection) { OC.Share.addShareWith(share.share_type, share.share_with, share.permissions, possiblePermissions, share.collection); @@ -323,18 +323,24 @@ OC.Share={ $('#expiration').show(); } }, - showLink:function(itemSource, password) { + showLink:function(token, password, itemSource) { 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; + if (! token) { + //fallback to pre token link + 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); } else { - var file = $('#dir').val() + '/' + filename; + //TODO add path param when showing a link to file in a subfolder of a public link share + var link = parent.location.protocol+'//'+location.host+OC.linkTo('', 'public.php')+'?service=files&t='+token; } - file = '/'+OC.currentUser+'/files'+file; - var link = parent.location.protocol+'//'+location.host+OC.linkTo('', 'public.php')+'?service=files&'+type+'='+encodeURIComponent(file); $('#linkText').val(link); $('#linkText').show('blind'); $('#showPassword').show(); @@ -480,8 +486,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, null, itemSource); OC.Share.updateIcon(itemType, itemSource); }); } else { |