Remove user name from public sharing page

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2020-03-12 17:38:18 +01:00
parent c1368b8696
commit f878ea9606
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
3 changed files with 40 additions and 9 deletions

View 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;

View 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 = [];

View 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>