allow editing single files shared as public link
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
This commit is contained in:
parent
5d486478d3
commit
92d7dd4781
3 changed files with 55 additions and 1 deletions
|
@ -668,6 +668,7 @@ class ShareAPIController extends OCSController {
|
|||
\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE, // legacy
|
||||
\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE, // correct
|
||||
\OCP\Constants::PERMISSION_CREATE, // hidden file list
|
||||
\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE, // allow to edit single files
|
||||
])
|
||||
) {
|
||||
throw new OCSBadRequestException($this->l->t('Can\'t change permissions for public share links'));
|
||||
|
|
|
@ -43,6 +43,13 @@
|
|||
'</div>' +
|
||||
' {{/if}}' +
|
||||
' {{/if}}' +
|
||||
' {{#if publicEditing}}' +
|
||||
'<div id="allowPublicEditingWrapper">' +
|
||||
' <span class="icon-loading-small hidden"></span>' +
|
||||
' <input type="checkbox" value="1" name="allowPublicEditing" id="sharingDialogAllowPublicEditing-{{cid}}" class="checkbox publicEditingCheckbox" {{{publicEditingChecked}}} />' +
|
||||
'<label for="sharingDialogAllowPublicEditing-{{cid}}">{{publicEditingLabel}}</label>' +
|
||||
'</div>' +
|
||||
' {{/if}}' +
|
||||
' {{#if showPasswordCheckBox}}' +
|
||||
'<input type="checkbox" name="showPassword" id="showPassword-{{cid}}" class="checkbox showPasswordCheckbox" {{#if isPasswordSet}}checked="checked"{{/if}} value="1" />' +
|
||||
'<label for="showPassword-{{cid}}">{{enablePasswordLabel}}</label>' +
|
||||
|
@ -87,6 +94,7 @@
|
|||
'click .linkCheckbox': 'onLinkCheckBoxChange',
|
||||
'click .linkText': 'onLinkTextClick',
|
||||
'change .publicUploadCheckbox': 'onAllowPublicUploadChange',
|
||||
'change .publicEditingCheckbox': 'onAllowPublicEditingChange',
|
||||
'change .hideFileListCheckbox': 'onHideFileListChange',
|
||||
'click .showPasswordCheckbox': 'onShowPasswordClick'
|
||||
},
|
||||
|
@ -128,7 +136,8 @@
|
|||
'onLinkTextClick',
|
||||
'onShowPasswordClick',
|
||||
'onHideFileListChange',
|
||||
'onAllowPublicUploadChange'
|
||||
'onAllowPublicUploadChange',
|
||||
'onAllowPublicEditingChange'
|
||||
);
|
||||
|
||||
var clipboard = new Clipboard('.clipboardButton');
|
||||
|
@ -266,6 +275,20 @@
|
|||
});
|
||||
},
|
||||
|
||||
onAllowPublicEditingChange: function() {
|
||||
var $checkbox = this.$('.publicEditingCheckbox');
|
||||
$checkbox.siblings('.icon-loading-small').removeClass('hidden').addClass('inlineblock');
|
||||
|
||||
var permissions = OC.PERMISSION_READ;
|
||||
if($checkbox.is(':checked')) {
|
||||
permissions = OC.PERMISSION_UPDATE | OC.PERMISSION_READ;
|
||||
}
|
||||
|
||||
this.model.saveLinkShare({
|
||||
permissions: permissions
|
||||
});
|
||||
},
|
||||
|
||||
onHideFileListChange: function () {
|
||||
var $checkbox = this.$('.hideFileListCheckbox');
|
||||
$checkbox.siblings('.icon-loading-small').removeClass('hidden').addClass('inlineblock');
|
||||
|
@ -307,6 +330,12 @@
|
|||
publicUploadChecked = 'checked="checked"';
|
||||
}
|
||||
|
||||
var publicEditingChecked = '';
|
||||
if(this.model.isPublicEditingAllowed()) {
|
||||
publicEditingChecked = 'checked="checked"';
|
||||
}
|
||||
|
||||
|
||||
var hideFileList = publicUploadChecked;
|
||||
|
||||
var hideFileListChecked = '';
|
||||
|
@ -320,6 +349,11 @@
|
|||
&& ( !this.configModel.get('enforcePasswordForPublicLink')
|
||||
|| !this.model.get('linkShare').password);
|
||||
|
||||
var publicEditable =
|
||||
!this.model.isFolder()
|
||||
&& isLinkShare
|
||||
&& this.model.updatePermissionPossible();
|
||||
|
||||
this.$el.html(linkShareTemplate({
|
||||
cid: this.cid,
|
||||
shareAllowed: true,
|
||||
|
@ -337,6 +371,9 @@
|
|||
publicUploadChecked: publicUploadChecked,
|
||||
hideFileListChecked: hideFileListChecked,
|
||||
publicUploadLabel: t('core', 'Allow upload and editing'),
|
||||
publicEditing: publicEditable,
|
||||
publicEditingChecked: publicEditingChecked,
|
||||
publicEditingLabel: t('core', 'Allow editing'),
|
||||
hideFileListLabel: t('core', 'File drop (upload only)'),
|
||||
mailPrivatePlaceholder: t('core', 'Email link to person'),
|
||||
mailButtonText: t('core', 'Send')
|
||||
|
|
|
@ -272,6 +272,10 @@
|
|||
return this.get('allowPublicUploadStatus');
|
||||
},
|
||||
|
||||
isPublicEditingAllowed: function() {
|
||||
return this.get('allowPublicEditingStatus');
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
|
@ -679,6 +683,17 @@
|
|||
});
|
||||
}
|
||||
|
||||
var allowPublicEditingStatus = true;
|
||||
if(!_.isUndefined(data.shares)) {
|
||||
$.each(data.shares, function (key, value) {
|
||||
if (value.share_type === OC.Share.SHARE_TYPE_LINK) {
|
||||
allowPublicEditingStatus = (value.permissions & OC.PERMISSION_UPDATE) ? true : false;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
var hideFileListStatus = false;
|
||||
if(!_.isUndefined(data.shares)) {
|
||||
$.each(data.shares, function (key, value) {
|
||||
|
@ -762,6 +777,7 @@
|
|||
linkShare: linkShare,
|
||||
permissions: permissions,
|
||||
allowPublicUploadStatus: allowPublicUploadStatus,
|
||||
allowPublicEditingStatus: allowPublicEditingStatus,
|
||||
hideFileListStatus: hideFileListStatus
|
||||
};
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue