diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2016-06-07 12:28:02 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2016-06-09 15:15:17 +0200 |
commit | bb54ab0db8bfa1ea62bfa2404cb084a9a68d6e20 (patch) | |
tree | 8127443d4c554ebcd1401ce8227408038f8717e2 /apps/files_sharing | |
parent | fc3ad7d5f7acb018329b22d5120c03cd07feecd6 (diff) | |
download | nextcloud-server-bb54ab0db8bfa1ea62bfa2404cb084a9a68d6e20.tar.gz nextcloud-server-bb54ab0db8bfa1ea62bfa2404cb084a9a68d6e20.zip |
add hide file list option
Diffstat (limited to 'apps/files_sharing')
-rw-r--r-- | apps/files_sharing/js/public.js | 9 | ||||
-rw-r--r-- | apps/files_sharing/lib/API/Share20OCS.php | 1 | ||||
-rw-r--r-- | apps/files_sharing/lib/Controllers/ShareController.php | 6 | ||||
-rw-r--r-- | apps/files_sharing/templates/public.php | 50 | ||||
-rw-r--r-- | apps/files_sharing/tests/Controllers/ShareControllerTest.php | 2 |
5 files changed, 48 insertions, 20 deletions
diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js index 572ccc47b71..7f780fd09e7 100644 --- a/apps/files_sharing/js/public.js +++ b/apps/files_sharing/js/public.js @@ -238,6 +238,11 @@ OCA.Sharing.PublicApp = { $(this).select(); }); + $(document).on('click', '.content-wrapper-upload', function (e) { + //e.preventDefault(); + $('#file_upload_start').focus().trigger('click'); + }); + $('.save-form').submit(function (event) { event.preventDefault(); @@ -302,7 +307,7 @@ OCA.Sharing.PublicApp = { $('#save-button-confirm') .removeClass("icon-loading-small") .addClass("icon-confirm"); - + } else { $('#save-button-confirm') @@ -314,7 +319,7 @@ OCA.Sharing.PublicApp = { toggleLoading(); var location = window.location.protocol + '//' + window.location.host + OC.webroot; - + if(remote.substr(-1) !== '/') { remote += '/' }; diff --git a/apps/files_sharing/lib/API/Share20OCS.php b/apps/files_sharing/lib/API/Share20OCS.php index 90e1f19130c..b10c51ce2c9 100644 --- a/apps/files_sharing/lib/API/Share20OCS.php +++ b/apps/files_sharing/lib/API/Share20OCS.php @@ -602,6 +602,7 @@ class Share20OCS { if ($newPermissions !== null && $newPermissions !== \OCP\Constants::PERMISSION_READ && + $newPermissions !== (\OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE) && $newPermissions !== (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE)) { $share->getNode()->unlock(ILockingProvider::LOCK_SHARED); return new \OC_OCS_Result(null, 400, $this->l->t('Can\'t change permissions for public share links')); diff --git a/apps/files_sharing/lib/Controllers/ShareController.php b/apps/files_sharing/lib/Controllers/ShareController.php index 96c0a0ca556..baf2fc9ed11 100644 --- a/apps/files_sharing/lib/Controllers/ShareController.php +++ b/apps/files_sharing/lib/Controllers/ShareController.php @@ -49,7 +49,6 @@ use OCP\ILogger; use OCP\IUserManager; use OCP\ISession; use OCP\IPreview; -use OCA\Files_Sharing\Helper; use OCP\Util; use OCA\Files_Sharing\Activity; use \OCP\Files\NotFoundException; @@ -314,6 +313,7 @@ class ShareController extends Controller { $shareTmpl['fileSize'] = \OCP\Util::humanFileSize($share->getNode()->getSize()); // Show file list + $hideFileList = false; if ($share->getNode() instanceof \OCP\Files\Folder) { $shareTmpl['dir'] = $rootFolder->getRelativePath($path->getPath()); @@ -329,12 +329,14 @@ class ShareController extends Controller { $uploadLimit = Util::uploadLimit(); $maxUploadFilesize = min($freeSpace, $uploadLimit); + $hideFileList = $share->getPermissions() & \OCP\Constants::PERMISSION_READ ? false : true; $folder = new Template('files', 'list', ''); $folder->assign('dir', $rootFolder->getRelativePath($path->getPath())); $folder->assign('dirToken', $token); $folder->assign('permissions', \OCP\Constants::PERMISSION_READ); $folder->assign('isPublic', true); + $folder->assign('hideFileList', $hideFileList); $folder->assign('publicUploadEnabled', 'no'); $folder->assign('uploadMaxFilesize', $maxUploadFilesize); $folder->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize)); @@ -345,6 +347,8 @@ class ShareController extends Controller { $shareTmpl['folder'] = $folder->fetchPage(); } + $shareTmpl['hideFileList'] = $hideFileList; + $shareTmpl['shareOwner'] = $this->userManager->get($share->getShareOwner())->getDisplayName(); $shareTmpl['downloadURL'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.downloadShare', array('token' => $token)); $shareTmpl['maxSizeAnimateGif'] = $this->config->getSystemValue('max_filesize_animated_gifs_public_sharing', 10); $shareTmpl['previewEnabled'] = $this->config->getSystemValue('enable_previews', true); diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php index e39d1b08076..3707bad92f0 100644 --- a/apps/files_sharing/templates/public.php +++ b/apps/files_sharing/templates/public.php @@ -66,26 +66,28 @@ OCP\Util::addscript('files', 'keyboardshortcuts'); <div class="header-right"> <span id="details"> <?php - if ($_['server2serversharing']) { - ?> - <span id="save" data-protected="<?php p($_['protected']) ?>" - data-owner-display-name="<?php p($_['displayName']) ?>" data-owner="<?php p($_['owner']) ?>" data-name="<?php p($_['filename']) ?>"> - <button id="save-button"><?php p($l->t('Add to your ownCloud')) ?></button> - <form class="save-form hidden" action="#"> - <input type="text" id="remote_address" placeholder="example.com/owncloud"/> - <button id="save-button-confirm" class="icon-confirm svg" disabled></button> - </form> - </span> + if (!isset($_['hideFileList']) || (isset($_['hideFileList']) && $_['hideFileList'] === false)) { + if ($_['server2serversharing']) { + ?> + <span id="save" data-protected="<?php p($_['protected']) ?>" + data-owner-display-name="<?php p($_['displayName']) ?>" data-owner="<?php p($_['owner']) ?>" data-name="<?php p($_['filename']) ?>"> + <button id="save-button"><?php p($l->t('Add to your ownCloud')) ?></button> + <form class="save-form hidden" action="#"> + <input type="text" id="remote_address" placeholder="example.com/owncloud"/> + <button id="save-button-confirm" class="icon-confirm svg" disabled></button> + </form> + </span> + <?php } ?> + <a href="<?php p($_['downloadURL']); ?>" id="download" class="button"> + <img class="svg" alt="" src="<?php print_unescaped(image_path("core", "actions/download.svg")); ?>"/> + <span id="download-text"><?php p($l->t('Download'))?></span> + </a> <?php } ?> - <a href="<?php p($_['downloadURL']); ?>" id="download" class="button"> - <img class="svg" alt="" src="<?php print_unescaped(image_path("core", "actions/download.svg")); ?>"/> - <span id="download-text"><?php p($l->t('Download'))?></span> - </a> </span> </div> -</div></header> -<div id="content-wrapper"> - <div id="content"> + </div></header> +<div id="content-wrapper" <?php if(isset($_['hideFileList']) && $_['hideFileList'] === true){ print_unescaped(" class=\"content-wrapper-upload\"");} ?>> + <?php if (!isset($_['hideFileList']) || (isset($_['hideFileList']) && $_['hideFileList'] === false)) { ?> <div id="preview"> <?php if (isset($_['folder'])): ?> <?php print_unescaped($_['folder']); ?> @@ -112,7 +114,21 @@ OCP\Util::addscript('files', 'keyboardshortcuts'); </div> <?php endif; ?> </div> + <?php } else { ?> + <div id="emptycontent" class=""> + <div class="icon-upload"></div> + <h2>Upload files to <?php print_unescaped($_['shareOwner']); ?></h2> + <a href="#" class="inlineblock button">Select</a> + </div> + <?php } ?> +</div> +<?php if (!isset($_['hideFileList']) || (isset($_['hideFileList']) && $_['hideFileList'] === true)): ?> + <input type="hidden" name="dir" id="dir" value="" /> + <div class="hiddenuploadfield"> + <input type="file" id="file_upload_start" class="hiddenuploadfield" name="files[]" + data-url="<?php print_unescaped(OCP\Util::linkTo('files', 'ajax/upload.php')); ?>" /> </div> + <?php endif; ?> <footer> <p class="info"> <?php print_unescaped($theme->getLongFooter()); ?> diff --git a/apps/files_sharing/tests/Controllers/ShareControllerTest.php b/apps/files_sharing/tests/Controllers/ShareControllerTest.php index d97b3a14928..b1c6daaf64a 100644 --- a/apps/files_sharing/tests/Controllers/ShareControllerTest.php +++ b/apps/files_sharing/tests/Controllers/ShareControllerTest.php @@ -372,6 +372,8 @@ class ShareControllerTest extends \Test\TestCase { 'previewEnabled' => true, 'previewMaxX' => 1024, 'previewMaxY' => 1024, + 'hideFileList' => false, + 'shareOwner' => 'ownerDisplay' ); $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy(); |