64 $this->
user = $DIC->user();
75 $this->_currentFolderId = $a_current_folder_id;
76 $this->_parentObject = $a_parent_obj;
86 $this->
setId(
'mail_folder_tbl_' . $a_current_folder_id);
94 parent::__construct($a_parent_obj, $a_parent_cmd);
96 $this->ctrl->setParameter($this->
getParentObject(),
'mobj_id', $this->_currentFolderId);
97 $this->
setFormAction($this->ctrl->getFormAction($this->getParentObject(),
'showFolder'));
102 $this->
setRowTemplate(
'tpl.mail_folder_row.html',
'Services/Mail');
114 return isset($column[
'optional']) && $column[
'optional'];
119 $columns[$column[
'field']] = $column;
132 if (array_key_exists($index, $columnDefinition)) {
133 $column = $columnDefinition[
$index];
134 if (isset($column[
'optional']) && !$column[
'optional']) {
138 is_array($this->visibleOptionalColumns) &&
139 array_key_exists($column[
'field'], $this->visibleOptionalColumns)
153 $this->tpl->setVariable(strtoupper(
$key), $value);
163 if (is_array($this->visibleOptionalColumns)) {
164 if (!array_key_exists(
'attachments', $this->visibleOptionalColumns)) {
165 unset($row[
'attachment_indicator']);
168 if (!array_key_exists(
'personal_picture', $this->visibleOptionalColumns)) {
169 unset($row[
'img_sender']);
170 unset($row[
'alt_sender']);
192 'is_checkbox' =>
true,
197 'field' =>
'attachments',
198 'txt' => $this->lng->txt(
'mail_tbl_head_attachments'),
207 'field' =>
'personal_picture',
208 'txt' => $this->lng->txt(
'personal_picture'),
219 'txt' => $this->lng->txt(
'recipient'),
228 'txt' => $this->lng->txt(
'sender'),
238 'field' =>
'search_content',
239 'txt' => $this->lng->txt(
'search_content'),
247 'field' =>
'm_subject',
248 'txt' => $this->lng->txt(
'subject'),
257 'field' =>
'send_time',
258 'txt' => $this->lng->txt(
'date'),
266 'field' =>
'actions',
267 'txt' => $this->lng->txt(
'actions'),
291 isset($column[
'sortable']) && $column[
'sortable'] ? $column[
'field'] :
'',
292 isset($column[
'width']) ? $column[
'width'] :
'',
293 isset($column[
'is_checkbox']) ? (
bool) $column[
'is_checkbox'] :
false 298 $mtree = new \ilTree($this->
user->getId());
299 $mtree->setTableNames(
'mail_tree',
'mail_obj_data');
300 $this->_folderNode = $mtree->getNodeData($this->_currentFolderId);
305 $this->
initMultiCommands($this->_parentObject->mbox->getActions($this->_currentFolderId));
317 if (null === $a_bool) {
321 $this->_isDraftsFolder = $a_bool;
333 if (null === $a_bool) {
337 $this->_isSentFolder = $a_bool;
349 if (null === $a_bool) {
353 $this->_isTrashFolder = $a_bool;
363 if ($this->_folderNode[
'm_type'] ===
'trash' && $this->
getNumberOfMails() > 0) {
364 $this->
addCommandButton(
'confirmEmptyTrash', $this->lng->txt(
'mail_empty_trash'));
377 if (
$key ===
'moveMails') {
378 $folders = $this->_parentObject->mbox->getSubFolders();
379 foreach ($folders as $folder) {
380 if ($folder[
'type'] !==
'trash' || !$this->
isTrashFolder()) {
381 if ($folder[
'type'] !==
'user_folder') {
382 $label =
$action .
' ' . $this->lng->txt(
'mail_' . $folder[
'title']) .
383 ($folder[
'type'] ===
'trash' ?
' (' . $this->lng->txt(
'delete') .
')' :
'');
406 $this->_selectedItems = $a_selected_items;
437 if ($this->_folderNode[
'm_type'] ==
'user_folder') {
438 $txt_folder = $this->_folderNode[
'title'];
439 $img_folder =
'icon_user_folder.png';
441 $txt_folder = $this->lng->txt(
'mail_' . $this->_folderNode[
'title']);
442 $img_folder =
'icon' . substr($this->_folderNode[
'title'], 1) .
'.png';
448 $query_parser->setFields(array(
449 'title' => (
bool) $this->filter[
'mail_filter_subject'],
450 'content' => (
bool) $this->filter[
'mail_filter_body'],
451 'mattachment' => (
bool) $this->filter[
'mail_filter_attach'],
452 'msender' => (
bool) $this->filter[
'mail_filter_sender'],
453 'mrcp' => (
bool) $this->filter[
'mail_filter_recipients']
455 $query_parser->parse();
467 'mail_filter_only_unread' => $this->filter[
'mail_filter_only_unread'],
468 'mail_filter_only_with_attachments' => $this->filter[
'mail_filter_only_with_attachments'],
500 if (
'mail_search_empty_result' === $e->getMessage()) {
501 $data[
'set'] = array();
503 $data[
'cnt_unread'] = 0;
511 foreach (
$data[
'set'] as $mail) {
512 if ($mail[
'sender_id'] && $mail[
'sender_id'] != ANONYMOUS_USER_ID) {
513 $user_ids[$mail[
'sender_id']] = $mail[
'sender_id'];
521 foreach (
$data[
'set'] as
$key => $mail) {
525 $mail[
'checked'] =
' checked="checked" ';
530 $this->_parentObject->umail->formatNamesForOutput($mail[
'rcp_to']),
534 if ($mail[
'sender_id'] == ANONYMOUS_USER_ID) {
536 $mail[
'from'] = $mail[
'mail_login'] = $mail[
'alt_sender'] = htmlspecialchars(ilMail::_getIliasMailerName());
541 $mail[
'img_sender'] =
$user->getPersonalPicturePath(
'xxsmall');
542 $mail[
'from'] = $mail[
'mail_login'] = $mail[
'alt_sender'] = htmlspecialchars(
$user->getPublicName());
544 $mail[
'img_sender'] =
'';
545 $mail[
'from'] = $mail[
'mail_login'] = $mail[
'import_name'] .
' (' . $this->lng->txt(
'user_deleted') .
')';
551 $this->ctrl->setParameterByClass(
'ilmailformgui',
'mail_id', $mail[
'mail_id']);
552 $this->ctrl->setParameterByClass(
'ilmailformgui',
'mobj_id', $this->_currentFolderId);
553 $this->ctrl->setParameterByClass(
'ilmailformgui',
'type',
'draft');
554 $link_mark_as_read = $this->ctrl->getLinkTargetByClass(
'ilmailformgui');
555 $this->ctrl->clearParametersByClass(
'ilmailformgui');
557 $this->ctrl->setParameter($this->
getParentObject(),
'mail_id', $mail[
'mail_id']);
558 $this->ctrl->setParameter($this->
getParentObject(),
'mobj_id', $this->_currentFolderId);
559 $link_mark_as_read = $this->ctrl->getLinkTarget($this->
getParentObject(),
'showMail');
562 $css_class = $mail[
'm_status'] ==
'read' ?
'mailread' :
'mailunread';
565 $search_result = array();
566 foreach (
$result->getFields($mail[
'mail_id']) as $content) {
567 if (
'title' == $content[0]) {
568 $mail[
'msr_subject_link_read'] = $link_mark_as_read;
569 $mail[
'msr_subject_mailclass'] = $css_class;
570 $mail[
'msr_subject'] = $content[1];
572 $search_result[] = $content[1];
575 $mail[
'msr_data'] = implode(
'', array_map(
function ($value) {
576 return '<p>' . $value .
'</p>';
579 if (!$mail[
'msr_subject']) {
580 $mail[
'msr_subject_link_read'] = $link_mark_as_read;
581 $mail[
'msr_subject_mailclass'] = $css_class;
582 $mail[
'msr_subject'] = htmlspecialchars($mail[
'm_subject']);
585 $mail[
'mail_link_read'] = $link_mark_as_read;
586 $mail[
'mailclass'] = $css_class;
587 $mail[
'mail_subject'] = htmlspecialchars($mail[
'm_subject']);
592 $mail[
'attachment_indicator'] =
'';
593 if (is_array($mail[
'attachments']) && count($mail[
'attachments']) > 0) {
594 $this->ctrl->setParameter($this->
getParentObject(),
'mail_id', (
int) $mail[
'mail_id']);
598 $this->ctrl->setParameter($this->
getParentObject(),
'mobj_id', $this->_currentFolderId);
599 $mail[
'attachment_indicator'] = $this->uiRenderer->render(
600 $this->uiFactory->glyph()->attachment(
601 $this->ctrl->getLinkTarget($this->getParentObject(),
'deliverAttachments')
616 $this->
setTitleData($txt_folder, (
int) $data[
'cnt'], (
int) $data[
'cnt_unread'], $img_folder);
629 protected function setTitleData(
string $folderLabel,
int $mailCount,
int $unreadCount,
string $imgFolder) : self
631 $titleTemplate =
new ilTemplate(
'tpl.mail_folder_title.html',
true,
true,
'Services/Mail');
632 $titleTemplate->setVariable(
'TXT_FOLDER', $folderLabel);
633 $titleTemplate->setVariable(
'MAIL_COUNT', $mailCount);
634 $titleTemplate->setVariable(
'TXT_MAIL_S', $this->lng->txt(
'mail_s'));
635 $titleTemplate->setVariable(
'MAIL_COUNT_UNREAD', $unreadCount);
636 $titleTemplate->setVariable(
'TXT_UNREAD', $this->lng->txt(
'unread'));
638 parent::setTitle($titleTemplate->get(), $imgFolder);
649 $this->_number_of_mails = $a_number_of_mails;
672 $quickFilter->readFromSession();
673 $this->filter[
'mail_filter'] = $quickFilter->getValue();
677 $this->lng->txt(
'mail_filter_recipients'),
678 'mail_filter_recipients' 680 $subFilterInRecipients->
setOptionTitle($this->lng->txt(
'mail_filter_recipients'));
681 $subFilterInRecipients->setValue(1);
682 $quickFilter->addSubItem($subFilterInRecipients);
683 $subFilterInRecipients->setParent($this);
684 $subFilterInRecipients->readFromSession();
685 $this->filter[
'mail_filter_recipients'] = (int) $subFilterInRecipients->getChecked();
688 $this->lng->txt(
'mail_filter_sender'),
691 $subFilterInSender->
setOptionTitle($this->lng->txt(
'mail_filter_sender'));
692 $subFilterInSender->setValue(1);
693 $quickFilter->addSubItem($subFilterInSender);
694 $subFilterInSender->setParent($this);
695 $subFilterInSender->readFromSession();
696 $this->filter[
'mail_filter_sender'] = (int) $subFilterInSender->getChecked();
700 $this->lng->txt(
'mail_filter_subject'),
701 'mail_filter_subject' 703 $subFilterInSubject->
setOptionTitle($this->lng->txt(
'mail_filter_subject'));
704 $subFilterInSubject->setValue(1);
705 $quickFilter->addSubItem($subFilterInSubject);
706 $subFilterInSubject->setParent($this);
707 $subFilterInSubject->readFromSession();
708 $this->filter[
'mail_filter_subject'] = (int) $subFilterInSubject->getChecked();
711 $this->lng->txt(
'mail_filter_body'),
714 $subFilterInBody->
setOptionTitle($this->lng->txt(
'mail_filter_body'));
715 $subFilterInBody->setValue(1);
716 $quickFilter->addSubItem($subFilterInBody);
717 $subFilterInBody->setParent($this);
718 $subFilterInBody->readFromSession();
719 $this->filter[
'mail_filter_body'] = (int) $subFilterInBody->getChecked();
722 $this->lng->txt(
'mail_filter_attach'),
725 $subFilterInAttachments->
setOptionTitle($this->lng->txt(
'mail_filter_attach'));
726 $subFilterInAttachments->setValue(1);
727 $quickFilter->addSubItem($subFilterInAttachments);
728 $subFilterInAttachments->setParent($this);
729 $subFilterInAttachments->readFromSession();
730 $this->filter[
'mail_filter_attach'] = (int) $subFilterInAttachments->getChecked();
734 $this->lng->txt(
'mail_filter_only_unread'),
735 'mail_filter_only_unread' 739 $onlyUnread->readFromSession();
740 $this->filter[
'mail_filter_only_unread'] = (int) $onlyUnread->getChecked();
745 $this->lng->txt(
'mail_filter_only_with_attachments'),
746 'mail_filter_only_with_attachments' 750 $onlyWithAttachments->readFromSession();
751 $this->filter[
'mail_filter_only_with_attachments'] = (int) $onlyWithAttachments->getChecked();
754 $duration = new \ilDateDurationInputGUI($this->lng->txt(
'mail_filter_period'),
'period');
755 $duration->setAllowOpenIntervals(
true);
756 $duration->setStartText($this->lng->txt(
'mail_filter_period_from'));
757 $duration->setEndText($this->lng->txt(
'mail_filter_period_until'));
760 $duration->setShowTime(
false);
762 $duration->readFromSession();
763 $this->filter[
'period'] = $duration->getValue();
771 parent::writeFilterToSession();
773 foreach ($this->sub_filter as $item) {
774 if ($item->checkInput()) {
775 $item->setValueByArray(
$_POST);
776 $item->writeToSession();
786 parent::resetFilter();
788 foreach ($this->sub_filter as $item) {
789 if ($item->checkInput()) {
790 $item->setValueByArray(
$_POST);
791 $item->clearFromSession();
809 $dropDown = $this->uiFactory
812 ->withLabel($this->lng->txt(
'actions'));
814 return $this->uiRenderer->render([$dropDown]);
824 $this->ctrl->setParameterByClass(
'ilmailformgui',
'mail_id', (
int) $mail[
'mail_id']);
825 $this->ctrl->setParameterByClass(
'ilmailformgui',
'mobj_id', $this->_currentFolderId);
826 $this->ctrl->setParameterByClass(
'ilmailformgui',
'type',
'draft');
827 $viewButton = $this->uiFactory
830 $this->lng->txt(
'view'),
831 $this->ctrl->getLinkTargetByClass(
'ilmailformgui')
833 $this->ctrl->clearParametersByClass(
'ilmailformgui');
835 $this->ctrl->setParameter($this->
getParentObject(),
'mail_id', (
int) $mail[
'mail_id']);
836 $this->ctrl->setParameter($this->
getParentObject(),
'mobj_id', $this->_currentFolderId);
837 $viewButton = $this->uiFactory
840 $this->lng->txt(
'view'),
846 $buttons[] = $viewButton;
856 if (isset($mail[
'sender_id']) && $mail[
'sender_id'] > 0 && $mail[
'sender_id'] != ANONYMOUS_USER_ID) {
857 $this->ctrl->setParameterByClass(
'ilmailformgui',
'mobj_id', $this->_currentFolderId);
858 $this->ctrl->setParameterByClass(
'ilmailformgui',
'mail_id', (
int) $mail[
'mail_id']);
859 $this->ctrl->setParameterByClass(
'ilmailformgui',
'type',
'reply');
860 $replyButton = $this->uiFactory
863 $this->lng->txt(
'reply'),
864 $this->ctrl->getLinkTargetByClass(
'ilmailformgui')
866 $this->ctrl->clearParametersByClass(
'ilmailformgui');
868 $buttons[] = $replyButton;
880 $this->ctrl->setParameterByClass(
'ilmailformgui',
'mobj_id', $this->_currentFolderId);
881 $this->ctrl->setParameterByClass(
'ilmailformgui',
'mail_id', (
int) $mail[
'mail_id']);
882 $this->ctrl->setParameterByClass(
'ilmailformgui',
'type',
'forward');
883 $forwardButton = $this->uiFactory
886 $this->lng->txt(
'forward'),
887 $this->ctrl->getLinkTargetByClass(
'ilmailformgui')
889 $this->ctrl->clearParametersByClass(
'ilmailformgui');
891 $buttons[] = $forwardButton;
902 $this->ctrl->setParameter($this->
getParentObject(),
'mobj_id', $this->_currentFolderId);
903 $this->ctrl->setParameter($this->
getParentObject(),
'mail_id', (
int) $mail[
'mail_id']);
904 $printButton = $this->uiFactory
907 $this->lng->txt(
'print'),
912 $buttons[] = $printButton;
921 $this->ctrl->setParameter($this->
getParentObject(),
'mobj_id', $this->_currentFolderId);
922 $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)
isTrashFolder(bool $a_bool=null)
Setter/Getter for folder status.
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)
isSentFolder(bool $a_bool=null)
Setter/Getter for folder status.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
removeInvisibleFields(array $row)
addViewRowAction(array $mail, array &$buttons)
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)
isDraftFolder(bool $a_bool=null)
Setter/Getter for folder status.
special template class to simplify handling of ITX/PEAR
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.
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.
__construct( $a_parent_obj, $a_current_folder_id, $a_parent_cmd='', Factory $uiFactory=null, Renderer $uiRenderer=null)
Constructor.
setFilterCommand($a_val, $a_caption=null)
Set filter command.