ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
AutoresponderNotification.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26use DateTimeImmutable;
27use ilDateTime;
28
30{
31 public function __construct(
32 private readonly ilMailOptions $sender_mail_options,
33 int $receiver_id,
34 private readonly DateTimeImmutable $next_auto_responder_datetime
35 ) {
37
38 $this->setSender($sender_mail_options->getUsrId());
39 $this->setRecipients([$receiver_id]);
40 }
41
42 public function send(): bool
43 {
44 $use_relative_dates = ilDatePresentation::useRelativeDates();
46
47 foreach ($this->getRecipients() as $recipient) {
48 $this->initLanguage($recipient);
49 $this->initMail();
50
51 $this->getMail()->setSaveInSentbox(false);
52 $former_language = ilDatePresentation::getLanguage();
54
55 $this->setSubject($this->sender_mail_options->getAbsenceAutoresponderSubject());
56
57 $this->setBody($this->sender_mail_options->getAbsenceAutoresponderBody());
58 $this->appendBody("\n");
59 $this->appendBody($this->sender_mail_options->getSignature());
60 $this->appendBody("\n\n");
61 $this->appendBody(
62 str_ireplace(
63 [
64 '[NEXT_AUTO_RESPONDER_DATETIME]'
65 ],
66 [
68 new ilDateTime($this->next_auto_responder_datetime->getTimestamp(), IL_CAL_UNIX)
69 )
70 ],
71 $this->getLanguageText('mail_absence_auto_responder_body_hint')
72 )
73 );
74
75 $this->sendMail([$recipient]);
76
77 ilDatePresentation::setLanguage($former_language);
78 }
79
80 ilDatePresentation::setUseRelativeDates($use_relative_dates);
81
82 return true;
83 }
84}
__construct(private readonly ilMailOptions $sender_mail_options, int $receiver_id, private readonly DateTimeImmutable $next_auto_responder_datetime)
const IL_CAL_UNIX
Class for date presentation.
static setUseRelativeDates(bool $a_status)
set use relative dates
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
static setLanguage(ilLanguage $a_lng)
@classDescription Date and time handling
sendMail(array $a_rcp, bool $a_parse_recipients=true)
setSubject(string $a_subject)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc