]> source.dussan.org Git - nextcloud-server.git/commitdiff
allow editing single files shared as public link 3231/head
authorBjoern Schiessle <bjoern@schiessle.org>
Tue, 24 Jan 2017 12:24:46 +0000 (13:24 +0100)
committerBjoern Schiessle <bjoern@schiessle.org>
Tue, 24 Jan 2017 12:41:27 +0000 (13:41 +0100)
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
apps/files_sharing/lib/Controller/ShareAPIController.php
core/js/sharedialoglinkshareview.js
core/js/shareitemmodel.js

index ccd0e3aa31d69083bdc0582fa47a39832c896b82..6181cde6fe66e675be2eec4738907ca3af01acbd 100644 (file)
@@ -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'));
index cb553947de6b4d7efdac11166c735b6805396578..84a3d18942f8411354230f2adbb3b3a3ebaac7f5 100644 (file)
                        '</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'
                },
                                'onLinkTextClick',
                                'onShowPasswordClick',
                                'onHideFileListChange',
-                               'onAllowPublicUploadChange'
+                               'onAllowPublicUploadChange',
+                               'onAllowPublicEditingChange'
                        );
 
                        var clipboard = new Clipboard('.clipboardButton');
                        });
                },
 
+               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');
                                publicUploadChecked = 'checked="checked"';
                        }
 
+                       var publicEditingChecked = '';
+                       if(this.model.isPublicEditingAllowed()) {
+                               publicEditingChecked = 'checked="checked"';
+                       }
+
+
                        var hideFileList = publicUploadChecked;
 
                        var hideFileListChecked = '';
                                && (   !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,
                                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')
index 9b10f067afc22109eecf793bd41e3bd222ad5b24..ae4c07e3f4e52c37ca2900cdee95032b6f8a2574 100644 (file)
                        return this.get('allowPublicUploadStatus');
                },
 
+               isPublicEditingAllowed: function() {
+                       return this.get('allowPublicEditingStatus');
+               },
+
                /**
                 * @returns {boolean}
                 */
                                });
                        }
 
+                       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) {
                                linkShare: linkShare,
                                permissions: permissions,
                                allowPublicUploadStatus: allowPublicUploadStatus,
+                               allowPublicEditingStatus: allowPublicEditingStatus,
                                hideFileListStatus: hideFileListStatus
                        };
                },