19 declare(strict_types=1);
44 $this->tpl = $DIC->ui()->mainTemplate();
45 $this->
ctrl = $DIC->ctrl();
46 $this->
lng = $DIC->language();
47 $this->
user = $DIC->user();
48 $this->
http = $DIC->http();
51 $this->
lng->loadLanguageModule(
'mail');
54 $this->umail =
new ilMail($this->
user->getId());
56 !$DIC->rbac()->system()->checkAccess(
58 $this->umail->getMailObjectReferenceId()
61 $DIC[
'ilErr']->raiseError($this->
lng->txt(
'permission_denied'), $DIC[
'ilErr']->WARNING);
66 $tool_context = $DIC->globalScreen()
71 $additional_data_exists = $tool_context->getAdditionalData()->exists(
72 MailGlobalScreenToolProvider::SHOW_MAIL_FOLDERS_TOOL
74 if ($additional_data_exists ===
false) {
75 $tool_context->addAdditionalData(MailGlobalScreenToolProvider::SHOW_MAIL_FOLDERS_TOOL,
true);
81 if ($this->
http->wrapper()->post()->has(
'mobj_id')) {
82 $folder_id = $this->
http->wrapper()->post()->retrieve(
'mobj_id', $this->
refinery->kindlyTo()->int());
83 } elseif ($this->
http->wrapper()->query()->has(
'mobj_id')) {
84 $folder_id = $this->
http->wrapper()->query()->retrieve(
'mobj_id', $this->
refinery->kindlyTo()->int());
86 $folder_id = $this->
refinery->byTrying([
88 $this->
refinery->always($this->current_folder_id),
91 if ($folder_id === 0 || !$this->mbox->isOwnedFolder($folder_id)) {
92 $folder_id = $this->mbox->getInboxFolder();
94 $this->current_folder_id = $folder_id;
100 if ($this->
http->wrapper()->query()->has(
'type')) {
101 $type = $this->
http->wrapper()->query()->retrieve(
'type', $this->
refinery->kindlyTo()->string());
104 if ($this->
http->wrapper()->query()->has(
'mail_id')) {
105 $mail_id = $this->
http->wrapper()->query()->retrieve(
'mail_id', $this->
refinery->kindlyTo()->int());
108 $this->
ctrl->setParameterByClass(ilMailFormGUI::class,
'mobj_id', $this->current_folder_id);
109 $this->
ctrl->setParameterByClass(ilMailFolderGUI::class,
'mobj_id', $this->current_folder_id);
113 $this->
ctrl->redirectByClass(ilMailFormGUI::class,
'searchResults');
116 $this->
ctrl->redirectByClass(ilMailFormGUI::class,
'mailAttachment');
118 foreach ([
'to',
'cc',
'bcc'] as $reciepient_type) {
119 $key =
'rcp_' . $reciepient_type;
122 if ($this->
http->wrapper()->query()->has($key)) {
123 $recipients = $this->
http->wrapper()->query()->retrieve(
125 $this->
refinery->kindlyTo()->string()
138 $this->
ctrl->redirectByClass(ilMailFormGUI::class,
'mailUser');
140 $this->
ctrl->setParameterByClass(ilMailFormGUI::class,
'mail_id', $mail_id);
141 $this->
ctrl->redirectByClass(ilMailFormGUI::class,
'replyMail');
142 } elseif ($type ===
'read') {
143 $this->
ctrl->setParameterByClass(ilMailFolderGUI::class,
'mail_id', $mail_id);
144 $this->
ctrl->redirectByClass(ilMailFolderGUI::class,
'showMail');
145 } elseif ($type ===
'deliverFile') {
147 if ($this->
http->wrapper()->post()->has(
'filename')) {
150 $this->
refinery->kindlyTo()->string()
152 } elseif ($this->
http->wrapper()->query()->has(
'filename')) {
155 $this->
refinery->kindlyTo()->string()
160 $this->
ctrl->setParameterByClass(ilMailFolderGUI::class,
'mail_id', $mail_id);
161 $this->
ctrl->redirectByClass(ilMailFolderGUI::class,
'deliverFile');
162 } elseif ($type ===
'message_sent') {
163 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'mail_message_send'),
true);
164 $this->
ctrl->redirectByClass(ilMailFolderGUI::class);
167 if ($this->
http->wrapper()->post()->has(
'roles')) {
168 $roles = $this->
http->wrapper()->post()->retrieve(
172 } elseif ($this->
http->wrapper()->query()->has(
'role')) {
173 $roles = [$this->
http->wrapper()->query()->retrieve(
'role', $this->
refinery->kindlyTo()->string())];
181 $this->
ctrl->redirectByClass(ilMailFormGUI::class,
'mailRole');
185 if ($this->
http->wrapper()->query()->has(
'view')) {
186 $view = $this->
http->wrapper()->query()->retrieve(
'view', $this->
refinery->kindlyTo()->string());
188 if ($view ===
'my_courses') {
190 if ($this->
http->wrapper()->query()->has(
'search_crs')) {
192 $this->
http->wrapper()->query()->retrieve(
'search_crs', $this->
refinery->kindlyTo()->string())
195 $this->
ctrl->setParameter($this,
'search_crs', $search_crs);
196 $this->
ctrl->redirectByClass(ilMailFormGUI::class,
'searchCoursesTo');
199 $this->forward_class = (string) $this->
ctrl->getNextClass($this);
202 switch (strtolower($this->forward_class)) {
203 case strtolower(ilMailFormGUI::class):
207 case strtolower(ilContactGUI::class):
208 $this->tpl->setTitle($this->
lng->txt(
'mail_addressbook'));
212 case strtolower(ilMailAttachmentGUI::class):
213 $this->tpl->setTitle($this->
lng->txt(
'mail'));
216 $this->
ctrl->forwardCommand($gui);
219 case strtolower(ilMailOptionsGUI::class):
220 $this->tpl->setTitle($this->
lng->txt(
'mail'));
224 case strtolower(ilMailFolderGUI::class):
229 if (!($cmd = $this->
ctrl->getCmd()) || !method_exists($this, $cmd)) {
230 $cmd =
'setViewMode';
240 $target_class = ilMailFolderGUI::class;
241 if ($this->
http->wrapper()->query()->has(
'target')) {
242 $target_class = $this->
http->wrapper()->query()->retrieve(
244 $this->
refinery->kindlyTo()->string()
248 if ($this->
http->wrapper()->query()->has(
'type')) {
249 $type = $this->
http->wrapper()->query()->retrieve(
'type', $this->
refinery->kindlyTo()->string());
252 if ($this->
http->wrapper()->query()->has(
'mail_id')) {
253 $mail_id = $this->
http->wrapper()->query()->retrieve(
'mail_id', $this->
refinery->kindlyTo()->int());
256 $this->
ctrl->setParameterByClass($target_class,
'mobj_id', $this->current_folder_id);
258 if ($type ===
'redirect_to_read') {
259 $this->
ctrl->setParameterByClass(
260 ilMailFolderGUI::class,
264 $this->
ctrl->setParameterByClass(
265 ilMailFolderGUI::class,
267 $this->current_folder_id
269 $this->
ctrl->redirectByClass(ilMailFolderGUI::class,
'showMail');
270 } elseif ($type ===
'add_subfolder') {
271 $this->
ctrl->redirectByClass($target_class,
'addSubFolder');
272 } elseif ($type ===
'enter_folderdata') {
273 $this->
ctrl->redirectByClass($target_class,
'enterFolderData');
274 } elseif ($type ===
'confirmdelete_folderdata') {
275 $this->
ctrl->redirectByClass($target_class,
'confirmDeleteFolder');
277 $this->
ctrl->redirectByClass($target_class);
285 $DIC[
'ilHelp']->setScreenIdComponent(
'mail');
287 $this->tpl->loadStandardTemplate();
290 $this->
ctrl->setParameterByClass(ilMailFolderGUI::class,
'mobj_id', $this->current_folder_id);
291 $DIC->tabs()->addTarget(
'fold', $this->
ctrl->getLinkTargetByClass(ilMailFolderGUI::class));
292 $this->
ctrl->clearParametersByClass(ilMailFormGUI::class);
295 $this->
ctrl->setParameterByClass(ilMailFormGUI::class,
'mobj_id', $this->current_folder_id);
296 $DIC->tabs()->addTarget(
'compose', $this->
ctrl->getLinkTargetByClass(ilMailFormGUI::class));
297 $this->
ctrl->clearParametersByClass(ilMailFormGUI::class);
299 $this->
ctrl->setParameterByClass(ilContactGUI::class,
'mobj_id', $this->current_folder_id);
300 $DIC->tabs()->addTarget(
302 $this->
ctrl->getLinkTargetByClass(ilContactGUI::class)
304 $this->
ctrl->clearParametersByClass(ilContactGUI::class);
306 $this->
ctrl->setParameterByClass(
307 ilMailAttachmentGUI::class,
309 $this->current_folder_id
311 $DIC->tabs()->addTarget(
312 'mail_manage_attachments',
313 $this->
ctrl->getLinkTargetByClass([self::class, ilMailAttachmentGUI::class])
315 $this->
ctrl->clearParametersByClass(ilMailAttachmentGUI::class);
317 if ($DIC->settings()->get(
'show_mail_settings',
'0')) {
318 $this->
ctrl->setParameterByClass(
319 ilMailOptionsGUI::class,
321 $this->current_folder_id
323 $DIC->tabs()->addTarget(
325 $this->
ctrl->getLinkTargetByClass(ilMailOptionsGUI::class)
327 $this->
ctrl->clearParametersByClass(ilMailOptionsGUI::class);
330 match (strtolower($this->forward_class)) {
331 strtolower(ilMailFormGUI::class) => $DIC->tabs()->setTabActive(
'compose'),
332 strtolower(ilContactGUI::class) => $DIC->tabs()->setTabActive(
'mail_addressbook'),
333 strtolower(ilMailOptionsGUI::class) => $DIC->tabs()->setTabActive(
'options'),
334 strtolower(ilMailAttachmentGUI::class) => $DIC->tabs()->setTabActive(
'mail_manage_attachments'),
335 default => $DIC->tabs()->setTabActive(
'fold'),
338 if ($this->
http->wrapper()->query()->has(
'message_sent')) {
339 $DIC->tabs()->setTabActive(
'fold');
346 $exp->toggleExplorerNodeState();
static get(string $a_var)
readonly GlobalHttpState $http
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
toggleExplorerNodeState()
readonly ilGlobalTemplateInterface $tpl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
readonly ilCtrlInterface $ctrl
static set(string $a_var, $a_val)
Set a value.
readonly Refinery $refinery