Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
user_registration_reminder
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
user_registration_reminder
Commits
9ffe4287
Commit
9ffe4287
authored
3 weeks ago
by
Joshua Sedler
Committed by
Julian Pustkuchen
3 weeks ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3501968
by anybody, grevil: Implement mail translation (by user preferred language)
parent
4f1f1cf4
No related branches found
Branches containing commit
Tags
1.0.0-rc1
Tags containing commit
1 merge request
!6
Issue #3501968: Implement mail translation (by user preferred language)
Pipeline
#407502
passed with warnings
3 weeks ago
Stage: build
Stage: validate
Stage: test
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Form/SettingsForm.php
+1
-1
1 addition, 1 deletion
src/Form/SettingsForm.php
src/Manager.php
+21
-14
21 additions, 14 deletions
src/Manager.php
tests/src/Kernel/UserRegistrationReminderKernelTest.php
+1
-1
1 addition, 1 deletion
tests/src/Kernel/UserRegistrationReminderKernelTest.php
with
23 additions
and
16 deletions
src/Form/SettingsForm.php
+
1
−
1
View file @
9ffe4287
...
...
@@ -146,7 +146,7 @@ final class SettingsForm extends ConfigFormBase {
'#type'
=>
'fieldset'
,
'#tree'
=>
TRUE
,
'#title'
=>
$this
->
t
(
'Final action'
),
'#description'
=>
$this
->
t
(
'The final action is taken after all escalation steps were executed for a user
, but
'
),
'#description'
=>
$this
->
t
(
'The final action is taken after all escalation steps were executed for a user
without login.
'
),
'#states'
=>
[
'visible'
=>
[
':input[name="enabled"]'
=>
[
'checked'
=>
TRUE
],
...
...
This diff is collapsed.
Click to expand it.
src/Manager.php
+
21
−
14
View file @
9ffe4287
...
...
@@ -6,7 +6,7 @@ namespace Drupal\user_registration_reminder;
use
Drupal\Component\Datetime\TimeInterface
;
use
Drupal\Component\Utility\Html
;
use
Drupal\Core\Config\
C
onfigFactoryInterface
;
use
Drupal\Core\Config\
c
onfigFactoryInterface
;
use
Drupal\Core\Config\ImmutableConfig
;
use
Drupal\Core\Entity\EntityTypeManagerInterface
;
use
Drupal\Core\Language\LanguageManagerInterface
;
...
...
@@ -45,7 +45,7 @@ class Manager {
* Constructs a Manager object.
*/
public
function
__construct
(
protected
readonly
C
onfigFactoryInterface
$configFactory
,
protected
readonly
c
onfigFactoryInterface
$configFactory
,
protected
readonly
EntityTypeManagerInterface
$entityTypeManager
,
protected
readonly
MailManagerInterface
$mailManager
,
protected
readonly
UserDataInterface
$userData
,
...
...
@@ -54,7 +54,6 @@ class Manager {
protected
readonly
Token
$token
,
protected
readonly
TimeInterface
$timeService
,
)
{
$this
->
config
=
$configFactory
->
get
(
'user_registration_reminder.settings'
);
$this
->
logger
=
$loggerChannelFactory
->
get
(
'user_registration_reminder'
);
}
...
...
@@ -62,7 +61,7 @@ class Manager {
* Runs the registration reminder check and processing.
*/
public
function
runRegistrationReminder
():
void
{
if
(
!
$this
->
config
->
get
(
'enabled'
))
{
if
(
!
$this
->
config
Factory
->
get
(
'user_registration_reminder.settings'
)
->
get
(
'enabled'
))
{
return
;
}
$inactiveRegistrationUsers
=
$this
->
getInactiveRegistrationUsers
();
...
...
@@ -112,7 +111,7 @@ class Manager {
*/
protected
function
getFinalEscalationStepCount
():
int
{
$i
=
0
;
$reminderEscalations
=
$this
->
config
->
get
(
"reminder_escalations"
);
$reminderEscalations
=
$this
->
config
Factory
->
get
(
'user_registration_reminder.settings'
)
->
get
(
"reminder_escalations"
);
foreach
(
$reminderEscalations
as
$reminderEscalation
)
{
if
(
$reminderEscalation
[
'delay'
]
>
0
)
{
$i
++
;
...
...
@@ -133,7 +132,7 @@ class Manager {
* The escalation step configuration or NULL if not existing.
*/
protected
function
getEscalationStepConfig
(
int
$escalationStep
):
?array
{
return
$this
->
config
->
get
(
"reminder_escalations.
{
$escalationStep
}
"
)
??
NULL
;
return
$this
->
config
Factory
->
get
(
'user_registration_reminder.settings'
)
->
get
(
"reminder_escalations.
{
$escalationStep
}
"
)
??
NULL
;
}
/**
...
...
@@ -146,7 +145,7 @@ class Manager {
* The final action delay after the last escalation step.
*/
protected
function
getFinalActionDelay
():
int
{
return
$this
->
config
->
get
(
'final_action.delay'
)
??
0
;
return
$this
->
config
Factory
->
get
(
'user_registration_reminder.settings'
)
->
get
(
'final_action.delay'
)
??
0
;
}
/**
...
...
@@ -159,7 +158,7 @@ class Manager {
* The final action delay after the last escalation step.
*/
protected
function
getFinalActionAction
():
string
{
return
$this
->
config
->
get
(
'final_action.action'
)
??
'none'
;
return
$this
->
config
Factory
->
get
(
'user_registration_reminder.settings'
)
->
get
(
'final_action.action'
)
??
'none'
;
}
/**
...
...
@@ -172,7 +171,7 @@ class Manager {
* The first escalation timestamp to compare user creation against.
*/
protected
function
getFirstEscalationTimestamp
():
int
{
$delay
=
$this
->
config
->
get
(
'reminder_escalations.0.delay'
);
$delay
=
$this
->
config
Factory
->
get
(
'user_registration_reminder.settings'
)
->
get
(
'reminder_escalations.0.delay'
);
$time
=
$this
->
timeService
->
getRequestTime
();
return
$time
-
$delay
;
}
...
...
@@ -223,16 +222,23 @@ class Manager {
*/
protected
function
sendReminderEmail
(
UserDecorator
$inactiveRegistrationUser
):
bool
{
$user
=
$inactiveRegistrationUser
->
getUser
();
$email
=
$user
->
getEmail
();
$userLangcode
=
$user
->
getPreferredLangcode
();
$userLanguage
=
$this
->
languageManager
->
getLanguage
(
$userLangcode
);
$original_language
=
$this
->
languageManager
->
getConfigOverrideLanguage
();
// Temporarily set the user's language as the config override language,
// So we can get the email subject / body in the user's language:
$this
->
languageManager
->
setConfigOverrideLanguage
(
$userLanguage
);
$escalationStep
=
$inactiveRegistrationUser
->
getRecentEscalationStep
();
// @todo: We need to get the config in the users language!
$escalationStepConfig
=
$this
->
getEscalationStepConfig
(
$escalationStep
);
// Reset the config override language:
$this
->
languageManager
->
setConfigOverrideLanguage
(
$original_language
);
$subject
=
$escalationStepConfig
[
'email_subject'
];
$body
=
$escalationStepConfig
[
'email_body'
];
$tokenValues
=
[
'user'
=>
$user
,
];
$token_options
=
[
'langcode'
=>
$user
->
getPreferred
Langcode
()
,
'callback'
=>
'user_mail_tokens'
,
'clear'
=>
TRUE
];
$token_options
=
[
'langcode'
=>
$userLangcode
,
'callback'
=>
'user_mail_tokens'
,
'clear'
=>
TRUE
];
$subject
=
$this
->
token
->
replace
(
$subject
,
$tokenValues
,
$token_options
);
$subject
=
Html
::
decodeEntities
(
strip_tags
(
$subject
));
$body
=
$this
->
token
->
replace
(
$body
,
$tokenValues
,
$token_options
);
...
...
@@ -241,14 +247,15 @@ class Manager {
'subject'
=>
$subject
,
'body'
=>
$body
,
];
if
(
$emailBcc
=
$this
->
config
->
get
(
"email_bcc"
))
{
if
(
$emailBcc
=
$this
->
config
Factory
->
get
(
'user_registration_reminder.settings'
)
->
get
(
"email_bcc"
))
{
$params
[
'headers'
][
'Bcc'
]
=
$emailBcc
;
}
$email
=
$user
->
getEmail
();
return
$this
->
mailManager
->
mail
(
'user_registration_reminder'
,
'user_registration_reminder'
,
$email
,
$user
->
getPreferred
Langcode
()
,
$userLangcode
,
$params
,
)[
'result'
]
??
TRUE
;
}
...
...
This diff is collapsed.
Click to expand it.
tests/src/Kernel/UserRegistrationReminderKernelTest.php
+
1
−
1
View file @
9ffe4287
...
...
@@ -411,7 +411,7 @@ final class UserRegistrationReminderKernelTest extends KernelTestBase {
$user_storage
->
resetCache
([
$user
->
id
()]);
$user
=
$user_storage
->
load
(
$user
->
id
());
// @todo
:
Find out why the user still exists here!
// @todo Find out why the user still exists here!
// $this->assertEmpty($user);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment