ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator 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 (array $values)
 
 extractType ($value)
 
- Protected Attributes inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
array $input = []
 
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 113 of file class.ilMailDeliveryJob.php.

113  : int
114  {
115  return 30;
116  }

◆ getInputTypes()

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

Implements ILIAS\BackgroundTasks\Task.

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

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

◆ getOutputType()

ilMailDeliveryJob::getOutputType ( )

Implements ILIAS\BackgroundTasks\Task.

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

118  : Type
119  {
120  return new SingleType(BooleanValue::class);
121  }

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

108  : bool
109  {
110  return true;
111  }

◆ run()

ilMailDeliveryJob::run ( array  $input,
Observer  $observer 
)
Parameters
Value[]$input This 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 36 of file class.ilMailDeliveryJob.php.

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().

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  $context_parameters = (array) unserialize($input[10]->getValue(), ['allowed_classes' => false]);
52 
53  if ((int) $input[0]->getValue() === ANONYMOUS_USER_ID) {
54  $mail = new ilMail((int) $input[0]->getValue());
55  } else {
56  $mail = new ilFormatMail((int) $input[0]->getValue());
57  }
58 
59  if (isset($context_parameters['auto_responder'])) {
60  if ($context_parameters['auto_responder']) {
61  $mail->autoresponder()->enableAutoresponder();
62  } else {
63  $mail->autoresponder()->disableAutoresponder();
64  }
65  }
66 
67  $mail->setSaveInSentbox((bool) $input[8]->getValue());
68  $mail = $mail
69  ->withContextId((string) $input[9]->getValue())
70  ->withContextParameters($context_parameters);
71 
72  $mail_data = new MailDeliveryData(
73  (string) $input[1]->getValue(), // To
74  (string) $input[2]->getValue(), // Cc
75  (string) $input[3]->getValue(), // Bcc
76  (string) $input[4]->getValue(), // Subject
77  (string) $input[5]->getValue(), // Message
78  (array) unserialize($input[6]->getValue(), ['allowed_classes' => false]), // Attachments
79  (bool) $input[7]->getValue() // Use Placeholders
80  );
81  $mail->sendMail($mail_data);
82 
83  $DIC->logger()->mail()->info('Mail delivery background task finished');
84 
85  $output = new BooleanValue();
86  $output->setValue(true);
87 
88  return $output;
89  }
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:22
+ Here is the call graph for this function:

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