Public upload feature

This commit is contained in:
Roman Geber 2013-06-25 12:24:14 +02:00
parent c3b8f2bf64
commit ddb0ff346d
11 changed files with 242 additions and 169 deletions

View file

@ -1,17 +1,53 @@
<?php <?php
// Init owncloud
// Firefox and Konqueror tries to download application/json for me. --Arthur // Firefox and Konqueror tries to download application/json for me. --Arthur
OCP\JSON::setContentTypeHeader('text/plain'); OCP\JSON::setContentTypeHeader('text/plain');
OCP\JSON::checkLoggedIn(); // If a directory token is sent along check if public upload is permitted.
OCP\JSON::callCheck(); // If not, check the login.
// If no token is sent along, rely on login only
$l = OC_L10N::get('files'); $l = OC_L10N::get('files');
if (!$_POST['dirToken']) {
// The standard case, files are uploaded through logged in users :)
OCP\JSON::checkLoggedIn();
$dir = isset($_POST['dir']) ? $_POST['dir'] : "";
if (!$dir || empty($dir) || $dir === false) {
OCP\JSON::error(array('data' => array_merge(array('message' => $l->t('Unable to set upload directory.')))));
die();
}
} else {
$linkItem = OCP\Share::getShareByToken($_POST['dirToken']);
if ($linkItem === false) {
OCP\JSON::error(array('data' => array_merge(array('message' => $l->t('Invalid Token')))));
die();
}
if (!($linkItem['permissions'] & OCP\PERMISSION_CREATE)) {
OCP\JSON::checkLoggedIn();
} else {
// The token defines the target directory (security reasons)
$dir = sprintf(
"/%s/%s",
$linkItem['file_target'],
isset($_POST['subdir']) ? $_POST['subdir'] : ''
);
if (!$dir || empty($dir) || $dir === false) {
OCP\JSON::error(array('data' => array_merge(array('message' => $l->t('Unable to set upload directory.')))));
die();
}
// Setup FS with owner
OC_Util::setupFS($linkItem['uid_owner']);
}
}
OCP\JSON::callCheck();
$dir = $_POST['dir'];
// get array with current storage stats (e.g. max file size) // get array with current storage stats (e.g. max file size)
$storageStats = \OCA\files\lib\Helper::buildFileStorageStatistics($dir); $storageStats = \OCA\files\lib\Helper::buildFileStorageStatistics($dir);

View file

@ -26,6 +26,7 @@ OCP\User::checkLoggedIn();
// Load the files we need // Load the files we need
OCP\Util::addStyle('files', 'files'); OCP\Util::addStyle('files', 'files');
OCP\Util::addscript('files', 'file-upload');
OCP\Util::addscript('files', 'jquery.iframe-transport'); OCP\Util::addscript('files', 'jquery.iframe-transport');
OCP\Util::addscript('files', 'jquery.fileupload'); OCP\Util::addscript('files', 'jquery.fileupload');
OCP\Util::addscript('files', 'jquery-visibility'); OCP\Util::addscript('files', 'jquery-visibility');
@ -137,4 +138,4 @@ if ($needUpgrade) {
$tmpl->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true))); $tmpl->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true)));
$tmpl->assign('usedSpacePercent', (int)$storageInfo['relative']); $tmpl->assign('usedSpacePercent', (int)$storageInfo['relative']);
$tmpl->printPage(); $tmpl->printPage();
} }

View file

@ -71,8 +71,20 @@ var FileList={
tr.append(td); tr.append(td);
return tr; return tr;
}, },
addFile:function(name,size,lastModified,loading,hidden){ addFile:function(name,size,lastModified,loading,hidden,param){
var imgurl; var imgurl;
if (!param) {
param = {};
}
var download_url = null;
if (!param.download_url) {
download_url = OC.Router.generate('download', { file: $('#dir').val()+'/'+name });
} else {
download_url = param.download_url;
}
if (loading) { if (loading) {
imgurl = OC.imagePath('core', 'loading.gif'); imgurl = OC.imagePath('core', 'loading.gif');
} else { } else {
@ -82,7 +94,7 @@ var FileList={
'file', 'file',
name, name,
imgurl, imgurl,
OC.Router.generate('download', { file: $('#dir').val()+'/'+name }), download_url,
size, size,
lastModified, lastModified,
$('#permissions').val() $('#permissions').val()
@ -197,7 +209,7 @@ var FileList={
len = input.val().length; len = input.val().length;
} }
input.selectRange(0,len); input.selectRange(0,len);
form.submit(function(event){ form.submit(function(event){
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
@ -423,8 +435,12 @@ $(document).ready(function(){
size=data.files[0].size; size=data.files[0].size;
} }
var date=new Date(); var date=new Date();
var param = {};
if ($('#publicUploadRequestToken')) {
param.download_url = document.location.href + '&download&path=/' + $('#dir').val() + '/' + uniqueName;
}
// create new file context // create new file context
data.context = FileList.addFile(uniqueName,size,date,true,false); data.context = FileList.addFile(uniqueName,size,date,true,false,param);
} }
} }

View file

@ -251,153 +251,6 @@ $(document).ready(function() {
e.preventDefault(); // prevent browser from doing anything, if file isn't dropped in dropZone e.preventDefault(); // prevent browser from doing anything, if file isn't dropped in dropZone
}); });
if ( document.getElementById('data-upload-form') ) {
$(function() {
$('#file_upload_start').fileupload({
dropZone: $('#content'), // restrict dropZone to content div
//singleFileUploads is on by default, so the data.files array will always have length 1
add: function(e, data) {
if(data.files[0].type === '' && data.files[0].size == 4096)
{
data.textStatus = 'dirorzero';
data.errorThrown = t('files','Unable to upload your file as it is a directory or has 0 bytes');
var fu = $(this).data('blueimp-fileupload') || $(this).data('fileupload');
fu._trigger('fail', e, data);
return true; //don't upload this file but go on with next in queue
}
var totalSize=0;
$.each(data.originalFiles, function(i,file){
totalSize+=file.size;
});
if(totalSize>$('#max_upload').val()){
data.textStatus = 'notenoughspace';
data.errorThrown = t('files','Not enough space available');
var fu = $(this).data('blueimp-fileupload') || $(this).data('fileupload');
fu._trigger('fail', e, data);
return false; //don't upload anything
}
// start the actual file upload
var jqXHR = data.submit();
// remember jqXHR to show warning to user when he navigates away but an upload is still in progress
if (typeof data.context !== 'undefined' && data.context.data('type') === 'dir') {
var dirName = data.context.data('file');
if(typeof uploadingFiles[dirName] === 'undefined') {
uploadingFiles[dirName] = {};
}
uploadingFiles[dirName][data.files[0].name] = jqXHR;
} else {
uploadingFiles[data.files[0].name] = jqXHR;
}
//show cancel button
if($('html.lte9').length === 0 && data.dataType !== 'iframe') {
$('#uploadprogresswrapper input.stop').show();
}
},
/**
* called after the first add, does NOT have the data param
* @param e
*/
start: function(e) {
//IE < 10 does not fire the necessary events for the progress bar.
if($('html.lte9').length > 0) {
return;
}
$('#uploadprogressbar').progressbar({value:0});
$('#uploadprogressbar').fadeIn();
},
fail: function(e, data) {
if (typeof data.textStatus !== 'undefined' && data.textStatus !== 'success' ) {
if (data.textStatus === 'abort') {
$('#notification').text(t('files', 'Upload cancelled.'));
} else {
// HTTP connection problem
$('#notification').text(data.errorThrown);
}
$('#notification').fadeIn();
//hide notification after 5 sec
setTimeout(function() {
$('#notification').fadeOut();
}, 5000);
}
delete uploadingFiles[data.files[0].name];
},
progress: function(e, data) {
// TODO: show nice progress bar in file row
},
progressall: function(e, data) {
//IE < 10 does not fire the necessary events for the progress bar.
if($('html.lte9').length > 0) {
return;
}
var progress = (data.loaded/data.total)*100;
$('#uploadprogressbar').progressbar('value',progress);
},
/**
* called for every successful upload
* @param e
* @param data
*/
done:function(e, data) {
// handle different responses (json or body from iframe for ie)
var response;
if (typeof data.result === 'string') {
response = data.result;
} else {
//fetch response from iframe
response = data.result[0].body.innerText;
}
var result=$.parseJSON(response);
if(typeof result[0] !== 'undefined' && result[0].status === 'success') {
var file = result[0];
} else {
data.textStatus = 'servererror';
data.errorThrown = t('files', result.data.message);
var fu = $(this).data('blueimp-fileupload') || $(this).data('fileupload');
fu._trigger('fail', e, data);
}
var filename = result[0].originalname;
// delete jqXHR reference
if (typeof data.context !== 'undefined' && data.context.data('type') === 'dir') {
var dirName = data.context.data('file');
delete uploadingFiles[dirName][filename];
if ($.assocArraySize(uploadingFiles[dirName]) == 0) {
delete uploadingFiles[dirName];
}
} else {
delete uploadingFiles[filename];
}
},
/**
* called after last upload
* @param e
* @param data
*/
stop: function(e, data) {
if(data.dataType !== 'iframe') {
$('#uploadprogresswrapper input.stop').hide();
}
//IE < 10 does not fire the necessary events for the progress bar.
if($('html.lte9').length > 0) {
return;
}
$('#uploadprogressbar').progressbar('value',100);
$('#uploadprogressbar').fadeOut();
}
})
});
}
$.assocArraySize = function(obj) { $.assocArraySize = function(obj) {
// http://stackoverflow.com/a/6700/11236 // http://stackoverflow.com/a/6700/11236
var size = 0, key; var size = 0, key;
@ -804,7 +657,7 @@ var dragOptions={
// sane browsers support using the distance option // sane browsers support using the distance option
if ( $('html.ie').length === 0) { if ( $('html.ie').length === 0) {
dragOptions['distance'] = 20; dragOptions['distance'] = 20;
} }
var folderDropOptions={ var folderDropOptions={
drop: function( event, ui ) { drop: function( event, ui ) {

View file

@ -50,7 +50,7 @@
</div> </div>
</div> </div>
<div id="file_action_panel"></div> <div id="file_action_panel"></div>
<?php else:?> <?php elseif( !$_['isPublic'] ):?>
<div class="actions"><input type="button" disabled value="<?php p($l->t('You dont have write permissions here.'))?>"></div> <div class="actions"><input type="button" disabled value="<?php p($l->t('You dont have write permissions here.'))?>"></div>
<input type="hidden" name="dir" value="<?php p($_['dir']) ?>" id="dir"> <input type="hidden" name="dir" value="<?php p($_['dir']) ?>" id="dir">
<?php endif;?> <?php endif;?>

View file

@ -15,15 +15,26 @@ body {
padding:.5em; padding:.5em;
} }
#details { #header #details {
color:#fff; color:#fff;
float: left;
} }
#header #public_upload,
#header #download { #header #download {
font-weight:700; font-weight:700;
margin-left:2em; margin: 0 0.4em 0 2em;
padding: 0 5px;
height: 27px;
float: left;
} }
#header #public_upload {
margin-left: 0.3em;
}
#header #public_upload img,
#header #download img { #header #download img {
padding-left:.1em; padding-left:.1em;
padding-right:.3em; padding-right:.3em;
@ -73,3 +84,49 @@ thead{
background-color: white; background-color: white;
padding-left:0 !important; /* fixes multiselect bar offset on shared page */ padding-left:0 !important; /* fixes multiselect bar offset on shared page */
} }
#data-upload-form {
position: relative;
right: 0;
height: 27px;
overflow: hidden;
padding: 0;
float: right;
display: inline;
margin: 0;
}
#file_upload_start {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: alpha(opacity=0);
opacity: 0;
z-index: 20;
position: absolute !important;
top: 0;
left: 0;
width: 100% !important;
}
.header-right #download span {
position: relative;
bottom: 3px;
}
#publicUploadButtonMock {
position:relative;
display:block;
width:100%;
height:27px;
cursor:pointer;
z-index:10;
background-image:url('%webroot%/core/img/actions/upload.svg');
background-repeat:no-repeat;
background-position:7px 6px;
}
#publicUploadButtonMock span {
margin: 0 5px 0 28px;
position: relative;
top: -2px;
color: #555;
}

View file

@ -7,6 +7,8 @@ function fileDownloadPath(dir, file) {
return url; return url;
} }
var form_data;
$(document).ready(function() { $(document).ready(function() {
if (typeof FileActions !== 'undefined') { if (typeof FileActions !== 'undefined') {
@ -46,4 +48,19 @@ $(document).ready(function() {
}); });
} }
}); // Add some form data to the upload handler
file_upload_param.formData = {
MAX_FILE_SIZE: $('#uploadMaxFilesize').val(),
requesttoken: $('#publicUploadRequestToken').val(),
dirToken: $('#dirToken').val(),
appname: 'files_sharing',
subdir: $('input#dir').val()
};
// Add Uploadprogress Wrapper to controls bar
$('#controls').append($('#additional_controls div#uploadprogresswrapper'));
// Cancel upload trigger
$('#cancel_upload_button').click(Files.cancelUploads);
});

View file

@ -132,15 +132,25 @@ if (isset($path)) {
} }
exit(); exit();
} else { } else {
OCP\Util::addScript('files', 'file-upload');
OCP\Util::addStyle('files_sharing', 'public'); OCP\Util::addStyle('files_sharing', 'public');
OCP\Util::addScript('files_sharing', 'public'); OCP\Util::addScript('files_sharing', 'public');
OCP\Util::addScript('files', 'fileactions'); OCP\Util::addScript('files', 'fileactions');
OCP\Util::addScript('files', 'jquery.iframe-transport');
OCP\Util::addScript('files', 'jquery.fileupload');
$maxUploadFilesize=OCP\Util::maxUploadFilesize($path);
$tmpl = new OCP\Template('files_sharing', 'public', 'base'); $tmpl = new OCP\Template('files_sharing', 'public', 'base');
$tmpl->assign('uidOwner', $shareOwner); $tmpl->assign('uidOwner', $shareOwner);
$tmpl->assign('displayName', \OCP\User::getDisplayName($shareOwner)); $tmpl->assign('displayName', \OCP\User::getDisplayName($shareOwner));
$tmpl->assign('filename', $file); $tmpl->assign('filename', $file);
$tmpl->assign('directory_path', $linkItem['file_target']);
$tmpl->assign('mimetype', \OC\Files\Filesystem::getMimeType($path)); $tmpl->assign('mimetype', \OC\Files\Filesystem::getMimeType($path));
$tmpl->assign('fileTarget', basename($linkItem['file_target'])); $tmpl->assign('fileTarget', basename($linkItem['file_target']));
$tmpl->assign('dirToken', $linkItem['token']);
$tmpl->assign('allowPublicUploadEnabled', (($linkItem['permissions'] & OCP\PERMISSION_CREATE) ? true : false ));
$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
$tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
$urlLinkIdentifiers= (isset($token)?'&t='.$token:'') $urlLinkIdentifiers= (isset($token)?'&t='.$token:'')
.(isset($_GET['dir'])?'&dir='.$_GET['dir']:'') .(isset($_GET['dir'])?'&dir='.$_GET['dir']:'')
.(isset($_GET['file'])?'&file='.$_GET['file']:''); .(isset($_GET['file'])?'&file='.$_GET['file']:'');
@ -191,15 +201,17 @@ if (isset($path)) {
$breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', ''); $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', '');
$breadcrumbNav->assign('breadcrumb', $breadcrumb); $breadcrumbNav->assign('breadcrumb', $breadcrumb);
$breadcrumbNav->assign('baseURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&path='); $breadcrumbNav->assign('baseURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&path=');
$maxUploadFilesize=OCP\Util::maxUploadFilesize($path);
$folder = new OCP\Template('files', 'index', ''); $folder = new OCP\Template('files', 'index', '');
$folder->assign('fileList', $list->fetchPage()); $folder->assign('fileList', $list->fetchPage());
$folder->assign('breadcrumb', $breadcrumbNav->fetchPage()); $folder->assign('breadcrumb', $breadcrumbNav->fetchPage());
$folder->assign('dir', $getPath); $folder->assign('dir', $getPath);
$folder->assign('isCreatable', false); $folder->assign('isCreatable', false);
$folder->assign('permissions', 0); $folder->assign('permissions', OCP\PERMISSION_READ);
$folder->assign('isPublic',true);
$folder->assign('files', $files); $folder->assign('files', $files);
$folder->assign('uploadMaxFilesize', 0); $folder->assign('uploadMaxFilesize', $maxUploadFilesize);
$folder->assign('uploadMaxHumanFilesize', 0); $folder->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
$folder->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true))); $folder->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true)));
$folder->assign('usedSpacePercent', 0); $folder->assign('usedSpacePercent', 0);
$tmpl->assign('folder', $folder->fetchPage()); $tmpl->assign('folder', $folder->fetchPage());

View file

@ -1,3 +1,7 @@
<div id="notification-container">
<div id="notification" style="display: none;"></div>
</div>
<input type="hidden" name="dir" value="<?php p($_['dir']) ?>" id="dir"> <input type="hidden" name="dir" value="<?php p($_['dir']) ?>" id="dir">
<input type="hidden" name="downloadURL" value="<?php p($_['downloadURL']) ?>" id="downloadURL"> <input type="hidden" name="downloadURL" value="<?php p($_['downloadURL']) ?>" id="downloadURL">
<input type="hidden" name="filename" value="<?php p($_['filename']) ?>" id="filename"> <input type="hidden" name="filename" value="<?php p($_['filename']) ?>" id="filename">
@ -13,13 +17,49 @@
<span id="details"><?php p($l->t('%s shared the file %s with you', <span id="details"><?php p($l->t('%s shared the file %s with you',
array($_['displayName'], $_['fileTarget']))) ?></span> array($_['displayName'], $_['fileTarget']))) ?></span>
<?php endif; ?> <?php endif; ?>
<?php if (!isset($_['folder']) || $_['allowZipDownload']): ?> <?php if (!isset($_['folder']) || $_['allowZipDownload']): ?>
<a href="<?php p($_['downloadURL']); ?>" class="button" id="download"><img <a href="<?php p($_['downloadURL']); ?>" class="button" id="download"><img
class="svg" alt="Download" src="<?php print_unescaped(OCP\image_path("core", "actions/download.svg")); ?>" class="svg" alt="Download" src="<?php print_unescaped(OCP\image_path("core", "actions/download.svg")); ?>"
/><?php p($l->t('Download'))?></a> /><span><?php p($l->t('Download'))?></span></a>
<?php endif; ?> <?php endif; ?>
<?php if ($_['allowPublicUploadEnabled']):?>
<input type="hidden" id="publicUploadRequestToken" name="requesttoken" value="<?php p($_['requesttoken']) ?>" />
<input type="hidden" id="dirToken" name="dirToken" value="<?php p($_['dirToken']) ?>" />
<input type="hidden" id="uploadMaxFilesize" name="uploadMaxFilesize" value="<?php p($_['uploadMaxFilesize']) ?>" />
<input type="hidden" id="uploadMaxHumanFilesize" name="uploadMaxHumanFilesize" value="<?php p($_['uploadMaxHumanFilesize']) ?>" />
<input type="hidden" id="directory_path" name="directory_path" value="<?php p($_['directory_path']) ?>" />
<div id="data-upload-form" class="button">
<input id="file_upload_start" type="file" name="files[]" data-url="<?php print_unescaped(OCP\Util::linkTo('files', 'ajax/upload.php')); ?>" multiple>
<a href="#" id="publicUploadButtonMock" class="svg">
<span><?php p($l->t('Upload'))?></span>
</a>
</div>
</div>
<div id="additional_controls" style="display:none">
<div id="uploadprogresswrapper">
<div id="uploadprogressbar"></div>
<input id="cancel_upload_button" type="button" class="stop" style="display:none"
value="<?php p($l->t('Cancel upload'));?>"
/>
</div>
<?php endif; ?>
</div> </div>
</div></header> </div></header>
<div id="content">
<div id="preview"> <div id="preview">
<?php if (isset($_['folder'])): ?> <?php if (isset($_['folder'])): ?>
<?php print_unescaped($_['folder']); ?> <?php print_unescaped($_['folder']); ?>

View file

@ -156,6 +156,19 @@ OC.Share={
html += '<br />'; html += '<br />';
} }
if (possiblePermissions & OC.PERMISSION_SHARE) { if (possiblePermissions & OC.PERMISSION_SHARE) {
// Determine the Allow Public Upload status.
// Used later on to determine if the
// respective checkbox should be checked or
// not.
var allowPublicUploadStatus = false;
$.each(data.shares, function(key, value) {
if (allowPublicUploadStatus) {
return true;
}
allowPublicUploadStatus = (value.permissions & OC.PERMISSION_CREATE) ? true : false;
});
html += '<input id="shareWith" type="text" placeholder="'+t('core', 'Share with')+'" />'; html += '<input id="shareWith" type="text" placeholder="'+t('core', 'Share with')+'" />';
html += '<ul id="shareWithList">'; html += '<ul id="shareWithList">';
html += '</ul>'; html += '</ul>';
@ -168,12 +181,16 @@ OC.Share={
html += '<div id="linkPass">'; html += '<div id="linkPass">';
html += '<input id="linkPassText" type="password" placeholder="'+t('core', 'Password')+'" />'; html += '<input id="linkPassText" type="password" placeholder="'+t('core', 'Password')+'" />';
html += '</div>'; html += '</div>';
html += '</div>'; html += '<div id="allowPublicUploadWrapper" style="display:none;">';
html += '<input type="checkbox" value="1" name="allowPublicUpload" id="sharingDialogAllowPublicUpload"' + ((allowPublicUploadStatus) ? 'checked="checked"' : '') + ' />';
html += '<label for="sharingDialogAllowPublicUpload">' + t('core', 'Allow Public Upload') + '</label>';
html += '</div></div>';
html += '<form id="emailPrivateLink" >'; html += '<form id="emailPrivateLink" >';
html += '<input id="email" style="display:none; width:62%;" value="" placeholder="'+t('core', 'Email link to person')+'" type="text" />'; html += '<input id="email" style="display:none; width:62%;" value="" placeholder="'+t('core', 'Email link to person')+'" type="text" />';
html += '<input id="emailButton" style="display:none;" type="submit" value="'+t('core', 'Send')+'" />'; html += '<input id="emailButton" style="display:none;" type="submit" value="'+t('core', 'Send')+'" />';
html += '</form>'; html += '</form>';
} }
html += '<div id="expiration">'; 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 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 += '<input id="expirationDate" type="text" placeholder="'+t('core', 'Expiration date')+'" style="display:none; width:90%;" />';
@ -370,6 +387,7 @@ OC.Share={
$('#expiration').show(); $('#expiration').show();
$('#emailPrivateLink #email').show(); $('#emailPrivateLink #email').show();
$('#emailPrivateLink #emailButton').show(); $('#emailPrivateLink #emailButton').show();
$('#allowPublicUploadWrapper').show();
}, },
hideLink:function() { hideLink:function() {
$('#linkText').hide('blind'); $('#linkText').hide('blind');
@ -378,6 +396,7 @@ OC.Share={
$('#linkPass').hide(); $('#linkPass').hide();
$('#emailPrivateLink #email').hide(); $('#emailPrivateLink #email').hide();
$('#emailPrivateLink #emailButton').hide(); $('#emailPrivateLink #emailButton').hide();
$('#allowPublicUploadWrapper').hide();
}, },
dirname:function(path) { dirname:function(path) {
return path.replace(/\\/g,'/').replace(/\/[^\/]*$/, ''); return path.replace(/\\/g,'/').replace(/\/[^\/]*$/, '');
@ -543,6 +562,28 @@ $(document).ready(function() {
$(this).select(); $(this).select();
}); });
// Handle the Allow Public Upload Checkbox
$(document).on('click', '#sharingDialogAllowPublicUpload', function() {
// Gather data
var allowPublicUpload = $(this).is(':checked');
var itemType = $('#dropdown').data('item-type');
var itemSource = $('#dropdown').data('item-source');
var permissions = 0;
// Calculate permissions
if (allowPublicUpload) {
permissions = OC.PERMISSION_UPDATE + OC.PERMISSION_CREATE + OC.PERMISSION_READ;
} else {
permissions = OC.PERMISSION_READ;
}
// Update the share information
OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', permissions, function(data) {
return;
});
});
$(document).on('click', '#dropdown #showPassword', function() { $(document).on('click', '#dropdown #showPassword', function() {
$('#linkPass').toggle('blind'); $('#linkPass').toggle('blind');
if (!$('#showPassword').is(':checked') ) { if (!$('#showPassword').is(':checked') ) {

View file

@ -754,7 +754,7 @@ class View {
if ($subStorage) { if ($subStorage) {
$subCache = $subStorage->getCache(''); $subCache = $subStorage->getCache('');
$rootEntry = $subCache->get(''); $rootEntry = $subCache->get('');
$data['size'] += $rootEntry['size']; $data['size'] += isset($rootEntry['size']) ? $rootEntry['size'] : 0;
} }
} }
} }