aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--files/admin.php3
-rw-r--r--files/js/admin.js28
-rw-r--r--files/js/fileactions.js15
-rw-r--r--files/templates/admin.php5
-rw-r--r--files/templates/index.php7
-rw-r--r--lib/files.php21
6 files changed, 60 insertions, 19 deletions
diff --git a/files/admin.php b/files/admin.php
index 7e410652cfb..b9c26c465f3 100644
--- a/files/admin.php
+++ b/files/admin.php
@@ -37,10 +37,12 @@ if($_POST) {
$maxZipInputSize=$_POST['maxZipInputSize'];
OC_Preferences::setValue('', 'files', 'maxZipInputSize', OC_Helper::computerFileSize($maxZipInputSize));
}
+ OC_Preferences::setValue('', 'files', 'allowZipDownload', isset($_POST['allowZipDownload']));
}else{
$upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize'));
$post_max_size = OC_Helper::computerFileSize(ini_get('post_max_size'));
$maxUploadFilesize = min($upload_max_filesize, $post_max_size);
+ $allowZipDownload = intval(OC_Preferences::getValue('', 'files', 'allowZipDownload', 1));
$maxZipInputSize = OC_Helper::humanfilesize(OC_Preferences::getValue('', 'files', 'maxZipInputSize', OC_Helper::computerFileSize('800 MB')));
}
@@ -49,5 +51,6 @@ OC_App::setActiveNavigationEntry( "files_administration" );
$tmpl = new OC_Template( 'files', 'admin' );
$tmpl->assign( 'htaccessWorking', $htaccessWorking );
$tmpl->assign( 'uploadMaxFilesize', $maxUploadFilesize);
+$tmpl->assign( 'allowZipDownload', $allowZipDownload);
$tmpl->assign( 'maxZipInputSize', $maxZipInputSize);
return $tmpl->fetchPage(); \ No newline at end of file
diff --git a/files/js/admin.js b/files/js/admin.js
index 5cbb2b9f5ac..bfa96670635 100644
--- a/files/js/admin.js
+++ b/files/js/admin.js
@@ -1,15 +1,23 @@
-function switchPublicFolder()
+function switchPublicFolder()
{
- var publicEnable = $('#publicEnable').is(':checked');
- var sharingaimGroup = $('input:radio[name=sharingaim]'); //find all radiobuttons of that group
- $.each(sharingaimGroup, function(index, sharingaimItem) {
- sharingaimItem.disabled = !publicEnable; //set all buttons to the correct state
- });
+ var publicEnable = $('#publicEnable').is(':checked');
+ var sharingaimGroup = $('input:radio[name=sharingaim]'); //find all radiobuttons of that group
+ $.each(sharingaimGroup, function(index, sharingaimItem) {
+ sharingaimItem.disabled = !publicEnable; //set all buttons to the correct state
+ });
}
$(document).ready(function(){
- switchPublicFolder(); // Execute the function after loading DOM tree
- $('#publicEnable').click(function(){
- switchPublicFolder(); // To get rid of onClick()
- });
+ switchPublicFolder(); // Execute the function after loading DOM tree
+ $('#publicEnable').click(function(){
+ switchPublicFolder(); // To get rid of onClick()
+ });
+
+ $('#allowZipDownload').bind('change', function() {
+ if($('#allowZipDownload').attr('checked')) {
+ $('#maxZipInputSize').removeAttr('disabled');
+ } else {
+ $('#maxZipInputSize').attr('disabled', 'disabled');
+ }
+ });
});
diff --git a/files/js/fileactions.js b/files/js/fileactions.js
index b5dd3982803..b33be280ad5 100644
--- a/files/js/fileactions.js
+++ b/files/js/fileactions.js
@@ -106,7 +106,7 @@ FileActions={
element.hide();
parent.parent().children().last().append(element);
}
- $('#fileList .action').css('-o-transition-property','none');//temporarly disable
+ $('#fileList .action').css('-o-transition-property','none');//temporarly disable
$('#fileList .action').fadeIn(200,function(){
$('#fileList .action').css('-o-transition-property','opacity');
});
@@ -128,8 +128,15 @@ FileActions={
}
}
-FileActions.register('all','Download',function(){return OC.imagePath('core','actions/download')},function(filename){
- window.location='ajax/download.php?files='+encodeURIComponent(filename)+'&dir='+encodeURIComponent($('#dir').val());
+$(document).ready(function(){
+ if($('#allowZipDownload').val() == 1){
+ var downloadScope = 'all';
+ } else {
+ var downloadScope = 'file';
+ }
+ FileActions.register(downloadScope,'Download',function(){return OC.imagePath('core','actions/download')},function(filename){
+ window.location='ajax/download.php?files='+encodeURIComponent(filename)+'&dir='+encodeURIComponent($('#dir').val());
+ });
});
FileActions.register('all','Delete',function(){return OC.imagePath('core','actions/delete')},function(filename){
@@ -144,4 +151,4 @@ FileActions.register('dir','Open','',function(filename){
window.location='index.php?dir='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename);
});
-FileActions.setDefault('dir','Open');
+FileActions.setDefault('dir','Open');
diff --git a/files/templates/admin.php b/files/templates/admin.php
index 8c3ba56ad52..fd86d02e1ed 100644
--- a/files/templates/admin.php
+++ b/files/templates/admin.php
@@ -6,7 +6,10 @@
<?php if($_['htaccessWorking']):?>
<label for="maxUploadSize"><?php echo $l->t( 'Maximum upload size' ); ?> </label><input name='maxUploadSize' id="maxUploadSize" value='<?php echo $_['uploadMaxFilesize'] ?>'/><br/>
<?php endif;?>
- <label for="maxZipInputSize"><?php echo $l->t( 'Maximum input size for zip files (affects folder- and multi-file download)' ); ?> </label><input name="maxZipInputSize" id="maxZipInputSize" value='<?php echo $_['maxZipInputSize'] ?>'/><br/>
+ <input type="checkbox" name="allowZipDownload" id="allowZipDownload" value="1" title="<?php echo $l->t( 'Needed for multi-file and folder downloads.' ); ?>"<?php if ($_['allowZipDownload']) echo ' checked="checked"'; ?> /> <label for="allowZipDownload"><?php echo $l->t( 'Enable ZIP-download' ); ?></label> <br/>
+ <fieldset class="personalblock">
+ <label for="maxZipInputSize"><?php echo $l->t( 'Maximum input size for ZIP files:' ); ?> </label><input name="maxZipInputSize" id="maxZipInputSize" value='<?php echo $_['maxZipInputSize'] ?>' title="<?php echo $l->t( '0 is unlimited' ); ?>"<?php if (!$_['allowZipDownload']) echo ' disabled="disabled"'; ?> /><br/>
+ </fieldset>
<input type="submit" value="Save"/>
</fieldset>
</form>
diff --git a/files/templates/index.php b/files/templates/index.php
index 7fc51c288e1..497a0f36c0d 100644
--- a/files/templates/index.php
+++ b/files/templates/index.php
@@ -40,7 +40,9 @@
<?php if(!isset($_['readonly']) || !$_['readonly']) { ?><input type="checkbox" id="select_all" /><?php } ?>
<span class='name'><?php echo $l->t( 'Name' ); ?></span>
<span class='selectedActions'>
- <a href="" title="<?php echo $l->t('Download')?>" class="download"><img class='svg' alt="Download" src="<?php echo image_path("core", "actions/download.svg"); ?>" /></a>
+ <?php if(OC_Preferences::getValue('', 'files', 'allowZipDownload', 1)) : ?>
+ <a href="" title="<?php echo $l->t('Download')?>" class="download"><img class='svg' alt="Download" src="<?php echo image_path("core", "actions/download.svg"); ?>" /></a>
+ <?php endif; ?>
<a href="" title="Share" class="share"><img class='svg' alt="Share" src="<?php echo image_path("core", "actions/share.svg"); ?>" /></a>
</span>
</th>
@@ -66,3 +68,6 @@
<?php echo $l->t('Current scanning');?> <span id='scan-current'></spann>
</p>
</div>
+
+<!-- config hints for javascript -->
+<input type="hidden" name="allowZipDownload" id="allowZipDownload" value="<?php echo OC_Preferences::getValue('', 'files', 'allowZipDownload', 1); ?>" /> \ No newline at end of file
diff --git a/lib/files.php b/lib/files.php
index 50223df1d36..662f0b59724 100644
--- a/lib/files.php
+++ b/lib/files.php
@@ -59,7 +59,7 @@ class OC_Files {
}
if(is_array($files)){
- self::checkZipInputSize($dir,$files);
+ self::validateZipDownload($dir,$files);
$executionTime = intval(ini_get('max_execution_time'));
set_time_limit(0);
$zip = new ZipArchive();
@@ -80,7 +80,7 @@ class OC_Files {
$zip->close();
set_time_limit($executionTime);
}elseif(OC_Filesystem::is_dir($dir.'/'.$files)){
- self::checkZipInputSize($dir,$files);
+ self::validateZipDownload($dir,$files);
$executionTime = intval(ini_get('max_execution_time'));
set_time_limit(0);
$zip = new ZipArchive();
@@ -223,7 +223,22 @@ class OC_Files {
* @param dir $dir
* @param files $files
*/
- static function checkZipInputSize($dir, $files) {
+ static function validateZipDownload($dir, $files) {
+ if(!OC_Preferences::getValue('', 'files', 'allowZipDownload', 1)) {
+ $l = new OC_L10N('files');
+ header("HTTP/1.0 409 Conflict");
+ $tmpl = new OC_Template( '', 'error', 'user' );
+ $errors = array(
+ array(
+ 'error' => $l->t('ZIP download is turned off.'),
+ 'hint' => $l->t('Files need to be downloaded one by one.') . '<br/><a href="javascript:history.back()">' . $l->t('Back to Files') . '</a>',
+ )
+ );
+ $tmpl->assign('errors', $errors);
+ $tmpl->printPage();
+ exit;
+ }
+
$zipLimit = OC_Preferences::getValue('', 'files', 'maxZipInputSize', OC_Helper::computerFileSize('800 MB'));
if($zipLimit > 0) {
$totalsize = 0;