aboutsummaryrefslogtreecommitdiffstats
path: root/apps/settings/lib
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 /apps/settings/lib
parentb997edad105d38703351b89998444ab0828f7d05 (diff)
downloadnextcloud-server-db8267db26e2e81ef4a39b424c5a8ea7bc124bfd.tar.gz
nextcloud-server-db8267db26e2e81ef4a39b424c5a8ea7bc124bfd.zip
Use the new method everywhere
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/settings/lib')
-rw-r--r--apps/settings/lib/Hooks.php52
-rw-r--r--apps/settings/lib/Mailer/NewUserMailHelper.php6
2 files changed, 19 insertions, 39 deletions
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) {