19 declare(strict_types=1);
85 $this->tpl = $DIC->ui()->mainTemplate();
86 $this->
ctrl = $DIC->ctrl();
87 $this->
lng = $DIC->language();
88 $this->
toolbar = $DIC->toolbar();
89 $this->
user = $DIC->user();
90 $this->
tabs = $DIC->tabs();
91 $this->
http = $DIC->http();
93 $this->error = $DIC[
'ilErr'];
94 $this->ui_factory = $DIC->ui()->factory();
95 $this->ui_renderer = $DIC->ui()->renderer();
96 $this->ui_service = $DIC->uiService();
105 $this->umail =
new ilMail($this->
user->getId());
108 if ($this->
http->wrapper()->post()->has(self::PARAM_FOLDER_ID)) {
109 $folder_id = $this->
http->wrapper()->post()->retrieve(
110 self::PARAM_FOLDER_ID,
113 } elseif ($this->
http->wrapper()->query()->has(self::PARAM_FOLDER_ID)) {
114 $folder_id = $this->
http->wrapper()->query()->retrieve(
115 self::PARAM_FOLDER_ID,
119 $folder_id = $this->
refinery->byTrying([
125 if ($folder_id === 0 || !$this->mbox->isOwnedFolder($folder_id)) {
126 $folder_id = $this->mbox->getInboxFolder();
129 $folder = $this->mbox->getFolderData($folder_id);
130 if ($folder ===
null) {
131 $this->tpl->setOnScreenMessage(
133 $this->
lng->txt(
'mail_operation_on_invalid_folder')
135 $this->tpl->printToStdout();
144 $next_class = $this->
ctrl->getNextClass($this) ??
'';
145 switch (strtolower($next_class)) {
146 case strtolower(ilContactGUI::class):
151 $cmd = $this->
ctrl->getCmd() ??
'';
153 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}(
162 $action = $this->
http->wrapper()->query()->retrieve(
163 self::URL_BUILDER_PREFIX . URLBuilder::SEPARATOR . self::PARAM_ACTION,
165 $this->refinery->kindlyTo()->string(),
171 $for_all_entries = implode(
173 $this->
http->wrapper()->query()->retrieve(
174 self::URL_BUILDER_PREFIX . URLBuilder::SEPARATOR . self::PARAM_MAIL_ID,
176 $this->refinery->kindlyTo()->listOf($this->
refinery->kindlyTo()->string()),
182 if ($for_all_entries) {
189 if (empty($mail_ids)) {
191 if ($action === MailFolderTableUI::ACTION_DELETE) {
192 $modal = $this->ui_factory->modal()->lightbox(
193 $this->ui_factory->modal()->lightboxTextPage(
194 $this->ui_renderer->render(
195 $this->ui_factory->messageBox()->failure($this->
lng->txt(
'mail_select_one'))
197 $this->
lng->txt(
'delete'),
200 $this->
http->saveResponse(
201 $this->
http->response()->withBody(
202 Streams::ofString($this->ui_renderer->renderAsync($modal))
205 $this->
http->sendResponse();
206 $this->
http->close();
208 $this->tpl->setOnScreenMessage(
210 $this->
lng->txt(
'mail_select_one'),
218 case MailFolderTableUI::ACTION_SHOW:
222 case MailFolderTableUI::ACTION_EDIT:
223 $this->
ctrl->setParameterByClass(
224 ilMailFormGUI::class,
225 self::PARAM_FOLDER_ID,
226 (
string) $this->folder->getFolderId()
228 $this->
ctrl->setParameterByClass(ilMailFormGUI::class, self::PARAM_MAIL_ID, (
string) $mail_ids[0]);
230 $this->
ctrl->redirectByClass(ilMailFormGUI::class);
233 case MailFolderTableUI::ACTION_REPLY:
234 $this->
ctrl->setParameterByClass(
235 ilMailFormGUI::class,
236 self::PARAM_FOLDER_ID,
237 (
string) $this->folder->getFolderId()
239 $this->
ctrl->setParameterByClass(ilMailFormGUI::class, self::PARAM_MAIL_ID, (
string) $mail_ids[0]);
241 $this->
ctrl->redirectByClass(ilMailFormGUI::class);
244 case MailFolderTableUI::ACTION_FORWARD:
245 $this->
ctrl->setParameterByClass(
246 ilMailFormGUI::class,
247 self::PARAM_FOLDER_ID,
248 (
string) $this->folder->getFolderId()
250 $this->
ctrl->setParameterByClass(ilMailFormGUI::class, self::PARAM_MAIL_ID, (
string) $mail_ids[0]);
252 $this->
ctrl->redirectByClass(ilMailFormGUI::class);
255 case MailFolderTableUI::ACTION_DOWNLOAD_ATTACHMENT:
259 case MailFolderTableUI::ACTION_PRINT:
263 case MailFolderTableUI::ACTION_PROFILE:
264 $mail_data = $this->umail->getMail($mail_ids[0] ?? 0);
266 $user->hasPublicProfile()) {
267 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, (
string) $this->folder->getFolderId());
268 $this->
ctrl->setParameter($this, self::PARAM_USER_ID, (
string) $user->getId());
269 $this->
ctrl->redirect($this, self::CMD_SHOW_USER);
271 $this->tpl->setOnScreenMessage(
273 $this->
lng->txt(
'permission_denied'),
279 case MailFolderTableUI::ACTION_MARK_READ:
280 $this->umail->markRead($mail_ids);
281 $this->tpl->setOnScreenMessage(
283 $this->
lng->txt(
'saved_successfully'),
288 case MailFolderTableUI::ACTION_MARK_UNREAD:
289 $this->umail->markUnread($mail_ids);
290 $this->tpl->setOnScreenMessage(
292 $this->
lng->txt(
'saved_successfully'),
297 case MailFolderTableUI::ACTION_MOVE_TO:
298 $folder_id = $this->
http->wrapper()->query()->retrieve(
299 self::URL_BUILDER_PREFIX . URLBuilder::SEPARATOR . self::PARAM_TARGET_FOLDER,
302 if (empty($folder_id)) {
303 $this->tpl->setOnScreenMessage(
305 $this->
lng->txt(
'mail_move_error')
307 } elseif ($this->umail->moveMailsToFolder($mail_ids, $folder_id)) {
308 $this->tpl->setOnScreenMessage(
310 $this->
lng->txt(
'mail_moved'),
314 $this->tpl->setOnScreenMessage(
316 $this->
lng->txt(
'mail_move_error')
321 case MailFolderTableUI::ACTION_DELETE:
326 $this->tpl->setOnScreenMessage(
328 $this->
lng->txt(
'permission_denied')
338 $this->umail->deleteMailsOfFolder($this->mbox->getTrashFolder());
339 $this->tpl->setOnScreenMessage(
341 $this->
lng->txt(
'mail_deleted'),
352 $usr_id = $this->
http->wrapper()->query()->retrieve(
354 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->
refinery->always(0)])
357 $this->tpl->setVariable(
'TBL_TITLE', implode(
' ', [
358 $this->
lng->txt(
'profile_of'),
362 $this->tpl->setVariable(
'TBL_TITLE_IMG_ALT', $this->
lng->txt(
'public_profile'));
366 $mail_id = $this->
http->wrapper()->query()->retrieve(
368 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->
refinery->always(0)])
372 $this->
ctrl->setParameter($this, self::PARAM_MAIL_ID, $mail_id);
373 $this->
tabs->clearTargets();
374 $this->
tabs->setBackTarget($this->
lng->txt(
'back'), $this->
ctrl->getLinkTarget($this, self::CMD_SHOW_MAIL));
376 $this->
tabs->clearTargets();
377 $this->
tabs->setBackTarget(
378 $this->
lng->txt(
'back_to_folder'),
379 $this->
ctrl->getLinkTarget($this, self::CMD_SHOW_FOLDER)
383 $this->
ctrl->clearParameters($this);
385 $this->tpl->setTitle($this->
lng->txt(
'mail'));
386 $this->tpl->setContent($this->
ctrl->getHTML($profile_gui));
387 $this->tpl->printToStdout();
393 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $this->folder->getFolderId());
395 if ($this->folder->isUserLocalFolder()) {
397 $this->ui_factory->button()->standard(
398 $this->
lng->txt(
'mail_add_subfolder'),
399 $this->
ctrl->getLinkTarget($this, self::CMD_ADD_SUB_FOLDER)
404 if ($this->folder->isUserFolder()) {
406 $this->ui_factory->button()->standard(
407 $this->
lng->txt(
'rename'),
408 $this->
ctrl->getLinkTarget($this, self::CMD_RENAME_SUB_FOLDER)
412 $components[] = $modal = $this->ui_factory->modal()->interruptive(
413 $this->
lng->txt(
'delete'),
414 $this->
lng->txt(
'mail_sure_delete_folder'),
415 $this->
ctrl->getLinkTarget($this, self::CMD_DELETE_SUB_FOLDER)
418 $this->ui_factory->button()->standard(
419 $this->
lng->txt(
'delete'),
422 ->withOnClick($modal->getShowSignal())
426 if ($this->folder->isTrash()) {
427 $components[] = $modal = $this->ui_factory->modal()->interruptive(
428 $this->
lng->txt(
'mail_empty_trash'),
429 $this->
lng->txt(
'mail_empty_trash_confirmation'),
430 $this->
ctrl->getLinkTarget($this, self::CMD_EMPTY_TRASH)
433 $this->ui_factory->button()->standard(
434 $this->
lng->txt(
'mail_empty_trash'),
436 )->withOnClick($modal->getShowSignal())
446 $this->data_factory->uri(
448 $this->ctrl->getLinkTarget($this, self::CMD_TABLE_ACTION)
451 )->acquireParameters(
452 [self::URL_BUILDER_PREFIX],
455 self::PARAM_TARGET_FOLDER
463 $this->mbox->getSubFolders(),
470 $this->
http->request(),
473 $this->
user->getDateFormat(),
474 $this->
user->getTimeFormat(),
481 $this->tpl->setTitle($this->folder->getTitle());
482 $this->tpl->setContent($this->ui_renderer->render(
$components));
483 $this->tpl->printToStdout();
488 $this->
ctrl->clearParameters($this);
489 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $this->folder->getFolderId());
490 $this->
ctrl->redirect($this, self::CMD_SHOW_FOLDER);
495 $parent_folder_id = $this->mbox->getParentFolderId($this->folder->getFolderId());
496 if ($parent_folder_id > 0 && $this->mbox->deleteFolder($this->folder->getFolderId())) {
497 $this->tpl->setOnScreenMessage(
499 $this->
lng->txt(
'mail_folder_deleted'),
502 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $parent_folder_id);
503 $this->
ctrl->redirect($this, self::CMD_SHOW_FOLDER);
505 $this->tpl->setOnScreenMessage(
507 $this->
lng->txt(
'mail_error_delete'),
516 $form = $this->ui_factory->input()->container()->form()->standard(
517 $this->
ctrl->getFormAction($this, self::CMD_ADD_SUB_FOLDER),
519 'folder' => $this->ui_factory->input()->field()->section([
520 'title' => $this->ui_factory->input()->field()->text($this->
lng->txt(
'title'))->withRequired(
true)
521 ], $this->
lng->txt(
'mail_add_folder'))
525 $request = $this->
http->request();
526 if ($request->getMethod() ===
'POST') {
527 $form = $form->withRequest($request);
528 $data = $form->getData();
529 if (!empty(
$data[
'folder'][
'title'])) {
530 $new_folder_id = $this->mbox->addFolder(
531 $this->folder->getFolderId(),
532 (string)
$data[
'folder'][
'title']
534 if ($new_folder_id > 0) {
535 $this->tpl->setOnScreenMessage(
537 $this->
lng->txt(
'mail_folder_created'),
540 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $new_folder_id);
541 $this->
ctrl->redirect($this, self::CMD_SHOW_FOLDER);
543 $this->tpl->setOnScreenMessage(
545 $this->
lng->txt(
'mail_folder_exists')
550 $this->tpl->setContent($this->ui_renderer->render($form));
551 $this->tpl->printToStdout();
556 $form = $this->ui_factory->input()->container()->form()->standard(
557 $this->
ctrl->getFormAction($this, self::CMD_RENAME_SUB_FOLDER),
559 'folder' => $this->ui_factory->input()->field()->section([
560 'title' => $this->ui_factory->input()->field()->text($this->
lng->txt(
'title'))->withRequired(
true)
561 ], $this->
lng->txt(
'mail_rename_folder'))
565 $request = $this->
http->request();
566 if ($request->getMethod() ===
'POST') {
567 $form = $form->withRequest($request);
568 $data = $form->getData();
569 if (!empty(
$data[
'folder'][
'title'])) {
570 if ($this->mbox->renameFolder($this->folder->getFolderId(), (string)
$data[
'folder'][
'title'])) {
571 $this->tpl->setOnScreenMessage(
573 $this->
lng->txt(
'mail_folder_name_changed'),
578 $this->tpl->setOnScreenMessage(
580 $this->
lng->txt(
'mail_folder_exists')
585 $this->tpl->setContent($this->ui_renderer->render($form));
586 $this->tpl->printToStdout();
592 $this->
ctrl->getFormAction($this, self::CMD_SHOW_FOLDER),
596 $this->ui_service->filter(),
623 self::URL_BUILDER_PREFIX . URLBuilder::SEPARATOR . self::PARAM_MAIL_ID,
625 self::PARAM_INTERRUPTIVE_ITEMS
630 $this->
http->wrapper()->post(),
631 $this->
http->wrapper()->query()
634 if ($wrapper->has($param)) {
635 return $wrapper->retrieve(
638 $this->refinery->kindlyTo()->listOf($this->
refinery->kindlyTo()->int()),
656 if (count($mail_ids) !== 1) {
658 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_select_one'));
662 $new_folder_id = $this->
http->wrapper()->query()->retrieve(
664 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->
refinery->always(0)])
666 $redirect_folder_id = $new_folder_id;
668 foreach ($mail_ids as $mail_id) {
669 $mail_data = $this->umail->getMail($mail_id);
670 if (isset($mail_data[
'folder_id']) &&
671 is_numeric($mail_data[
'folder_id']) &&
672 (
int) $mail_data[
'folder_id'] > 0) {
673 $redirect_folder_id = (
int) $mail_data[
'folder_id'];
678 if ($this->umail->moveMailsToFolder($mail_ids, $new_folder_id)) {
679 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'mail_moved'),
true);
680 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $redirect_folder_id);
681 $this->
ctrl->redirect($this, self::CMD_SHOW_FOLDER);
683 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'mail_move_error'));
690 if (!$this->folder->isTrash()) {
691 $this->tpl->setOnScreenMessage(
693 $this->
lng->txt(
'mail_operation_on_invalid_folder'),
700 $this->tpl->setOnScreenMessage(
702 $this->
lng->txt(
'mail_deleted'),
717 foreach ($records as $record) {
719 if (!empty($record->getSendTime())) {
720 $time = $record->getSendTime()->setTimezone($user_timezone);
721 $prefix = $time->format($this->
user->getDateFormat()->toString()) .
' ';
723 $items[] = $this->ui_factory->modal()->interruptiveItem()->standard(
724 (
string) $record->getMailId(),
725 $prefix . $this->
refinery->encode()->htmlSpecialCharsAsEntities()->transform($record->getSubject())
729 $modal = $this->ui_factory->modal()->interruptive(
730 $this->
lng->txt(
'delete'),
731 $this->
lng->txt(
'mail_sure_delete_' . (count($items) === 1 ?
's' :
'p')),
732 $this->
ctrl->getFormAction($this, self::CMD_DELETE_MAILS)
733 )->withAffectedItems($items);
735 $this->
http->saveResponse(
736 $this->
http->response()->withBody(
737 Streams::ofString($this->ui_renderer->renderAsync($modal))
740 $this->
http->sendResponse();
741 $this->
http->close();
744 protected function showMail():
void 750 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
753 $mail_data = $this->umail->getMail($mail_id);
754 if ($mail_data ===
null) {
755 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
758 $this->umail->markRead([$mail_id]);
760 $this->tpl->setTitle($this->
lng->txt(
'mail_mails_of'));
762 $this->
tabs->clearTargets();
763 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $mail_data[
'folder_id']);
764 $this->
tabs->setBackTarget(
765 $this->
lng->txt(
'back_to_folder'),
766 $this->
ctrl->getFormAction($this, self::CMD_SHOW_FOLDER)
768 $this->
ctrl->clearParameters($this);
770 $this->
ctrl->setParameter($this, self::PARAM_MAIL_ID, $mail_id);
771 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $mail_data[
'folder_id']);
772 $this->
toolbar->setFormAction($this->
ctrl->getFormAction($this, self::CMD_SHOW_MAIL));
773 $this->
ctrl->clearParameters($this);
776 $form->setId(
'MailContent');
777 $form->setPreventDoubleSubmission(
false);
778 $form->setTableWidth(
'100%');
779 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $mail_data[
'folder_id']);
780 $this->
ctrl->setParameter($this, self::PARAM_MAIL_ID, $mail_id);
781 $form->setFormAction($this->
ctrl->getFormAction($this, self::CMD_SHOW_MAIL));
782 $this->
ctrl->clearParameters($this);
783 $form->setTitle($this->
lng->txt(
'mail_mails_of'));
788 if ($sender instanceof
ilObjUser && $sender->getId() !== 0 && !$sender->isAnonymous()) {
789 $this->
ctrl->setParameterByClass(
790 ilMailFormGUI::class,
791 self::PARAM_FOLDER_ID,
792 $mail_data[
'folder_id']
794 $this->
ctrl->setParameterByClass(ilMailFormGUI::class, self::PARAM_MAIL_ID, $mail_id);
796 $reply_btn = $this->ui_factory->button()->primary(
797 $this->
lng->txt(
'reply'),
798 $this->
ctrl->getLinkTargetByClass(ilMailFormGUI::class)
800 $this->
toolbar->addStickyItem($reply_btn);
801 $this->
ctrl->clearParametersByClass(ilMailFormGUI::class);
804 $this->
ctrl->setParameterByClass(ilMailFormGUI::class, self::PARAM_FOLDER_ID, $mail_data[
'folder_id']);
805 $this->
ctrl->setParameterByClass(ilMailFormGUI::class, self::PARAM_MAIL_ID, $mail_id);
807 if ($reply_btn ===
null) {
808 $fwd_btn = $this->ui_factory->button()->primary(
809 $this->
lng->txt(
'forward'),
810 $this->
ctrl->getLinkTargetByClass(ilMailFormGUI::class)
812 $this->
toolbar->addStickyItem($fwd_btn);
814 $fwd_btn = $this->ui_factory->button()->standard(
815 $this->
lng->txt(
'forward'),
816 $this->
ctrl->getLinkTargetByClass(ilMailFormGUI::class)
818 $this->
toolbar->addComponent($fwd_btn);
820 $this->
ctrl->clearParametersByClass(ilMailFormGUI::class);
822 if ($sender && $sender->getId() && !$sender->isAnonymous()) {
823 $linked_fullname = $sender->getPublicName();
824 $avatar = $this->ui_factory->symbol()->avatar()->picture(
825 $sender->getPersonalPicturePath(
'xsmall'),
826 $sender->getPublicName()
830 $this->
ctrl->setParameter($this, self::PARAM_MAIL_ID, $mail_id);
831 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $mail_data[
'folder_id']);
832 $this->
ctrl->setParameter($this, self::PARAM_USER_ID, $sender->getId());
833 $linked_fullname =
'<br /><a class="mailusername" href="' . $this->
ctrl->getLinkTarget(
836 ) .
'" title="' . $linked_fullname .
'">' . $linked_fullname .
'</a>';
837 $this->
ctrl->clearParameters($this);
841 $from->setHtml($this->ui_renderer->render($avatar) .
' ' . $linked_fullname);
842 } elseif (!$sender || !$sender->getId()) {
844 $from->setHtml(trim(($mail_data[
'import_name'] ??
'') .
' (' . $this->
lng->txt(
'user_deleted') .
')'));
848 $this->ui_renderer->render(
856 $form->addItem($from);
861 $this->umail->formatNamesForOutput($mail_data[
'rcp_to'] ??
''),
867 if ($mail_data[
'rcp_cc']) {
871 $this->umail->formatNamesForOutput($mail_data[
'rcp_cc']),
878 if ($mail_data[
'rcp_bcc']) {
882 $this->umail->formatNamesForOutput($mail_data[
'rcp_bcc']),
886 $form->addItem($bcc);
891 $form->addItem($subject);
899 $form->addItem($date);
905 if ($mail_data[
'attachments']) {
909 foreach ($mail_data[
'attachments'] as $file) {
910 $radiog->addOption(
new ilRadioOption($file, md5((
string) $file)));
913 $att->
setHtml($radiog->render());
914 $form->addCommandButton(self::CMD_DELIVER_FILE, $this->
lng->txt(
'download'));
915 $form->addItem($att);
918 $current_folder = $this->mbox->getFolderData((
int) $mail_data[
'folder_id']);
919 if ($current_folder ===
null) {
920 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'mail_operation_on_invalid_folder'),
true);
921 $this->
ctrl->setParameterByClass(ilMailGUI::class, self::PARAM_FOLDER_ID, $this->mbox->getInboxFolder());
922 $this->
ctrl->redirectByClass(ilMailGUI::class);
925 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $this->folder->getFolderId());
928 $current_folder->getTitle(),
929 $this->
ctrl->getLinkTarget($this, self::CMD_SHOW_FOLDER)
931 $this->
ctrl->clearParameters($this);
932 $this->
tabs->activateTab(
'current_folder');
935 $folders = $this->mbox->getSubFolders();
936 foreach ($folders as $folder) {
937 if ((!$folder->isTrash() || !$current_folder->isTrash()) &&
938 $folder->getFolderId() !== $mail_data[
'folder_id']) {
939 $move_links[] = $this->ui_factory->button()->shy(
941 $this->
lng->txt(
'mail_move_to_folder_x'),
943 ) . ($folder->isTrash() ?
' (' . $this->
lng->txt(
'delete') .
')' :
''),
945 )->withOnLoadCode(
static fn(
$id):
string =>
" 946 document.getElementById('$id').addEventListener('click', function(e) { 947 const frm = this.closest('form'), 948 action = new URL(frm.action), 949 action_params = new URLSearchParams(action.search); 951 action_params.delete('cmd'); 952 action_params.append('cmd', '" . self::CMD_MOVE_SINGLE_MAIL .
"'); 953 action_params.delete('folder_id'); 954 action_params.append('folder_id', '" . $folder->getFolderId() .
"'); 956 action.search = action_params.toString(); 958 frm.action = action.href; 969 if ($this->folder->isTrash()) {
970 $this->
ctrl->setParameter($this, self::PARAM_MAIL_ID, $mail_id);
971 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $mail_data[
'folder_id']);
972 $modal = $this->ui_factory->modal()->interruptive(
973 $this->
lng->txt(
'delete'),
974 $this->
lng->txt(
'mail_sure_delete_s'),
975 $this->
ctrl->getLinkTarget($this, self::CMD_DELETE_MAILS)
976 )->withAffectedItems([
977 $this->ui_factory->modal()->interruptiveItem()->standard(
981 ) .
' ' . $mail_data[
'm_subject']
985 $this->ui_factory->button()->standard(
986 $this->
lng->txt(
'delete'),
988 )->withOnClick($modal->getShowSignal())
990 $this->
ctrl->clearParameters($this);
992 $ui_components[] = $modal;
995 if ($move_links !== []) {
997 $this->ui_factory->dropdown()->standard($move_links)
998 ->withLabel($this->
lng->txt(
'mail_move_to_folder_btn_label'))
1002 $this->
toolbar->addSeparator();
1004 $this->
ctrl->setParameter($this, self::PARAM_MAIL_ID, $mail_id);
1005 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $mail_data[
'folder_id']);
1006 $print_url = $this->
ctrl->getLinkTarget($this, self::CMD_PRINT_MAIL);
1007 $this->
ctrl->clearParameters($this);
1008 $print_btn = $this->ui_factory->button()
1009 ->standard($this->
lng->txt(
'print'),
'#')
1011 document.getElementById('$id').addEventListener('click', function() { 1012 const frm = this.closest('form'), 1013 action = frm.action; 1015 frm.action = '$print_url'; 1016 frm.target = '_blank'; 1019 frm.action = action; 1020 frm.removeAttribute('target'); 1025 $this->
toolbar->addComponent($print_btn);
1027 $prev_mail = $this->umail->getPreviousMail($mail_id);
1028 $next_mail = $this->umail->getNextMail($mail_id);
1029 if (is_array($prev_mail) || is_array($next_mail)) {
1030 $this->
toolbar->addSeparator();
1032 if ($prev_mail && $prev_mail[self::PARAM_MAIL_ID]) {
1033 $this->
ctrl->setParameter($this, self::PARAM_MAIL_ID, $prev_mail[self::PARAM_MAIL_ID]);
1034 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $this->folder->getFolderId());
1035 $pref_btn = $this->ui_factory->button()
1037 $this->
lng->txt(
'previous'),
1038 $this->
ctrl->getLinkTarget($this, self::CMD_SHOW_MAIL)
1040 $this->
toolbar->addComponent($pref_btn);
1041 $this->
ctrl->clearParameters($this);
1044 if ($next_mail && $next_mail[self::PARAM_MAIL_ID]) {
1045 $this->
ctrl->setParameter($this, self::PARAM_MAIL_ID, $next_mail[self::PARAM_MAIL_ID]);
1046 $this->
ctrl->setParameter($this, self::PARAM_FOLDER_ID, $this->folder->getFolderId());
1047 $next_btn = $this->ui_factory->button()
1049 $this->
lng->txt(
'next'),
1050 $this->
ctrl->getLinkTarget($this, self::CMD_SHOW_MAIL)
1052 $this->
toolbar->addComponent($next_btn);
1053 $this->
ctrl->clearParameters($this);
1057 $this->tpl->setContent($form->getHTML() . $this->ui_renderer->render($ui_components));
1058 $this->tpl->printToStdout();
1063 $tplprint =
new ilTemplate(
'tpl.mail_print.html',
true,
true,
'components/ILIAS/Mail');
1066 $mail_data = $this->umail->getMail($mail_id);
1070 $tplprint->setVariable(
'TXT_FROM', $this->
lng->txt(
'from'));
1071 if ($sender instanceof
ilObjUser && $sender->getId() !== 0 && !$sender->isAnonymous()) {
1072 $tplprint->setVariable(
'FROM', $sender->getPublicName());
1073 } elseif (!$sender instanceof
ilObjUser || $sender->getId() === 0) {
1074 $tplprint->setVariable(
1076 trim(($mail_data[
'import_name'] ??
'') .
' (' . $this->
lng->txt(
'user_deleted') .
')')
1082 $tplprint->setVariable(
'TXT_TO', $this->
lng->txt(
'mail_to'));
1083 $tplprint->setVariable(
'TO', $mail_data[
'rcp_to']);
1085 if ($mail_data[
'rcp_cc']) {
1086 $tplprint->setCurrentBlock(
'cc');
1087 $tplprint->setVariable(
'TXT_CC', $this->
lng->txt(
'mail_cc'));
1088 $tplprint->setVariable(
'CC', $mail_data[
'rcp_cc']);
1089 $tplprint->parseCurrentBlock();
1092 if ($mail_data[
'rcp_bcc']) {
1093 $tplprint->setCurrentBlock(
'bcc');
1094 $tplprint->setVariable(
'TXT_BCC', $this->
lng->txt(
'mail_bcc'));
1095 $tplprint->setVariable(
'BCC', $mail_data[
'rcp_bcc']);
1096 $tplprint->parseCurrentBlock();
1099 $tplprint->setVariable(
'TXT_SUBJECT', $this->
lng->txt(
'subject'));
1100 $tplprint->setVariable(
'SUBJECT', htmlspecialchars((
string) $mail_data[
'm_subject']));
1102 $tplprint->setVariable(
'TXT_DATE', $this->
lng->txt(
'date'));
1103 $tplprint->setVariable(
1108 $tplprint->setVariable(
'TXT_MESSAGE', $this->
lng->txt(
'message'));
1109 $tplprint->setVariable(
'MAIL_MESSAGE', nl2br(htmlspecialchars((
string) $mail_data[
'm_message'])));
1116 $mail_id = $this->
http->wrapper()->query()->retrieve(
1117 self::PARAM_MAIL_ID,
1118 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->
refinery->always(0)])
1120 if ($mail_id <= 0) {
1121 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1126 $this->
refinery->byTrying([$this->refinery->kindlyTo()->string(), $this->
refinery->always(
'')])
1136 while (str_contains((
string)
$filename,
'..')) {
1137 $filename = str_replace(
'..',
'', $filename);
1148 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_select_attachment'));
1152 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt($e->getMessage()),
true);
1161 $mail_data = $this->umail->getMail($mail_id);
1162 if ($mail_data ===
null || [] === (array) $mail_data[
'attachments']) {
1166 $type = $this->
http->wrapper()->query()->retrieve(
1168 $this->
refinery->byTrying([$this->refinery->kindlyTo()->string(), $this->
refinery->always(
'')])
1172 if (count($mail_data[
'attachments']) === 1) {
1173 $attachment = current($mail_data[
'attachments']);
1176 if ($type ===
'draft') {
1177 if (!$mail_file_data->checkFilesExist([$attachment])) {
1180 $path_to_file = $mail_file_data->getAbsoluteAttachmentPoolPathByFilename($attachment);
1183 $file = $mail_file_data->getAttachmentPathAndFilenameByMd5Hash(
1184 md5((
string) $attachment),
1187 $path_to_file = $file[
'path'];
1195 $mail_file_data->deliverAttachmentsAsZip(
1196 $mail_data[
'm_subject'],
1198 $mail_data[
'attachments'],
1203 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt($e->getMessage()),
true);
getAttachmentPathAndFilenameByMd5Hash(string $md5FileHash, int $mail_id)
static get(string $a_var)
This class represents an option in a radio group.
readonly GlobalHttpState $http
readonly ilCtrlInterface $ctrl
static getUserObjectById(int $usr_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const string CMD_DELIVER_FILE
const string CMD_SHOW_MAIL
readonly ilUIService $ui_service
const string PARAM_ACTION
const string CMD_EMPTY_TRASH
const string CMD_ADD_SUB_FOLDER
const string URL_BUILDER_PREFIX
static _getIliasMailerName()
readonly ilGlobalTemplateInterface $tpl
static _lookupPref(int $a_usr_id, string $a_keyword)
const MESSAGE_TYPE_SUCCESS
readonly Factory $ui_factory
const string PARAM_TARGET_FOLDER
const string CMD_RENAME_SUB_FOLDER
withOnLoadCode(Closure $binder)
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.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
confirmDeleteMails(array $mail_ids)
Confirm the deletion of selected mails in async modal.
const string PARAM_MAIL_ID
GUI class for public user profile presentation.
const string CMD_SHOW_FOLDER
static http()
Fetches the global http state from ILIAS.
This is how the factory for UI elements looks.
initRequest()
Init class variables that can be determined in an actual request.
const string CMD_TABLE_ACTION
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const string CMD_PRINT_MAIL
const string CMD_MOVE_SINGLE_MAIL
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 Refinery $refinery
const string PARAM_INTERRUPTIVE_ITEMS
const string PARAM_FOLDER_ID
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
const string CMD_DELETE_SUB_FOLDER
moveSingleMail()
Move a single mail to a folder Called from showMail page.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
readonly Renderer $ui_renderer
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
readonly ilToolbarGUI $toolbar
readonly ilErrorHandling $error
getFilteredSearch()
Searcher for mails in the folder, initialized with the current filter values needed for table display...
const MESSAGE_TYPE_FAILURE
const string CMD_DELETE_MAILS
const string CMD_SHOW_USER
readonly DataFactory $data_factory
const string PARAM_USER_ID
static set(string $a_var, $a_val)
Set a value.
static _lookupLogin(int $a_user_id)