ILIAS  release_8 Revision v8.24
class.ilMailDeliveryJob.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
29
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
102 {
103 return 30;
104 }
105
106 public function getOutputType(): Type
107 {
108 return new SingleType(BooleanValue::class);
109 }
110}
Class ilMailDeliveryJob.
run(array $input, Observer $observer)
const ANONYMOUS_USER_ID
Definition: constants.php:27
global $DIC
Definition: feed.php:28
getValue()
Get the value that is displayed in the input client side.
Definition: Group.php:47