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(ilMailFormGUI::class, self::PARAM_MAIL_ID, (
string) $mail_ids[0]);
237 if ($this->folder->isOutbox()) {
238 $this->umail->moveMailsToFolder($mail_ids, $this->mbox->getDraftsFolder());
240 $this->
ctrl->setParameterByClass(
241 ilMailFormGUI::class,
242 self::PARAM_FOLDER_ID,
243 (
string) $this->mbox->getDraftsFolder()
246 $this->
ctrl->redirectByClass(ilMailFormGUI::class);
249 case MailFolderTableUI::ACTION_REPLY:
250 $this->
ctrl->setParameterByClass(
251 ilMailFormGUI::class,
252 self::PARAM_FOLDER_ID,
253 (
string) $this->folder->getFolderId()
255 $this->
ctrl->setParameterByClass(ilMailFormGUI::class, self::PARAM_MAIL_ID, (
string) $mail_ids[0]);
257 $this->
ctrl->redirectByClass(ilMailFormGUI::class);
260 case MailFolderTableUI::ACTION_FORWARD:
261 $this->
ctrl->setParameterByClass(
262 ilMailFormGUI::class,
263 self::PARAM_FOLDER_ID,
264 (
string) $this->folder->getFolderId()
266 $this->
ctrl->setParameterByClass(ilMailFormGUI::class, self::PARAM_MAIL_ID, (
string) $mail_ids[0]);
268 $this->
ctrl->redirectByClass(ilMailFormGUI::class);
271 case MailFolderTableUI::ACTION_DOWNLOAD_ATTACHMENT:
275 case MailFolderTableUI::ACTION_PRINT:
279 case MailFolderTableUI::ACTION_PROFILE:
280 $mail_data = $this->umail->getMail($mail_ids[0] ?? 0);
283 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, (
string) $this->folder->getFolderId());
284 $this->
ctrl->setParameter($this, self::PARAM_USER_ID, (
string)
$user->
getId());
285 $this->
ctrl->redirect($this, self::CMD_SHOW_USER);
287 $this->tpl->setOnScreenMessage(
289 $this->
lng->txt(
'permission_denied'),
295 case MailFolderTableUI::ACTION_MARK_READ:
296 $this->umail->markRead($mail_ids);
297 $this->tpl->setOnScreenMessage(
299 $this->
lng->txt(
'saved_successfully'),
304 case MailFolderTableUI::ACTION_MARK_UNREAD:
305 $this->umail->markUnread($mail_ids);
306 $this->tpl->setOnScreenMessage(
308 $this->
lng->txt(
'saved_successfully'),
313 case MailFolderTableUI::ACTION_MOVE_TO:
314 $folder_id = $this->
http->wrapper()->query()->retrieve(
315 self::URL_BUILDER_PREFIX . URLBuilder::SEPARATOR . self::PARAM_TARGET_FOLDER,
318 if (empty($folder_id) || $folder_id === $this->mbox->getOutboxFolder()) {
319 $this->tpl->setOnScreenMessage(
321 $this->
lng->txt(
'mail_move_error')
323 } elseif ($this->umail->moveMailsToFolder($mail_ids, $folder_id)) {
324 $this->tpl->setOnScreenMessage(
326 $this->
lng->txt(
'mail_moved'),
330 $this->tpl->setOnScreenMessage(
332 $this->
lng->txt(
'mail_move_error')
337 case MailFolderTableUI::ACTION_DELETE:
342 $this->tpl->setOnScreenMessage(
344 $this->
lng->txt(
'permission_denied')
354 $this->umail->deleteMailsOfFolder($this->mbox->getTrashFolder());
355 $this->tpl->setOnScreenMessage(
357 $this->
lng->txt(
'mail_deleted'),
368 $usr_id = $this->
http->wrapper()->query()->retrieve(
370 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->refinery->always(0)])
373 $this->tpl->setVariable(
'TBL_TITLE', implode(
' ', [
374 $this->
lng->txt(
'profile_of'),
378 $this->tpl->setVariable(
'TBL_TITLE_IMG_ALT', $this->
lng->txt(
'public_profile'));
382 $mail_id = $this->
http->wrapper()->query()->retrieve(
384 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->refinery->always(0)])
388 $this->
ctrl->setParameter($this, self::PARAM_MAIL_ID, $mail_id);
389 $this->
tabs->clearTargets();
390 $this->
tabs->setBackTarget($this->
lng->txt(
'back'), $this->ctrl->getLinkTarget($this, self::CMD_SHOW_MAIL));
392 $this->
tabs->clearTargets();
393 $this->
tabs->setBackTarget(
394 $this->
lng->txt(
'back_to_folder'),
395 $this->ctrl->getLinkTarget($this, self::CMD_SHOW_FOLDER)
399 $this->
ctrl->clearParameters($this);
401 $this->tpl->setTitle($this->
lng->txt(
'mail'));
402 $this->tpl->setContent($this->
ctrl->getHTML($profile_gui));
403 $this->tpl->printToStdout();
409 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $this->folder->getFolderId());
411 if ($this->folder->isUserLocalFolder()) {
413 $this->ui_factory->button()->standard(
414 $this->lng->txt(
'mail_add_subfolder'),
415 $this->ctrl->getLinkTarget($this, self::CMD_ADD_SUB_FOLDER)
420 if ($this->folder->isUserFolder()) {
422 $this->ui_factory->button()->standard(
423 $this->lng->txt(
'rename'),
424 $this->ctrl->getLinkTarget($this, self::CMD_RENAME_SUB_FOLDER)
428 $components[] = $modal = $this->ui_factory->modal()->interruptive(
429 $this->
lng->txt(
'delete'),
430 $this->lng->txt(
'mail_sure_delete_folder'),
431 $this->ctrl->getLinkTarget($this, self::CMD_DELETE_SUB_FOLDER)
434 $this->ui_factory->button()->standard(
435 $this->lng->txt(
'delete'),
438 ->withOnClick($modal->getShowSignal())
442 if ($this->folder->isTrash()) {
443 $components[] = $modal = $this->ui_factory->modal()->interruptive(
444 $this->
lng->txt(
'mail_empty_trash'),
445 $this->lng->txt(
'mail_empty_trash_confirmation'),
446 $this->ctrl->getLinkTarget($this, self::CMD_EMPTY_TRASH)
449 $this->ui_factory->button()->standard(
450 $this->lng->txt(
'mail_empty_trash'),
452 )->withOnClick($modal->getShowSignal())
462 $this->data_factory->uri(
464 $this->ctrl->getLinkTarget($this, self::CMD_TABLE_ACTION)
467 )->acquireParameters(
468 [self::URL_BUILDER_PREFIX],
471 self::PARAM_TARGET_FOLDER
479 $this->mbox->getSubFolders(),
481 $this->getFilteredSearch(),
486 $this->http->request(),
489 $this->user->getDateFormat(),
490 $this->user->getTimeFormat(),
491 new DateTimeZone($this->
user->getTimeZone())
497 $this->tpl->setTitle($this->folder->getTitle());
498 $this->tpl->setContent($this->ui_renderer->render(
$components));
499 $this->tpl->printToStdout();
504 $this->
ctrl->clearParameters($this);
505 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $this->folder->getFolderId());
506 $this->
ctrl->redirect($this, self::CMD_SHOW_FOLDER);
511 $parent_folder_id = $this->mbox->getParentFolderId($this->folder->getFolderId());
512 if ($parent_folder_id > 0 && $this->mbox->deleteFolder($this->folder->getFolderId())) {
513 $this->tpl->setOnScreenMessage(
515 $this->
lng->txt(
'mail_folder_deleted'),
518 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $parent_folder_id);
519 $this->
ctrl->redirect($this, self::CMD_SHOW_FOLDER);
521 $this->tpl->setOnScreenMessage(
523 $this->
lng->txt(
'mail_error_delete'),
532 $form = $this->ui_factory->input()->container()->form()->standard(
533 $this->
ctrl->getFormAction($this, self::CMD_ADD_SUB_FOLDER),
535 'folder' => $this->ui_factory->input()->field()->section([
536 'title' => $this->ui_factory->input()->field()->text($this->lng->txt(
'title'))->withRequired(
true)
537 ], $this->lng->txt(
'mail_add_folder'))
541 $request = $this->
http->request();
542 if ($request->getMethod() ===
'POST') {
543 $form = $form->withRequest($request);
544 $data = $form->getData();
545 if (!empty(
$data[
'folder'][
'title'])) {
546 $new_folder_id = $this->mbox->addFolder(
547 $this->folder->getFolderId(),
548 (
string)
$data[
'folder'][
'title']
550 if ($new_folder_id > 0) {
551 $this->tpl->setOnScreenMessage(
553 $this->
lng->txt(
'mail_folder_created'),
556 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $new_folder_id);
557 $this->
ctrl->redirect($this, self::CMD_SHOW_FOLDER);
559 $this->tpl->setOnScreenMessage(
561 $this->
lng->txt(
'mail_folder_exists')
566 $this->tpl->setContent($this->ui_renderer->render($form));
567 $this->tpl->printToStdout();
572 $form = $this->ui_factory->input()->container()->form()->standard(
573 $this->
ctrl->getFormAction($this, self::CMD_RENAME_SUB_FOLDER),
575 'folder' => $this->ui_factory->input()->field()->section([
576 'title' => $this->ui_factory->input()->field()->text($this->lng->txt(
'title'))->withRequired(
true)
577 ], $this->lng->txt(
'mail_rename_folder'))
581 $request = $this->
http->request();
582 if ($request->getMethod() ===
'POST') {
583 $form = $form->withRequest($request);
584 $data = $form->getData();
585 if (!empty(
$data[
'folder'][
'title'])) {
586 if ($this->mbox->renameFolder($this->folder->getFolderId(), (
string)
$data[
'folder'][
'title'])) {
587 $this->tpl->setOnScreenMessage(
589 $this->
lng->txt(
'mail_folder_name_changed'),
594 $this->tpl->setOnScreenMessage(
596 $this->
lng->txt(
'mail_folder_exists')
601 $this->tpl->setContent($this->ui_renderer->render($form));
602 $this->tpl->printToStdout();
608 $this->
ctrl->getFormAction($this, self::CMD_SHOW_FOLDER),
612 $this->ui_service->filter(),
614 new DateTimeZone($this->
user->getTimeZone()),
639 self::URL_BUILDER_PREFIX . URLBuilder::SEPARATOR . self::PARAM_MAIL_ID,
641 self::PARAM_INTERRUPTIVE_ITEMS
646 $this->
http->wrapper()->post(),
647 $this->http->wrapper()->query()
650 if ($wrapper->has(
$param)) {
651 return $wrapper->retrieve(
654 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int()),
655 $this->refinery->always([])
672 if (count($mail_ids) !== 1) {
674 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_select_one'));
678 $new_folder_id = $this->
http->wrapper()->query()->retrieve(
680 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->refinery->always(0)])
682 $redirect_folder_id = $new_folder_id;
684 foreach ($mail_ids as $mail_id) {
685 $mail_data = $this->umail->getMail($mail_id);
686 if (isset($mail_data[
'folder_id']) &&
687 is_numeric($mail_data[
'folder_id']) &&
688 (
int) $mail_data[
'folder_id'] > 0) {
689 $redirect_folder_id = (
int) $mail_data[
'folder_id'];
694 if ($this->umail->moveMailsToFolder($mail_ids, $new_folder_id)) {
695 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'mail_moved'),
true);
696 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $redirect_folder_id);
697 $this->
ctrl->redirect($this, self::CMD_SHOW_FOLDER);
699 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'mail_move_error'));
706 if (!$this->folder->isTrash()) {
707 $this->tpl->setOnScreenMessage(
709 $this->
lng->txt(
'mail_operation_on_invalid_folder'),
716 $this->tpl->setOnScreenMessage(
718 $this->
lng->txt(
'mail_deleted'),
730 $user_timezone =
new DateTimeZone($this->
user->getTimeZone());
731 $records = $this->
getFilteredSearch()->forMailIds($mail_ids)->getPagedRecords(10, 0,
null,
null);
733 foreach ($records as $record) {
735 if (!empty($record->getSendTime())) {
736 $time = $record->getSendTime()->setTimezone($user_timezone);
737 $prefix = $time->format($this->
user->getDateFormat()->toString()) .
' ';
739 $items[] = $this->ui_factory->modal()->interruptiveItem()->standard(
740 (
string) $record->getMailId(),
741 $prefix . $this->refinery->encode()->htmlSpecialCharsAsEntities()->transform($record->getSubject())
745 $modal = $this->ui_factory->modal()->interruptive(
746 $this->
lng->txt(
'delete'),
747 $this->lng->txt(
'mail_sure_delete_' . (count($items) === 1 ?
's' :
'p')),
748 $this->
ctrl->getFormAction($this, self::CMD_DELETE_MAILS)
749 )->withAffectedItems($items);
751 $this->
http->saveResponse(
752 $this->
http->response()->withBody(
753 Streams::ofString($this->ui_renderer->renderAsync($modal))
756 $this->
http->sendResponse();
757 $this->
http->close();
760 protected function showMail(): void
766 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
769 $mail_data = $this->umail->getMail($mail_id);
770 if ($mail_data ===
null) {
771 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
774 $this->umail->markRead([$mail_id]);
776 $this->tpl->setTitle($this->
lng->txt(
'mail_mails_of'));
778 $this->
tabs->clearTargets();
779 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $mail_data[
'folder_id']);
780 $this->
tabs->setBackTarget(
781 $this->
lng->txt(
'back_to_folder'),
782 $this->ctrl->getFormAction($this, self::CMD_SHOW_FOLDER)
784 $this->
ctrl->clearParameters($this);
786 $this->
ctrl->setParameter($this, self::PARAM_MAIL_ID, $mail_id);
787 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $mail_data[
'folder_id']);
788 $this->
toolbar->setFormAction($this->
ctrl->getFormAction($this, self::CMD_SHOW_MAIL));
789 $this->
ctrl->clearParameters($this);
792 $form->setId(
'MailContent');
793 $form->setPreventDoubleSubmission(
false);
794 $form->setTableWidth(
'100%');
795 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $mail_data[
'folder_id']);
796 $this->
ctrl->setParameter($this, self::PARAM_MAIL_ID, $mail_id);
797 $form->setFormAction($this->
ctrl->getFormAction($this, self::CMD_SHOW_MAIL));
798 $this->
ctrl->clearParameters($this);
799 $form->setTitle($this->
lng->txt(
'mail_mails_of'));
804 if ($sender instanceof
ilObjUser && $sender->
getId() !== 0 && !$sender->isAnonymous()) {
805 $this->
ctrl->setParameterByClass(
806 ilMailFormGUI::class,
807 self::PARAM_FOLDER_ID,
808 $mail_data[
'folder_id']
810 $this->
ctrl->setParameterByClass(ilMailFormGUI::class, self::PARAM_MAIL_ID, $mail_id);
812 $reply_btn = $this->ui_factory->button()->primary(
813 $this->
lng->txt(
'reply'),
814 $this->ctrl->getLinkTargetByClass(ilMailFormGUI::class)
816 $this->
toolbar->addStickyItem($reply_btn);
817 $this->
ctrl->clearParametersByClass(ilMailFormGUI::class);
820 $this->
ctrl->setParameterByClass(ilMailFormGUI::class, self::PARAM_FOLDER_ID, $mail_data[
'folder_id']);
821 $this->
ctrl->setParameterByClass(ilMailFormGUI::class, self::PARAM_MAIL_ID, $mail_id);
823 if ($reply_btn ===
null) {
824 $fwd_btn = $this->ui_factory->button()->primary(
825 $this->
lng->txt(
'forward'),
826 $this->ctrl->getLinkTargetByClass(ilMailFormGUI::class)
828 $this->
toolbar->addStickyItem($fwd_btn);
830 $fwd_btn = $this->ui_factory->button()->standard(
831 $this->
lng->txt(
'forward'),
832 $this->ctrl->getLinkTargetByClass(ilMailFormGUI::class)
834 $this->
toolbar->addComponent($fwd_btn);
836 $this->
ctrl->clearParametersByClass(ilMailFormGUI::class);
838 if ($sender && $sender->getId() && !$sender->isAnonymous()) {
839 $linked_fullname = $sender->getPublicName();
840 $avatar = $this->ui_factory->symbol()->avatar()->picture(
841 $sender->getPersonalPicturePath(
'xsmall'),
842 $sender->getPublicName()
846 $this->
ctrl->setParameter($this, self::PARAM_MAIL_ID, $mail_id);
847 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $mail_data[
'folder_id']);
848 $this->
ctrl->setParameter($this, self::PARAM_USER_ID, $sender->getId());
849 $linked_fullname =
'<br /><a class="mailusername" href="' . $this->
ctrl->getLinkTarget(
852 ) .
'" title="' . $linked_fullname .
'">' . $linked_fullname .
'</a>';
853 $this->
ctrl->clearParameters($this);
857 $from->setHtml($this->ui_renderer->render($avatar) .
' ' . $linked_fullname);
858 } elseif (!$sender || !$sender->getId()) {
860 $from->setHtml(trim(($mail_data[
'import_name'] ??
'') .
' (' . $this->
lng->txt(
'user_deleted') .
')'));
864 $this->ui_renderer->render(
872 $form->addItem($from);
877 $this->umail->formatNamesForOutput($mail_data[
'rcp_to'] ??
''),
883 if ($mail_data[
'rcp_cc']) {
887 $this->umail->formatNamesForOutput($mail_data[
'rcp_cc']),
894 if ($mail_data[
'rcp_bcc']) {
898 $this->umail->formatNamesForOutput($mail_data[
'rcp_bcc']),
902 $form->addItem($bcc);
907 $form->addItem($subject);
915 $form->addItem($date);
921 [
'{',
'}'],
922 html_entity_decode($this->
refinery->string()->markdown()->toHTML()->transform($mail_data[
'm_message']) ??
'')
926 $form->addItem($message);
928 if ($mail_data[
'attachments']) {
932 foreach ($mail_data[
'attachments'] as $file) {
936 $att->setHtml($radiog->render());
937 $form->addCommandButton(self::CMD_DELIVER_FILE, $this->
lng->txt(
'download'));
938 $form->addItem($att);
941 $current_folder = $this->mbox->getFolderData((
int) $mail_data[
'folder_id']);
942 if ($current_folder ===
null) {
943 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'mail_operation_on_invalid_folder'),
true);
944 $this->
ctrl->setParameterByClass(ilMailGUI::class, self::PARAM_FOLDER_ID, $this->mbox->getInboxFolder());
945 $this->
ctrl->redirectByClass(ilMailGUI::class);
948 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $this->folder->getFolderId());
951 $current_folder->getTitle(),
952 $this->ctrl->getLinkTarget($this, self::CMD_SHOW_FOLDER)
954 $this->
ctrl->clearParameters($this);
955 $this->
tabs->activateTab(
'current_folder');
958 $folders = $this->mbox->getSubFolders();
959 foreach ($folders as
$folder) {
962 $move_links[] = $this->ui_factory->button()->shy(
964 $this->
lng->txt(
'mail_move_to_folder_x'),
966 ) . (
$folder->
isTrash() ?
' (' . $this->lng->txt(
'delete') .
')' :
''),
968 )->withOnLoadCode(
static fn(
$id):
string =>
"
969 document.getElementById('$id').addEventListener('click', function(e) {
970 const frm = this.closest('form'),
971 action = new URL(frm.action),
972 action_params = new URLSearchParams(action.search);
974 action_params.delete('cmd');
975 action_params.append('cmd', '" . self::CMD_MOVE_SINGLE_MAIL .
"');
976 action_params.delete('folder_id');
979 action.search = action_params.toString();
981 frm.action = action.href;
992 if ($this->folder->isTrash()) {
993 $this->
ctrl->setParameter($this, self::PARAM_MAIL_ID, $mail_id);
994 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $mail_data[
'folder_id']);
995 $modal = $this->ui_factory->modal()->interruptive(
996 $this->
lng->txt(
'delete'),
997 $this->lng->txt(
'mail_sure_delete_s'),
998 $this->ctrl->getLinkTarget($this, self::CMD_DELETE_MAILS)
999 )->withAffectedItems([
1000 $this->ui_factory->modal()->interruptiveItem()->standard(
1004 ) .
' ' . $mail_data[
'm_subject']
1008 $this->ui_factory->button()->standard(
1009 $this->lng->txt(
'delete'),
1011 )->withOnClick($modal->getShowSignal())
1013 $this->
ctrl->clearParameters($this);
1015 $ui_components[] = $modal;
1018 if ($move_links !== []) {
1020 $this->ui_factory->dropdown()->standard($move_links)
1021 ->withLabel($this->lng->txt(
'mail_move_to_folder_btn_label'))
1025 $this->
toolbar->addSeparator();
1027 $this->
ctrl->setParameter($this, self::PARAM_MAIL_ID, $mail_id);
1028 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $mail_data[
'folder_id']);
1029 $print_url = $this->
ctrl->getLinkTarget($this, self::CMD_PRINT_MAIL);
1030 $this->
ctrl->clearParameters($this);
1031 $print_btn = $this->ui_factory->button()
1032 ->standard($this->
lng->txt(
'print'),
'#')
1033 ->withOnLoadCode(
static fn(
$id):
string =>
"
1034 document.getElementById('$id').addEventListener('click', function() {
1035 const frm = this.closest('form'),
1036 action = frm.action;
1038 frm.action = '$print_url';
1039 frm.target = '_blank';
1042 frm.action = action;
1043 frm.removeAttribute('target');
1048 $this->
toolbar->addComponent($print_btn);
1050 $prev_mail = $this->umail->getPreviousMail($mail_id);
1051 $next_mail = $this->umail->getNextMail($mail_id);
1052 if (is_array($prev_mail) || is_array($next_mail)) {
1053 $this->
toolbar->addSeparator();
1055 if ($prev_mail && $prev_mail[self::PARAM_MAIL_ID]) {
1056 $this->
ctrl->setParameter($this, self::PARAM_MAIL_ID, $prev_mail[self::PARAM_MAIL_ID]);
1057 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $this->folder->getFolderId());
1058 $pref_btn = $this->ui_factory->button()
1060 $this->
lng->txt(
'previous'),
1061 $this->ctrl->getLinkTarget($this, self::CMD_SHOW_MAIL)
1063 $this->
toolbar->addComponent($pref_btn);
1064 $this->
ctrl->clearParameters($this);
1067 if ($next_mail && $next_mail[self::PARAM_MAIL_ID]) {
1068 $this->
ctrl->setParameter($this, self::PARAM_MAIL_ID, $next_mail[self::PARAM_MAIL_ID]);
1069 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $this->folder->getFolderId());
1070 $next_btn = $this->ui_factory->button()
1072 $this->
lng->txt(
'next'),
1073 $this->ctrl->getLinkTarget($this, self::CMD_SHOW_MAIL)
1075 $this->
toolbar->addComponent($next_btn);
1076 $this->
ctrl->clearParameters($this);
1080 $this->tpl->setContent($form->getHTML() . $this->ui_renderer->render($ui_components));
1081 $this->tpl->printToStdout();
1086 $tplprint =
new ilTemplate(
'tpl.mail_print.html',
true,
true,
'components/ILIAS/Mail');
1089 $mail_data = $this->umail->getMail($mail_id);
1093 $tplprint->setVariable(
'TXT_FROM', $this->
lng->txt(
'from'));
1094 if ($sender instanceof
ilObjUser && $sender->
getId() !== 0 && !$sender->isAnonymous()) {
1095 $tplprint->setVariable(
'FROM', $sender->getPublicName());
1096 } elseif (!$sender instanceof
ilObjUser || $sender->
getId() === 0) {
1097 $tplprint->setVariable(
1099 trim(($mail_data[
'import_name'] ??
'') .
' (' . $this->
lng->txt(
'user_deleted') .
')')
1105 $tplprint->setVariable(
'TXT_TO', $this->
lng->txt(
'mail_to'));
1106 $tplprint->setVariable(
'TO', $mail_data[
'rcp_to']);
1108 if ($mail_data[
'rcp_cc']) {
1109 $tplprint->setCurrentBlock(
'cc');
1110 $tplprint->setVariable(
'TXT_CC', $this->
lng->txt(
'mail_cc'));
1111 $tplprint->setVariable(
'CC', $mail_data[
'rcp_cc']);
1112 $tplprint->parseCurrentBlock();
1115 if ($mail_data[
'rcp_bcc']) {
1116 $tplprint->setCurrentBlock(
'bcc');
1117 $tplprint->setVariable(
'TXT_BCC', $this->
lng->txt(
'mail_bcc'));
1118 $tplprint->setVariable(
'BCC', $mail_data[
'rcp_bcc']);
1119 $tplprint->parseCurrentBlock();
1122 $tplprint->setVariable(
'TXT_SUBJECT', $this->
lng->txt(
'subject'));
1123 $tplprint->setVariable(
'SUBJECT', htmlspecialchars((
string) $mail_data[
'm_subject']));
1125 $tplprint->setVariable(
'TXT_DATE', $this->
lng->txt(
'date'));
1126 $tplprint->setVariable(
1131 $tplprint->setVariable(
'TXT_MESSAGE', $this->
lng->txt(
'message'));
1132 $tplprint->setVariable(
'MAIL_MESSAGE', html_entity_decode($this->
refinery->string()->markdown()->toHTML()->transform($mail_data[
'm_message'])));
1139 $mail_id = $this->
http->wrapper()->query()->retrieve(
1140 self::PARAM_MAIL_ID,
1141 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->refinery->always(0)])
1143 if ($mail_id <= 0) {
1144 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1149 $this->
refinery->byTrying([$this->refinery->kindlyTo()->string(), $this->refinery->always(
'')])
1159 while (str_contains((
string)
$filename,
'..')) {
1165 $file = $mail_file_data->getAttachmentPathAndFilenameByMd5Hash(
$filename, (
int) $mail_id);
1167 }
catch (OutOfBoundsException
$e) {
1171 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_select_attachment'));
1174 }
catch (Exception
$e) {
1175 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt($e->getMessage()),
true);
1184 $mail_data = $this->umail->getMail($mail_id);
1185 if ($mail_data ===
null || [] === (array) $mail_data[
'attachments']) {
1189 $type = $this->
http->wrapper()->query()->retrieve(
1191 $this->
refinery->byTrying([$this->refinery->kindlyTo()->string(), $this->refinery->always(
'')])
1195 if (count($mail_data[
'attachments']) === 1) {
1196 $attachment = current($mail_data[
'attachments']);
1199 if ($type ===
'draft') {
1200 if (!$mail_file_data->checkFilesExist([$attachment])) {
1201 throw new OutOfBoundsException(
'');
1203 $path_to_file = $mail_file_data->getAbsoluteAttachmentPoolPathByFilename($attachment);
1206 $file = $mail_file_data->getAttachmentPathAndFilenameByMd5Hash(
1207 md5((
string) $attachment),
1210 $path_to_file = $file[
'path'];
1214 }
catch (OutOfBoundsException
$e) {
1218 $mail_file_data->deliverAttachmentsAsZip(
1219 $mail_data[
'm_subject'],
1221 $mail_data[
'attachments'],
1225 }
catch (Exception
$e) {
1226 $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: ILIAS\User\Profile\PublicProfileGUI
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.