diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2018-07-12 18:17:22 +0200 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-07-21 15:02:18 +0200 |
commit | b56ccef564f19e78d5e3c9f255cfebcf2df8e31b (patch) | |
tree | 7ba7413847780bc0af1f38787274419cd39fd873 | |
parent | a29261175d1b8062e81239a54d456018d792d3e9 (diff) | |
download | nextcloud-server-b56ccef564f19e78d5e3c9f255cfebcf2df8e31b.tar.gz nextcloud-server-b56ccef564f19e78d5e3c9f255cfebcf2df8e31b.zip |
add direct link to the file for user/group shares
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
-rw-r--r-- | lib/private/Share20/DefaultShareProvider.php | 22 | ||||
-rw-r--r-- | lib/private/Share20/ProviderFactory.php | 3 |
2 files changed, 20 insertions, 5 deletions
diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index 2594b9e2973..90fa5044aeb 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -33,6 +33,7 @@ use OC\Files\Cache\Cache; use OCP\Defaults; use OCP\Files\Folder; use OCP\IL10N; +use OCP\IURLGenerator; use OCP\IUser; use OCP\Mail\IMailer; use OCP\Share\IShare; @@ -81,6 +82,9 @@ class DefaultShareProvider implements IShareProvider { /** @var IL10N */ private $l; + /** @var IURLGenerator */ + private $urlGenerator; + /** * DefaultShareProvider constructor. * @@ -91,6 +95,7 @@ class DefaultShareProvider implements IShareProvider { * @param IMailer $mailer ; * @param Defaults $defaults * @param IL10N $l + * @param IURLGenerator $urlGenerator */ public function __construct( IDBConnection $connection, @@ -99,7 +104,8 @@ class DefaultShareProvider implements IShareProvider { IRootFolder $rootFolder, IMailer $mailer, Defaults $defaults, - IL10N $l) { + IL10N $l, + IURLGenerator $urlGenerator) { $this->dbConn = $connection; $this->userManager = $userManager; $this->groupManager = $groupManager; @@ -107,6 +113,7 @@ class DefaultShareProvider implements IShareProvider { $this->mailer = $mailer; $this->defaults = $defaults; $this->l = $l; + $this->urlGenerator = $urlGenerator; } /** @@ -1309,18 +1316,25 @@ class DefaultShareProvider implements IShareProvider { $initiatorUser = $this->userManager->get($initiator); $initiatorDisplayName = ($initiatorUser instanceof IUser) ? $initiatorUser->getDisplayName() : $initiator; $initiatorEmailAddress = ($initiatorUser instanceof IUser) ? $initiatorUser->getEMailAddress() : null; - $plainHeading = $this->l->t('%1$s shared »%2$s« with you and want to add:', [$initiatorDisplayName, $filename]); $htmlHeading = $this->l->t('%1$s shared »%2$s« with you and want to add:', [$initiatorDisplayName, $filename]); - + $link = $this->urlGenerator->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $share->getNode()->getId()]); + if($share->getNode()->getType() === \OCP\Files\FileInfo::TYPE_FILE) { + $plainLink = $this->l->t('Direct link to the file: %s', [$link]); + $htmlLink = $this->l->t('<a href="%s">Direct link to the file.</a>', [$link]); + } else { + $plainLink = $this->l->t('Direct link to the folder: %s', [$link]); + $htmlLink = $this->l->t('<a href="%s">Direct link to the folder.</a>', [$link]); + } $message = $this->mailer->createMessage(); $emailTemplate = $this->mailer->createEMailTemplate('defaultShareProvider.sendNote'); $emailTemplate->setSubject($this->l->t('»%s« added a note to a file shared with you', [$initiatorDisplayName])); $emailTemplate->addHeader(); - $emailTemplate->addHeading(htmlspecialchars($htmlHeading), $plainHeading); + $emailTemplate->addHeading($htmlHeading, $plainHeading); $emailTemplate->addBodyText(htmlspecialchars($note), $note); + $emailTemplate->addBodyText($htmlLink, $plainLink); // The "From" contains the sharers name $instanceName = $this->defaults->getName(); diff --git a/lib/private/Share20/ProviderFactory.php b/lib/private/Share20/ProviderFactory.php index 22a2fe7a019..0aacca409d1 100644 --- a/lib/private/Share20/ProviderFactory.php +++ b/lib/private/Share20/ProviderFactory.php @@ -84,7 +84,8 @@ class ProviderFactory implements IProviderFactory { $this->serverContainer->getLazyRootFolder(), $this->serverContainer->getMailer(), $this->serverContainer->query(Defaults::class), - $this->serverContainer->getL10N('sharing') + $this->serverContainer->getL10N('sharing'), + $this->serverContainer->getURLGenerator() ); } |