diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2012-03-19 11:56:02 +0100 |
---|---|---|
committer | Arthur Schiwon <blizzz@owncloud.com> | 2012-03-19 11:56:02 +0100 |
commit | b13ab2b17eb485aec13c7fb1e88e25e1c9901d72 (patch) | |
tree | 58259ba29b5833107b62bf08688eaefefe46cdb9 /files | |
parent | 194211500b601d8582fa1e8396fb4c8e4970224d (diff) | |
download | nextcloud-server-b13ab2b17eb485aec13c7fb1e88e25e1c9901d72.tar.gz nextcloud-server-b13ab2b17eb485aec13c7fb1e88e25e1c9901d72.zip |
enable admin to turn off ZIP downloads
user interface offers multi-file/folder downloads only if available
make function name more clear
Diffstat (limited to 'files')
-rw-r--r-- | files/admin.php | 3 | ||||
-rw-r--r-- | files/js/admin.js | 28 | ||||
-rw-r--r-- | files/js/fileactions.js | 15 | ||||
-rw-r--r-- | files/templates/admin.php | 5 | ||||
-rw-r--r-- | files/templates/index.php | 7 |
5 files changed, 42 insertions, 16 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 |