diff options
author | Morris Jobke <hey@morrisjobke.de> | 2017-09-08 19:15:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-08 19:15:05 +0200 |
commit | 8a79d0cc706f00d920bf26b693bbf2f3ee1f6dd7 (patch) | |
tree | 16be70a6e1489c548f4aac26e2c574678d4461eb /lib | |
parent | 75c38d5d9862bea2945162226e9bc233872bfc74 (diff) | |
parent | 7e625a8d22b4a243632a30f242d275d27a327258 (diff) | |
download | nextcloud-server-8a79d0cc706f00d920bf26b693bbf2f3ee1f6dd7.tar.gz nextcloud-server-8a79d0cc706f00d920bf26b693bbf2f3ee1f6dd7.zip |
Merge pull request #6414 from nextcloud/share-notification-wrong-language
Use the language of the recipient for the share notification
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Server.php | 6 | ||||
-rw-r--r-- | lib/private/Share20/Manager.php | 26 |
2 files changed, 20 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, |