ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 90 of file class.ilMailDeliveryJob.php.

91  {
92  return 30;
93  }

◆ getInputTypes()

ilMailDeliveryJob::getInputTypes ( )

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

Implements ILIAS\BackgroundTasks\Task.

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

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

◆ getOutputType()

ilMailDeliveryJob::getOutputType ( )

Returns
Type A single type.

Implements ILIAS\BackgroundTasks\Task.

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

99  {
100  return new SingleType(BooleanValue::class);
101  }

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

83  {
84  return true;
85  }

◆ 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, and ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask\$output.

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_PRETTY_PRINT)
33  ));
34 
35  $mail = new ilMail((int) $input[0]->getValue());
36  $mail->setSaveInSentbox((bool) $input[8]->getValue());
37  $mail = $mail
38  ->withContextId((string) $input[9]->getValue())
39  ->withContextParameters((array) unserialize($input[10]->getValue()));
40 
41  $mail->sendMail(
42  (string) $input[1]->getValue(), // To
43  (string) $input[2]->getValue(), // Cc
44  (string) $input[3]->getValue(), // Bcc
45  (string) $input[4]->getValue(), // Subject
46  (string) $input[5]->getValue(), // Message
47  (array) unserialize($input[6]->getValue()), // Attachments
48  (bool) $input[7]->getValue() // Use Placeholders
49  );
50 
51  $DIC->logger()->mail()->info('Mail delivery background task finished');
52 
53  $output = new BooleanValue();
54  $output->setValue(true);
55 
56  return $output;
57  }
$DIC
Definition: xapitoken.php:46

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