19declare(strict_types=1);
86 $this->tpl =
$DIC->ui()->mainTemplate();
87 $this->
ctrl = $DIC->ctrl();
88 $this->
lng = $DIC->language();
89 $this->
toolbar = $DIC->toolbar();
90 $this->
user = $DIC->user();
91 $this->
tabs = $DIC->tabs();
92 $this->
http = $DIC->http();
94 $this->
error = $DIC[
'ilErr'];
95 $this->ui_factory =
$DIC->ui()->factory();
96 $this->ui_renderer =
$DIC->ui()->renderer();
97 $this->ui_service =
$DIC->uiService();
118 $this->umail =
new ilMail($this->
user->getId());
121 if ($this->
http->wrapper()->post()->has(self::PARAM_FOLDER_ID)) {
122 $folder_id = $this->
http->wrapper()->post()->retrieve(
123 self::PARAM_FOLDER_ID,
126 } elseif ($this->
http->wrapper()->query()->has(self::PARAM_FOLDER_ID)) {
127 $folder_id = $this->
http->wrapper()->query()->retrieve(
128 self::PARAM_FOLDER_ID,
132 $folder_id = $this->
refinery->byTrying([
134 $this->refinery->always(0),
138 if ($folder_id === 0 || !$this->mbox->isOwnedFolder($folder_id)) {
139 $folder_id = $this->mbox->getInboxFolder();
142 $folder = $this->mbox->getFolderData($folder_id);
144 $this->tpl->setOnScreenMessage(
146 $this->
lng->txt(
'mail_operation_on_invalid_folder')
148 $this->tpl->printToStdout();
157 $next_class = $this->
ctrl->getNextClass($this) ??
'';
158 switch (strtolower($next_class)) {
159 case strtolower(ilContactGUI::class):
164 $cmd = $this->
ctrl->getCmd() ??
'';
166 self::CMD_ADD_SUB_FOLDER,
self::CMD_DELETE_MAILS,
self::CMD_DELETE_SUB_FOLDER,
self::CMD_DELIVER_FILE,
self::CMD_EMPTY_TRASH,
self::CMD_MOVE_SINGLE_MAIL,
self::CMD_PRINT_MAIL,
self::CMD_RENAME_SUB_FOLDER,
self::CMD_SHOW_MAIL,
self::CMD_SHOW_FOLDER,
self::CMD_SHOW_USER, self::CMD_TABLE_ACTION => $this->{$cmd}(
175 $action = $this->
http->wrapper()->query()->retrieve(
176 self::URL_BUILDER_PREFIX . URLBuilder::SEPARATOR . self::PARAM_ACTION,
178 $this->refinery->kindlyTo()->string(),
179 $this->refinery->always(
'')
184 $for_all_entries = implode(
186 $this->
http->wrapper()->query()->retrieve(
187 self::URL_BUILDER_PREFIX . URLBuilder::SEPARATOR . self::PARAM_MAIL_ID,
188 $this->refinery->byTrying([
189 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->string()),
190 $this->refinery->always([])
195 if ($for_all_entries) {
202 if (empty($mail_ids)) {
204 if ($action === MailFolderTableUI::ACTION_DELETE) {
205 $modal = $this->ui_factory->modal()->lightbox(
206 $this->ui_factory->modal()->lightboxTextPage(
207 $this->ui_renderer->render(
208 $this->ui_factory->messageBox()->failure($this->lng->txt(
'mail_select_one'))
210 $this->lng->txt(
'delete'),
213 $this->
http->saveResponse(
214 $this->
http->response()->withBody(
215 Streams::ofString($this->ui_renderer->renderAsync($modal))
218 $this->
http->sendResponse();
219 $this->
http->close();
221 $this->tpl->setOnScreenMessage(
223 $this->
lng->txt(
'mail_select_one'),
231 case MailFolderTableUI::ACTION_SHOW:
235 case MailFolderTableUI::ACTION_EDIT:
236 $this->
ctrl->setParameterByClass(
237 ilMailFormGUI::class,
238 self::PARAM_FOLDER_ID,
239 (
string) $this->folder->getFolderId()
241 $this->
ctrl->setParameterByClass(ilMailFormGUI::class, self::PARAM_MAIL_ID, (
string) $mail_ids[0]);
243 $this->
ctrl->redirectByClass(ilMailFormGUI::class);
246 case MailFolderTableUI::ACTION_REPLY:
247 $this->
ctrl->setParameterByClass(
248 ilMailFormGUI::class,
249 self::PARAM_FOLDER_ID,
250 (
string) $this->folder->getFolderId()
252 $this->
ctrl->setParameterByClass(ilMailFormGUI::class, self::PARAM_MAIL_ID, (
string) $mail_ids[0]);
254 $this->
ctrl->redirectByClass(ilMailFormGUI::class);
257 case MailFolderTableUI::ACTION_FORWARD:
258 $this->
ctrl->setParameterByClass(
259 ilMailFormGUI::class,
260 self::PARAM_FOLDER_ID,
261 (
string) $this->folder->getFolderId()
263 $this->
ctrl->setParameterByClass(ilMailFormGUI::class, self::PARAM_MAIL_ID, (
string) $mail_ids[0]);
265 $this->
ctrl->redirectByClass(ilMailFormGUI::class);
268 case MailFolderTableUI::ACTION_DOWNLOAD_ATTACHMENT:
272 case MailFolderTableUI::ACTION_PRINT:
276 case MailFolderTableUI::ACTION_PROFILE:
277 $mail_data = $this->umail->getMail($mail_ids[0] ?? 0);
280 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, (
string) $this->folder->getFolderId());
281 $this->
ctrl->setParameter($this, self::PARAM_USER_ID, (
string)
$user->
getId());
282 $this->
ctrl->redirect($this, self::CMD_SHOW_USER);
284 $this->tpl->setOnScreenMessage(
286 $this->
lng->txt(
'permission_denied'),
292 case MailFolderTableUI::ACTION_MARK_READ:
293 $this->umail->markRead($mail_ids);
294 $this->tpl->setOnScreenMessage(
296 $this->
lng->txt(
'saved_successfully'),
301 case MailFolderTableUI::ACTION_MARK_UNREAD:
302 $this->umail->markUnread($mail_ids);
303 $this->tpl->setOnScreenMessage(
305 $this->
lng->txt(
'saved_successfully'),
310 case MailFolderTableUI::ACTION_MOVE_TO:
311 $folder_id = $this->
http->wrapper()->query()->retrieve(
312 self::URL_BUILDER_PREFIX . URLBuilder::SEPARATOR . self::PARAM_TARGET_FOLDER,
315 if (empty($folder_id)) {
316 $this->tpl->setOnScreenMessage(
318 $this->
lng->txt(
'mail_move_error')
320 } elseif ($this->umail->moveMailsToFolder($mail_ids, $folder_id)) {
321 $this->tpl->setOnScreenMessage(
323 $this->
lng->txt(
'mail_moved'),
327 $this->tpl->setOnScreenMessage(
329 $this->
lng->txt(
'mail_move_error')
334 case MailFolderTableUI::ACTION_DELETE:
339 $this->tpl->setOnScreenMessage(
341 $this->
lng->txt(
'permission_denied')
351 $this->umail->deleteMailsOfFolder($this->mbox->getTrashFolder());
352 $this->tpl->setOnScreenMessage(
354 $this->
lng->txt(
'mail_deleted'),
365 $usr_id = $this->
http->wrapper()->query()->retrieve(
367 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->refinery->always(0)])
370 $this->tpl->setVariable(
'TBL_TITLE', implode(
' ', [
371 $this->
lng->txt(
'profile_of'),
375 $this->tpl->setVariable(
'TBL_TITLE_IMG_ALT', $this->
lng->txt(
'public_profile'));
379 $mail_id = $this->
http->wrapper()->query()->retrieve(
381 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->refinery->always(0)])
385 $this->
ctrl->setParameter($this, self::PARAM_MAIL_ID, $mail_id);
386 $this->
tabs->clearTargets();
387 $this->
tabs->setBackTarget($this->
lng->txt(
'back'), $this->ctrl->getLinkTarget($this, self::CMD_SHOW_MAIL));
389 $this->
tabs->clearTargets();
390 $this->
tabs->setBackTarget(
391 $this->
lng->txt(
'back_to_folder'),
392 $this->ctrl->getLinkTarget($this, self::CMD_SHOW_FOLDER)
396 $this->
ctrl->clearParameters($this);
398 $this->tpl->setTitle($this->
lng->txt(
'mail'));
399 $this->tpl->setContent($this->
ctrl->getHTML($profile_gui));
400 $this->tpl->printToStdout();
406 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $this->folder->getFolderId());
408 if ($this->folder->isUserLocalFolder()) {
410 $this->ui_factory->button()->standard(
411 $this->lng->txt(
'mail_add_subfolder'),
412 $this->ctrl->getLinkTarget($this, self::CMD_ADD_SUB_FOLDER)
417 if ($this->folder->isUserFolder()) {
419 $this->ui_factory->button()->standard(
420 $this->lng->txt(
'rename'),
421 $this->ctrl->getLinkTarget($this, self::CMD_RENAME_SUB_FOLDER)
425 $components[] = $modal = $this->ui_factory->modal()->interruptive(
426 $this->
lng->txt(
'delete'),
427 $this->lng->txt(
'mail_sure_delete_folder'),
428 $this->ctrl->getLinkTarget($this, self::CMD_DELETE_SUB_FOLDER)
431 $this->ui_factory->button()->standard(
432 $this->lng->txt(
'delete'),
435 ->withOnClick($modal->getShowSignal())
439 if ($this->folder->isTrash()) {
440 $components[] = $modal = $this->ui_factory->modal()->interruptive(
441 $this->
lng->txt(
'mail_empty_trash'),
442 $this->lng->txt(
'mail_empty_trash_confirmation'),
443 $this->ctrl->getLinkTarget($this, self::CMD_EMPTY_TRASH)
446 $this->ui_factory->button()->standard(
447 $this->lng->txt(
'mail_empty_trash'),
449 )->withOnClick($modal->getShowSignal())
459 $this->data_factory->uri(
461 $this->ctrl->getLinkTarget($this, self::CMD_TABLE_ACTION)
464 )->acquireParameters(
465 [self::URL_BUILDER_PREFIX],
468 self::PARAM_TARGET_FOLDER
476 $this->mbox->getSubFolders(),
478 $this->getFilteredSearch(),
483 $this->http->request(),
486 $this->user->getDateFormat(),
487 $this->user->getTimeFormat(),
488 new DateTimeZone($this->
user->getTimeZone())
494 $this->tpl->setTitle($this->folder->getTitle());
495 $this->tpl->setContent($this->ui_renderer->render(
$components));
496 $this->tpl->printToStdout();
501 $this->
ctrl->clearParameters($this);
502 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $this->folder->getFolderId());
503 $this->
ctrl->redirect($this, self::CMD_SHOW_FOLDER);
508 $parent_folder_id = $this->mbox->getParentFolderId($this->folder->getFolderId());
509 if ($parent_folder_id > 0 && $this->mbox->deleteFolder($this->folder->getFolderId())) {
510 $this->tpl->setOnScreenMessage(
512 $this->
lng->txt(
'mail_folder_deleted'),
515 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $parent_folder_id);
516 $this->
ctrl->redirect($this, self::CMD_SHOW_FOLDER);
518 $this->tpl->setOnScreenMessage(
520 $this->
lng->txt(
'mail_error_delete'),
529 $form = $this->ui_factory->input()->container()->form()->standard(
530 $this->
ctrl->getFormAction($this, self::CMD_ADD_SUB_FOLDER),
532 'folder' => $this->ui_factory->input()->field()->section([
533 'title' => $this->ui_factory->input()->field()->text($this->lng->txt(
'title'))->withRequired(
true)
534 ], $this->lng->txt(
'mail_add_folder'))
538 $request = $this->
http->request();
539 if ($request->getMethod() ===
'POST') {
540 $form = $form->withRequest($request);
541 $data = $form->getData();
542 if (!empty(
$data[
'folder'][
'title'])) {
543 $new_folder_id = $this->mbox->addFolder(
544 $this->folder->getFolderId(),
545 (
string)
$data[
'folder'][
'title']
547 if ($new_folder_id > 0) {
548 $this->tpl->setOnScreenMessage(
550 $this->
lng->txt(
'mail_folder_created'),
553 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $new_folder_id);
554 $this->
ctrl->redirect($this, self::CMD_SHOW_FOLDER);
556 $this->tpl->setOnScreenMessage(
558 $this->
lng->txt(
'mail_folder_exists')
563 $this->tpl->setContent($this->ui_renderer->render($form));
564 $this->tpl->printToStdout();
569 $form = $this->ui_factory->input()->container()->form()->standard(
570 $this->
ctrl->getFormAction($this, self::CMD_RENAME_SUB_FOLDER),
572 'folder' => $this->ui_factory->input()->field()->section([
573 'title' => $this->ui_factory->input()->field()->text($this->lng->txt(
'title'))->withRequired(
true)
574 ], $this->lng->txt(
'mail_rename_folder'))
578 $request = $this->
http->request();
579 if ($request->getMethod() ===
'POST') {
580 $form = $form->withRequest($request);
581 $data = $form->getData();
582 if (!empty(
$data[
'folder'][
'title'])) {
583 if ($this->mbox->renameFolder($this->folder->getFolderId(), (
string)
$data[
'folder'][
'title'])) {
584 $this->tpl->setOnScreenMessage(
586 $this->
lng->txt(
'mail_folder_name_changed'),
591 $this->tpl->setOnScreenMessage(
593 $this->
lng->txt(
'mail_folder_exists')
598 $this->tpl->setContent($this->ui_renderer->render($form));
599 $this->tpl->printToStdout();
605 $this->
ctrl->getFormAction($this, self::CMD_SHOW_FOLDER),
609 $this->ui_service->filter(),
611 new DateTimeZone($this->
user->getTimeZone()),
636 self::URL_BUILDER_PREFIX . URLBuilder::SEPARATOR . self::PARAM_MAIL_ID,
638 self::PARAM_INTERRUPTIVE_ITEMS
643 $this->
http->wrapper()->post(),
644 $this->http->wrapper()->query()
647 if ($wrapper->has(
$param)) {
648 return $wrapper->retrieve(
651 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int()),
652 $this->refinery->always([])
669 if (count($mail_ids) !== 1) {
671 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_select_one'));
675 $new_folder_id = $this->
http->wrapper()->query()->retrieve(
677 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->refinery->always(0)])
679 $redirect_folder_id = $new_folder_id;
681 foreach ($mail_ids as $mail_id) {
682 $mail_data = $this->umail->getMail($mail_id);
683 if (isset($mail_data[
'folder_id']) &&
684 is_numeric($mail_data[
'folder_id']) &&
685 (
int) $mail_data[
'folder_id'] > 0) {
686 $redirect_folder_id = (
int) $mail_data[
'folder_id'];
691 if ($this->umail->moveMailsToFolder($mail_ids, $new_folder_id)) {
692 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'mail_moved'),
true);
693 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $redirect_folder_id);
694 $this->
ctrl->redirect($this, self::CMD_SHOW_FOLDER);
696 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'mail_move_error'));
703 if (!$this->folder->isTrash()) {
704 $this->tpl->setOnScreenMessage(
706 $this->
lng->txt(
'mail_operation_on_invalid_folder'),
713 $this->tpl->setOnScreenMessage(
715 $this->
lng->txt(
'mail_deleted'),
727 $user_timezone =
new DateTimeZone($this->
user->getTimeZone());
728 $records = $this->
getFilteredSearch()->forMailIds($mail_ids)->getPagedRecords(10, 0,
null,
null);
730 foreach ($records as $record) {
732 if (!empty($record->getSendTime())) {
733 $time = $record->getSendTime()->setTimezone($user_timezone);
734 $prefix = $time->format($this->
user->getDateFormat()->toString()) .
' ';
736 $items[] = $this->ui_factory->modal()->interruptiveItem()->standard(
737 (
string) $record->getMailId(),
738 $prefix . $this->refinery->encode()->htmlSpecialCharsAsEntities()->transform($record->getSubject())
742 $modal = $this->ui_factory->modal()->interruptive(
743 $this->
lng->txt(
'delete'),
744 $this->lng->txt(
'mail_sure_delete_' . (count($items) === 1 ?
's' :
'p')),
745 $this->
ctrl->getFormAction($this, self::CMD_DELETE_MAILS)
746 )->withAffectedItems($items);
748 $this->
http->saveResponse(
749 $this->
http->response()->withBody(
750 Streams::ofString($this->ui_renderer->renderAsync($modal))
753 $this->
http->sendResponse();
754 $this->
http->close();
757 protected function showMail(): void
763 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
766 $mail_data = $this->umail->getMail($mail_id);
767 if ($mail_data ===
null) {
768 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
771 $this->umail->markRead([$mail_id]);
773 $this->tpl->setTitle($this->
lng->txt(
'mail_mails_of'));
775 $this->
tabs->clearTargets();
776 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $mail_data[
'folder_id']);
777 $this->
tabs->setBackTarget(
778 $this->
lng->txt(
'back_to_folder'),
779 $this->ctrl->getFormAction($this, self::CMD_SHOW_FOLDER)
781 $this->
ctrl->clearParameters($this);
783 $this->
ctrl->setParameter($this, self::PARAM_MAIL_ID, $mail_id);
784 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $mail_data[
'folder_id']);
785 $this->
toolbar->setFormAction($this->
ctrl->getFormAction($this, self::CMD_SHOW_MAIL));
786 $this->
ctrl->clearParameters($this);
789 $form->setId(
'MailContent');
790 $form->setPreventDoubleSubmission(
false);
791 $form->setTableWidth(
'100%');
792 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $mail_data[
'folder_id']);
793 $this->
ctrl->setParameter($this, self::PARAM_MAIL_ID, $mail_id);
794 $form->setFormAction($this->
ctrl->getFormAction($this, self::CMD_SHOW_MAIL));
795 $this->
ctrl->clearParameters($this);
796 $form->setTitle($this->
lng->txt(
'mail_mails_of'));
801 if ($sender instanceof
ilObjUser && $sender->
getId() !== 0 && !$sender->isAnonymous()) {
802 $this->
ctrl->setParameterByClass(
803 ilMailFormGUI::class,
804 self::PARAM_FOLDER_ID,
805 $mail_data[
'folder_id']
807 $this->
ctrl->setParameterByClass(ilMailFormGUI::class, self::PARAM_MAIL_ID, $mail_id);
809 $reply_btn = $this->ui_factory->button()->primary(
810 $this->
lng->txt(
'reply'),
811 $this->ctrl->getLinkTargetByClass(ilMailFormGUI::class)
813 $this->
toolbar->addStickyItem($reply_btn);
814 $this->
ctrl->clearParametersByClass(ilMailFormGUI::class);
817 $this->
ctrl->setParameterByClass(ilMailFormGUI::class, self::PARAM_FOLDER_ID, $mail_data[
'folder_id']);
818 $this->
ctrl->setParameterByClass(ilMailFormGUI::class, self::PARAM_MAIL_ID, $mail_id);
820 if ($reply_btn ===
null) {
821 $fwd_btn = $this->ui_factory->button()->primary(
822 $this->
lng->txt(
'forward'),
823 $this->ctrl->getLinkTargetByClass(ilMailFormGUI::class)
825 $this->
toolbar->addStickyItem($fwd_btn);
827 $fwd_btn = $this->ui_factory->button()->standard(
828 $this->
lng->txt(
'forward'),
829 $this->ctrl->getLinkTargetByClass(ilMailFormGUI::class)
831 $this->
toolbar->addComponent($fwd_btn);
833 $this->
ctrl->clearParametersByClass(ilMailFormGUI::class);
835 if ($sender && $sender->getId() && !$sender->isAnonymous()) {
836 $linked_fullname = $sender->getPublicName();
837 $avatar = $this->ui_factory->symbol()->avatar()->picture(
838 $sender->getPersonalPicturePath(
'xsmall'),
839 $sender->getPublicName()
843 $this->
ctrl->setParameter($this, self::PARAM_MAIL_ID, $mail_id);
844 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $mail_data[
'folder_id']);
845 $this->
ctrl->setParameter($this, self::PARAM_USER_ID, $sender->getId());
846 $linked_fullname =
'<br /><a class="mailusername" href="' . $this->
ctrl->getLinkTarget(
849 ) .
'" title="' . $linked_fullname .
'">' . $linked_fullname .
'</a>';
850 $this->
ctrl->clearParameters($this);
854 $from->setHtml($this->ui_renderer->render($avatar) .
' ' . $linked_fullname);
855 } elseif (!$sender || !$sender->getId()) {
857 $from->setHtml(trim(($mail_data[
'import_name'] ??
'') .
' (' . $this->
lng->txt(
'user_deleted') .
')'));
861 $this->ui_renderer->render(
869 $form->addItem($from);
874 $this->umail->formatNamesForOutput($mail_data[
'rcp_to'] ??
''),
880 if ($mail_data[
'rcp_cc']) {
884 $this->umail->formatNamesForOutput($mail_data[
'rcp_cc']),
891 if ($mail_data[
'rcp_bcc']) {
895 $this->umail->formatNamesForOutput($mail_data[
'rcp_bcc']),
899 $form->addItem($bcc);
904 $form->addItem($subject);
912 $form->addItem($date);
918 if ($mail_data[
'attachments']) {
922 foreach ($mail_data[
'attachments'] as $file) {
923 $radiog->addOption(
new ilRadioOption($file, md5((
string) $file)));
926 $att->setHtml($radiog->render());
927 $form->addCommandButton(self::CMD_DELIVER_FILE, $this->
lng->txt(
'download'));
928 $form->addItem($att);
931 $current_folder = $this->mbox->getFolderData((
int) $mail_data[
'folder_id']);
932 if ($current_folder ===
null) {
933 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'mail_operation_on_invalid_folder'),
true);
934 $this->
ctrl->setParameterByClass(ilMailGUI::class, self::PARAM_FOLDER_ID, $this->mbox->getInboxFolder());
935 $this->
ctrl->redirectByClass(ilMailGUI::class);
938 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $this->folder->getFolderId());
941 $current_folder->getTitle(),
942 $this->ctrl->getLinkTarget($this, self::CMD_SHOW_FOLDER)
944 $this->
ctrl->clearParameters($this);
945 $this->
tabs->activateTab(
'current_folder');
948 $folders = $this->mbox->getSubFolders();
949 foreach ($folders as
$folder) {
952 $move_links[] = $this->ui_factory->button()->shy(
954 $this->
lng->txt(
'mail_move_to_folder_x'),
956 ) . (
$folder->
isTrash() ?
' (' . $this->lng->txt(
'delete') .
')' :
''),
958 )->withOnLoadCode(
static fn(
$id):
string =>
"
959 document.getElementById('$id').addEventListener('click', function(e) {
960 const frm = this.closest('form'),
961 action = new URL(frm.action),
962 action_params = new URLSearchParams(action.search);
964 action_params.delete('cmd');
965 action_params.append('cmd', '" . self::CMD_MOVE_SINGLE_MAIL .
"');
966 action_params.delete('folder_id');
969 action.search = action_params.toString();
971 frm.action = action.href;
982 if ($this->folder->isTrash()) {
983 $this->
ctrl->setParameter($this, self::PARAM_MAIL_ID, $mail_id);
984 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $mail_data[
'folder_id']);
985 $modal = $this->ui_factory->modal()->interruptive(
986 $this->
lng->txt(
'delete'),
987 $this->lng->txt(
'mail_sure_delete_s'),
988 $this->ctrl->getLinkTarget($this, self::CMD_DELETE_MAILS)
989 )->withAffectedItems([
990 $this->ui_factory->modal()->interruptiveItem()->standard(
994 ) .
' ' . $mail_data[
'm_subject']
998 $this->ui_factory->button()->standard(
999 $this->lng->txt(
'delete'),
1001 )->withOnClick($modal->getShowSignal())
1003 $this->
ctrl->clearParameters($this);
1005 $ui_components[] = $modal;
1008 if ($move_links !== []) {
1010 $this->ui_factory->dropdown()->standard($move_links)
1011 ->withLabel($this->lng->txt(
'mail_move_to_folder_btn_label'))
1015 $this->
toolbar->addSeparator();
1017 $this->
ctrl->setParameter($this, self::PARAM_MAIL_ID, $mail_id);
1018 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $mail_data[
'folder_id']);
1019 $print_url = $this->
ctrl->getLinkTarget($this, self::CMD_PRINT_MAIL);
1020 $this->
ctrl->clearParameters($this);
1021 $print_btn = $this->ui_factory->button()
1022 ->standard($this->
lng->txt(
'print'),
'#')
1023 ->withOnLoadCode(
static fn(
$id):
string =>
"
1024 document.getElementById('$id').addEventListener('click', function() {
1025 const frm = this.closest('form'),
1026 action = frm.action;
1028 frm.action = '$print_url';
1029 frm.target = '_blank';
1032 frm.action = action;
1033 frm.removeAttribute('target');
1038 $this->
toolbar->addComponent($print_btn);
1040 $prev_mail = $this->umail->getPreviousMail($mail_id);
1041 $next_mail = $this->umail->getNextMail($mail_id);
1042 if (is_array($prev_mail) || is_array($next_mail)) {
1043 $this->
toolbar->addSeparator();
1045 if ($prev_mail && $prev_mail[self::PARAM_MAIL_ID]) {
1046 $this->
ctrl->setParameter($this, self::PARAM_MAIL_ID, $prev_mail[self::PARAM_MAIL_ID]);
1047 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $this->folder->getFolderId());
1048 $pref_btn = $this->ui_factory->button()
1050 $this->
lng->txt(
'previous'),
1051 $this->ctrl->getLinkTarget($this, self::CMD_SHOW_MAIL)
1053 $this->
toolbar->addComponent($pref_btn);
1054 $this->
ctrl->clearParameters($this);
1057 if ($next_mail && $next_mail[self::PARAM_MAIL_ID]) {
1058 $this->
ctrl->setParameter($this, self::PARAM_MAIL_ID, $next_mail[self::PARAM_MAIL_ID]);
1059 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $this->folder->getFolderId());
1060 $next_btn = $this->ui_factory->button()
1062 $this->
lng->txt(
'next'),
1063 $this->ctrl->getLinkTarget($this, self::CMD_SHOW_MAIL)
1065 $this->
toolbar->addComponent($next_btn);
1066 $this->
ctrl->clearParameters($this);
1070 $this->tpl->setContent($form->getHTML() . $this->ui_renderer->render($ui_components));
1071 $this->tpl->printToStdout();
1076 $tplprint =
new ilTemplate(
'tpl.mail_print.html',
true,
true,
'components/ILIAS/Mail');
1079 $mail_data = $this->umail->getMail($mail_id);
1083 $tplprint->setVariable(
'TXT_FROM', $this->
lng->txt(
'from'));
1084 if ($sender instanceof
ilObjUser && $sender->
getId() !== 0 && !$sender->isAnonymous()) {
1085 $tplprint->setVariable(
'FROM', $sender->getPublicName());
1086 } elseif (!$sender instanceof
ilObjUser || $sender->
getId() === 0) {
1087 $tplprint->setVariable(
1089 trim(($mail_data[
'import_name'] ??
'') .
' (' . $this->
lng->txt(
'user_deleted') .
')')
1095 $tplprint->setVariable(
'TXT_TO', $this->
lng->txt(
'mail_to'));
1096 $tplprint->setVariable(
'TO', $mail_data[
'rcp_to']);
1098 if ($mail_data[
'rcp_cc']) {
1099 $tplprint->setCurrentBlock(
'cc');
1100 $tplprint->setVariable(
'TXT_CC', $this->
lng->txt(
'mail_cc'));
1101 $tplprint->setVariable(
'CC', $mail_data[
'rcp_cc']);
1102 $tplprint->parseCurrentBlock();
1105 if ($mail_data[
'rcp_bcc']) {
1106 $tplprint->setCurrentBlock(
'bcc');
1107 $tplprint->setVariable(
'TXT_BCC', $this->
lng->txt(
'mail_bcc'));
1108 $tplprint->setVariable(
'BCC', $mail_data[
'rcp_bcc']);
1109 $tplprint->parseCurrentBlock();
1112 $tplprint->setVariable(
'TXT_SUBJECT', $this->
lng->txt(
'subject'));
1113 $tplprint->setVariable(
'SUBJECT', htmlspecialchars((
string) $mail_data[
'm_subject']));
1115 $tplprint->setVariable(
'TXT_DATE', $this->
lng->txt(
'date'));
1116 $tplprint->setVariable(
1121 $tplprint->setVariable(
'TXT_MESSAGE', $this->
lng->txt(
'message'));
1122 $tplprint->setVariable(
'MAIL_MESSAGE', nl2br(htmlspecialchars((
string) $mail_data[
'm_message'])));
1129 $mail_id = $this->
http->wrapper()->query()->retrieve(
1130 self::PARAM_MAIL_ID,
1131 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->refinery->always(0)])
1133 if ($mail_id <= 0) {
1134 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1139 $this->
refinery->byTrying([$this->refinery->kindlyTo()->string(), $this->refinery->always(
'')])
1149 while (str_contains((
string)
$filename,
'..')) {
1155 $file = $mail_file_data->getAttachmentPathAndFilenameByMd5Hash(
$filename, (
int) $mail_id);
1157 }
catch (OutOfBoundsException
$e) {
1161 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_select_attachment'));
1164 }
catch (Exception
$e) {
1165 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt($e->getMessage()),
true);
1174 $mail_data = $this->umail->getMail($mail_id);
1175 if ($mail_data ===
null || [] === (array) $mail_data[
'attachments']) {
1179 $type = $this->
http->wrapper()->query()->retrieve(
1181 $this->
refinery->byTrying([$this->refinery->kindlyTo()->string(), $this->refinery->always(
'')])
1185 if (count($mail_data[
'attachments']) === 1) {
1186 $attachment = current($mail_data[
'attachments']);
1189 if ($type ===
'draft') {
1190 if (!$mail_file_data->checkFilesExist([$attachment])) {
1191 throw new OutOfBoundsException(
'');
1193 $path_to_file = $mail_file_data->getAbsoluteAttachmentPoolPathByFilename($attachment);
1196 $file = $mail_file_data->getAttachmentPathAndFilenameByMd5Hash(
1197 md5((
string) $attachment),
1200 $path_to_file = $file[
'path'];
1204 }
catch (OutOfBoundsException
$e) {
1208 $mail_file_data->deliverAttachmentsAsZip(
1209 $mail_data[
'm_subject'],
1211 $mail_data[
'attachments'],
1215 }
catch (Exception
$e) {
1216 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt($e->getMessage()),
true);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Builds a Color from either hex- or rgb values.
Stream factory which enables the user to create streams without the knowledge of the concrete class.
GUI class for public user profile presentation.
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
Error Handling & global info handling.
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
@ilCtrl_Calls ilMailFolderGUI:
readonly Renderer $ui_renderer
const string CMD_PRINT_MAIL
const string URL_BUILDER_PREFIX
const string CMD_ADD_SUB_FOLDER
const string CMD_DELETE_SUB_FOLDER
const string CMD_SHOW_USER
getSafePostCommands()
This method must return a list of safe POST commands.
readonly ilGlobalTemplateInterface $tpl
readonly Refinery $refinery
const string PARAM_TARGET_FOLDER
getFilteredSearch()
Searcher for mails in the folder, initialized with the current filter values needed for table display...
readonly Factory $ui_factory
const string CMD_DELETE_MAILS
readonly ilUIService $ui_service
readonly DataFactory $data_factory
const string PARAM_USER_ID
readonly GlobalHttpState $http
const string CMD_MOVE_SINGLE_MAIL
readonly ilCtrlInterface $ctrl
const string PARAM_MAIL_ID
readonly ilToolbarGUI $toolbar
const string PARAM_INTERRUPTIVE_ITEMS
const string CMD_EMPTY_TRASH
const string CMD_SHOW_FOLDER
const string PARAM_ACTION
const string CMD_SHOW_MAIL
const string PARAM_FOLDER_ID
confirmDeleteMails(array $mail_ids)
Confirm the deletion of selected mails in async modal.
const string CMD_DELIVER_FILE
getUnsafeGetCommands()
This method must return a list of unsafe GET commands.
const string CMD_TABLE_ACTION
moveSingleMail()
Move a single mail to a folder Called from showMail page.
readonly ilErrorHandling $error
const string CMD_RENAME_SUB_FOLDER
initRequest()
Init class variables that can be determined in an actual request.
static getUserObjectById(int $usr_id)
static _getIliasMailerName()
static _lookupPref(int $a_usr_id, string $a_keyword)
static _lookupLogin(int $a_user_id)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
This class represents an option in a radio group.
static get(string $a_var)
static set(string $a_var, $a_val)
Set a value.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
special template class to simplify handling of ITX/PEAR
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
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.
Interface GlobalHttpState.
const MESSAGE_TYPE_SUCCESS
const MESSAGE_TYPE_FAILURE
This is how the factory for UI elements looks.
An entity that renders components to a string output.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.