summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/private/Server.php6
-rw-r--r--lib/private/Share20/Manager.php26
-rw-r--r--tests/lib/Share20/ManagerTest.php11
3 files changed, 31 insertions, 12 deletions
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 3a4fac175e8..fb0aa76cd17 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -55,8 +55,6 @@ use OC\Authentication\LoginCredentials\Store;
use OC\Command\CronBus;
use OC\Contacts\ContactsMenu\ActionFactory;
use OC\Diagnostics\EventLogger;
-use OC\Diagnostics\NullEventLogger;
-use OC\Diagnostics\NullQueryLogger;
use OC\Diagnostics\QueryLogger;
use OC\Federation\CloudIdManager;
use OC\Files\Config\UserMountCache;
@@ -114,7 +112,6 @@ use OCP\IL10N;
use OCP\IServerContainer;
use OCP\ITempManager;
use OCP\Contacts\ContactsMenu\IActionFactory;
-use OCP\IURLGenerator;
use OCP\Lock\ILockingProvider;
use OCP\RichObjectStrings\IValidator;
use OCP\Security\IContentSecurityPolicyManager;
@@ -980,7 +977,8 @@ class Server extends ServerContainer implements IServerContainer {
$c->getHasher(),
$c->getMountManager(),
$c->getGroupManager(),
- $c->getL10N('core'),
+ $c->getL10N('lib'),
+ $c->getL10NFactory(),
$factory,
$c->getUserManager(),
$c->getLazyRootFolder(),
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index 886a319b1e7..6546fc48141 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -31,7 +31,6 @@ use OC\Cache\CappedMemoryCache;
use OC\Files\Mount\MoveableMount;
use OC\HintException;
use OC\Share20\Exception\ProviderException;
-use OCP\Defaults;
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
@@ -44,6 +43,7 @@ use OCP\ILogger;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserManager;
+use OCP\L10N\IFactory;
use OCP\Mail\IMailer;
use OCP\Security\IHasher;
use OCP\Security\ISecureRandom;
@@ -76,6 +76,8 @@ class Manager implements IManager {
private $groupManager;
/** @var IL10N */
private $l;
+ /** @var IFactory */
+ private $l10nFactory;
/** @var IUserManager */
private $userManager;
/** @var IRootFolder */
@@ -104,6 +106,7 @@ class Manager implements IManager {
* @param IMountManager $mountManager
* @param IGroupManager $groupManager
* @param IL10N $l
+ * @param IFactory $l10nFactory
* @param IProviderFactory $factory
* @param IUserManager $userManager
* @param IRootFolder $rootFolder
@@ -120,6 +123,7 @@ class Manager implements IManager {
IMountManager $mountManager,
IGroupManager $groupManager,
IL10N $l,
+ IFactory $l10nFactory,
IProviderFactory $factory,
IUserManager $userManager,
IRootFolder $rootFolder,
@@ -135,6 +139,7 @@ class Manager implements IManager {
$this->mountManager = $mountManager;
$this->groupManager = $groupManager;
$this->l = $l;
+ $this->l10nFactory = $l10nFactory;
$this->factory = $factory;
$this->userManager = $userManager;
$this->rootFolder = $rootFolder;
@@ -658,7 +663,10 @@ class Manager implements IManager {
if ($user !== null) {
$emailAddress = $user->getEMailAddress();
if ($emailAddress !== null && $emailAddress !== '') {
+ $userLang = $this->config->getUserValue($share->getSharedWith(), 'core', 'lang', null);
+ $l = $this->l10nFactory->get('lib', $userLang);
$this->sendMailNotification(
+ $l,
$share->getNode()->getName(),
$this->urlGenerator->linkToRouteAbsolute('files.viewcontroller.showFile', [ 'fileid' => $share->getNode()->getId() ]),
$share->getSharedBy(),
@@ -678,6 +686,7 @@ class Manager implements IManager {
}
/**
+ * @param IL10N $l Language of the recipient
* @param string $filename file/folder name
* @param string $link link to the file/folder
* @param string $initiator user ID of share sender
@@ -685,14 +694,15 @@ class Manager implements IManager {
* @param \DateTime|null $expiration
* @throws \Exception If mail couldn't be sent
*/
- protected function sendMailNotification($filename,
+ protected function sendMailNotification(IL10N $l,
+ $filename,
$link,
$initiator,
$shareWith,
\DateTime $expiration = null) {
$initiatorUser = $this->userManager->get($initiator);
$initiatorDisplayName = ($initiatorUser instanceof IUser) ? $initiatorUser->getDisplayName() : $initiator;
- $subject = (string)$this->l->t('%s shared »%s« with you', array($initiatorDisplayName, $filename));
+ $subject = $l->t('%s shared »%s« with you', array($initiatorDisplayName, $filename));
$message = $this->mailer->createMessage();
@@ -705,15 +715,15 @@ class Manager implements IManager {
]);
$emailTemplate->addHeader();
- $emailTemplate->addHeading($this->l->t('%s shared »%s« with you', [$initiatorDisplayName, $filename]), false);
- $text = $this->l->t('%s shared »%s« with you.', [$initiatorDisplayName, $filename]);
+ $emailTemplate->addHeading($l->t('%s shared »%s« with you', [$initiatorDisplayName, $filename]), false);
+ $text = $l->t('%s shared »%s« with you.', [$initiatorDisplayName, $filename]);
$emailTemplate->addBodyText(
- $text . ' ' . $this->l->t('Click the button below to open it.'),
+ $text . ' ' . $l->t('Click the button below to open it.'),
$text
);
$emailTemplate->addBodyButton(
- $this->l->t('Open »%s«', [$filename]),
+ $l->t('Open »%s«', [$filename]),
$link
);
@@ -721,7 +731,7 @@ class Manager implements IManager {
// The "From" contains the sharers name
$instanceName = $this->defaults->getName();
- $senderName = $this->l->t(
+ $senderName = $l->t(
'%s via %s',
[
$initiatorDisplayName,
diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php
index 174aaffd0b6..b9271c2f752 100644
--- a/tests/lib/Share20/ManagerTest.php
+++ b/tests/lib/Share20/ManagerTest.php
@@ -35,6 +35,7 @@ use OCP\IServerContainer;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserManager;
+use OCP\L10N\IFactory;
use OCP\Mail\IMailer;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IProviderFactory;
@@ -80,6 +81,8 @@ class ManagerTest extends \Test\TestCase {
protected $groupManager;
/** @var IL10N|\PHPUnit_Framework_MockObject_MockObject */
protected $l;
+ /** @var IFactory|\PHPUnit_Framework_MockObject_MockObject */
+ protected $l10nFactory;
/** @var DummyFactory */
protected $factory;
/** @var IUserManager|\PHPUnit_Framework_MockObject_MockObject */
@@ -110,6 +113,7 @@ class ManagerTest extends \Test\TestCase {
$this->urlGenerator = $this->createMock(IURLGenerator::class);
$this->defaults = $this->createMock(\OC_Defaults::class);
+ $this->l10nFactory = $this->createMock(IFactory::class);
$this->l = $this->createMock(IL10N::class);
$this->l->method('t')
->will($this->returnCallback(function($text, $parameters = []) {
@@ -126,6 +130,7 @@ class ManagerTest extends \Test\TestCase {
$this->mountManager,
$this->groupManager,
$this->l,
+ $this->l10nFactory,
$this->factory,
$this->userManager,
$this->rootFolder,
@@ -153,6 +158,7 @@ class ManagerTest extends \Test\TestCase {
$this->mountManager,
$this->groupManager,
$this->l,
+ $this->l10nFactory,
$this->factory,
$this->userManager,
$this->rootFolder,
@@ -2124,6 +2130,7 @@ class ManagerTest extends \Test\TestCase {
$this->mountManager,
$this->groupManager,
$this->l,
+ $this->l10nFactory,
$factory,
$this->userManager,
$this->rootFolder,
@@ -2166,6 +2173,7 @@ class ManagerTest extends \Test\TestCase {
$this->mountManager,
$this->groupManager,
$this->l,
+ $this->l10nFactory,
$factory,
$this->userManager,
$this->rootFolder,
@@ -2817,6 +2825,7 @@ class ManagerTest extends \Test\TestCase {
$this->mountManager,
$this->groupManager,
$this->l,
+ $this->l10nFactory,
$factory,
$this->userManager,
$this->rootFolder,
@@ -2848,6 +2857,7 @@ class ManagerTest extends \Test\TestCase {
$this->mountManager,
$this->groupManager,
$this->l,
+ $this->l10nFactory,
$factory,
$this->userManager,
$this->rootFolder,
@@ -2910,6 +2920,7 @@ class ManagerTest extends \Test\TestCase {
$this->mountManager,
$this->groupManager,
$this->l,
+ $this->l10nFactory,
$factory,
$this->userManager,
$this->rootFolder,