ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilMailDeliveryJob Class Reference
+ Inheritance diagram for ilMailDeliveryJob:
+ Collaboration diagram for ilMailDeliveryJob:

Public Member Functions

 run (array $input, Observer $observer)
 
 getInputTypes ()
 
 isStateless ()
 
 getExpectedTimeOfTaskInSeconds ()
 
 getOutputType ()
 
- Public Member Functions inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractJob
 getInput ()
 
Returns
Value[]
More...
 
- Public Member Functions inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
 setInput (array $values)
 
 getOutput ()
 
 getInput ()
 
 getType ()
 
 unfoldTask ()
 Unfold the task. More...
 
 getRemoveOption ()
 
Returns
Option An Option to remove the current task and do some cleanup if possible. This Option is displayed if the Bucket is completed. You do not have to provide an additional Option to remove in your UserInteraction, the remove-Option is added to the list of Options (last position)
See also
self::getAbortOption();
More...
 
 getAbortOption ()
 
Returns
Option In case a Job is failed or did not respond for some time, an Abort-Option is displayed. There is already a Standard-Abort-Option registered, you can override with your own and do some cleanup if possible.
More...
 
 getType ()
 
 getInputTypes ()
 
 getOutputType ()
 
 getOutput ()
 
 setInput (array $values)
 
 getInput ()
 
 unfoldTask ()
 
 getRemoveOption ()
 
 getAbortOption ()
 
 run (array $input, Observer $observer)
 
 isStateless ()
 
 getInput ()
 
 getExpectedTimeOfTaskInSeconds ()
 

Additional Inherited Members

- Data Fields inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
const MAIN_REMOVE = 'bt_main_remove'
 
const MAIN_ABORT = 'bt_main_abort'
 
- Protected Member Functions inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
 checkTypes (array $values)
 
 extractType ($value)
 
- Protected Attributes inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
array $input = []
 
Value $output
 

Detailed Description

Definition at line 30 of file class.ilMailDeliveryJob.php.

Member Function Documentation

◆ getExpectedTimeOfTaskInSeconds()

ilMailDeliveryJob::getExpectedTimeOfTaskInSeconds ( )
Returns
int the amount of seconds this task usually taskes. If your task-duration scales with the the amount of data, try to set a possible high value of try to calculate it. If a task duration exceeds this value, it will be displayed as "possibly failed" to the user

Implements ILIAS\BackgroundTasks\Task\Job.

Definition at line 107 of file class.ilMailDeliveryJob.php.

107 : int
108 {
109 return 30;
110 }

◆ getInputTypes()

ilMailDeliveryJob::getInputTypes ( )
Returns
Type[] A list of types that are taken as input.

Implements ILIAS\BackgroundTasks\Task.

Definition at line 85 of file class.ilMailDeliveryJob.php.

85 : array
86 {
87 return [
88 new SingleType(IntegerValue::class), // 0. User Id
89 new SingleType(StringValue::class), // 1. To
90 new SingleType(StringValue::class), // 2. CC
91 new SingleType(StringValue::class), // 3. BCC
92 new SingleType(StringValue::class), // 4. Subject
93 new SingleType(StringValue::class), // 5. Message
94 new SingleType(StringValue::class), // 6. Attachments
95 new SingleType(BooleanValue::class), // 7. Use placeholders
96 new SingleType(BooleanValue::class), // 8. Save in sentbox
97 new SingleType(StringValue::class), // 9. Context Id
98 new SingleType(StringValue::class), // 10. Context Parameters
99 ];
100 }

◆ getOutputType()

ilMailDeliveryJob::getOutputType ( )

Implements ILIAS\BackgroundTasks\Task.

Definition at line 112 of file class.ilMailDeliveryJob.php.

112 : Type
113 {
114 return new SingleType(BooleanValue::class);
115 }

◆ isStateless()

ilMailDeliveryJob::isStateless ( )
Returns
bool returns true iff the job's output ONLY depends on the input. Stateless task results may be cached!

Implements ILIAS\BackgroundTasks\Task\Job.

Definition at line 102 of file class.ilMailDeliveryJob.php.

102 : bool
103 {
104 return true;
105 }

◆ run()

ilMailDeliveryJob::run ( array  $input,
Observer  $observer 
)
Parameters
Value[]$inputThis will be a list of Values hinted by getInputTypes.
Observer$observerNotify the bucket about your progress!
Returns
Value The returned Value must be of the type hinted by getOutputType.

Implements ILIAS\BackgroundTasks\Task\Job.

Definition at line 32 of file class.ilMailDeliveryJob.php.

32 : Value
33 {
34 global $DIC;
35
36 $arguments = array_map(static fn($value) => $value->getValue(), $input);
37
38 $DIC->logger()->mail()->info('Mail delivery background task executed');
39
40 $DIC->logger()->mail()->debug(sprintf(
41 'Input: %s',
42 json_encode(array_slice($arguments, 0, 5), JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT)
43 ));
44
45 $context_parameters = (array) unserialize($input[10]->getValue(), ['allowed_classes' => false]);
46
47 if ((int) $input[0]->getValue() === ANONYMOUS_USER_ID) {
48 $mail = new ilMail((int) $input[0]->getValue());
49 } else {
50 $mail = new ilFormatMail((int) $input[0]->getValue());
51 }
52
53 if (isset($context_parameters['auto_responder'])) {
54 if ($context_parameters['auto_responder']) {
55 $mail->autoresponder()->enableAutoresponder();
56 } else {
57 $mail->autoresponder()->disableAutoresponder();
58 }
59 }
60
61 $mail->setSaveInSentbox((bool) $input[8]->getValue());
62 $mail = $mail
63 ->withContextId((string) $input[9]->getValue())
64 ->withContextParameters($context_parameters);
65
66 $mail_data = new MailDeliveryData(
67 (string) $input[1]->getValue(), // To
68 (string) $input[2]->getValue(), // Cc
69 (string) $input[3]->getValue(), // Bcc
70 (string) $input[4]->getValue(), // Subject
71 (string) $input[5]->getValue(), // Message
72 (array) unserialize($input[6]->getValue(), ['allowed_classes' => false]), // Attachments
73 (bool) $input[7]->getValue() // Use Placeholders
74 );
75 $mail->sendMail($mail_data);
76
77 $DIC->logger()->mail()->info('Mail delivery background task finished');
78
79 $output = new BooleanValue();
80 $output->setValue(true);
81
82 return $output;
83 }
const ANONYMOUS_USER_ID
Definition: constants.php:27
getValue()
Get the value that is displayed in the input client side.
Definition: Group.php:49
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask\$input, ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask\$output, ANONYMOUS_USER_ID, ILIAS\UI\Implementation\Component\Input\getValue(), and ILIAS\BackgroundTasks\Value\setValue().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: