aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2020-06-23 08:45:01 +0200
committerJoas Schilling <coding@schilljs.com>2020-07-03 10:59:43 +0200
commitdb8267db26e2e81ef4a39b424c5a8ea7bc124bfd (patch)
tree0d63e8dd40150166639f84083bfaf37cd9c52077
parentb997edad105d38703351b89998444ab0828f7d05 (diff)
downloadnextcloud-server-db8267db26e2e81ef4a39b424c5a8ea7bc124bfd.tar.gz
nextcloud-server-db8267db26e2e81ef4a39b424c5a8ea7bc124bfd.zip
Use the new method everywhere
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--apps/dav/lib/CalDAV/Reminder/NotificationProvider/AbstractProvider.php2
-rw-r--r--apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php11
-rw-r--r--apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/EmailProviderTest.php113
-rw-r--r--apps/provisioning_api/lib/Controller/AUserData.php18
-rw-r--r--apps/provisioning_api/lib/Controller/GroupsController.php17
-rw-r--r--apps/provisioning_api/lib/Controller/UsersController.php20
-rw-r--r--apps/provisioning_api/tests/Controller/GroupsControllerTest.php3
-rw-r--r--apps/provisioning_api/tests/Controller/UsersControllerTest.php57
-rw-r--r--apps/settings/lib/Hooks.php52
-rw-r--r--apps/settings/lib/Mailer/NewUserMailHelper.php6
-rw-r--r--lib/private/Share20/DefaultShareProvider.php5
-rw-r--r--lib/private/Share20/Manager.php2
12 files changed, 106 insertions, 200 deletions
diff --git a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/AbstractProvider.php b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/AbstractProvider.php
index 5a6591fb749..d694b249e96 100644
--- a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/AbstractProvider.php
+++ b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/AbstractProvider.php
@@ -54,7 +54,7 @@ abstract class AbstractProvider implements INotificationProvider {
protected $logger;
/** @var L10NFactory */
- private $l10nFactory;
+ protected $l10nFactory;
/** @var IL10N[] */
private $l10ns;
diff --git a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php
index 4152e02dc8d..90a86230ec3 100644
--- a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php
+++ b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php
@@ -35,7 +35,6 @@ use OCP\IConfig;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IURLGenerator;
-use OCP\IUser;
use OCP\L10N\IFactory as L10NFactory;
use OCP\Mail\IEMailTemplate;
use OCP\Mail\IMailer;
@@ -349,7 +348,7 @@ class EmailProvider extends AbstractProvider {
foreach ($users as $user) {
$emailAddress = $user->getEMailAddress();
if ($emailAddress) {
- $lang = $this->getLangForUser($user);
+ $lang = $this->l10nFactory->getUserLanguage($user);
if ($lang) {
$emailAddresses[$emailAddress] = [
'LANG' => $lang,
@@ -364,14 +363,6 @@ class EmailProvider extends AbstractProvider {
}
/**
- * @param IUser $user
- * @return string
- */
- private function getLangForUser(IUser $user): ?string {
- return $this->config->getUserValue($user->getUID(), 'core', 'lang', null);
- }
-
- /**
* @param IL10N $l10n
* @param VEvent $vevent
* @return string
diff --git a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/EmailProviderTest.php b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/EmailProviderTest.php
index 9a22f63c1be..d8df7613729 100644
--- a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/EmailProviderTest.php
+++ b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/EmailProviderTest.php
@@ -40,27 +40,28 @@ use OCP\L10N\IFactory as L10NFactory;
use OCP\Mail\IEMailTemplate;
use OCP\Mail\IMailer;
use OCP\Mail\IMessage;
+use PHPUnit\Framework\MockObject\MockObject;
use Sabre\VObject\Component\VCalendar;
class EmailProviderTest extends AbstractNotificationProviderTest {
public const USER_EMAIL = 'frodo@hobb.it';
- /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var ILogger|MockObject */
protected $logger;
- /** @var L10NFactory|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var L10NFactory|MockObject */
protected $l10nFactory;
- /** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IL10N|MockObject */
protected $l10n;
- /** @var IURLGenerator|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IURLGenerator|MockObject */
protected $urlGenerator;
- /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IConfig|MockObject */
protected $config;
- /** @var IMailer|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IMailer|MockObject */
private $mailer;
protected function setUp(): void {
@@ -101,19 +102,6 @@ class EmailProviderTest extends AbstractNotificationProviderTest {
$users = [$user1, $user2, $user3, $user4];
- $this->config->expects($this->at(0))
- ->method('getUserValue')
- ->with('uid1', 'core', 'lang', null)
- ->willReturn(null);
- $this->config->expects($this->at(1))
- ->method('getUserValue')
- ->with('uid2', 'core', 'lang', null)
- ->willReturn('de');
- $this->config->expects($this->at(2))
- ->method('getUserValue')
- ->with('uid3', 'core', 'lang', null)
- ->willReturn('de');
-
$enL10N = $this->createMock(IL10N::class);
$enL10N->method('t')
->willReturnArgument(0);
@@ -126,30 +114,31 @@ class EmailProviderTest extends AbstractNotificationProviderTest {
$deL10N->method('l')
->willReturnArgument(0);
- $this->l10nFactory->expects($this->at(0))
+ $this->l10nFactory
+ ->method('getUserLanguage')
+ ->willReturnMap([
+ [$user1, 'en'],
+ [$user2, 'de'],
+ [$user3, 'de'],
+ ]);
+
+ $this->l10nFactory
->method('findLanguage')
- ->with()
->willReturn('en');
- $this->l10nFactory->expects($this->at(1))
- ->method('languageExists')
- ->with('dav', 'en')
- ->willReturn(true);
-
- $this->l10nFactory->expects($this->at(2))
- ->method('get')
- ->with('dav', 'en')
- ->willReturn($enL10N);
-
- $this->l10nFactory->expects($this->at(3))
+ $this->l10nFactory
->method('languageExists')
- ->with('dav', 'de')
- ->willReturn(true);
+ ->willReturnMap([
+ ['dav', 'en', true],
+ ['dav', 'de', true],
+ ]);
- $this->l10nFactory->expects($this->at(4))
+ $this->l10nFactory
->method('get')
- ->with('dav', 'de')
- ->willReturn($deL10N);
+ ->willReturnMap([
+ ['dav', 'en', null, $enL10N],
+ ['dav', 'de', null, $deL10N],
+ ]);
$template1 = $this->getTemplateMock();
$message11 = $this->getMessageMock('uid1@example.com', $template1);
@@ -223,19 +212,6 @@ class EmailProviderTest extends AbstractNotificationProviderTest {
$users = [$user1, $user2, $user3, $user4];
- $this->config->expects($this->at(0))
- ->method('getUserValue')
- ->with('uid1', 'core', 'lang', null)
- ->willReturn(null);
- $this->config->expects($this->at(1))
- ->method('getUserValue')
- ->with('uid2', 'core', 'lang', null)
- ->willReturn('de');
- $this->config->expects($this->at(2))
- ->method('getUserValue')
- ->with('uid3', 'core', 'lang', null)
- ->willReturn('de');
-
$enL10N = $this->createMock(IL10N::class);
$enL10N->method('t')
->willReturnArgument(0);
@@ -248,30 +224,31 @@ class EmailProviderTest extends AbstractNotificationProviderTest {
$deL10N->method('l')
->willReturnArgument(0);
- $this->l10nFactory->expects($this->at(0))
+ $this->l10nFactory
+ ->method('getUserLanguage')
+ ->willReturnMap([
+ [$user1, 'en'],
+ [$user2, 'de'],
+ [$user3, 'de'],
+ ]);
+
+ $this->l10nFactory
->method('findLanguage')
- ->with()
->willReturn('en');
- $this->l10nFactory->expects($this->at(1))
- ->method('languageExists')
- ->with('dav', 'de')
- ->willReturn(true);
-
- $this->l10nFactory->expects($this->at(2))
- ->method('get')
- ->with('dav', 'de')
- ->willReturn($enL10N);
-
- $this->l10nFactory->expects($this->at(3))
+ $this->l10nFactory
->method('languageExists')
- ->with('dav', 'en')
- ->willReturn(true);
+ ->willReturnMap([
+ ['dav', 'en', true],
+ ['dav', 'de', true],
+ ]);
- $this->l10nFactory->expects($this->at(4))
+ $this->l10nFactory
->method('get')
- ->with('dav', 'en')
- ->willReturn($deL10N);
+ ->willReturnMap([
+ ['dav', 'en', null, $enL10N],
+ ['dav', 'de', null, $deL10N],
+ ]);
$template1 = $this->getTemplateMock();
$message11 = $this->getMessageMock('foo1@example.org', $template1);
diff --git a/apps/provisioning_api/lib/Controller/AUserData.php b/apps/provisioning_api/lib/Controller/AUserData.php
index 10d223815c3..131db91add9 100644
--- a/apps/provisioning_api/lib/Controller/AUserData.php
+++ b/apps/provisioning_api/lib/Controller/AUserData.php
@@ -44,6 +44,7 @@ use OCP\IGroupManager;
use OCP\IRequest;
use OCP\IUserManager;
use OCP\IUserSession;
+use OCP\L10N\IFactory;
use OCP\User\Backend\ISetDisplayNameBackend;
use OCP\User\Backend\ISetPasswordBackend;
@@ -59,23 +60,17 @@ abstract class AUserData extends OCSController {
protected $userSession;
/** @var AccountManager */
protected $accountManager;
+ /** @var IFactory */
+ protected $l10nFactory;
- /**
- * @param string $appName
- * @param IRequest $request
- * @param IUserManager $userManager
- * @param IConfig $config
- * @param IGroupManager $groupManager
- * @param IUserSession $userSession
- * @param AccountManager $accountManager
- */
public function __construct(string $appName,
IRequest $request,
IUserManager $userManager,
IConfig $config,
IGroupManager $groupManager,
IUserSession $userSession,
- AccountManager $accountManager) {
+ AccountManager $accountManager,
+ IFactory $l10nFactory) {
parent::__construct($appName, $request);
$this->userManager = $userManager;
@@ -83,6 +78,7 @@ abstract class AUserData extends OCSController {
$this->groupManager = $groupManager;
$this->userSession = $userSession;
$this->accountManager = $accountManager;
+ $this->l10nFactory = $l10nFactory;
}
/**
@@ -146,7 +142,7 @@ abstract class AUserData extends OCSController {
$data[AccountManager::PROPERTY_WEBSITE] = $userAccount[AccountManager::PROPERTY_WEBSITE]['value'];
$data[AccountManager::PROPERTY_TWITTER] = $userAccount[AccountManager::PROPERTY_TWITTER]['value'];
$data['groups'] = $gids;
- $data['language'] = $this->config->getSystemValue('force_language', $this->config->getUserValue($targetUserObject->getUID(), 'core', 'lang'));
+ $data['language'] = $this->l10nFactory->getUserLanguage($targetUserObject);
$data['locale'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'locale');
$backend = $targetUserObject->getBackend();
diff --git a/apps/provisioning_api/lib/Controller/GroupsController.php b/apps/provisioning_api/lib/Controller/GroupsController.php
index ee4e7b575df..243ef8ea6be 100644
--- a/apps/provisioning_api/lib/Controller/GroupsController.php
+++ b/apps/provisioning_api/lib/Controller/GroupsController.php
@@ -47,23 +47,13 @@ use OCP\IRequest;
use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
+use OCP\L10N\IFactory;
class GroupsController extends AUserData {
/** @var ILogger */
private $logger;
- /**
- * @param string $appName
- * @param IRequest $request
- * @param IUserManager $userManager
- * @param IConfig $config
- * @param IGroupManager $groupManager
- * @param IUserSession $userSession
- * @param AccountManager $accountManager
- * @param ILogger $logger
- * @param UsersController $userController
- */
public function __construct(string $appName,
IRequest $request,
IUserManager $userManager,
@@ -71,6 +61,7 @@ class GroupsController extends AUserData {
IGroupManager $groupManager,
IUserSession $userSession,
AccountManager $accountManager,
+ IFactory $l10nFactory,
ILogger $logger) {
parent::__construct($appName,
$request,
@@ -78,7 +69,9 @@ class GroupsController extends AUserData {
$config,
$groupManager,
$userSession,
- $accountManager);
+ $accountManager,
+ $l10nFactory
+ );
$this->logger = $logger;
}
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php
index 07a1514dd1f..52a712dc848 100644
--- a/apps/provisioning_api/lib/Controller/UsersController.php
+++ b/apps/provisioning_api/lib/Controller/UsersController.php
@@ -67,7 +67,7 @@ class UsersController extends AUserData {
/** @var ILogger */
private $logger;
/** @var IFactory */
- private $l10nFactory;
+ protected $l10nFactory;
/** @var NewUserMailHelper */
private $newUserMailHelper;
/** @var FederatedFileSharingFactory */
@@ -77,21 +77,6 @@ class UsersController extends AUserData {
/** @var RemoteWipe */
private $remoteWipe;
- /**
- * @param string $appName
- * @param IRequest $request
- * @param IUserManager $userManager
- * @param IConfig $config
- * @param IAppManager $appManager
- * @param IGroupManager $groupManager
- * @param IUserSession $userSession
- * @param AccountManager $accountManager
- * @param ILogger $logger
- * @param IFactory $l10nFactory
- * @param NewUserMailHelper $newUserMailHelper
- * @param FederatedFileSharingFactory $federatedFileSharingFactory
- * @param ISecureRandom $secureRandom
- */
public function __construct(string $appName,
IRequest $request,
IUserManager $userManager,
@@ -112,7 +97,8 @@ class UsersController extends AUserData {
$config,
$groupManager,
$userSession,
- $accountManager);
+ $accountManager,
+ $l10nFactory);
$this->appManager = $appManager;
$this->logger = $logger;
diff --git a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php
index 3496d445ad1..367a54465bc 100644
--- a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php
@@ -41,6 +41,7 @@ use OCP\IRequest;
use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
+use OCP\L10N\IFactory;
use OCP\UserInterface;
class GroupsControllerTest extends \Test\TestCase {
@@ -75,6 +76,7 @@ class GroupsControllerTest extends \Test\TestCase {
$this->groupManager = $this->createMock(Manager::class);
$this->userSession = $this->createMock(IUserSession::class);
$this->accountManager = $this->createMock(AccountManager::class);
+ $this->l10nFactory = $this->createMock(IFactory::class);
$this->logger = $this->createMock(ILogger::class);
$this->subAdminManager = $this->createMock(SubAdmin::class);
@@ -92,6 +94,7 @@ class GroupsControllerTest extends \Test\TestCase {
$this->groupManager,
$this->userSession,
$this->accountManager,
+ $this->l10nFactory,
$this->logger
])
->setMethods(['fillStorageInfo'])
diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
index afd7304622b..f001611cebe 100644
--- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
@@ -953,16 +953,6 @@ class UsersControllerTest extends TestCase {
->method('getUserValue')
->with('UID', 'core', 'enabled', 'true')
->willReturn('true');
- $this->config
- ->expects($this->at(1))
- ->method('getUserValue')
- ->with('UID', 'core', 'lang')
- ->willReturn('de');
- $this->config
- ->expects($this->once())
- ->method('getSystemValue')
- ->with('force_language', 'de')
- ->willReturn('de');
$this->api
->expects($this->once())
->method('fillStorageInfo')
@@ -995,10 +985,15 @@ class UsersControllerTest extends TestCase {
->method('getBackend')
->willReturn($backend);
$targetUser
- ->expects($this->exactly(6))
->method('getUID')
->willReturn('UID');
+ $this->l10nFactory
+ ->expects($this->once())
+ ->method('getUserLanguage')
+ ->with($targetUser)
+ ->willReturn('de');
+
$expected = [
'id' => 'UID',
'enabled' => true,
@@ -1078,16 +1073,6 @@ class UsersControllerTest extends TestCase {
->method('getUserValue')
->with('UID', 'core', 'enabled', 'true')
->willReturn('true');
- $this->config
- ->expects($this->once())
- ->method('getSystemValue')
- ->with('force_language', 'da')
- ->willReturn('da');
- $this->config
- ->expects($this->at(1))
- ->method('getUserValue')
- ->with('UID', 'core', 'lang')
- ->willReturn('da');
$this->api
->expects($this->once())
->method('fillStorageInfo')
@@ -1120,7 +1105,6 @@ class UsersControllerTest extends TestCase {
->method('getBackend')
->willReturn($backend);
$targetUser
- ->expects($this->exactly(6))
->method('getUID')
->willReturn('UID');
$this->accountManager->expects($this->any())->method('getUser')
@@ -1134,6 +1118,12 @@ class UsersControllerTest extends TestCase {
]
);
+ $this->l10nFactory
+ ->expects($this->once())
+ ->method('getUserLanguage')
+ ->with($targetUser)
+ ->willReturn('da');
+
$expected = [
'id' => 'UID',
'enabled' => true,
@@ -1255,11 +1245,6 @@ class UsersControllerTest extends TestCase {
->method('fillStorageInfo')
->with('UID')
->willReturn(['DummyValue']);
- $this->config
- ->expects($this->once())
- ->method('getSystemValue')
- ->with('force_language', 'ru')
- ->willReturn('ru');
$backend = $this->createMock(UserInterface::class);
$backend->expects($this->atLeastOnce())
@@ -1275,7 +1260,6 @@ class UsersControllerTest extends TestCase {
->method('getEMailAddress')
->willReturn('subadmin@nextcloud.com');
$targetUser
- ->expects($this->exactly(6))
->method('getUID')
->willReturn('UID');
$targetUser
@@ -1294,11 +1278,6 @@ class UsersControllerTest extends TestCase {
->expects($this->once())
->method('getBackend')
->willReturn($backend);
- $this->config
- ->expects($this->at(0))
- ->method('getUserValue')
- ->with('UID', 'core', 'lang')
- ->willReturn('ru');
$this->accountManager->expects($this->any())->method('getUser')
->with($targetUser)
->willReturn(
@@ -1310,6 +1289,12 @@ class UsersControllerTest extends TestCase {
]
);
+ $this->l10nFactory
+ ->expects($this->once())
+ ->method('getUserLanguage')
+ ->with($targetUser)
+ ->willReturn('ru');
+
$expected = [
'id' => 'UID',
'storageLocation' => '/var/www/newtcloud/data/UID',
@@ -2911,8 +2896,7 @@ class UsersControllerTest extends TestCase {
$subAdminManager
->expects($this->once())
->method('createSubAdmin')
- ->with($targetUser, $targetGroup)
- ->willReturn(true);
+ ->with($targetUser, $targetGroup);
$this->groupManager
->expects($this->once())
->method('getSubAdmin')
@@ -3014,8 +2998,7 @@ class UsersControllerTest extends TestCase {
$subAdminManager
->expects($this->once())
->method('deleteSubAdmin')
- ->with($targetUser, $targetGroup)
- ->willReturn(true);
+ ->with($targetUser, $targetGroup);
$this->groupManager
->expects($this->once())
->method('getSubAdmin')
diff --git a/apps/settings/lib/Hooks.php b/apps/settings/lib/Hooks.php
index ed72194488d..b701934b084 100644
--- a/apps/settings/lib/Hooks.php
+++ b/apps/settings/lib/Hooks.php
@@ -34,7 +34,6 @@ use OCP\Activity\IManager as IActivityManager;
use OCP\IConfig;
use OCP\IGroup;
use OCP\IGroupManager;
-use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserManager;
@@ -60,8 +59,6 @@ class Hooks {
protected $config;
/** @var IFactory */
protected $languageFactory;
- /** @var IL10N */
- protected $l;
public function __construct(IActivityManager $activityManager,
IGroupManager $groupManager,
@@ -70,8 +67,7 @@ class Hooks {
IURLGenerator $urlGenerator,
IMailer $mailer,
IConfig $config,
- IFactory $languageFactory,
- IL10N $l) {
+ IFactory $languageFactory) {
$this->activityManager = $activityManager;
$this->groupManager = $groupManager;
$this->userManager = $userManager;
@@ -80,7 +76,6 @@ class Hooks {
$this->mailer = $mailer;
$this->config = $config;
$this->languageFactory = $languageFactory;
- $this->l = $l;
}
/**
@@ -103,36 +98,30 @@ class Hooks {
->setAffectedUser($user->getUID());
$instanceUrl = $this->urlGenerator->getAbsoluteURL('/');
+ $language = $this->languageFactory->getUserLanguage($user);
+ $l = $this->languageFactory->get('settings', $language);
$actor = $this->userSession->getUser();
if ($actor instanceof IUser) {
if ($actor->getUID() !== $user->getUID()) {
// Admin changed the password through the user panel
- $this->l = $this->languageFactory->get(
- 'settings',
- $this->config->getUserValue(
- $user->getUID(), 'core', 'lang',
- $this->config->getSystemValue('default_language', 'en')
- )
- );
-
- $text = $this->l->t('%1$s changed your password on %2$s.', [$actor->getDisplayName(), $instanceUrl]);
+ $text = $l->t('%1$s changed your password on %2$s.', [$actor->getDisplayName(), $instanceUrl]);
$event->setAuthor($actor->getUID())
->setSubject(Provider::PASSWORD_CHANGED_BY, [$actor->getUID()]);
} else {
// User changed their password themselves through settings
- $text = $this->l->t('Your password on %s was changed.', [$instanceUrl]);
+ $text = $l->t('Your password on %s was changed.', [$instanceUrl]);
$event->setAuthor($actor->getUID())
->setSubject(Provider::PASSWORD_CHANGED_SELF);
}
} else {
if (\OC::$CLI) {
// Admin used occ to reset the password
- $text = $this->l->t('Your password on %s was reset by an administrator.', [$instanceUrl]);
+ $text = $l->t('Your password on %s was reset by an administrator.', [$instanceUrl]);
$event->setSubject(Provider::PASSWORD_RESET);
} else {
// User reset their password from Lost page
- $text = $this->l->t('Your password on %s was reset.', [$instanceUrl]);
+ $text = $l->t('Your password on %s was reset.', [$instanceUrl]);
$event->setSubject(Provider::PASSWORD_RESET_SELF);
}
}
@@ -146,10 +135,10 @@ class Hooks {
'instanceUrl' => $instanceUrl,
]);
- $template->setSubject($this->l->t('Password for %1$s changed on %2$s', [$user->getDisplayName(), $instanceUrl]));
+ $template->setSubject($l->t('Password for %1$s changed on %2$s', [$user->getDisplayName(), $instanceUrl]));
$template->addHeader();
- $template->addHeading($this->l->t('Password changed for %s', [$user->getDisplayName()]), false);
- $template->addBodyText($text . ' ' . $this->l->t('If you did not request this, please contact an administrator.'));
+ $template->addHeading($l->t('Password changed for %s', [$user->getDisplayName()]), false);
+ $template->addBodyText($text . ' ' . $l->t('If you did not request this, please contact an administrator.'));
$template->addFooter();
@@ -180,25 +169,20 @@ class Hooks {
->setAffectedUser($user->getUID());
$instanceUrl = $this->urlGenerator->getAbsoluteURL('/');
+ $language = $this->languageFactory->getUserLanguage($user);
+ $l = $this->languageFactory->get('settings', $language);
$actor = $this->userSession->getUser();
if ($actor instanceof IUser) {
$subject = Provider::EMAIL_CHANGED_SELF;
if ($actor->getUID() !== $user->getUID()) {
- $this->l = $this->languageFactory->get(
- 'settings',
- $this->config->getUserValue(
- $user->getUID(), 'core', 'lang',
- $this->config->getSystemValue('default_language', 'en')
- )
- );
$subject = Provider::EMAIL_CHANGED;
}
- $text = $this->l->t('Your email address on %s was changed.', [$instanceUrl]);
+ $text = $l->t('Your email address on %s was changed.', [$instanceUrl]);
$event->setAuthor($actor->getUID())
->setSubject($subject);
} else {
- $text = $this->l->t('Your email address on %s was changed by an administrator.', [$instanceUrl]);
+ $text = $l->t('Your email address on %s was changed by an administrator.', [$instanceUrl]);
$event->setSubject(Provider::EMAIL_CHANGED);
}
$this->activityManager->publish($event);
@@ -212,12 +196,12 @@ class Hooks {
'instanceUrl' => $instanceUrl,
]);
- $template->setSubject($this->l->t('Email address for %1$s changed on %2$s', [$user->getDisplayName(), $instanceUrl]));
+ $template->setSubject($l->t('Email address for %1$s changed on %2$s', [$user->getDisplayName(), $instanceUrl]));
$template->addHeader();
- $template->addHeading($this->l->t('Email address changed for %s', [$user->getDisplayName()]), false);
- $template->addBodyText($text . ' ' . $this->l->t('If you did not request this, please contact an administrator.'));
+ $template->addHeading($l->t('Email address changed for %s', [$user->getDisplayName()]), false);
+ $template->addBodyText($text . ' ' . $l->t('If you did not request this, please contact an administrator.'));
if ($user->getEMailAddress()) {
- $template->addBodyText($this->l->t('The new email address is %s', [$user->getEMailAddress()]));
+ $template->addBodyText($l->t('The new email address is %s', [$user->getEMailAddress()]));
}
$template->addFooter();
diff --git a/apps/settings/lib/Mailer/NewUserMailHelper.php b/apps/settings/lib/Mailer/NewUserMailHelper.php
index 75b1593c6b1..4b4428e1221 100644
--- a/apps/settings/lib/Mailer/NewUserMailHelper.php
+++ b/apps/settings/lib/Mailer/NewUserMailHelper.php
@@ -99,11 +99,7 @@ class NewUserMailHelper {
*/
public function generateTemplate(IUser $user, $generatePasswordResetToken = false) {
$userId = $user->getUID();
- $lang = $this->config->getUserValue($userId, 'core', 'lang', 'en');
- if (!$this->l10nFactory->languageExists('settings', $lang)) {
- $lang = 'en';
- }
-
+ $lang = $this->l10nFactory->getUserLanguage($user);
$l10n = $this->l10nFactory->get('settings', $lang);
if ($generatePasswordResetToken) {
diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php
index 202b11a6c3d..ecfe282dfbf 100644
--- a/lib/private/Share20/DefaultShareProvider.php
+++ b/lib/private/Share20/DefaultShareProvider.php
@@ -1401,10 +1401,7 @@ class DefaultShareProvider implements IShareProvider {
/** @var IUser $recipient */
$email = $recipient->getEMailAddress();
if ($email) {
- $language = $this->config->getSystemValue('force_language', false);
- $language = \is_string($language) ? $language : $this->config->getUserValue($recipient->getUID(), 'core', 'lang', null);
- $language = $language ?? $this->config->getSystemValue('default_language', 'en');
-
+ $language = $this->l10nFactory->getUserLanguage($recipient);
if (!isset($toListByLanguage[$language])) {
$toListByLanguage[$language] = [];
}
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index 289545f0a46..24aa54ea0d6 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -805,7 +805,7 @@ class Manager implements IManager {
if ($user !== null) {
$emailAddress = $user->getEMailAddress();
if ($emailAddress !== null && $emailAddress !== '') {
- $userLang = $this->config->getUserValue($share->getSharedWith(), 'core', 'lang', null);
+ $userLang = $this->l10nFactory->getUserLanguage($user);
$l = $this->l10nFactory->get('lib', $userLang);
$this->sendMailNotification(
$l,