ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilMailDeliveryJob Class Reference

Class ilMailDeliveryJob. More...

+ Inheritance diagram for ilMailDeliveryJob:
+ Collaboration diagram for ilMailDeliveryJob:

Public Member Functions

 run (array $input, Observer $observer)
 
Parameters
More...
 
 getInputTypes ()
 
Returns
Type[] A list of types that are taken as input.
More...
 
 isStateless ()
 
Returns
bool returns true iff the job's output ONLY depends on the input. Stateless task results may be cached!
More...
 
 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
More...
 
 getOutputType ()
 
Returns
Type A single type.
More...
 
- Public Member Functions inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractJob
 getInput ()
 
Returns
mixed returns the input array
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...
 

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 ($values)
 
 extractType ($value)
 
- Protected Attributes inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
 $input = []
 
 $output
 

Detailed Description

Class ilMailDeliveryJob.

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de

Definition at line 15 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 94 of file class.ilMailDeliveryJob.php.

95  {
96  return 30;
97  }

◆ getInputTypes()

ilMailDeliveryJob::getInputTypes ( )

Returns
Type[] A list of types that are taken as input.

Implements ILIAS\BackgroundTasks\Task.

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

67  {
68  return [
69  new SingleType(IntegerValue::class), // 0. User Id
70  new SingleType(StringValue::class), // 1. To
71  new SingleType(StringValue::class), // 2. CC
72  new SingleType(StringValue::class), // 3. BCC
73  new SingleType(StringValue::class), // 4. Subject
74  new SingleType(StringValue::class), // 5. Message
75  new SingleType(StringValue::class), // 6. Attachments
76  new SingleType(BooleanValue::class), // 7. Use placeholders
77  new SingleType(BooleanValue::class), // 8. Save in sentbox
78  new SingleType(StringValue::class), // 9. Context Id
79  new SingleType(StringValue::class), // 10. Context Parameters
80  ];
81  }

◆ getOutputType()

ilMailDeliveryJob::getOutputType ( )

Returns
Type A single type.

Implements ILIAS\BackgroundTasks\Task.

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

103  {
104  return new SingleType(BooleanValue::class);
105  }

◆ 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 86 of file class.ilMailDeliveryJob.php.

87  {
88  return true;
89  }

◆ run()

ilMailDeliveryJob::run ( array  $input,
Observer  $observer 
)

Parameters

Implements ILIAS\BackgroundTasks\Task\Job.

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

References $DIC, ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask\$input, ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask\$output, and ANONYMOUS_USER_ID.

21  {
22  global $DIC;
23 
24  $arguments = array_map(function ($value) {
25  return $value->getValue();
26  }, $input);
27 
28  $DIC->logger()->mail()->info('Mail delivery background task executed');
29 
30  $DIC->logger()->mail()->debug(sprintf(
31  'Input: %s',
32  json_encode(array_slice($arguments, 0, 5), JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT)
33  ));
34 
35  if ((int) $input[0]->getValue() === (int) ANONYMOUS_USER_ID) {
36  $mail = new ilMail((int) $input[0]->getValue());
37  } else {
38  $mail = new ilFormatMail((int) $input[0]->getValue());
39  }
40  $mail->setSaveInSentbox((bool) $input[8]->getValue());
41  $mail = $mail
42  ->withContextId((string) $input[9]->getValue())
43  ->withContextParameters((array) unserialize($input[10]->getValue()));
44 
45  $mail->sendMail(
46  (string) $input[1]->getValue(), // To
47  (string) $input[2]->getValue(), // Cc
48  (string) $input[3]->getValue(), // Bcc
49  (string) $input[4]->getValue(), // Subject
50  (string) $input[5]->getValue(), // Message
51  (array) unserialize($input[6]->getValue()), // Attachments
52  (bool) $input[7]->getValue() // Use Placeholders
53  );
54 
55  $DIC->logger()->mail()->info('Mail delivery background task finished');
56 
57  $output = new BooleanValue();
58  $output->setValue(true);
59 
60  return $output;
61  }
const ANONYMOUS_USER_ID
Definition: constants.php:25
Class UserMail this class handles user mails.
global $DIC
Definition: goto.php:24

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