ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
Notification.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24
26{
27 protected \ilObjUser $to;
28 protected \ilObjUser $cc;
29 protected int $talk_ref_id;
30 protected string $talk_name;
31 protected string $talk_description;
32 protected string $talk_location;
33 protected string $subject_key;
34 protected string $message_key;
35
39 protected array $dates;
40 protected bool $add_goto;
41 protected string $attachment;
42
43 public function __construct(
46 int $talk_ref_id,
47 string $talk_name,
48 string $talk_description,
49 string $talk_location,
50 string $subject_key,
51 string $message_key,
52 string $attachment,
53 bool $add_goto,
54 string ...$dates,
55 ) {
56 $this->to = $to;
57 $this->cc = $cc;
58 $this->talk_ref_id = $talk_ref_id;
59 $this->talk_name = $talk_name;
60 $this->talk_description = $talk_description;
61 $this->talk_location = $talk_location;
62 $this->subject_key = $subject_key;
63 $this->message_key = $message_key;
64 $this->dates = $dates;
65 $this->add_goto = $add_goto;
66 $this->attachment = $attachment;
67 }
68
69 public function send(): void
70 {
71 $notif = new \ilSystemNotification();
72 $notif->setLangModules(['etal', 'orgu']);
73 $attachment = new \ilFileDataMail(ANONYMOUS_USER_ID);
74
75 $subject = sprintf(
76 $notif->getUserLanguage($this->to->getId())->txt($this->subject_key),
77 $this->talk_name
78 );
79
80 $notif->setRefId($this->talk_ref_id);
81 $notif->setObjId(0);
82 $notif->setIntroductionLangId($this->message_key);
83
84 $notif->addAdditionalInfo(
85 'obj_etal',
86 $this->talk_name
87 );
88
89 if ($this->talk_description) {
90 $notif->addAdditionalInfo(
91 'description',
92 $this->talk_description
93 );
94 }
95
96 if ($this->talk_location) {
97 $notif->addAdditionalInfo(
98 'location',
99 $this->talk_location
100 );
101 }
102
103 $notif->addAdditionalInfo(
104 'superior',
105 $this->cc->getFullname()
106 );
107
108 $notif->addAdditionalInfo(
109 'notification_talks_date_list_header',
110 "- " . implode("\r\n- ", $this->dates),
111 true
112 );
113
114 if ($this->add_goto) {
115 $notif->addAdditionalInfo(
116 'url',
117 $this->getTalkGoto()
118 );
119 }
120
121 $attachment_name = 'appointments.ics';
122 $rcid = $attachment->createCollectionFromContent($attachment_name, $this->attachment);
123 $attachments = $rcid !== null
126
127 $mail = new \ilMail(ANONYMOUS_USER_ID);
128 $mail->enqueue(
129 $this->to->getLogin(),
130 $this->cc->getLogin(),
131 '',
132 $subject,
133 $notif->composeAndGetMessage($this->to->getId(), null, '', true),
134 $attachments
135 );
136 }
137
138 protected function getTalkGoto(): string
139 {
140 return ILIAS_HTTP_PATH . '/goto.php?target=' . \ilObjEmployeeTalk::TYPE . '_' .
141 $this->talk_ref_id . '&client_id=' . CLIENT_ID;
142 }
143}
__construct(\ilObjUser $to, \ilObjUser $cc, int $talk_ref_id, string $talk_name, string $talk_description, string $talk_location, string $subject_key, string $message_key, string $attachment, bool $add_goto, string ... $dates,)
static fromIrss(ResourceCollectionIdentification $rcid)
User class.
const CLIENT_ID
Definition: constants.php:41
const ANONYMOUS_USER_ID
Definition: constants.php:27
to(\GdImage $image, ?int $quality=null)
Currently this is the only way to make a FileStream from a GD image resource.