19 declare(strict_types=1);
47 $this->tpl = $DIC->ui()->mainTemplate();
48 $this->
ctrl = $DIC->ctrl();
49 $this->
lng = $DIC->language();
50 $this->
user = $DIC->user();
51 $this->
http = $DIC->http();
54 $this->
lng->loadLanguageModule(
'mail');
57 $this->umail =
new ilMail($this->
user->getId());
59 !$DIC->rbac()->system()->checkAccess(
61 $this->umail->getMailObjectReferenceId()
64 $DIC[
'ilErr']->raiseError($this->
lng->txt(
'permission_denied'), $DIC[
'ilErr']->WARNING);
69 $toolContext = $DIC->globalScreen()
74 $additionalDataExists = $toolContext->getAdditionalData()->exists(
75 MailGlobalScreenToolProvider::SHOW_MAIL_FOLDERS_TOOL
77 if (
false === $additionalDataExists) {
78 $toolContext->addAdditionalData(MailGlobalScreenToolProvider::SHOW_MAIL_FOLDERS_TOOL,
true);
84 if ($this->
http->wrapper()->post()->has(
'mobj_id')) {
85 $folderId = $this->
http->wrapper()->post()->retrieve(
'mobj_id', $this->
refinery->kindlyTo()->int());
86 } elseif ($this->
http->wrapper()->query()->has(
'mobj_id')) {
87 $folderId = $this->
http->wrapper()->query()->retrieve(
'mobj_id', $this->
refinery->kindlyTo()->int());
89 $folderId = $this->
refinery->byTrying([
91 $this->
refinery->always($this->currentFolderId),
94 if (0 === $folderId || !$this->mbox->isOwnedFolder($folderId)) {
95 $folderId = $this->mbox->getInboxFolder();
97 $this->currentFolderId = $folderId;
103 if ($this->
http->wrapper()->query()->has(
'type')) {
104 $type = $this->
http->wrapper()->query()->retrieve(
'type', $this->
refinery->kindlyTo()->string());
107 if ($this->
http->wrapper()->query()->has(
'mail_id')) {
108 $mailId = $this->
http->wrapper()->query()->retrieve(
'mail_id', $this->
refinery->kindlyTo()->int());
111 $this->
ctrl->setParameterByClass(ilMailFormGUI::class,
'mobj_id', $this->currentFolderId);
112 $this->
ctrl->setParameterByClass(ilMailFolderGUI::class,
'mobj_id', $this->currentFolderId);
116 $this->
ctrl->redirectByClass(ilMailFormGUI::class,
'searchResults');
119 $this->
ctrl->redirectByClass(ilMailFormGUI::class,
'mailAttachment');
121 foreach ([
'to',
'cc',
'bcc'] as $reciepient_type) {
122 $key =
'rcp_' . $reciepient_type;
125 if ($this->
http->wrapper()->query()->has($key)) {
126 $recipients = $this->
http->wrapper()->query()->retrieve(
128 $this->
refinery->kindlyTo()->string()
141 $this->
ctrl->redirectByClass(ilMailFormGUI::class,
'mailUser');
143 $this->
ctrl->setParameterByClass(ilMailFormGUI::class,
'mail_id', $mailId);
144 $this->
ctrl->redirectByClass(ilMailFormGUI::class,
'replyMail');
145 } elseif (
'read' === $type) {
146 $this->
ctrl->setParameterByClass(ilMailFolderGUI::class,
'mail_id', $mailId);
147 $this->
ctrl->redirectByClass(ilMailFolderGUI::class,
'showMail');
148 } elseif (
'deliverFile' === $type) {
150 if ($this->
http->wrapper()->post()->has(
'filename')) {
151 $fileName = $this->
http->wrapper()->post()->retrieve(
153 $this->
refinery->kindlyTo()->string()
155 } elseif ($this->
http->wrapper()->query()->has(
'filename')) {
156 $fileName = $this->
http->wrapper()->query()->retrieve(
158 $this->
refinery->kindlyTo()->string()
163 $this->
ctrl->setParameterByClass(ilMailFolderGUI::class,
'mail_id', $mailId);
164 $this->
ctrl->redirectByClass(ilMailFolderGUI::class,
'deliverFile');
165 } elseif (
'message_sent' === $type) {
166 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'mail_message_send'),
true);
167 $this->
ctrl->redirectByClass(ilMailFolderGUI::class);
170 if ($this->
http->wrapper()->post()->has(
'roles')) {
171 $roles = $this->
http->wrapper()->post()->retrieve(
175 } elseif ($this->
http->wrapper()->query()->has(
'role')) {
176 $roles = [$this->
http->wrapper()->query()->retrieve(
'role', $this->
refinery->kindlyTo()->string())];
184 $this->
ctrl->redirectByClass(ilMailFormGUI::class,
'mailRole');
188 if ($this->
http->wrapper()->query()->has(
'view')) {
189 $view = $this->
http->wrapper()->query()->retrieve(
'view', $this->
refinery->kindlyTo()->string());
191 if (
'my_courses' === $view) {
193 if ($this->
http->wrapper()->query()->has(
'search_crs')) {
195 $this->
http->wrapper()->query()->retrieve(
'search_crs', $this->
refinery->kindlyTo()->string())
198 $this->
ctrl->setParameter($this,
'search_crs', $search_crs);
199 $this->
ctrl->redirectByClass(ilMailFormGUI::class,
'searchCoursesTo');
202 $this->forwardClass = (string) $this->
ctrl->getNextClass($this);
205 switch (strtolower($this->forwardClass)) {
206 case strtolower(ilMailFormGUI::class):
210 case strtolower(ilContactGUI::class):
211 $this->tpl->setTitle($this->
lng->txt(
'mail_addressbook'));
215 case strtolower(ilMailAttachmentGUI::class):
216 $this->tpl->setTitle($this->
lng->txt(
'mail'));
219 $this->
ctrl->forwardCommand($gui);
222 case strtolower(ilMailOptionsGUI::class):
223 $this->tpl->setTitle($this->
lng->txt(
'mail'));
227 case strtolower(ilMailFolderGUI::class):
232 if (!($cmd = $this->
ctrl->getCmd()) || !method_exists($this, $cmd)) {
233 $cmd =
'setViewMode';
243 $targetClass = ilMailFolderGUI::class;
244 if ($this->
http->wrapper()->query()->has(
'target')) {
245 $targetClass = $this->
http->wrapper()->query()->retrieve(
247 $this->
refinery->kindlyTo()->string()
251 if ($this->
http->wrapper()->query()->has(
'type')) {
252 $type = $this->
http->wrapper()->query()->retrieve(
'type', $this->
refinery->kindlyTo()->string());
255 if ($this->
http->wrapper()->query()->has(
'mail_id')) {
256 $mailId = $this->
http->wrapper()->query()->retrieve(
'mail_id', $this->
refinery->kindlyTo()->int());
259 $this->
ctrl->setParameterByClass($targetClass,
'mobj_id', $this->currentFolderId);
261 if (
'redirect_to_read' === $type) {
262 $this->
ctrl->setParameterByClass(
263 ilMailFolderGUI::class,
267 $this->
ctrl->setParameterByClass(
268 ilMailFolderGUI::class,
270 $this->currentFolderId
272 $this->
ctrl->redirectByClass(ilMailFolderGUI::class,
'showMail');
273 } elseif (
'add_subfolder' === $type) {
274 $this->
ctrl->redirectByClass($targetClass,
'addSubFolder');
275 } elseif (
'enter_folderdata' === $type) {
276 $this->
ctrl->redirectByClass($targetClass,
'enterFolderData');
277 } elseif (
'confirmdelete_folderdata' === $type) {
278 $this->
ctrl->redirectByClass($targetClass,
'confirmDeleteFolder');
280 $this->
ctrl->redirectByClass($targetClass);
288 $DIC[
'ilHelp']->setScreenIdComponent(
'mail');
290 $this->tpl->loadStandardTemplate();
293 $this->
ctrl->setParameterByClass(ilMailFolderGUI::class,
'mobj_id', $this->currentFolderId);
294 $DIC->tabs()->addTarget(
'fold', $this->
ctrl->getLinkTargetByClass(ilMailFolderGUI::class));
295 $this->
ctrl->clearParametersByClass(ilMailFormGUI::class);
298 $this->
ctrl->setParameterByClass(ilMailFormGUI::class,
'mobj_id', $this->currentFolderId);
299 $DIC->tabs()->addTarget(
'compose', $this->
ctrl->getLinkTargetByClass(ilMailFormGUI::class));
300 $this->
ctrl->clearParametersByClass(ilMailFormGUI::class);
302 $this->
ctrl->setParameterByClass(ilContactGUI::class,
'mobj_id', $this->currentFolderId);
303 $DIC->tabs()->addTarget(
305 $this->
ctrl->getLinkTargetByClass(ilContactGUI::class)
307 $this->
ctrl->clearParametersByClass(ilContactGUI::class);
309 $this->
ctrl->setParameterByClass(
310 ilMailAttachmentGUI::class,
312 $this->currentFolderId
314 $DIC->tabs()->addTarget(
315 'mail_manage_attachments',
316 $this->
ctrl->getLinkTargetByClass([self::class, ilMailAttachmentGUI::class])
318 $this->
ctrl->clearParametersByClass(ilMailAttachmentGUI::class);
320 if ($DIC->settings()->get(
'show_mail_settings',
'0')) {
321 $this->
ctrl->setParameterByClass(
322 ilMailOptionsGUI::class,
324 $this->currentFolderId
326 $DIC->tabs()->addTarget(
328 $this->
ctrl->getLinkTargetByClass(ilMailOptionsGUI::class)
330 $this->
ctrl->clearParametersByClass(ilMailOptionsGUI::class);
333 match (strtolower($this->forwardClass)) {
334 strtolower(ilMailFormGUI::class) => $DIC->tabs()->setTabActive(
'compose'),
335 strtolower(ilContactGUI::class) => $DIC->tabs()->setTabActive(
'mail_addressbook'),
336 strtolower(ilMailOptionsGUI::class) => $DIC->tabs()->setTabActive(
'options'),
337 strtolower(ilMailAttachmentGUI::class) => $DIC->tabs()->setTabActive(
'mail_manage_attachments'),
338 default => $DIC->tabs()->setTabActive(
'fold'),
341 if ($this->
http->wrapper()->query()->has(
'message_sent')) {
342 $DIC->tabs()->setTabActive(
'fold');
349 $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.
Mail Box class Base class for creating and handling mail boxes.
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