]> source.dussan.org Git - nextcloud-server.git/commitdiff
Remove user name from public sharing page
authorJoas Schilling <coding@schilljs.com>
Thu, 12 Mar 2020 16:38:18 +0000 (17:38 +0100)
committerJoas Schilling <coding@schilljs.com>
Wed, 1 Apr 2020 15:14:38 +0000 (17:14 +0200)
Signed-off-by: Joas Schilling <coding@schilljs.com>
apps/files_sharing/css/public.scss
apps/files_sharing/lib/Controller/ShareController.php
apps/files_sharing/templates/public.php

index a8207167c2c7d681afb24082fc76f2f3c2504171..b5b3f4f1f42af3ecbeb7b4286dd20e6ddb4c1c01 100644 (file)
@@ -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;
index a7c936f28a71bb45adcbed152e98c8df3047926a..616b9754634d3c81a1202833dad83de0c7e3883a 100644 (file)
@@ -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 = [];
 
index a9cfaae9df13b0b54b81b8ae1e592c6d08e2ef76..ce251028eec9ef07e2ded81711235e5fea8355cf 100644 (file)
@@ -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>