Skip to content

Commit

Permalink
Issue #565: Add the checkbox in the share dialogue to allow uploading…
Browse files Browse the repository at this point in the history
… from the public side
  • Loading branch information
imjalpreet committed Mar 11, 2016
1 parent e60e79b commit 3a2ca47
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 58 deletions.
3 changes: 2 additions & 1 deletion controller/pagecontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ public function index() {
// Parameters sent to the template
$params = [
'appName' => $appName,
'uploadUrl' => $this->urlGenerator->linkTo('files', 'ajax/upload.php')
'uploadUrl' => $this->urlGenerator->linkTo('files', 'ajax/upload.php'),
'publicUploadEnabled' => $this->appConfig->getAppValue('core', 'shareapi_allow_public_upload', 'yes')
];

// Will render the page using the template found in templates/index.php
Expand Down
109 changes: 53 additions & 56 deletions js/vendor/owncloud/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,20 +173,19 @@
// Used later on to determine if the
// respective checkbox should be checked or
// not.
// FIXME public uploading is not supported in Gallery
/*var publicUploadEnabled = $('#filestable').data('allow-public-upload');
if (typeof publicUploadEnabled == 'undefined') {
publicUploadEnabled = 'no';
}
var allowPublicUploadStatus = false;
var publicUploadEnabled = $('#gallery').data('allow-public-upload');
if (typeof publicUploadEnabled == 'undefined') {
publicUploadEnabled = 'no';
}
var allowPublicUploadStatus = false;

$.each(data, function (key, value) {
if (value.share_type === self.SHARE_TYPE_LINK) {
allowPublicUploadStatus =
(value.permissions & OC.PERMISSION_CREATE) ? true : false;
return true;
}
});*/
$.each(data, function (key, value) {
if (value.share_type === self.SHARE_TYPE_LINK) {
allowPublicUploadStatus =
(value.permissions & OC.PERMISSION_CREATE) ? true : false;
return true;
}
});

var sharePlaceholder = t('core', 'Share with users or groups …');
if (oc_appconfig.core.remoteShareAllowed) {
Expand Down Expand Up @@ -244,20 +243,18 @@
html += '<span class="icon-loading-small hidden"></span>';
html += '</div>';

// FIXME public uploading is not supported in Gallery
/*if (itemType === 'folder' && (possiblePermissions & OC.PERMISSION_CREATE) &&
publicUploadEnabled === 'yes') {
html += '<div id="allowPublicUploadWrapper" style="display:none;">';
html += '<span class="icon-loading-small hidden"></span>';
html +=
'<input type="checkbox" class="checkbox checkbox--right" value="1" name="allowPublicUpload" id="sharingDialogAllowPublicUpload"' +
((allowPublicUploadStatus) ? 'checked="checked"' : '') + ' />';
html += '<label for="sharingDialogAllowPublicUpload">' +
t('core', 'Allow editing') + '</label>';
html += '</div>';
}
html += '</div>';
var mailPublicNotificationEnabled = $(
if (itemType === 'folder' && (possiblePermissions & OC.PERMISSION_CREATE) &&
publicUploadEnabled === 'yes') {
html += '<div id="allowPublicUploadWrapper" style="display:none;">';
html += '<span class="icon-loading-small hidden"></span>';
html +=
'<input type="checkbox" class="checkbox checkbox--right" value="1" name="allowPublicUpload" id="sharingDialogAllowPublicUpload"' +
((allowPublicUploadStatus) ? 'checked="checked"' : '') + ' />';
html += '<label for="sharingDialogAllowPublicUpload">' +
t('core', 'Allow editing') + '</label>';
html += '</div>';
}
/*var mailPublicNotificationEnabled = $(
'input:hidden[name=mailPublicNotificationEnabled]').val();
if (mailPublicNotificationEnabled === 'yes') {
html += '<form id="emailPrivateLink">';
Expand Down Expand Up @@ -1028,38 +1025,38 @@ $(document).ready(function () {
});

// Handle the Allow Public Upload Checkbox
// FIXME public uploading is not supported in Gallery
/*$(document).on('click', '#sharingDialogAllowPublicUpload', function () {
$(document).on('click', '#sharingDialogAllowPublicUpload', function () {

// Gather data
var $dropDown = $('#dropdown');
var allowPublicUpload = $(this).is(':checked');
var $button = $(this);
var $loading = $dropDown.find('#allowPublicUploadWrapper .icon-loading-small');
// Gather data
var $dropDown = $('#dropdown');
var shareId = $('#linkCheckbox').data('id');
var allowPublicUpload = $(this).is(':checked');
var $button = $(this);
var $loading = $dropDown.find('#allowPublicUploadWrapper .icon-loading-small');

if (!$loading.hasClass('hidden')) {
// already in progress
return false;
}
if (!$loading.hasClass('hidden')) {
// already in progress
return false;
}

// Update the share information
$button.addClass('hidden');
$button.prop('disabled', true);
$loading.removeClass('hidden');
//(path, shareType, shareWith, publicUpload, password, permissions)
$.ajax({
url: OC.linkToOCS('apps/files_sharing/api/v1', 2) + 'shares/' + shareId +
'?format=json',
type: 'PUT',
data: {
publicUpload: allowPublicUpload
}
}).done(function () {
$loading.addClass('hidden');
$button.removeClass('hidden');
$button.prop('disabled', false);
});
});*/
// Update the share information
$button.addClass('hidden');
$button.prop('disabled', true);
$loading.removeClass('hidden');
//(path, shareType, shareWith, publicUpload, password, permissions)
$.ajax({
url: OC.linkToOCS('apps/files_sharing/api/v1', 2) + 'shares/' + shareId +
'?format=json',
type: 'PUT',
data: {
publicUpload: allowPublicUpload
}
}).done(function () {
$loading.addClass('hidden');
$button.removeClass('hidden');
$button.prop('disabled', false);
});
});

$(document).on('click', '#dropdown #showPassword', function () {
$('#linkPass').slideToggle(OC.menuSpeed);
Expand Down
2 changes: 1 addition & 1 deletion templates/part.content.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
</div>
</span>
</div>
<div id="gallery" class="hascontrols"></div>
<div id="gallery" data-allow-public-upload="<?php p($_['publicUploadEnabled'])?>" class="hascontrols"></div>
<div id="emptycontent" class="hidden"></div>
<input type="hidden" name="allowShareWithLink" id="allowShareWithLink" value="yes"/>
<div class="hiddenuploadfield">
Expand Down

0 comments on commit 3a2ca47

Please sign in to comment.