19 declare(strict_types=1);
56 $this->tpl = $DIC->ui()->mainTemplate();
57 $this->
ctrl = $DIC->ctrl();
58 $this->
lng = $DIC->language();
59 $this->
toolbar = $DIC->toolbar();
60 $this->
user = $DIC->user();
61 $this->
tabs = $DIC->tabs();
62 $this->
http = $DIC->http();
64 $this->error = $DIC[
'ilErr'];
65 $this->ui_factory = $DIC->ui()->factory();
66 $this->ui_renderer = $DIC->ui()->renderer();
68 $this->umail =
new ilMail($this->
user->getId());
76 if ($this->
http->wrapper()->post()->has(
'mobj_id')) {
77 $folderId = $this->
http->wrapper()->post()->retrieve(
'mobj_id', $this->
refinery->kindlyTo()->int());
78 } elseif ($this->
http->wrapper()->query()->has(
'mobj_id')) {
79 $folderId = $this->
http->wrapper()->query()->retrieve(
'mobj_id', $this->
refinery->kindlyTo()->int());
81 $folderId = $this->
refinery->byTrying([
83 $this->
refinery->always($this->currentFolderId),
87 if (0 === $folderId || !$this->mbox->isOwnedFolder($folderId)) {
88 $folderId = $this->mbox->getInboxFolder();
91 $this->currentFolderId = $folderId;
96 if (preg_match(
'/^([a-zA-Z0-9]+?)_(\d+?)$/', $originalCommand, $matches) && 3 === count($matches)) {
97 $originalCommand = $matches[1];
100 return $originalCommand;
106 preg_match(
'/^([a-zA-Z0-9]+?)_(\d+?)$/', $command, $matches) &&
107 3 === count($matches) && is_numeric($matches[2])
109 return (
int) $matches[2];
118 $this->
ctrl->getCmd()
121 $nextClass = $this->
ctrl->getNextClass($this);
122 switch (strtolower($nextClass)) {
123 case strtolower(ilContactGUI::class):
127 case strtolower(ilPublicUserProfileGUI::class):
128 $this->tpl->setTitle($this->
lng->txt(
'mail'));
130 if ($this->
http->wrapper()->query()->has(
'user')) {
131 $userId = $this->
http->wrapper()->query()->retrieve(
'user', $this->
refinery->kindlyTo()->int());
135 $this->
ctrl->setParameter($this,
'mobj_id', $this->currentFolderId);
136 $profileGui->setBackUrl($this->
ctrl->getLinkTarget($this,
'showMail'));
137 $this->
ctrl->clearParameters($this);
139 $ret = $this->
ctrl->forwardCommand($profileGui);
141 $this->tpl->setContent($ret);
143 $this->tpl->printToStdout();
147 if (!method_exists($this, $cmd)) {
157 $this->umail->deleteMailsOfFolder($this->currentFolderId);
159 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'mail_deleted'),
true);
160 $this->
ctrl->setParameter($this,
'mobj_id', $this->currentFolderId);
161 $this->
ctrl->redirect($this,
'showFolder');
166 if ($this->umail->countMailsOfFolder($this->currentFolderId) !== 0) {
167 $this->confirmTrashDeletion =
true;
179 if ($this->
http->wrapper()->query()->has(
'user')) {
180 $userId = $this->
http->wrapper()->query()->retrieve(
'user', $this->
refinery->kindlyTo()->int());
182 $this->tpl->setVariable(
'TBL_TITLE', implode(
' ', [
183 $this->
lng->txt(
'profile_of'),
187 $this->tpl->setVariable(
'TBL_TITLE_IMG_ALT', $this->
lng->txt(
'public_profile'));
192 if ($this->
http->wrapper()->query()->has(
'mail_id')) {
193 $mailId = $this->
http->wrapper()->query()->retrieve(
'mail_id', $this->
refinery->kindlyTo()->int());
196 $this->
ctrl->setParameter(
201 $this->
ctrl->setParameter($this,
'mobj_id', $this->currentFolderId);
202 $profile_gui->setBackUrl($this->
ctrl->getLinkTarget($this,
'showMail'));
203 $this->
ctrl->clearParameters($this);
205 $this->tpl->setTitle($this->
lng->txt(
'mail'));
206 $this->tpl->setContent($this->
ctrl->getHTML($profile_gui));
207 $this->tpl->printToStdout();
212 $this->
ctrl->setParameter($this,
'mobj_id', $this->currentFolderId);
214 $this->
lng->txt(
'mail_add_subfolder'),
215 $this->
ctrl->getLinkTarget($this,
'addSubFolder')
218 if ($isUserSubFolder) {
220 $this->
lng->txt(
'rename'),
221 $this->
ctrl->getLinkTarget($this,
'renameSubFolder')
224 $this->
lng->txt(
'delete'),
225 $this->
ctrl->getLinkTarget($this,
'deleteSubFolder')
228 $this->
ctrl->clearParameters($this);
231 protected function showFolder(
bool $oneConfirmationDialogueRendered =
false): void
233 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.mail.html',
'Services/Mail');
234 $this->tpl->setTitle($this->
lng->txt(
'mail'));
236 $isTrashFolder = $this->currentFolderId === $this->mbox->getTrashFolder();
239 if (!$this->errorDelete && $isTrashFolder &&
'deleteMails' === $this->
parseCommand($this->
ctrl->getCmd())) {
241 $confirmationGui->setHeaderText($this->
lng->txt(
'mail_sure_delete'));
243 foreach ($selected_mail_ids as $mailId) {
244 $confirmationGui->addHiddenItem(
'mail_id[]', (
string) $mailId);
246 $this->
ctrl->setParameter($this,
'mobj_id', $this->currentFolderId);
247 $confirmationGui->setFormAction($this->
ctrl->getFormAction($this,
'showFolder'));
248 $this->
ctrl->clearParameters($this);
249 $confirmationGui->setConfirm($this->
lng->txt(
'confirm'),
'confirmDeleteMails');
250 $confirmationGui->setCancel($this->
lng->txt(
'cancel'),
'showFolder');
251 $this->tpl->setVariable(
'CONFIRMATION', $confirmationGui->getHTML());
252 $oneConfirmationDialogueRendered =
true;
256 $mtree->setTableNames(
'mail_tree',
'mail_obj_data');
258 $isUserSubFolder =
false;
259 $isUserRootFolder =
false;
261 $folder_d = $mtree->getNodeData($this->currentFolderId);
262 if ($folder_d[
'm_type'] ===
'user_folder') {
263 $isUserSubFolder =
true;
264 } elseif ($folder_d[
'm_type'] ===
'local') {
265 $isUserRootFolder =
true;
269 $mailtable->setSelectedItems($selected_mail_ids);
272 $mailtable->prepareHTML();
274 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt($e->getMessage()) !==
'-' . $e->getMessage() .
'-' ?
275 $this->
lng->txt($e->getMessage()) :
279 $table_html = $mailtable->getHTML();
281 if (!$oneConfirmationDialogueRendered && !$this->confirmTrashDeletion) {
282 $this->
toolbar->setFormAction($this->
ctrl->getFormAction($this,
'showFolder'));
284 if ($isUserRootFolder || $isUserSubFolder) {
289 if ($this->confirmTrashDeletion && $mailtable->isTrashFolder() && $mailtable->getNumberOfMails() > 0) {
291 $confirmationGui->setHeaderText($this->
lng->txt(
'mail_empty_trash_confirmation'));
292 $this->
ctrl->setParameter($this,
'mobj_id', $this->currentFolderId);
293 $confirmationGui->setFormAction($this->
ctrl->getFormAction($this,
'performEmptyTrash'));
294 $this->
ctrl->clearParameters($this);
295 $confirmationGui->setConfirm($this->
lng->txt(
'confirm'),
'performEmptyTrash');
296 $confirmationGui->setCancel($this->
lng->txt(
'cancel'),
'showFolder');
297 $this->tpl->setVariable(
'CONFIRMATION', $confirmationGui->getHTML());
300 $this->tpl->setVariable(
'MAIL_TABLE', $table_html);
301 $this->tpl->printToStdout();
306 if ($a_show_confirm) {
308 $this->
ctrl->setParameter($this,
'mobj_id', $this->currentFolderId);
309 $confirmationGui->setFormAction($this->
ctrl->getFormAction($this,
'showFolder'));
310 $this->
ctrl->clearParameters($this);
311 $confirmationGui->setHeaderText($this->
lng->txt(
'mail_sure_delete_folder'));
312 $confirmationGui->setCancel($this->
lng->txt(
'cancel'),
'showFolder');
313 $confirmationGui->setConfirm($this->
lng->txt(
'confirm'),
'performDeleteSubFolder');
314 $this->tpl->setVariable(
'CONFIRMATION', $confirmationGui->getHTML());
327 $parentFolderId = $this->mbox->getParentFolderId($this->currentFolderId);
328 if ($parentFolderId > 0 && $this->mbox->deleteFolder($this->currentFolderId)) {
329 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_folder_deleted'),
true);
330 $this->
ctrl->setParameterByClass(ilMailGUI::class,
'mobj_id', $parentFolderId);
331 $this->
ctrl->redirectByClass(ilMailGUI::class);
333 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'mail_error_delete'));
341 $this->
ctrl->setParameter($this,
'mobj_id', $this->currentFolderId);
342 $form->setFormAction($this->
ctrl->getFormAction($this,
'performAddSubFolder'));
343 $this->
ctrl->clearParameters($this);
344 if (
'edit' === $mode) {
345 $form->addCommandButton(
'performRenameSubFolder', $this->
lng->txt(
'save'));
346 $form->setTitle($this->
lng->txt(
'mail_rename_folder'));
348 $form->addCommandButton(
'performAddSubFolder', $this->
lng->txt(
'save'));
349 $form->setTitle($this->
lng->txt(
'mail_add_folder'));
351 $form->addCommandButton(
'showFolder', $this->
lng->txt(
'cancel'));
354 $title->setRequired(
true);
355 $form->addItem($title);
363 $isFormValid = $form->checkInput();
364 $form->setValuesByPost();
370 $newFolderId = $this->mbox->addFolder($this->currentFolderId, $form->getInput(
'subfolder_title'));
371 if ($newFolderId > 0) {
372 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'mail_folder_created'),
true);
373 $this->
ctrl->setParameterByClass(ilMailGUI::class,
'mobj_id', $newFolderId);
374 $this->
ctrl->redirectByClass(ilMailGUI::class);
377 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'mail_folder_exists'));
383 if (null === $form) {
387 $this->tpl->setTitle($this->
lng->txt(
'mail'));
388 $this->tpl->setContent($form->getHTML());
389 $this->tpl->printToStdout();
395 $isFormValid = $form->checkInput();
396 $form->setValuesByPost();
402 $folderData = $this->mbox->getFolderData($this->currentFolderId);
403 if ($folderData === null) {
404 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'mail_operation_on_invalid_folder'),
true);
405 $this->
ctrl->setParameterByClass(ilMailGUI::class,
'mobj_id', $this->mbox->getInboxFolder());
406 $this->
ctrl->redirectByClass(ilMailGUI::class);
409 if ($folderData[
'title'] === $form->getInput(
'subfolder_title')) {
414 if ($this->mbox->renameFolder($this->currentFolderId, $form->getInput(
'subfolder_title'))) {
415 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'mail_folder_name_changed'),
true);
416 $this->
ctrl->setParameterByClass(ilMailGUI::class,
'mobj_id', $this->currentFolderId);
417 $this->
ctrl->redirectByClass(ilMailGUI::class);
420 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'mail_folder_exists'));
426 if (null === $form) {
428 $form->setValuesByArray(
429 [
'subfolder_title' => $this->mbox->getFolderData($this->currentFolderId)[
'title'] ??
'']
433 $this->tpl->setTitle($this->
lng->txt(
'mail'));
434 $this->tpl->setContent($form->getHTML());
435 $this->tpl->printToStdout();
444 if ($this->
http->wrapper()->post()->has(
'mail_id')) {
445 $mailIds = $this->
http->wrapper()->post()->retrieve(
451 if ($mailIds === [] && !$ignoreHttpGet) {
453 if ($this->
http->wrapper()->query()->has(
'mail_id')) {
454 $mailId = $this->
http->wrapper()->query()->retrieve(
'mail_id', $this->
refinery->kindlyTo()->int());
456 if (is_numeric($mailId)) {
457 $mailIds = [$mailId];
461 return array_filter(array_map(
'intval', $mailIds));
467 if ($mailIds !== []) {
468 $this->umail->markRead($mailIds);
469 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'));
471 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_select_one'));
480 if ($mailIds !== []) {
481 $this->umail->markUnread($mailIds);
482 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'));
484 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_select_one'));
493 if (1 !== count($mailIds)) {
495 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_select_one'));
500 if ($this->
http->wrapper()->query()->has(
'folder_id')) {
501 $newFolderId = $this->
http->wrapper()->query()->retrieve(
506 $redirectFolderId = $newFolderId;
508 foreach ($mailIds as $mailId) {
509 $mailData = $this->umail->getMail($mailId);
510 if (isset($mailData[
'folder_id']) &&
511 is_numeric($mailData[
'folder_id']) &&
512 (
int) $mailData[
'folder_id'] > 0
514 $redirectFolderId = (
int) $mailData[
'folder_id'];
519 if ($this->umail->moveMailsToFolder($mailIds, $newFolderId)) {
520 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'mail_moved'),
true);
521 $this->
ctrl->setParameter($this,
'mobj_id', $redirectFolderId);
522 $this->
ctrl->redirect($this,
'showFolder');
524 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'mail_move_error'));
532 if ($mailIds === []) {
534 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_select_one'));
539 if ($this->umail->moveMailsToFolder($mailIds, $folderId)) {
540 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'mail_moved'),
true);
541 $this->
ctrl->setParameter($this,
'mobj_id', $this->currentFolderId);
542 $this->
ctrl->redirect($this,
'showFolder');
544 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'mail_move_error'));
551 $trashFolderId = $this->mbox->getTrashFolder();
554 if ($trashFolderId === $this->currentFolderId) {
555 if ($mailIds === []) {
556 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_select_one'));
557 $this->errorDelete =
true;
559 } elseif ($mailIds === []) {
560 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_select_one'));
561 } elseif ($this->umail->moveMailsToFolder($mailIds, $trashFolderId)) {
562 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'mail_moved_to_trash'),
true);
563 $this->
ctrl->setParameter($this,
'mobj_id', $this->currentFolderId);
564 $this->
ctrl->redirect($this,
'showFolder');
566 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'mail_move_error'));
575 if ($mailIds === []) {
577 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_select_one'));
582 $this->umail->deleteMails($mailIds);
583 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'mail_deleted'),
true);
584 $this->
ctrl->setParameter($this,
'mobj_id', $this->currentFolderId);
585 $this->
ctrl->redirect($this,
'showFolder');
591 protected function showMail():
void 594 if ($this->
http->wrapper()->query()->has(
'mail_id')) {
595 $mailId = $this->
http->wrapper()->query()->retrieve(
'mail_id', $this->
refinery->kindlyTo()->int());
599 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
602 $mailData = $this->umail->getMail($mailId);
603 if ($mailData === null) {
604 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
607 $this->umail->markRead([$mailId]);
609 $this->tpl->setTitle($this->
lng->txt(
'mail_mails_of'));
611 $this->
tabs->clearTargets();
612 $this->
ctrl->setParameter($this,
'mobj_id', $mailData[
'folder_id']);
613 $this->
tabs->setBackTarget(
614 $this->
lng->txt(
'back_to_folder'),
615 $this->
ctrl->getFormAction($this,
'showFolder')
617 $this->
ctrl->clearParameters($this);
619 $this->
ctrl->setParameter($this,
'mail_id', $mailId);
620 $this->
ctrl->setParameter($this,
'mobj_id', $mailData[
'folder_id']);
621 $this->
toolbar->setFormAction($this->
ctrl->getFormAction($this,
'showMail'));
622 $this->
ctrl->clearParameters($this);
625 $form->setId(
'MailContent');
626 $form->setPreventDoubleSubmission(
false);
627 $form->setTableWidth(
'100%');
628 $this->
ctrl->setParameter($this,
'mobj_id', $mailData[
'folder_id']);
629 $this->
ctrl->setParameter($this,
'mail_id', $mailId);
630 $form->setFormAction($this->
ctrl->getFormAction($this,
'showMail'));
631 $this->
ctrl->clearParameters($this);
632 $form->setTitle($this->
lng->txt(
'mail_mails_of'));
637 if ($sender instanceof
ilObjUser && $sender->getId() !== 0 && !$sender->isAnonymous()) {
638 $this->
ctrl->setParameterByClass(
639 ilMailFormGUI::class,
641 $mailData[
'folder_id']
643 $this->
ctrl->setParameterByClass(ilMailFormGUI::class,
'mail_id', $mailId);
645 $replyBtn = $this->ui_factory->button()->primary(
646 $this->
lng->txt(
'reply'),
647 $this->
ctrl->getLinkTargetByClass(ilMailFormGUI::class)
649 $this->
toolbar->addStickyItem($replyBtn);
650 $this->
ctrl->clearParametersByClass(ilMailFormGUI::class);
653 $this->
ctrl->setParameterByClass(ilMailFormGUI::class,
'mobj_id', $mailData[
'folder_id']);
654 $this->
ctrl->setParameterByClass(ilMailFormGUI::class,
'mail_id', $mailId);
656 if ($replyBtn === null) {
657 $fwdBtn = $this->ui_factory->button()->primary(
658 $this->
lng->txt(
'forward'),
659 $this->
ctrl->getLinkTargetByClass(ilMailFormGUI::class)
661 $this->
toolbar->addStickyItem($fwdBtn);
663 $fwdBtn = $this->ui_factory->button()->standard(
664 $this->
lng->txt(
'forward'),
665 $this->
ctrl->getLinkTargetByClass(ilMailFormGUI::class)
667 $this->
toolbar->addComponent($fwdBtn);
669 $this->
ctrl->clearParametersByClass(ilMailFormGUI::class);
671 if ($sender && $sender->getId() && !$sender->isAnonymous()) {
672 $linked_fullname = $sender->getPublicName();
674 $sender->getPersonalPicturePath(
'xsmall'),
675 $sender->getPublicName(),
684 $this->
ctrl->setParameter($this,
'mail_id', $mailId);
685 $this->
ctrl->setParameter($this,
'mobj_id', $mailData[
'folder_id']);
686 $this->
ctrl->setParameter($this,
'user', $sender->getId());
687 $linked_fullname =
'<br /><a class="mailusername" href="' . $this->
ctrl->getLinkTarget(
690 ) .
'" title="' . $linked_fullname .
'">' . $linked_fullname .
'</a>';
691 $this->
ctrl->clearParameters($this);
695 $from->setHtml($picture .
' ' . $linked_fullname);
696 } elseif (!$sender || !$sender->getId()) {
698 $from->setHtml(trim(($mailData[
'import_name'] ??
'') .
' (' . $this->
lng->txt(
'user_deleted') .
')'));
714 $form->addItem($from);
718 $this->umail->formatNamesForOutput($mailData[
'rcp_to'] ??
''),
723 if ($mailData[
'rcp_cc']) {
726 $this->umail->formatNamesForOutput($mailData[
'rcp_cc'] ??
''),
732 if ($mailData[
'rcp_bcc']) {
735 $this->umail->formatNamesForOutput($mailData[
'rcp_bcc'] ??
''),
738 $form->addItem($bcc);
743 $form->addItem($subject);
749 $form->addItem($date);
755 if ($mailData[
'attachments']) {
759 foreach ($mailData[
'attachments'] as $file) {
763 $att->
setHtml($radiog->render());
764 $form->addCommandButton(
'deliverFile', $this->
lng->txt(
'download'));
765 $form->addItem($att);
768 $isTrashFolder =
false;
769 if ($this->mbox->getTrashFolder() === $mailData[
'folder_id']) {
770 $isTrashFolder =
true;
773 $currentFolderData = $this->mbox->getFolderData((
int) $mailData[
'folder_id']);
774 if ($currentFolderData === null) {
775 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'mail_operation_on_invalid_folder'),
true);
776 $this->
ctrl->setParameterByClass(ilMailGUI::class,
'mobj_id', $this->mbox->getInboxFolder());
777 $this->
ctrl->redirectByClass(ilMailGUI::class);
780 $this->
ctrl->setParameter($this,
'mobj_id', $this->currentFolderId);
783 $currentFolderData[
'type'] ===
'user_folder' ? $currentFolderData[
'title'] : $this->
lng->txt(
784 'mail_' . $currentFolderData[
'title']
786 $this->
ctrl->getLinkTarget($this,
'showFolder')
788 $this->
ctrl->clearParameters($this);
789 $this->
tabs->activateTab(
'current_folder');
792 $folders = $this->mbox->getSubFolders();
793 foreach ($folders as $folder) {
794 if (($folder[
'type'] !==
'trash' || !$isTrashFolder) &&
795 $folder[
'obj_id'] !== $mailData[
'folder_id']) {
796 $folder_name = $folder[
'title'];
797 if ($folder[
'type'] !==
'user_folder') {
798 $folder_name = $this->
lng->txt(
'mail_' . $folder[
'title']);
801 $move_links[] = $this->ui_factory->button()->shy(
803 $this->
lng->txt(
'mail_move_to_folder_x'),
805 ) . ($folder[
'type'] ===
'trash' ?
' (' . $this->
lng->txt(
'delete') .
')' :
''),
807 )->withOnLoadCode(
static fn(
$id):
string =>
" 808 document.getElementById('$id').addEventListener('click', function(e) { 809 const frm = this.closest('form'), 810 action = new URL(frm.action), 811 action_params = new URLSearchParams(action.search); 813 action_params.delete('cmd'); 814 action_params.append('cmd', 'moveSingleMail'); 815 action_params.delete('folder_id'); 816 action_params.append('folder_id', '" . $folder[
'obj_id'] .
"'); 818 action.search = action_params.toString(); 820 frm.action = action.href; 831 if ($isTrashFolder) {
832 $deleteBtn = $this->ui_factory->button()
833 ->standard($this->
lng->txt(
'delete'),
'#')
835 document.getElementById('$id').addEventListener('click', function() { 836 const frm = this.closest('form'), 837 action = new URL(frm.action), 838 action_params = new URLSearchParams(action.search); 840 action_params.delete('cmd'); 841 action_params.append('cmd', 'deleteMails'); 843 action.search = action_params.toString(); 845 frm.action = action.href; 850 $this->
toolbar->addComponent($deleteBtn);
853 if ($move_links !== []) {
855 $this->ui_factory->dropdown()->standard($move_links)
856 ->withLabel($this->
lng->txt(
'mail_move_to_folder_btn_label'))
860 $this->
toolbar->addSeparator();
862 $this->
ctrl->setParameter($this,
'mail_id', $mailId);
863 $this->
ctrl->setParameter($this,
'mobj_id', $mailData[
'folder_id']);
864 $print_url = $this->
ctrl->getLinkTarget($this,
'printMail');
865 $this->
ctrl->clearParameters($this);
866 $print_btn = $this->ui_factory->button()
867 ->standard($this->
lng->txt(
'print'),
'#')
869 document.getElementById('$id').addEventListener('click', function() { 870 const frm = this.closest('form'), 873 frm.action = '$print_url'; 874 frm.target = '_blank'; 878 frm.removeAttribute('target'); 883 $this->
toolbar->addComponent($print_btn);
885 $prevMail = $this->umail->getPreviousMail($mailId);
886 $nextMail = $this->umail->getNextMail($mailId);
887 if (is_array($prevMail) || is_array($nextMail)) {
888 $this->
toolbar->addSeparator();
890 if ($prevMail && $prevMail[
'mail_id']) {
891 $this->
ctrl->setParameter($this,
'mail_id', $prevMail[
'mail_id']);
892 $this->
ctrl->setParameter($this,
'mobj_id', $this->currentFolderId);
893 $prevBtn = $this->ui_factory->button()
895 $this->
lng->txt(
'previous'),
896 $this->
ctrl->getLinkTarget($this,
'showMail')
898 $this->
toolbar->addComponent($prevBtn);
899 $this->
ctrl->clearParameters($this);
902 if ($nextMail && $nextMail[
'mail_id']) {
903 $this->
ctrl->setParameter($this,
'mail_id', $nextMail[
'mail_id']);
904 $this->
ctrl->setParameter($this,
'mobj_id', $this->currentFolderId);
905 $nextBtn = $this->ui_factory->button()
907 $this->
lng->txt(
'next'),
908 $this->
ctrl->getLinkTarget($this,
'showMail')
910 $this->
toolbar->addComponent($nextBtn);
911 $this->
ctrl->clearParameters($this);
915 $this->tpl->setContent($form->getHTML());
916 $this->tpl->printToStdout();
921 $tplprint =
new ilTemplate(
'tpl.mail_print.html',
true,
true,
'Services/Mail');
924 if ($this->
http->wrapper()->query()->has(
'mail_id')) {
925 $mailId = $this->
http->wrapper()->query()->retrieve(
'mail_id', $this->
refinery->kindlyTo()->int());
927 $mailData = $this->umail->getMail($mailId);
931 $tplprint->setVariable(
'TXT_FROM', $this->
lng->txt(
'from'));
932 if ($sender instanceof
ilObjUser && $sender->getId() !== 0 && !$sender->isAnonymous()) {
933 $tplprint->setVariable(
'FROM', $sender->getPublicName());
934 } elseif (!$sender instanceof
ilObjUser || 0 === $sender->getId()) {
935 $tplprint->setVariable(
937 trim(($mailData[
'import_name'] ??
'') .
' (' . $this->
lng->txt(
'user_deleted') .
')')
943 $tplprint->setVariable(
'TXT_TO', $this->
lng->txt(
'mail_to'));
944 $tplprint->setVariable(
'TO', $mailData[
'rcp_to']);
946 if ($mailData[
'rcp_cc']) {
947 $tplprint->setCurrentBlock(
'cc');
948 $tplprint->setVariable(
'TXT_CC', $this->
lng->txt(
'mail_cc'));
949 $tplprint->setVariable(
'CC', $mailData[
'rcp_cc']);
950 $tplprint->parseCurrentBlock();
953 if ($mailData[
'rcp_bcc']) {
954 $tplprint->setCurrentBlock(
'bcc');
955 $tplprint->setVariable(
'TXT_BCC', $this->
lng->txt(
'mail_bcc'));
956 $tplprint->setVariable(
'BCC', $mailData[
'rcp_bcc']);
957 $tplprint->parseCurrentBlock();
960 $tplprint->setVariable(
'TXT_SUBJECT', $this->
lng->txt(
'subject'));
961 $tplprint->setVariable(
'SUBJECT', htmlspecialchars($mailData[
'm_subject']));
963 $tplprint->setVariable(
'TXT_DATE', $this->
lng->txt(
'date'));
964 $tplprint->setVariable(
969 $tplprint->setVariable(
'TXT_MESSAGE', $this->
lng->txt(
'message'));
970 $tplprint->setVariable(
'MAIL_MESSAGE', nl2br(htmlspecialchars($mailData[
'm_message'])));
978 if ($this->
http->wrapper()->query()->has(
'mail_id')) {
979 $mailId = $this->
http->wrapper()->query()->retrieve(
'mail_id', $this->
refinery->kindlyTo()->int());
983 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
987 if ($this->
http->wrapper()->post()->has(
'filename')) {
988 $filename = $this->
http->wrapper()->post()->retrieve(
'filename', $this->
refinery->kindlyTo()->string());
998 while (str_contains((
string)
$filename,
'..')) {
999 $filename = str_replace(
'..',
'', $filename);
1010 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_select_attachment'));
1014 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt($e->getMessage()),
true);
1015 $this->
ctrl->setParameter($this,
'mobj_id', $this->currentFolderId);
1016 $this->
ctrl->redirect($this);
1024 if ($this->
http->wrapper()->query()->has(
'mail_id')) {
1025 $mailId = $this->
http->wrapper()->query()->retrieve(
'mail_id', $this->
refinery->kindlyTo()->int());
1028 $mailData = $this->umail->getMail((
int) $mailId);
1029 if (null === $mailData || [] === (array) $mailData[
'attachments']) {
1034 if ($this->
http->wrapper()->query()->has(
'type')) {
1035 $type = $this->
http->wrapper()->query()->retrieve(
'type', $this->
refinery->kindlyTo()->string());
1039 if (count($mailData[
'attachments']) === 1) {
1040 $attachment = current($mailData[
'attachments']);
1043 if (
'draft' === $type) {
1044 if (!$mailFileData->checkFilesExist([$attachment])) {
1047 $pathToFile = $mailFileData->getAbsoluteAttachmentPoolPathByFilename($attachment);
1048 $fileName = $attachment;
1050 $file = $mailFileData->getAttachmentPathAndFilenameByMd5Hash(
1054 $pathToFile = $file[
'path'];
1055 $fileName = $file[
'filename'];
1062 $mailFileData->deliverAttachmentsAsZip(
1063 $mailData[
'm_subject'],
1065 $mailData[
'attachments'],
1070 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt($e->getMessage()),
true);
1071 $this->
ctrl->setParameter($this,
'mobj_id', $this->currentFolderId);
1072 $this->
ctrl->redirect($this);
1080 $this->currentFolderId,
1082 $this->currentFolderId === $this->mbox->getTrashFolder(),
1083 $this->currentFolderId === $this->mbox->getSentFolder(),
1084 $this->currentFolderId === $this->mbox->getDraftsFolder()
1093 $table->resetOffset();
1094 $table->writeFilterToSession();
1102 $table->resetOffset();
1103 $table->resetFilter();
deleteSubFolder(bool $a_show_confirm=true)
getAttachmentPathAndFilenameByMd5Hash(string $md5FileHash, int $mailId)
Interface GlobalHttpState.
static get(string $a_var)
getMailIdsFromRequest(bool $ignoreHttpGet=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An entity that renders components to a string output.
readonly GlobalHttpState $http
readonly ilCtrlInterface $ctrl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class handles all operations on files (attachments) in directory ilias_data/mail.
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
static _getIliasMailerName()
readonly ilGlobalTemplateInterface $tpl
static _lookupPref(int $a_usr_id, string $a_keyword)
readonly Factory $ui_factory
static img(string $a_src, ?string $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
bool $confirmTrashDeletion
withOnLoadCode(Closure $binder)
addSubFolder(ilPropertyFormGUI $form=null)
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
static htmlencodePlainString(string $a_str, bool $a_make_links_clickable, bool $a_detect_goto_links=false)
Encodes a plain text string into HTML for display in a browser.
GUI class for public user profile presentation.
parseFolderIdFromCommand(string $command)
static http()
Fetches the global http state from ILIAS.
getSubFolderForm(string $mode='create')
Mail Box class Base class for creating and handling mail boxes.
addSubFolderCommands(bool $isUserSubFolder=false)
renameSubFolder(ilPropertyFormGUI $form=null)
showFolder(bool $oneConfirmationDialogueRendered=false)
parseCommand(string $originalCommand)
readonly Refinery $refinery
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
Error Handling & global info handling.
readonly Renderer $ui_renderer
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
readonly ilToolbarGUI $toolbar
readonly ilErrorHandling $error
static set(string $a_var, $a_val)
Set a value.
static _lookupLogin(int $a_user_id)