ILIAS  release_8 Revision v8.19
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)
 
 getInputTypes ()
 
 isStateless ()
 
 getExpectedTimeOfTaskInSeconds ()
 
 getOutputType ()
 
- Public Member Functions inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractJob
 getInput ()
 
Returns
array 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
array $input = []
 
ILIAS BackgroundTasks Value $output
 

Detailed Description

Class ilMailDeliveryJob.

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

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

101  : int
102  {
103  return 30;
104  }

◆ getInputTypes()

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

Implements ILIAS\BackgroundTasks\Task.

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

79  : 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  }

◆ getOutputType()

ilMailDeliveryJob::getOutputType ( )

Implements ILIAS\BackgroundTasks\Task.

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

106  : Type
107  {
108  return new SingleType(BooleanValue::class);
109  }

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

96  : bool
97  {
98  return true;
99  }

◆ run()

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

Implements ILIAS\BackgroundTasks\Task\Job.

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

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

36  : 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  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
getValue()
Get the value that is displayed in the input client side.
Definition: Group.php:47
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

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