diff options
author | Andreas Fischer <bantu@owncloud.com> | 2014-05-28 22:57:33 +0200 |
---|---|---|
committer | Andreas Fischer <bantu@owncloud.com> | 2014-05-28 22:57:33 +0200 |
commit | 5754b0b9e70824786878b847abb6b728ca0414bb (patch) | |
tree | 9ad1fbc35edde8f54f44c9ef7029e007a16815b9 /core/js/share.js | |
parent | f81ee94cad8a997c3a2fef0b6aac4f8d509571f6 (diff) | |
parent | ce9d5df6df37e51587dcde638086dfe501892b56 (diff) | |
download | nextcloud-server-5754b0b9e70824786878b847abb6b728ca0414bb.tar.gz nextcloud-server-5754b0b9e70824786878b847abb6b728ca0414bb.zip |
Merge remote-tracking branch 'owncloud/master' into add_resetadminpass_command
* owncloud/master: (238 commits)
Change visibility of scanner internals
[tx-robot] updated from transifex
remove legacy OC_Filesystem being used in a hook callback
add title property to share dialog
forgotten infobox messages translations
reverts 188c543 and translates only mail
fix warning text and margin
Adjust core apps to use "requiremin" instead of "require"
Added requiremin/requiremax fields for apps
[tx-robot] updated from transifex
unwrapped strings fix
allow resharing of files with only share permissions
don't lose file size during rename
drop superflous statement in phpdoc
add preRememberedLogin hook and document this and postRememberedLogin in class descripttion. Also fixes documentation of postLogin hook
[tx-robot] updated from transifex
fix grammar
make user_ldap fully translatable
[tx-robot] updated from transifex
fix typo
...
Conflicts:
core/register_command.php
Diffstat (limited to 'core/js/share.js')
-rw-r--r-- | core/js/share.js | 129 |
1 files changed, 101 insertions, 28 deletions
diff --git a/core/js/share.js b/core/js/share.js index 2813570f718..d013f257579 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -136,7 +136,21 @@ OC.Share={ return data; }, - share:function(itemType, itemSource, shareType, shareWith, permissions, itemSourceName, callback) { + share:function(itemType, itemSource, shareType, shareWith, permissions, itemSourceName, expirationDate, callback) { + // Add a fallback for old share() calls without expirationDate. + // We should remove this in a later version, + // after the Apps have been updated. + if (typeof callback === 'undefined' && + typeof expirationDate === 'function') { + callback = expirationDate; + expirationDate = ''; + console.warn( + "Call to 'OC.Share.share()' with too few arguments. " + + "'expirationDate' was assumed to be 'callback'. " + + "Please revisit the call and fix the list of arguments." + ); + } + $.post(OC.filePath('core', 'ajax', 'share.php'), { action: 'share', @@ -145,7 +159,8 @@ OC.Share={ shareType: shareType, shareWith: shareWith, permissions: permissions, - itemSourceName: itemSourceName + itemSourceName: itemSourceName, + expirationDate: expirationDate }, function (result) { if (result && result.status === 'success') { if (callback) { @@ -219,11 +234,22 @@ OC.Share={ html += '<div id="link">'; html += '<input type="checkbox" name="linkCheckbox" id="linkCheckbox" value="1" /><label for="linkCheckbox">'+t('core', 'Share link')+'</label>'; html += '<br />'; + + var defaultExpireMessage = ''; + if ((itemType === 'folder' || itemType === 'file') && oc_appconfig.core.defaultExpireDateEnabled === 'yes') { + if (oc_appconfig.core.defaultExpireDateEnforced === 'yes') { + defaultExpireMessage = t('core', 'The public link will expire no later than {days} days after it is created', {'days': oc_appconfig.core.defaultExpireDate}) + '<br/>'; + } else { + defaultExpireMessage = t('core', 'By default the public link will expire after {days} days', {'days': oc_appconfig.core.defaultExpireDate}) + '<br/>'; + } + } + html += '<input id="linkText" type="text" readonly="readonly" />'; html += '<input type="checkbox" name="showPassword" id="showPassword" value="1" style="display:none;" /><label for="showPassword" style="display:none;">'+t('core', 'Password protect')+'</label>'; html += '<div id="linkPass">'; - html += '<input id="linkPassText" type="password" placeholder="'+t('core', 'Password')+'" />'; + html += '<input id="linkPassText" type="password" placeholder="'+t('core', 'Choose a password for the public link')+'" />'; html += '</div>'; + if (itemType === 'folder' && (possiblePermissions & OC.PERMISSION_CREATE) && publicUploadEnabled === 'yes') { html += '<div id="allowPublicUploadWrapper" style="display:none;">'; html += '<input type="checkbox" value="1" name="allowPublicUpload" id="sharingDialogAllowPublicUpload"' + ((allowPublicUploadStatus) ? 'checked="checked"' : '') + ' />'; @@ -239,6 +265,7 @@ OC.Share={ html += '<div id="expiration">'; html += '<input type="checkbox" name="expirationCheckbox" id="expirationCheckbox" value="1" /><label for="expirationCheckbox">'+t('core', 'Set expiration date')+'</label>'; html += '<input id="expirationDate" type="text" placeholder="'+t('core', 'Expiration date')+'" style="display:none; width:90%;" />'; + html += '<div id="defaultExpireMessage">'+defaultExpireMessage+'</div>'; html += '</div>'; dropDownEl = $(html); dropDownEl = dropDownEl.appendTo(appendTo); @@ -291,6 +318,10 @@ OC.Share={ var itemType = $('#dropdown').data('item-type'); var itemSource = $('#dropdown').data('item-source'); var itemSourceName = $('#dropdown').data('item-source-name'); + var expirationDate = ''; + if ( $('#expirationCheckbox').is(':checked') === true ) { + expirationDate = $( "#expirationDate" ).val(); + } var shareType = selected.item.value.shareType; var shareWith = selected.item.value.shareWith; $(this).val(shareWith); @@ -310,7 +341,7 @@ OC.Share={ permissions = permissions | OC.PERMISSION_SHARE; } - OC.Share.share(itemType, itemSource, shareType, shareWith, permissions, itemSourceName, function() { + OC.Share.share(itemType, itemSource, shareType, shareWith, permissions, itemSourceName, expirationDate, function() { OC.Share.addShareWith(shareType, shareWith, selected.item.label, permissions, possiblePermissions); $('#shareWith').val(''); OC.Share.updateIcon(itemType, itemSource); @@ -347,8 +378,8 @@ OC.Share={ } }) .data("ui-autocomplete")._renderItem = function( ul, item ) { - return $( "<li>" ) - .append( "<a>" + item.displayname + "<br>" + item.email + "</a>" ) + return $('<li>') + .append('<a>' + escapeHTML(item.displayname) + "<br>" + escapeHTML(item.email) + '</a>' ) .appendTo( ul ); }; } @@ -420,7 +451,7 @@ OC.Share={ } var html = '<li style="clear: both;" data-share-type="'+escapeHTML(shareType)+'" data-share-with="'+escapeHTML(shareWith)+'" title="' + escapeHTML(shareWith) + '">'; var showCrudsButton; - html += '<a href="#" class="unshare"><img class="svg" alt="'+t('core', 'Unshare')+'" src="'+OC.imagePath('core', 'actions/delete')+'"/></a>'; + html += '<a href="#" class="unshare"><img class="svg" alt="'+t('core', 'Unshare')+'" title="'+t('core', 'Unshare')+'" src="'+OC.imagePath('core', 'actions/delete')+'"/></a>'; html += '<span class="username">' + escapeHTML(shareWithDisplayName) + '</span>'; var mailNotificationEnabled = $('input:hidden[name=mailNotificationEnabled]').val(); if (mailNotificationEnabled === 'yes') { @@ -433,7 +464,7 @@ OC.Share={ if (possiblePermissions & OC.PERMISSION_CREATE || possiblePermissions & OC.PERMISSION_UPDATE || possiblePermissions & OC.PERMISSION_DELETE) { html += '<label><input type="checkbox" name="edit" class="permissions" '+editChecked+' />'+t('core', 'can edit')+'</label> '; } - showCrudsButton = '<a href="#" class="showCruds"><img class="svg" alt="'+t('core', 'access control')+'" src="'+OC.imagePath('core', 'actions/triangle-s')+'"/></a>'; + showCrudsButton = '<a href="#" class="showCruds"><img class="svg" alt="'+t('core', 'access control')+'" title="'+t('core', 'access control')+'" src="'+OC.imagePath('core', 'actions/triangle-s')+'"/></a>'; html += '<div class="cruds" style="display:none;">'; if (possiblePermissions & OC.PERMISSION_CREATE) { html += '<label><input type="checkbox" name="create" class="permissions" '+createChecked+' data-permissions="'+OC.PERMISSION_CREATE+'" />'+t('core', 'create')+'</label>'; @@ -464,6 +495,10 @@ OC.Share={ showLink:function(token, password, itemSource) { OC.Share.itemShares[OC.Share.SHARE_TYPE_LINK] = true; $('#linkCheckbox').attr('checked', true); + + //check itemType + var linkSharetype=$('#dropdown').data('item-type'); + if (! token) { //fallback to pre token link var filename = $('tr').filterAttr('data-id', String(itemSource)).data('file'); @@ -477,32 +512,43 @@ OC.Share={ var link = parent.location.protocol+'//'+location.host+OC.linkTo('', 'public.php')+'?service=files&'+type+'='+encodeURIComponent(file); } else { //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; + var service=''; + if(linkSharetype === 'folder' || linkSharetype === 'file'){ + service='files'; + }else{ + service=linkSharetype; + } + + var link = parent.location.protocol+'//'+location.host+OC.linkTo('', 'public.php')+'?service='+service+'&t='+token; + } $('#linkText').val(link); $('#linkText').show('blind'); $('#linkText').css('display','block'); - $('#showPassword').show(); - $('#showPassword+label').show(); + if (oc_appconfig.core.enforcePasswordForPublicLink === false || password === null) { + $('#showPassword').show(); + $('#showPassword+label').show(); + } if (password != null) { $('#linkPass').show('blind'); $('#showPassword').attr('checked', true); $('#linkPassText').attr('placeholder', '**********'); } $('#expiration').show(); + $('#defaultExpireMessage').show(); $('#emailPrivateLink #email').show(); $('#emailPrivateLink #emailButton').show(); $('#allowPublicUploadWrapper').show(); }, hideLink:function() { $('#linkText').hide('blind'); + $('#defaultExpireMessage').hide(); $('#showPassword').hide(); $('#showPassword+label').hide(); - $('#linkPass').hide(); + $('#linkPass').hide('blind'); $('#emailPrivateLink #email').hide(); $('#emailPrivateLink #emailButton').hide(); $('#allowPublicUploadWrapper').hide(); - $('#expirationDate').hide(); }, dirname:function(path) { return path.replace(/\\/g,'/').replace(/\/[^\/]*$/, ''); @@ -628,22 +674,33 @@ $(document).ready(function() { var itemType = $('#dropdown').data('item-type'); var itemSource = $('#dropdown').data('item-source'); var itemSourceName = $('#dropdown').data('item-source-name'); + var expirationDate = ''; + if ($('#expirationCheckbox').is(':checked') === true) { + expirationDate = $( "#expirationDate" ).val(); + } if (this.checked) { // Create a link - OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', OC.PERMISSION_READ, itemSourceName, function(data) { - OC.Share.showLink(data.token, null, itemSource); - OC.Share.updateIcon(itemType, itemSource); - }); + if (oc_appconfig.core.enforcePasswordForPublicLink === false) { + OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', OC.PERMISSION_READ, itemSourceName, expirationDate, function(data) { + OC.Share.showLink(data.token, null, itemSource); + OC.Share.updateIcon(itemType, itemSource); + }); + } else { + $('#linkPass').toggle('blind'); + $('#linkPassText').focus(); + } } else { // Delete private link - OC.Share.unshare(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', function() { - OC.Share.hideLink(); - OC.Share.itemShares[OC.Share.SHARE_TYPE_LINK] = false; - OC.Share.updateIcon(itemType, itemSource); - if (typeof OC.Share.statuses[itemSource] === 'undefined') { - $('#expiration').hide('blind'); - } - }); + OC.Share.hideLink(); + if ($('#linkText').val() !== '') { + OC.Share.unshare(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', function() { + OC.Share.itemShares[OC.Share.SHARE_TYPE_LINK] = false; + OC.Share.updateIcon(itemType, itemSource); + if (typeof OC.Share.statuses[itemSource] === 'undefined') { + $('#expiration').hide('blind'); + } + }); + } } }); @@ -660,6 +717,10 @@ $(document).ready(function() { var itemType = $('#dropdown').data('item-type'); var itemSource = $('#dropdown').data('item-source'); var itemSourceName = $('#dropdown').data('item-source-name'); + var expirationDate = ''; + if ($('#expirationCheckbox').is(':checked') === true) { + expirationDate = $( "#expirationDate" ).val(); + } var permissions = 0; // Calculate permissions @@ -670,7 +731,7 @@ $(document).ready(function() { } // Update the share information - OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', permissions, itemSourceName, function(data) { + OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', permissions, itemSourceName, expirationDate, function(data) { }); }); @@ -715,11 +776,16 @@ $(document).ready(function() { permissions = OC.PERMISSION_READ; } - OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, $('#linkPassText').val(), permissions, itemSourceName, function() { - console.log("password set to: '" + linkPassText.val() +"' by event: " + event.type); + OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, $('#linkPassText').val(), permissions, itemSourceName, function(data) { linkPassText.val(''); linkPassText.attr('placeholder', t('core', 'Password protected')); + + if (oc_appconfig.core.enforcePasswordForPublicLink) { + OC.Share.showLink(data.token, "password set", itemSource); + OC.Share.updateIcon(itemType, itemSource); + } }); + } }); @@ -734,6 +800,9 @@ $(document).ready(function() { OC.dialogs.alert(t('core', 'Error unsetting expiration date'), t('core', 'Error')); } $('#expirationDate').hide('blind'); + if (oc_appconfig.core.defaultExpireDateEnforced === 'no') { + $('#defaultExpireMessage'). show('blind'); + } }); } }); @@ -756,6 +825,10 @@ $(document).ready(function() { expirationDateField.tipsy({gravity: 'n', fade: true}); expirationDateField.tipsy('show'); expirationDateField.addClass('error'); + } else { + if (oc_appconfig.core.defaultExpireDateEnforced === 'no') { + $('#defaultExpireMessage'). hide('blind'); + } } }); }); |