From f878ea96067ff634800a06bff7ecafdfa09e040a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 12 Mar 2020 17:38:18 +0100 Subject: [PATCH] Remove user name from public sharing page Signed-off-by: Joas Schilling --- apps/files_sharing/css/public.scss | 6 ++++ .../lib/Controller/ShareController.php | 30 +++++++++++++++---- 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); - +
@@ -88,9 +88,14 @@ $maxUploadFilesize = min($upload_max_filesize, $post_max_size);
-
-

t('Upload files to %s', [$_['shareOwner']])) ?>

-

+ +
+

t('Upload files to %s', [$_['shareOwner']])) ?>

+

+ +
+

t('Upload files to %s', [$_['filename']])) ?>

+

t('Note')); ?>

-- 2.39.5