ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
ilMassMailDeliveryJob Class Reference
+ Inheritance diagram for ilMassMailDeliveryJob:
+ Collaboration diagram for ilMassMailDeliveryJob:

Public Member Functions

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

Private Attributes

readonly ILIAS DI Container $dic
 
readonly ilMailValueObjectJsonService $mail_json_service
 

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.ilMassMailDeliveryJob.php.

Constructor & Destructor Documentation

◆ __construct()

ilMassMailDeliveryJob::__construct ( )

Definition at line 35 of file class.ilMassMailDeliveryJob.php.

References $DIC.

36  {
37  global $DIC;
38  $this->dic = $DIC;
39 
40  $this->mail_json_service = new ilMailValueObjectJsonService();
41  }
global $DIC
Definition: shib_login.php:26

Member Function Documentation

◆ getExpectedTimeOfTaskInSeconds()

ilMassMailDeliveryJob::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 103 of file class.ilMassMailDeliveryJob.php.

103  : int
104  {
105  return 42; // The answer to life, universe and the rest
106  }

◆ getInputTypes()

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

Implements ILIAS\BackgroundTasks\Task.

Definition at line 88 of file class.ilMassMailDeliveryJob.php.

88  : array
89  {
90  return [
91  new SingleType(IntegerValue::class), // User Id
92  new SingleType(StringValue::class), // JSON encoded array of ilMailValueObject
93  new SingleType(StringValue::class), // Context Id
94  new SingleType(StringValue::class), // Context Parameters
95  ];
96  }

◆ getOutputType()

ilMassMailDeliveryJob::getOutputType ( )

Implements ILIAS\BackgroundTasks\Task.

Definition at line 108 of file class.ilMassMailDeliveryJob.php.

108  : Type
109  {
110  return new SingleType(BooleanValue::class);
111  }

◆ isStateless()

ilMassMailDeliveryJob::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 98 of file class.ilMassMailDeliveryJob.php.

98  : bool
99  {
100  return true;
101  }

◆ run()

ilMassMailDeliveryJob::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 43 of file class.ilMassMailDeliveryJob.php.

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

43  : Value
44  {
45  $value_objects = $this->mail_json_service->convertFromJson((string) $input[1]->getValue());
46 
47  foreach ($value_objects as $value_object) {
48  $mail = new ilMail((int) $input[0]->getValue());
49 
50  $mail->setSaveInSentbox($value_object->shouldSaveInSentBox());
51  $context_id = $input[2]->getValue();
52  $mail = $mail
53  ->withContextId((string) $context_id)
54  ->withContextParameters((array) unserialize($input[3]->getValue(), ['allowed_classes' => false]));
55 
56  $recipients = $value_object->getRecipients();
57  $recipients_cc = $value_object->getRecipientsCC();
58  $recipients_bcc = $value_object->getRecipientsBCC();
59 
60  $this->dic->logger()->mail()->info(
61  sprintf(
62  'Mail delivery to recipients: "%s" CC: "%s" BCC: "%s" From sender: "%s"',
63  $recipients,
64  $recipients_cc,
65  $recipients_bcc,
66  $value_object->getFrom()
67  )
68  );
69 
70  $mail_data = new MailDeliveryData(
71  $recipients,
72  $recipients_cc,
73  $recipients_bcc,
74  $value_object->getSubject(),
75  $value_object->getBody(),
76  $value_object->getAttachments(),
77  $value_object->isUsingPlaceholders()
78  );
79  $mail->sendMail($mail_data);
80  }
81 
82  $output = new BooleanValue();
83  $output->setValue(true);
84 
85  return $output;
86  }
getValue()
Get the value that is displayed in the input client side.
Definition: Group.php:49
+ Here is the call graph for this function:

Field Documentation

◆ $dic

readonly ILIAS DI Container ilMassMailDeliveryJob::$dic
private

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

◆ $mail_json_service

readonly ilMailValueObjectJsonService ilMassMailDeliveryJob::$mail_json_service
private

Definition at line 33 of file class.ilMassMailDeliveryJob.php.


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