diff options
author | Joas Schilling <coding@schilljs.com> | 2020-03-12 19:38:18 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-04-01 18:14:38 +0300 |
commit | f878ea96067ff634800a06bff7ecafdfa09e040a (patch) | |
tree | 7dc9285bb601eba769e33dfa689150f3184fc2d4 /apps/files_sharing | |
parent | c1368b86963b93a42ec98a856f8d307d922c8967 (diff) |
Remove user name from public sharing page
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/files_sharing')
-rw-r--r-- | apps/files_sharing/css/public.scss | 6 | ||||
-rw-r--r-- | apps/files_sharing/lib/Controller/ShareController.php | 30 | ||||
-rw-r--r-- | apps/files_sharing/templates/public.php | 13 |
3 files changed, 40 insertions, 9 deletions
diff --git a/apps/files_sharing/css/public.scss b/apps/files_sharing/css/public.scss index a8207167c2c..b5b3f4f1f42 100644 --- a/apps/files_sharing/css/public.scss +++ b/apps/files_sharing/css/public.scss @@ -123,6 +123,12 @@ thead { opacity: 1; } +#public-upload #emptycontent #displayavatar .icon-folder { + height: 48px; + width: 48px; + background-size: 48px; +} + #public-upload #emptycontent .button { display: inline-block; height: auto; diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index a7c936f28a7..616b9754634 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -48,6 +48,7 @@ use OC\Security\CSP\ContentSecurityPolicy; use OCA\FederatedFileSharing\FederatedShareProvider; use OCA\Files_Sharing\Activity\Providers\Downloads; use OCA\Viewer\Event\LoadViewer; +use OCP\Accounts\IAccountManager; use OCP\AppFramework\AuthPublicShareController; use OCP\AppFramework\Http\NotFoundResponse; use OCP\AppFramework\Http\Template\ExternalShareMenuAction; @@ -66,6 +67,7 @@ use OCP\IPreview; use OCP\IRequest; use OCP\ISession; use OCP\IURLGenerator; +use OCP\IUser; use OCP\IUserManager; use OCP\Share; use OCP\Share\Exceptions\ShareNotFound; @@ -95,6 +97,8 @@ class ShareController extends AuthPublicShareController { protected $rootFolder; /** @var FederatedShareProvider */ protected $federatedShareProvider; + /** @var IAccountManager */ + protected $accountManager; /** @var EventDispatcherInterface */ protected $eventDispatcher; /** @var IL10N */ @@ -120,6 +124,7 @@ class ShareController extends AuthPublicShareController { * @param IPreview $previewManager * @param IRootFolder $rootFolder * @param FederatedShareProvider $federatedShareProvider + * @param IAccountManager $accountManager * @param EventDispatcherInterface $eventDispatcher * @param IL10N $l10n * @param Defaults $defaults @@ -136,6 +141,7 @@ class ShareController extends AuthPublicShareController { IPreview $previewManager, IRootFolder $rootFolder, FederatedShareProvider $federatedShareProvider, + IAccountManager $accountManager, EventDispatcherInterface $eventDispatcher, IL10N $l10n, Defaults $defaults) { @@ -148,6 +154,7 @@ class ShareController extends AuthPublicShareController { $this->previewManager = $previewManager; $this->rootFolder = $rootFolder; $this->federatedShareProvider = $federatedShareProvider; + $this->accountManager = $accountManager; $this->eventDispatcher = $eventDispatcher; $this->l10n = $l10n; $this->defaults = $defaults; @@ -328,8 +335,20 @@ class ShareController extends AuthPublicShareController { } $shareTmpl = []; - $shareTmpl['displayName'] = $this->userManager->get($share->getShareOwner())->getDisplayName(); - $shareTmpl['owner'] = $share->getShareOwner(); + $shareTmpl['owner'] = ''; + $shareTmpl['shareOwner'] = ''; + + $owner = $this->userManager->get($share->getShareOwner()); + if ($owner instanceof IUser) { + $ownerAccount = $this->accountManager->getAccount($owner); + + $ownerName = $ownerAccount->getProperty(IAccountManager::PROPERTY_DISPLAYNAME); + if ($ownerName->getScope() === IAccountManager::VISIBILITY_PUBLIC) { + $shareTmpl['owner'] = $owner->getUID(); + $shareTmpl['shareOwner'] = $owner->getDisplayName(); + } + } + $shareTmpl['filename'] = $shareNode->getName(); $shareTmpl['directory_path'] = $share->getTarget(); $shareTmpl['note'] = $share->getNote(); @@ -396,7 +415,6 @@ class ShareController extends AuthPublicShareController { $shareTmpl['showgridview'] = false; $shareTmpl['hideFileList'] = $hideFileList; - $shareTmpl['shareOwner'] = $this->userManager->get($share->getShareOwner())->getDisplayName(); $shareTmpl['downloadURL'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.downloadShare', ['token' => $this->getToken()]); $shareTmpl['shareUrl'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.showShare', ['token' => $this->getToken()]); $shareTmpl['maxSizeAnimateGif'] = $this->config->getSystemValue('max_filesize_animated_gifs_public_sharing', 10); @@ -479,7 +497,9 @@ class ShareController extends AuthPublicShareController { $response = new PublicTemplateResponse($this->appName, 'public', $shareTmpl); $response->setHeaderTitle($shareTmpl['filename']); - $response->setHeaderDetails($this->l10n->t('shared by %s', [$shareTmpl['displayName']])); + if ($shareTmpl['shareOwner'] !== '') { + $response->setHeaderDetails($this->l10n->t('shared by %s', [$shareTmpl['shareOwner']])); + } $isNoneFileDropFolder = $shareIsFolder === false || $share->getPermissions() !== \OCP\Constants::PERMISSION_CREATE; @@ -491,7 +511,7 @@ class ShareController extends AuthPublicShareController { $download = new SimpleMenuAction('download', $this->l10n->t('Download'), 'icon-download', $shareTmpl['downloadURL'], 10, $shareTmpl['fileSize']); $downloadAll = new SimpleMenuAction('download', $this->l10n->t('Download all files'), 'icon-download', $shareTmpl['downloadURL'], 10, $shareTmpl['fileSize']); $directLink = new LinkMenuAction($this->l10n->t('Direct link'), 'icon-public', $shareTmpl['previewURL']); - $externalShare = new ExternalShareMenuAction($this->l10n->t('Add to your Nextcloud'), 'icon-external', $shareTmpl['owner'], $shareTmpl['displayName'], $shareTmpl['filename']); + $externalShare = new ExternalShareMenuAction($this->l10n->t('Add to your Nextcloud'), 'icon-external', $shareTmpl['owner'], $shareTmpl['shareOwner'], $shareTmpl['filename']); $responseComposer = []; diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php index a9cfaae9df1..ce251028eec 100644 --- a/apps/files_sharing/templates/public.php +++ b/apps/files_sharing/templates/public.php @@ -54,7 +54,7 @@ $maxUploadFilesize = min($upload_max_filesize, $post_max_size); <label id="view-toggle" for="showgridview" class="button <?php p($_['showgridview'] ? 'icon-toggle-filelist' : 'icon-toggle-pictures') ?>" title="<?php p($l->t('Toggle grid view'))?>"></label> <?php } ?> - + <!-- files listing --> <div id="files-public-content"> <div id="preview"> @@ -88,9 +88,14 @@ $maxUploadFilesize = min($upload_max_filesize, $post_max_size); <div id="emptycontent" class="<?php if (!empty($_['note'])) { ?>has-note<?php } ?>"> - <div id="displayavatar"><div class="avatardiv"></div></div> - <h2><?php p($l->t('Upload files to %s', [$_['shareOwner']])) ?></h2> - <p><span class="icon-folder"></span> <?php p($_['filename']) ?></p> + <?php if ($_['shareOwner']) { ?> + <div id="displayavatar"><div class="avatardiv"></div></div> + <h2><?php p($l->t('Upload files to %s', [$_['shareOwner']])) ?></h2> + <p><span class="icon-folder"></span> <?php p($_['filename']) ?></p> + <?php } else { ?> + <div id="displayavatar"><span class="icon-folder"></span></div> + <h2><?php p($l->t('Upload files to %s', [$_['filename']])) ?></h2> + <?php } ?> <?php if (empty($_['note']) === false) { ?> <h3><?php p($l->t('Note')); ?></h3> |