ILIAS
release_8 Revision v8.24
◀ ilDoc Overview
class.ilMailDeliveryJob.php
Go to the documentation of this file.
1
<?php
2
19
declare(strict_types=1);
20
21
use
ILIAS\BackgroundTasks\Implementation\Tasks\AbstractJob
;
22
use
ILIAS\BackgroundTasks\Implementation\Values\ScalarValues\BooleanValue
;
23
use
ILIAS\BackgroundTasks\Implementation\Values\ScalarValues\IntegerValue
;
24
use
ILIAS\BackgroundTasks\Implementation\Values\ScalarValues\StringValue
;
25
use
ILIAS\BackgroundTasks\Observer
;
26
use
ILIAS\BackgroundTasks\Types\SingleType
;
27
use
ILIAS\BackgroundTasks\Types\Type
;
28
use
ILIAS\BackgroundTasks\Value
;
29
34
class
ilMailDeliveryJob
extends
AbstractJob
35
{
36
public
function
run
(array
$input
,
Observer
$observer):
Value
37
{
38
global
$DIC
;
39
40
$arguments = array_map(
static
function
($value) {
41
return
$value->getValue();
42
},
$input
);
43
44
$DIC
->logger()->mail()->info(
'Mail delivery background task executed'
);
45
46
$DIC
->logger()->mail()->debug(sprintf(
47
'Input: %s'
,
48
json_encode(array_slice($arguments, 0, 5), JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT)
49
));
50
51
if
((
int
)
$input
[0]->
getValue
() ===
ANONYMOUS_USER_ID
) {
52
$mail =
new
ilMail
((
int
)
$input
[0]->
getValue
());
53
}
else
{
54
$mail =
new
ilFormatMail
((
int
)
$input
[0]->
getValue
());
55
}
56
$mail->setSaveInSentbox((
bool
)
$input
[8]->
getValue
());
57
$mail = $mail
58
->withContextId((
string
)
$input
[9]->
getValue
())
59
->withContextParameters((array) unserialize(
$input
[10]->
getValue
(), [
'allowed_classes'
=>
false
]));
60
61
$mail->sendMail(
62
(
string
)
$input
[1]->
getValue
(),
// To
63
(
string
)
$input
[2]->
getValue
(),
// Cc
64
(
string
)
$input
[3]->
getValue
(),
// Bcc
65
(
string
)
$input
[4]->
getValue
(),
// Subject
66
(
string
)
$input
[5]->
getValue
(),
// Message
67
(array) unserialize(
$input
[6]->
getValue
(), [
'allowed_classes'
=>
false
]),
// Attachments
68
(
bool
)
$input
[7]->
getValue
()
// Use Placeholders
69
);
70
71
$DIC
->logger()->mail()->info(
'Mail delivery background task finished'
);
72
73
$output
=
new
BooleanValue
();
74
$output
->setValue(
true
);
75
76
return
$output
;
77
}
78
79
public
function
getInputTypes
(): array
80
{
81
return
[
82
new
SingleType
(IntegerValue::class),
// 0. User Id
83
new
SingleType
(StringValue::class),
// 1. To
84
new
SingleType
(StringValue::class),
// 2. CC
85
new
SingleType
(StringValue::class),
// 3. BCC
86
new
SingleType
(StringValue::class),
// 4. Subject
87
new
SingleType
(StringValue::class),
// 5. Message
88
new
SingleType
(StringValue::class),
// 6. Attachments
89
new
SingleType
(BooleanValue::class),
// 7. Use placeholders
90
new
SingleType
(BooleanValue::class),
// 8. Save in sentbox
91
new
SingleType
(StringValue::class),
// 9. Context Id
92
new
SingleType
(StringValue::class),
// 10. Context Parameters
93
];
94
}
95
96
public
function
isStateless
(): bool
97
{
98
return
true
;
99
}
100
101
public
function
getExpectedTimeOfTaskInSeconds
():
int
102
{
103
return
30;
104
}
105
106
public
function
getOutputType
():
Type
107
{
108
return
new
SingleType
(BooleanValue::class);
109
}
110
}
ILIAS\BackgroundTasks\Implementation\Tasks\AbstractJob
Definition:
AbstractJob.php:29
ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask\$input
array $input
Definition:
AbstractTask.php:44
ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask\$output
ILIAS BackgroundTasks Value $output
Definition:
AbstractTask.php:45
ILIAS\BackgroundTasks\Implementation\Values\ScalarValues\BooleanValue
Definition:
BooleanValue.php:24
ILIAS\BackgroundTasks\Implementation\Values\ScalarValues\IntegerValue
Definition:
IntegerValue.php:25
ILIAS\BackgroundTasks\Implementation\Values\ScalarValues\StringValue
Definition:
StringValue.php:25
ILIAS\BackgroundTasks\Types\SingleType
Definition:
SingleType.php:22
ilFormatMail
Definition:
class.ilFormatMail.php:26
ilMailDeliveryJob
Class ilMailDeliveryJob.
Definition:
class.ilMailDeliveryJob.php:35
ilMailDeliveryJob\getOutputType
getOutputType()
Definition:
class.ilMailDeliveryJob.php:106
ilMailDeliveryJob\getInputTypes
getInputTypes()
Definition:
class.ilMailDeliveryJob.php:79
ilMailDeliveryJob\run
run(array $input, Observer $observer)
Definition:
class.ilMailDeliveryJob.php:36
ilMailDeliveryJob\isStateless
isStateless()
Definition:
class.ilMailDeliveryJob.php:96
ilMailDeliveryJob\getExpectedTimeOfTaskInSeconds
getExpectedTimeOfTaskInSeconds()
Definition:
class.ilMailDeliveryJob.php:101
ilMail
Definition:
class.ilMail.php:28
ANONYMOUS_USER_ID
const ANONYMOUS_USER_ID
Definition:
constants.php:27
$DIC
global $DIC
Definition:
feed.php:28
ILIAS\BackgroundTasks\Observer
Definition:
Observer.php:22
ILIAS\BackgroundTasks\Types\Type
Definition:
Type.php:22
ILIAS\BackgroundTasks\Value
Definition:
Value.php:30
ILIAS\Repository\int
int(string $key)
Definition:
trait.BaseGUIRequest.php:61
ILIAS\UI\Implementation\Component\Input\getValue
getValue()
Get the value that is displayed in the input client side.
Definition:
Group.php:47
Services
Mail
classes
BackgroundTask
class.ilMailDeliveryJob.php
Generated on Sun Nov 2 2025 22:01:39 for ILIAS by
1.9.4 (using
Doxyfile
)