ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 $mailJsonService
 

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

Constructor & Destructor Documentation

◆ __construct()

ilMassMailDeliveryJob::__construct ( )

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

References $DIC.

39  {
40  global $DIC;
41  $this->dic = $DIC;
42 
43  $this->mailJsonService = new ilMailValueObjectJsonService();
44  }
global $DIC
Definition: shib_login.php:22

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

106  : int
107  {
108  return 42; // The answer to life, universe and the rest
109  }

◆ getInputTypes()

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

Implements ILIAS\BackgroundTasks\Task.

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

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

◆ getOutputType()

ilMassMailDeliveryJob::getOutputType ( )

Implements ILIAS\BackgroundTasks\Task.

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

111  : Type
112  {
113  return new SingleType(BooleanValue::class);
114  }

◆ 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 101 of file class.ilMassMailDeliveryJob.php.

101  : bool
102  {
103  return true;
104  }

◆ 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 46 of file class.ilMassMailDeliveryJob.php.

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

46  : Value
47  {
48  $mailValueObjects = $this->mailJsonService->convertFromJson((string) $input[1]->getValue());
49 
50  foreach ($mailValueObjects as $mailValueObject) {
51  $mail = new ilMail((int) $input[0]->getValue());
52 
53  $mail->setSaveInSentbox($mailValueObject->shouldSaveInSentBox());
54  $contextId = $input[2]->getValue();
55  $mail = $mail
56  ->withContextId((string) $contextId)
57  ->withContextParameters((array) unserialize($input[3]->getValue(), ['allowed_classes' => false]));
58 
59  $recipients = $mailValueObject->getRecipients();
60  $recipientsCC = $mailValueObject->getRecipientsCC();
61  $recipientsBCC = $mailValueObject->getRecipientsBCC();
62 
63  $this->dic->logger()->mail()->info(
64  sprintf(
65  'Mail delivery to recipients: "%s" CC: "%s" BCC: "%s" From sender: "%s"',
66  $recipients,
67  $recipientsCC,
68  $recipientsBCC,
69  $mailValueObject->getFrom()
70  )
71  );
72 
73  $mail_data = new MailDeliveryData(
74  $recipients,
75  $recipientsCC,
76  $recipientsBCC,
77  $mailValueObject->getSubject(),
78  $mailValueObject->getBody(),
79  $mailValueObject->getAttachments(),
80  $mailValueObject->isUsingPlaceholders()
81  );
82  $mail->sendMail($mail_data);
83  }
84 
85  $output = new BooleanValue();
86  $output->setValue(true);
87 
88  return $output;
89  }
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 35 of file class.ilMassMailDeliveryJob.php.

◆ $mailJsonService

readonly ilMailValueObjectJsonService ilMassMailDeliveryJob::$mailJsonService
private

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


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