1 <?php declare(strict_types=1);
71 $this->
user = $DIC->user();
82 $this->_currentFolderId = $a_current_folder_id;
83 $this->_parentObject = $a_parent_obj;
85 $this->_isTrashFolder = $isTrashFolder;
86 $this->_isSentFolder = $isSentFolder;
87 $this->_isDraftsFolder = $isDraftsFolder;
89 $this->
setId(
'mail_folder_tbl_' . $a_current_folder_id);
99 $this->ctrl->setParameter($this->
getParentObject(),
'mobj_id', $this->_currentFolderId);
100 $this->
setFormAction($this->ctrl->getFormAction($this->getParentObject(),
'showFolder'));
105 $this->
setRowTemplate(
'tpl.mail_folder_row.html',
'Services/Mail');
117 return isset($column[
'optional']) && $column[
'optional'];
122 $columns[$column[
'field']] = $column;
135 if (array_key_exists($index, $columnDefinition)) {
136 $column = $columnDefinition[
$index];
137 if (isset($column[
'optional']) && !$column[
'optional']) {
141 is_array($this->visibleOptionalColumns) &&
142 array_key_exists($column[
'field'], $this->visibleOptionalColumns)
156 $this->tpl->setVariable(strtoupper($key), $value);
166 if (is_array($this->visibleOptionalColumns)) {
167 if (!array_key_exists(
'attachments', $this->visibleOptionalColumns)) {
168 unset($row[
'attachment_indicator']);
171 if (!array_key_exists(
'personal_picture', $this->visibleOptionalColumns)) {
172 unset($row[
'img_sender'], $row[
'alt_sender']);
184 if ($this->column_definition !== null) {
198 'is_checkbox' =>
true,
203 'field' =>
'attachments',
204 'txt' => $this->lng->txt(
'mail_tbl_head_attachments'),
213 'field' =>
'personal_picture',
214 'txt' => $this->lng->txt(
'personal_picture'),
225 'txt' => $this->lng->txt(
'recipient'),
234 'txt' => $this->lng->txt(
'sender'),
244 'field' =>
'search_content',
245 'txt' => $this->lng->txt(
'search_content'),
253 'field' =>
'm_subject',
254 'txt' => $this->lng->txt(
'subject'),
263 'field' =>
'send_time',
264 'txt' => $this->lng->txt(
'date'),
272 'field' =>
'actions',
273 'txt' => $this->lng->txt(
'actions'),
280 $this->column_definition =
$columns;
298 isset($column[
'sortable']) && $column[
'sortable'] ? $column[
'field'] :
'',
299 $column[
'width'] ??
'',
300 isset($column[
'is_checkbox']) ? (
bool) $column[
'is_checkbox'] :
false 306 $mtree->setTableNames(
'mail_tree',
'mail_obj_data');
307 $this->_folderNode = $mtree->getNodeData($this->_currentFolderId);
312 $this->
initMultiCommands($this->_parentObject->mbox->getActions($this->_currentFolderId));
337 if ($this->_folderNode[
'm_type'] ===
'trash' && $this->
getNumberOfMails() > 0) {
338 $this->
addCommandButton(
'confirmEmptyTrash', $this->lng->txt(
'mail_empty_trash'));
350 foreach ($actions as $key => $action) {
351 if ($key ===
'moveMails') {
352 $folders = $this->_parentObject->mbox->getSubFolders();
353 foreach ($folders as $folder) {
354 if ($folder[
'type'] !==
'trash' || !$this->
isTrashFolder()) {
355 if ($folder[
'type'] !==
'user_folder') {
356 $label = $action .
' ' . $this->lng->txt(
'mail_' . $folder[
'title']) .
357 ($folder[
'type'] ===
'trash' ?
' (' . $this->lng->txt(
'delete') .
')' :
'');
360 $this->
addMultiCommand($key .
'_' . $folder[
'obj_id'], $action .
' ' . $folder[
'title']);
380 $this->_selectedItems = $a_selected_items;
399 isset($this->
filter[
'mail_filter']) &&
400 is_string($this->
filter[
'mail_filter']) &&
401 $this->
filter[
'mail_filter'] !==
'' &&
424 if ($this->_folderNode[
'm_type'] ===
'user_folder') {
425 $txt_folder = $this->_folderNode[
'title'];
426 $img_folder =
'icon_user_folder.png';
428 $txt_folder = $this->lng->txt(
'mail_' . $this->_folderNode[
'title']);
429 $img_folder =
'icon' . substr($this->_folderNode[
'title'], 1) .
'.png';
435 $query_parser->setFields([
436 'title' => (
bool) $this->
filter[
'mail_filter_subject'],
437 'content' => (
bool) $this->filter[
'mail_filter_body'],
438 'mattachment' => (
bool) $this->filter[
'mail_filter_attach'],
439 'msender' => (
bool) $this->filter[
'mail_filter_sender'],
440 'mrcp' => (
bool) $this->filter[
'mail_filter_recipients']
442 $query_parser->parse();
454 'mail_filter_only_unread' => $this->filter[
'mail_filter_only_unread'],
455 'mail_filter_only_with_attachments' => $this->filter[
'mail_filter_only_with_attachments'],
490 if (
'mail_search_empty_result' === $e->getMessage()) {
493 $data[
'cnt_unread'] = 0;
501 foreach (
$data[
'set'] as $mail) {
503 $user_ids[$mail[
'sender_id']] = $mail[
'sender_id'];
511 foreach (
$data[
'set'] as $key => $mail) {
515 $mail[
'checked'] =
' checked="checked" ';
518 $mail[
'txt_select_mail_with_subject'] = sprintf(
519 $this->lng->txt(
'select_mail_with_subject_x'),
520 htmlspecialchars($mail[
'm_subject'] ??
'')
525 $this->_parentObject->umail->formatNamesForOutput((
string) $mail[
'rcp_to']),
531 $mail[
'from'] = $mail[
'mail_login'] = $mail[
'alt_sender'] = htmlspecialchars(ilMail::_getIliasMailerName());
536 $mail[
'img_sender'] =
$user->getPersonalPicturePath(
'xxsmall');
537 $mail[
'from'] = $mail[
'mail_login'] = $mail[
'alt_sender'] = htmlspecialchars(
$user->getPublicName());
539 $mail[
'img_sender'] =
'';
540 $mail[
'from'] = $mail[
'mail_login'] = $mail[
'import_name'] .
' (' . $this->lng->txt(
'user_deleted') .
')';
546 $this->ctrl->setParameterByClass(
'ilmailformgui',
'mail_id', $mail[
'mail_id']);
547 $this->ctrl->setParameterByClass(
'ilmailformgui',
'mobj_id', $this->_currentFolderId);
548 $this->ctrl->setParameterByClass(
'ilmailformgui',
'type',
'draft');
549 $link_mark_as_read = $this->ctrl->getLinkTargetByClass(
'ilmailformgui');
550 $this->ctrl->clearParametersByClass(
'ilmailformgui');
552 $this->ctrl->setParameter($this->
getParentObject(),
'mail_id', $mail[
'mail_id']);
553 $this->ctrl->setParameter($this->
getParentObject(),
'mobj_id', $this->_currentFolderId);
554 $link_mark_as_read = $this->ctrl->getLinkTarget($this->
getParentObject(),
'showMail');
557 $css_class = $mail[
'm_status'] ===
'read' ?
'mailread' :
'mailunread';
560 $search_result = array();
561 foreach (
$result->getFields($mail[
'mail_id']) as $content) {
562 if (
'title' === $content[0]) {
563 $mail[
'msr_subject_link_read'] = $link_mark_as_read;
564 $mail[
'msr_subject_mailclass'] = $css_class;
565 $mail[
'msr_subject'] = $content[1];
567 $search_result[] = $content[1];
570 $mail[
'msr_data'] = implode(
'', array_map(
function ($value) {
571 return '<p>' . $value .
'</p>';
574 if (!$mail[
'msr_subject']) {
575 $mail[
'msr_subject_link_read'] = $link_mark_as_read;
576 $mail[
'msr_subject_mailclass'] = $css_class;
577 $mail[
'msr_subject'] = htmlspecialchars($mail[
'm_subject'] ??
'');
579 $mail[
'msr_subject_read_unread'] = $mail[
'm_status'] ===
'read' ? $this->lng->txt(
'mail_is_read') : $this->lng->txt(
'mail_is_unread');
581 $mail[
'mail_link_read'] = $link_mark_as_read;
582 $mail[
'mailclass'] = $css_class;
583 $mail[
'mail_subject'] = htmlspecialchars($mail[
'm_subject'] ??
'');
584 $mail[
'mail_subject_read_unread'] = $mail[
'm_status'] ===
'read' ? $this->lng->txt(
'mail_is_read') : $this->lng->txt(
'mail_is_unread');
589 $mail[
'attachment_indicator'] =
'';
590 if (is_array($mail[
'attachments']) && count($mail[
'attachments']) > 0) {
591 $this->ctrl->setParameter($this->
getParentObject(),
'mail_id', (
int) $mail[
'mail_id']);
595 $this->ctrl->setParameter($this->
getParentObject(),
'mobj_id', $this->_currentFolderId);
596 $mail[
'attachment_indicator'] = $this->uiRenderer->render(
597 $this->uiFactory->symbol()->glyph()->attachment(
598 $this->ctrl->getLinkTarget($this->getParentObject(),
'deliverAttachments')
606 $data[
'set'][$key] = $mail;
613 $this->
setTitleData($txt_folder, (
int) $data[
'cnt'], (
int) $data[
'cnt_unread'], $img_folder);
626 protected function setTitleData(
string $folderLabel,
int $mailCount,
int $unreadCount,
string $imgFolder) : self
628 $titleTemplate =
new ilTemplate(
'tpl.mail_folder_title.html',
true,
true,
'Services/Mail');
629 $titleTemplate->setVariable(
'TXT_FOLDER', $folderLabel);
630 $titleTemplate->setVariable(
'MAIL_COUNT', $mailCount);
631 $titleTemplate->setVariable(
'TXT_MAIL_S', $this->lng->txt(
'mail_s'));
632 $titleTemplate->setVariable(
'MAIL_COUNT_UNREAD', $unreadCount);
633 $titleTemplate->setVariable(
'TXT_UNREAD', $this->lng->txt(
'unread'));
635 parent::setTitle($titleTemplate->get(), $imgFolder);
646 $this->_number_of_mails = $a_number_of_mails;
669 $quickFilter->readFromSession();
670 $this->
filter[
'mail_filter'] = $quickFilter->getValue();
674 $this->lng->txt(
'mail_filter_recipients'),
675 'mail_filter_recipients' 677 $subFilterInRecipients->
setOptionTitle($this->lng->txt(
'mail_filter_recipients'));
678 $subFilterInRecipients->setValue(1);
679 $quickFilter->addSubItem($subFilterInRecipients);
680 $subFilterInRecipients->setParent($this);
681 $subFilterInRecipients->readFromSession();
682 $this->
filter[
'mail_filter_recipients'] = (int) $subFilterInRecipients->getChecked();
685 $this->lng->txt(
'mail_filter_sender'),
688 $subFilterInSender->
setOptionTitle($this->lng->txt(
'mail_filter_sender'));
689 $subFilterInSender->setValue(1);
690 $quickFilter->addSubItem($subFilterInSender);
691 $subFilterInSender->setParent($this);
692 $subFilterInSender->readFromSession();
693 $this->
filter[
'mail_filter_sender'] = (int) $subFilterInSender->getChecked();
697 $this->lng->txt(
'mail_filter_subject'),
698 'mail_filter_subject' 700 $subFilterInSubject->
setOptionTitle($this->lng->txt(
'mail_filter_subject'));
701 $subFilterInSubject->setValue(1);
702 $quickFilter->addSubItem($subFilterInSubject);
703 $subFilterInSubject->setParent($this);
704 $subFilterInSubject->readFromSession();
705 $this->
filter[
'mail_filter_subject'] = (int) $subFilterInSubject->getChecked();
708 $this->lng->txt(
'mail_filter_body'),
711 $subFilterInBody->
setOptionTitle($this->lng->txt(
'mail_filter_body'));
712 $subFilterInBody->setValue(1);
713 $quickFilter->addSubItem($subFilterInBody);
714 $subFilterInBody->setParent($this);
715 $subFilterInBody->readFromSession();
716 $this->
filter[
'mail_filter_body'] = (int) $subFilterInBody->getChecked();
720 $this->lng->txt(
'mail_filter_attach'),
723 $subFilterInAttachments->
setOptionTitle($this->lng->txt(
'mail_filter_attach'));
724 $subFilterInAttachments->setValue(1);
725 $quickFilter->addSubItem($subFilterInAttachments);
726 $subFilterInAttachments->setParent($this);
727 $subFilterInAttachments->readFromSession();
728 $this->
filter[
'mail_filter_attach'] = (int) $subFilterInAttachments->getChecked();
733 $this->lng->txt(
'mail_filter_only_unread'),
734 'mail_filter_only_unread' 738 $onlyUnread->readFromSession();
739 $this->
filter[
'mail_filter_only_unread'] = (int) $onlyUnread->getChecked();
744 $this->lng->txt(
'mail_filter_only_with_attachments'),
745 'mail_filter_only_with_attachments' 749 $onlyWithAttachments->readFromSession();
750 $this->
filter[
'mail_filter_only_with_attachments'] = (int) $onlyWithAttachments->getChecked();
755 $duration->setStartText($this->lng->txt(
'mail_filter_period_from'));
756 $duration->setEndText($this->lng->txt(
'mail_filter_period_until'));
759 $duration->setShowTime(
false);
761 $duration->readFromSession();
762 $this->
filter[
'period'] = $duration->getValue();
770 parent::writeFilterToSession();
772 foreach ($this->sub_filter as $item) {
773 if ($item->checkInput()) {
774 $item->setValueByArray(
$_POST);
775 $item->writeToSession();
785 parent::resetFilter();
787 foreach ($this->sub_filter as $item) {
788 if ($item->checkInput()) {
789 $item->setValueByArray(
$_POST);
790 $item->clearFromSession();
808 $dropDown = $this->uiFactory
811 ->withLabel($this->lng->txt(
'actions'));
813 return $this->uiRenderer->render([$dropDown]);
823 $this->ctrl->setParameterByClass(
'ilmailformgui',
'mail_id', (
int) $mail[
'mail_id']);
824 $this->ctrl->setParameterByClass(
'ilmailformgui',
'mobj_id', $this->_currentFolderId);
825 $this->ctrl->setParameterByClass(
'ilmailformgui',
'type',
'draft');
826 $viewButton = $this->uiFactory
829 $this->lng->txt(
'view'),
830 $this->ctrl->getLinkTargetByClass(
'ilmailformgui')
832 $this->ctrl->clearParametersByClass(
'ilmailformgui');
834 $this->ctrl->setParameter($this->
getParentObject(),
'mail_id', (
int) $mail[
'mail_id']);
835 $this->ctrl->setParameter($this->
getParentObject(),
'mobj_id', $this->_currentFolderId);
836 $viewButton = $this->uiFactory
839 $this->lng->txt(
'view'),
845 $buttons[] = $viewButton;
855 if (isset($mail[
'sender_id']) && $mail[
'sender_id'] > 0 && $mail[
'sender_id'] !=
ANONYMOUS_USER_ID) {
856 $this->ctrl->setParameterByClass(
'ilmailformgui',
'mobj_id', $this->_currentFolderId);
857 $this->ctrl->setParameterByClass(
'ilmailformgui',
'mail_id', (
int) $mail[
'mail_id']);
858 $this->ctrl->setParameterByClass(
'ilmailformgui',
'type',
'reply');
859 $replyButton = $this->uiFactory
862 $this->lng->txt(
'reply'),
863 $this->ctrl->getLinkTargetByClass(
'ilmailformgui')
865 $this->ctrl->clearParametersByClass(
'ilmailformgui');
867 $buttons[] = $replyButton;
879 $this->ctrl->setParameterByClass(
'ilmailformgui',
'mobj_id', $this->_currentFolderId);
880 $this->ctrl->setParameterByClass(
'ilmailformgui',
'mail_id', (
int) $mail[
'mail_id']);
881 $this->ctrl->setParameterByClass(
'ilmailformgui',
'type',
'forward');
882 $forwardButton = $this->uiFactory
885 $this->lng->txt(
'forward'),
886 $this->ctrl->getLinkTargetByClass(
'ilmailformgui')
888 $this->ctrl->clearParametersByClass(
'ilmailformgui');
890 $buttons[] = $forwardButton;
901 $this->ctrl->setParameter($this->
getParentObject(),
'mobj_id', $this->_currentFolderId);
902 $this->ctrl->setParameter($this->
getParentObject(),
'mail_id', (
int) $mail[
'mail_id']);
903 $printButton = $this->uiFactory
906 $this->lng->txt(
'print'),
908 )->withOpenInNewViewport(
true);
911 $buttons[] = $printButton;
920 $this->ctrl->setParameter($this->
getParentObject(),
'mobj_id', $this->_currentFolderId);
921 $html = parent::getHTML();
setSubmitFormOnEnter($a_val)
Set submit form on enter.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
addForwardRowAction(array $mail, array &$buttons)
An entity that renders components to a string output.
setExternalSorting($a_val)
Set external sorting.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
addReplyRowAction(array $mail, array &$buttons)
setTitleData(string $folderLabel, int $mailCount, int $unreadCount, string $imgFolder)
setExternalSegmentation($a_val)
Set external segmentation.
static _getMailBoxListData()
_getMailBoxListData
resetOffset($a_in_determination=false)
Reset offset.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
getOrderDirection()
Get order direction.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
getParentObject()
Get parent object.
initMultiCommands(array $actions)
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
removeInvisibleFields(array $row)
addViewRowAction(array $mail, array &$buttons)
__construct( $a_parent_obj, $a_current_folder_id, $a_parent_cmd, bool $isTrashFolder, bool $isSentFolder, bool $isDraftsFolder, Factory $uiFactory=null, Renderer $uiRenderer=null)
Constructor.
setResetCommand($a_val, $a_caption=null)
Set reset filter command.
setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top=false)
Set the name of the checkbox that should be toggled with a select all button.
This is how the factory for UI elements looks.
formatActionsDropDown(array $mail)
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
setSelectedItems(array $a_selected_items)
addMultiCommand($a_cmd, $a_text)
Add Command button.
static preloadUserObjects(array $usr_ids)
static getUserObjectById($usr_id)
getSelectedColumns()
Get selected columns.
setNumberOfMails(int $a_number_of_mails)
prepareHTML()
Call this before using getHTML()
isColumnVisible(int $index)
setRowTemplate($a_template, $a_template_dir="")
Set row template.
determineOffsetAndOrder($a_omit_offset=false)
Determine offset and order.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
__construct(Container $dic, ilPlugin $plugin)
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
addPrintRowAction(array $mail, array &$buttons)
static htmlencodePlainString($a_str, $a_make_links_clickable, $a_detect_goto_links=false)
Encodes a plain text string into HTML for display in a browser.
setMaxCount($a_max_count)
set max.
setEnableTitle($a_enabletitle)
Set Enable Title.
setFilterCommand($a_val, $a_caption=null)
Set filter command.