ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilMailFolderTableGUI.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2
3/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4
7
14{
15 protected $_folderNode = [];
16 protected $_parentObject = null;
17 protected $_currentFolderId = 0;
18 protected $_number_of_mails = 0;
19 protected $_selectedItems = [];
20 protected $_isTrashFolder = false;
21 protected $_isDraftsFolder = false;
22 protected $_isSentFolder = false;
23
25 protected $user;
26
28 protected $filter = [];
29
31 protected $sub_filter = [];
32
35
37 protected $optionalColumns = [];
38
40 protected $optional_filter = [];
41
43 private $uiFactory;
44
46 private $uiRenderer;
47
49 private $column_definition = null;
50
59 public function __construct(
60 $a_parent_obj,
61 $a_current_folder_id,
62 $a_parent_cmd,
63 bool $isTrashFolder,
64 bool $isSentFolder,
65 bool $isDraftsFolder,
66 Factory $uiFactory = null,
68 ) {
69 global $DIC;
70
71 $this->user = $DIC->user();
72
73 if (null === $uiFactory) {
74 $uiFactory = $DIC->ui()->factory();
75 }
76 if (null === $uiRenderer) {
77 $uiRenderer = $DIC->ui()->renderer();
78 }
79 $this->uiFactory = $uiFactory;
80 $this->uiRenderer = $uiRenderer;
81
82 $this->_currentFolderId = $a_current_folder_id;
83 $this->_parentObject = $a_parent_obj;
84
85 $this->_isTrashFolder = $isTrashFolder;
86 $this->_isSentFolder = $isSentFolder;
87 $this->_isDraftsFolder = $isDraftsFolder;
88
89 $this->setId('mail_folder_tbl_' . $a_current_folder_id);
90 $this->setPrefix('mtable');
91
92 $this->setExternalSorting(true);
93 $this->setExternalSegmentation(true);
94 $this->setDefaultOrderField('send_time');
95 $this->setDefaultOrderDirection('desc');
96
97 parent::__construct($a_parent_obj, $a_parent_cmd);
98
99 $this->ctrl->setParameter($this->getParentObject(), 'mobj_id', $this->_currentFolderId);
100 $this->setFormAction($this->ctrl->getFormAction($this->getParentObject(), 'showFolder'));
101 $this->ctrl->clearParameters($this->getParentObject());
102
103 $this->setEnableTitle(true);
104 $this->setSelectAllCheckbox('mail_id[]');
105 $this->setRowTemplate('tpl.mail_folder_row.html', 'Services/Mail');
106
107 $this->setFilterCommand('applyFilter');
108 $this->setResetCommand('resetFilter');
109 }
110
114 public function getSelectableColumns()
115 {
116 $optionalColumns = array_filter($this->getColumnDefinition(), function ($column) {
117 return isset($column['optional']) && $column['optional'];
118 });
119
120 $columns = array();
121 foreach ($optionalColumns as $index => $column) {
122 $columns[$column['field']] = $column;
123 }
124
125 return $columns;
126 }
127
132 protected function isColumnVisible(int $index) : bool
133 {
134 $columnDefinition = $this->getColumnDefinition();
135 if (array_key_exists($index, $columnDefinition)) {
136 $column = $columnDefinition[$index];
137 if (isset($column['optional']) && !$column['optional']) {
138 return true;
139 }
140 if (
141 is_array($this->visibleOptionalColumns) &&
142 array_key_exists($column['field'], $this->visibleOptionalColumns)
143 ) {
144 return true;
145 }
146 }
147
148 return false;
149 }
150
153 final protected function fillRow($a_set)
154 {
155 foreach ($this->removeInvisibleFields($a_set) as $key => $value) {
156 $this->tpl->setVariable(strtoupper($key), $value);
157 }
158 }
159
164 protected function removeInvisibleFields(array $row) : array
165 {
166 if (is_array($this->visibleOptionalColumns)) {
167 if (!array_key_exists('attachments', $this->visibleOptionalColumns)) {
168 unset($row['attachment_indicator']);
169 }
170
171 if (!array_key_exists('personal_picture', $this->visibleOptionalColumns)) {
172 unset($row['img_sender'], $row['alt_sender']);
173 }
174 }
175
176 return $row;
177 }
178
182 protected function getColumnDefinition() : array
183 {
184 if ($this->column_definition !== null) {
186 }
187
188 $i = 0;
189
190 $columns = [];
191
192 $columns[++$i] = [
193 'field' => 'chb',
194 'txt' => '',
195 'default' => true,
196 'optional' => false,
197 'sortable' => false,
198 'is_checkbox' => true,
199 'width' => '1%'
200 ];
201
202 $columns[++$i] = [
203 'field' => 'attachments',
204 'txt' => $this->lng->txt('mail_tbl_head_attachments'),
205 'default' => false,
206 'optional' => true,
207 'sortable' => false,
208 'width' => '5%'
209 ];
210
211 if (!$this->isDraftFolder() && !$this->isSentFolder()) {
212 $columns[++$i] = [
213 'field' => 'personal_picture',
214 'txt' => $this->lng->txt('personal_picture'),
215 'default' => true,
216 'optional' => true,
217 'sortable' => false,
218 'width' => '5%'
219 ];
220 }
221
222 if ($this->isDraftFolder() || $this->isSentFolder()) {
223 $columns[++$i] = [
224 'field' => 'rcp_to',
225 'txt' => $this->lng->txt('recipient'),
226 'default' => true,
227 'optional' => false,
228 'sortable' => true,
229 'width' => '35%'
230 ];
231 } else {
232 $columns[++$i] = [
233 'field' => 'from',
234 'txt' => $this->lng->txt('sender'),
235 'default' => true,
236 'optional' => false,
237 'sortable' => true,
238 'width' => '20%'
239 ];
240 }
241
242 if ($this->shouldUseLuceneSearch()) {
243 $columns[++$i] = [
244 'field' => 'search_content',
245 'txt' => $this->lng->txt('search_content'),
246 'default' => true,
247 'optional' => false,
248 'sortable' => false,
249 'width' => '35%'
250 ];
251 } else {
252 $columns[++$i] = [
253 'field' => 'm_subject',
254 'txt' => $this->lng->txt('subject'),
255 'default' => true,
256 'optional' => false,
257 'sortable' => true,
258 'width' => '35%'
259 ];
260 }
261
262 $columns[++$i] = [
263 'field' => 'send_time',
264 'txt' => $this->lng->txt('date'),
265 'default' => true,
266 'optional' => false,
267 'sortable' => true,
268 'width' => '20%'
269 ];
270
271 $columns[++$i] = [
272 'field' => 'actions',
273 'txt' => $this->lng->txt('actions'),
274 'default' => true,
275 'optional' => false,
276 'sortable' => false,
277 'width' => '5%'
278 ];
279
280 $this->column_definition = $columns;
282 }
283
289 final public function prepareHTML() : self
290 {
291 $columns = $this->getColumnDefinition();
292 $this->optionalColumns = (array) $this->getSelectableColumns();
293 $this->visibleOptionalColumns = (array) $this->getSelectedColumns();
294 foreach ($columns as $index => $column) {
295 if ($this->isColumnVisible($index)) {
296 $this->addColumn(
297 $column['txt'],
298 isset($column['sortable']) && $column['sortable'] ? $column['field'] : '',
299 $column['width'] ?? '',
300 isset($column['is_checkbox']) ? (bool) $column['is_checkbox'] : false
301 );
302 }
303 }
304
305 $mtree = new ilTree($this->user->getId());
306 $mtree->setTableNames('mail_tree', 'mail_obj_data');
307 $this->_folderNode = $mtree->getNodeData($this->_currentFolderId);
308
309 $this->fetchTableData();
310
311 $this->initCommandButtons();
312 $this->initMultiCommands($this->_parentObject->mbox->getActions($this->_currentFolderId));
313
314 return $this;
315 }
316
317 public function isDraftFolder() : bool
318 {
320 }
321
322 public function isSentFolder() : bool
323 {
325 }
326
327 public function isTrashFolder() : bool
328 {
330 }
331
335 private function initCommandButtons() : self
336 {
337 if ($this->_folderNode['m_type'] === 'trash' && $this->getNumberOfMails() > 0) {
338 $this->addCommandButton('confirmEmptyTrash', $this->lng->txt('mail_empty_trash'));
339 }
340
341 return $this;
342 }
343
348 private function initMultiCommands(array $actions) : self
349 {
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') . ')' : '');
358 $this->addMultiCommand($key . '_' . $folder['obj_id'], $label);
359 } else {
360 $this->addMultiCommand($key . '_' . $folder['obj_id'], $action . ' ' . $folder['title']);
361 }
362 }
363 }
364 } else {
365 if ($key !== 'deleteMails' || $this->isTrashFolder()) {
366 $this->addMultiCommand($key, $action);
367 }
368 }
369 }
370
371 return $this;
372 }
373
378 public function setSelectedItems(array $a_selected_items) : self
379 {
380 $this->_selectedItems = $a_selected_items;
381
382 return $this;
383 }
384
388 public function getSelectedItems() : array
389 {
391 }
392
396 protected function shouldUseLuceneSearch() : bool
397 {
398 if (
399 isset($this->filter['mail_filter']) &&
400 is_string($this->filter['mail_filter']) &&
401 $this->filter['mail_filter'] !== '' &&
402 $this->isLuceneEnabled()
403 ) {
404 return true;
405 }
406
407 return false;
408 }
409
413 private function isLuceneEnabled() : bool
414 {
415 return ilSearchSettings::getInstance()->enabledLucene();
416 }
417
422 protected function fetchTableData() : self
423 {
424 if ($this->_folderNode['m_type'] === 'user_folder') {
425 $txt_folder = $this->_folderNode['title'];
426 $img_folder = 'icon_user_folder.png';
427 } else {
428 $txt_folder = $this->lng->txt('mail_' . $this->_folderNode['title']);
429 $img_folder = 'icon' . substr($this->_folderNode['title'], 1) . '.png';
430 }
431
432 try {
433 if ($this->shouldUseLuceneSearch()) {
434 $query_parser = new ilMailLuceneQueryParser($this->filter['mail_filter']);
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']
441 ]);
442 $query_parser->parse();
443
445 $searcher = new ilMailLuceneSearcher($query_parser, $result);
446 $searcher->search($this->user->getId(), $this->_currentFolderId);
447
448 if (!$result->getIds()) {
449 throw new ilException('mail_search_empty_result');
450 }
451
454 'mail_filter_only_unread' => $this->filter['mail_filter_only_unread'],
455 'mail_filter_only_with_attachments' => $this->filter['mail_filter_only_with_attachments'],
456 ];
457 } else {
458 ilMailBoxQuery::$filter = (array) $this->filter;
459 }
460
461 if (
462 isset(ilMailBoxQuery::$filter['mail_filter_only_unread']) &&
463 ($this->isDraftFolder() || $this->isSentFolder())
464 ) {
465 unset(ilMailBoxQuery::$filter['mail_filter_only_unread']);
466 }
467
468 if (isset(ilMailBoxQuery::$filter['mail_filter_only_with_attachments']) && $this->isDraftFolder()) {
469 unset(ilMailBoxQuery::$filter['mail_filter_only_with_attachments']);
470 }
471
473
475 ilMailBoxQuery::$userId = $this->user->getId();
481
482 if (!count($data['set']) && $this->getOffset() > 0) {
483 $this->resetOffset();
484
488 }
489 } catch (Exception $e) {
490 if ('mail_search_empty_result' === $e->getMessage()) {
491 $data['set'] = [];
492 $data['cnt'] = 0;
493 $data['cnt_unread'] = 0;
494 } else {
495 throw $e;
496 }
497 }
498
499 if (!$this->isDraftFolder() && !$this->isSentFolder()) {
500 $user_ids = [];
501 foreach ($data['set'] as $mail) {
502 if ($mail['sender_id'] && $mail['sender_id'] != ANONYMOUS_USER_ID) {
503 $user_ids[$mail['sender_id']] = $mail['sender_id'];
504 }
505 }
506
508 }
509
510 $counter = 0;
511 foreach ($data['set'] as $key => $mail) {
512 ++$counter;
513
514 if (is_array($this->getSelectedItems()) && in_array($mail['mail_id'], $this->getSelectedItems(), false)) {
515 $mail['checked'] = ' checked="checked" ';
516 }
517
518 $mail['txt_select_mail_with_subject'] = sprintf(
519 $this->lng->txt('select_mail_with_subject_x'),
520 htmlspecialchars($mail['m_subject'] ?? '')
521 );
522
523 if ($this->isDraftFolder() || $this->isSentFolder()) {
524 $mail['rcp_to'] = $mail['mail_login'] = ilUtil::htmlencodePlainString(
525 $this->_parentObject->umail->formatNamesForOutput((string) $mail['rcp_to']),
526 false
527 );
528 } else {
529 if ($mail['sender_id'] == ANONYMOUS_USER_ID) {
530 $mail['img_sender'] = ilUtil::getImagePath('HeaderIconAvatar.svg');
531 $mail['from'] = $mail['mail_login'] = $mail['alt_sender'] = htmlspecialchars(ilMail::_getIliasMailerName());
532 } else {
533 $user = ilMailUserCache::getUserObjectById($mail['sender_id']);
534
535 if ($user) {
536 $mail['img_sender'] = $user->getPersonalPicturePath('xxsmall');
537 $mail['from'] = $mail['mail_login'] = $mail['alt_sender'] = htmlspecialchars($user->getPublicName());
538 } else {
539 $mail['img_sender'] = '';
540 $mail['from'] = $mail['mail_login'] = $mail['import_name'] . ' (' . $this->lng->txt('user_deleted') . ')';
541 }
542 }
543 }
544
545 if ($this->isDraftFolder()) {
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');
551 } else {
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');
555 $this->ctrl->clearParameters($this->getParentObject());
556 }
557 $css_class = $mail['m_status'] === 'read' ? 'mailread' : 'mailunread';
558
559 if ($this->shouldUseLuceneSearch()) {
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];
566 } else {
567 $search_result[] = $content[1];
568 }
569 }
570 $mail['msr_data'] = implode('', array_map(function ($value) {
571 return '<p>' . $value . '</p>';
572 }, $search_result));
573
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'] ?? '');
578 }
579 $mail['msr_subject_read_unread'] = $mail['m_status'] === 'read' ? $this->lng->txt('mail_is_read') : $this->lng->txt('mail_is_unread');
580 } else {
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');
585 }
586
587 $mail['mail_date'] = ilDatePresentation::formatDate(new ilDateTime($mail['send_time'], IL_CAL_DATETIME));
588
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']);
592 if ($this->isDraftFolder()) {
593 $this->ctrl->setParameter($this->getParentObject(), 'type', 'draft');
594 }
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')
599 )
600 );
601 $this->ctrl->clearParameters($this->getParentObject());
602 }
603
604 $mail['actions'] = $this->formatActionsDropDown($mail);
605
606 $data['set'][$key] = $mail;
607 }
608
609 $this->setData($data['set']);
610 $this->setMaxCount((int) $data['cnt']);
611 $this->setNumberOfMails((int) $data['cnt']);
612
613 $this->setTitleData($txt_folder, (int) $data['cnt'], (int) $data['cnt_unread'], $img_folder);
614
615 return $this;
616 }
617
626 protected function setTitleData(string $folderLabel, int $mailCount, int $unreadCount, string $imgFolder) : self
627 {
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'));
634
635 parent::setTitle($titleTemplate->get(), $imgFolder);
636
637 return $this;
638 }
639
644 public function setNumberOfMails(int $a_number_of_mails) : self
645 {
646 $this->_number_of_mails = $a_number_of_mails;
647
648 return $this;
649 }
650
654 public function getNumberOfMails() : int
655 {
657 }
658
662 public function initFilter()
663 {
664 $this->filter = [];
665
666 $quickFilter = new ilMailQuickFilterInputGUI($this->lng->txt('mail_filter'), 'mail_filter');
667 $quickFilter->setSubmitFormOnEnter(false);
668 $this->addFilterItem($quickFilter);
669 $quickFilter->readFromSession();
670 $this->filter['mail_filter'] = $quickFilter->getValue();
671
672 if ($this->isDraftFolder() || $this->isSentFolder()) {
673 $this->sub_filter[] = $subFilterInRecipients = new ilCheckboxInputGUI(
674 $this->lng->txt('mail_filter_recipients'),
675 'mail_filter_recipients'
676 );
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();
683 } else {
684 $this->sub_filter[] = $subFilterInSender = new ilCheckboxInputGUI(
685 $this->lng->txt('mail_filter_sender'),
686 'mail_filter_sender'
687 );
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();
694 }
695
696 $this->sub_filter[] = $subFilterInSubject = new ilCheckboxInputGUI(
697 $this->lng->txt('mail_filter_subject'),
698 'mail_filter_subject'
699 );
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();
706
707 $this->sub_filter[] = $subFilterInBody = new ilCheckboxInputGUI(
708 $this->lng->txt('mail_filter_body'),
709 'mail_filter_body'
710 );
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();
717
718 if ($this->isLuceneEnabled()) {
719 $this->sub_filter[] = $subFilterInAttachments = new ilCheckboxInputGUI(
720 $this->lng->txt('mail_filter_attach'),
721 'mail_filter_attach'
722 );
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();
729 }
730
731 if (!$this->isDraftFolder() && !$this->isSentFolder()) {
732 $onlyUnread = new ilCheckboxInputGUI(
733 $this->lng->txt('mail_filter_only_unread'),
734 'mail_filter_only_unread'
735 );
736 $onlyUnread->setValue(1);
737 $this->addFilterItem($onlyUnread);
738 $onlyUnread->readFromSession();
739 $this->filter['mail_filter_only_unread'] = (int) $onlyUnread->getChecked();
740 }
741
742 if (!$this->isDraftFolder()) {
743 $onlyWithAttachments = new ilCheckboxInputGUI(
744 $this->lng->txt('mail_filter_only_with_attachments'),
745 'mail_filter_only_with_attachments'
746 );
747 $onlyWithAttachments->setValue(1);
748 $this->addFilterItem($onlyWithAttachments);
749 $onlyWithAttachments->readFromSession();
750 $this->filter['mail_filter_only_with_attachments'] = (int) $onlyWithAttachments->getChecked();
751 }
752
753 $duration = new ilDateDurationInputGUI($this->lng->txt('mail_filter_period'), 'period');
754 $duration->setAllowOpenIntervals(true);
755 $duration->setStartText($this->lng->txt('mail_filter_period_from'));
756 $duration->setEndText($this->lng->txt('mail_filter_period_until'));
757 $duration->setStart(new ilDateTime(null, IL_CAL_UNIX));
758 $duration->setEnd(new ilDateTime(null, IL_CAL_UNIX));
759 $duration->setShowTime(false);
760 $this->addFilterItem($duration);
761 $duration->readFromSession();
762 $this->filter['period'] = $duration->getValue();
763 }
764
768 public function writeFilterToSession()
769 {
770 parent::writeFilterToSession();
771
772 foreach ($this->sub_filter as $item) {
773 if ($item->checkInput()) {
774 $item->setValueByArray($_POST);
775 $item->writeToSession();
776 }
777 }
778 }
779
783 public function resetFilter()
784 {
785 parent::resetFilter();
786
787 foreach ($this->sub_filter as $item) {
788 if ($item->checkInput()) {
789 $item->setValueByArray($_POST);
790 $item->clearFromSession();
791 }
792 }
793 }
794
799 protected function formatActionsDropDown(array $mail) : string
800 {
801 $buttons = [];
802
803 $this->addViewRowAction($mail, $buttons);
804 $this->addReplyRowAction($mail, $buttons);
805 $this->addForwardRowAction($mail, $buttons);
806 $this->addPrintRowAction($mail, $buttons);
807
808 $dropDown = $this->uiFactory
809 ->dropdown()
810 ->standard($buttons)
811 ->withLabel($this->lng->txt('actions'));
812
813 return $this->uiRenderer->render([$dropDown]);
814 }
815
820 protected function addViewRowAction(array $mail, array &$buttons) : void
821 {
822 if ($this->isDraftFolder()) {
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
827 ->link()
828 ->standard(
829 $this->lng->txt('view'),
830 $this->ctrl->getLinkTargetByClass('ilmailformgui')
831 );
832 $this->ctrl->clearParametersByClass('ilmailformgui');
833 } else {
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
837 ->link()
838 ->standard(
839 $this->lng->txt('view'),
840 $this->ctrl->getLinkTarget($this->getParentObject(), 'showMail')
841 );
842 $this->ctrl->clearParameters($this->getParentObject());
843 }
844
845 $buttons[] = $viewButton;
846 }
847
852 protected function addReplyRowAction(array $mail, array &$buttons) : void
853 {
854 if (!$this->isDraftFolder()) {
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
860 ->link()
861 ->standard(
862 $this->lng->txt('reply'),
863 $this->ctrl->getLinkTargetByClass('ilmailformgui')
864 );
865 $this->ctrl->clearParametersByClass('ilmailformgui');
866
867 $buttons[] = $replyButton;
868 }
869 }
870 }
871
876 protected function addForwardRowAction(array $mail, array &$buttons) : void
877 {
878 if (!$this->isDraftFolder()) {
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
883 ->link()
884 ->standard(
885 $this->lng->txt('forward'),
886 $this->ctrl->getLinkTargetByClass('ilmailformgui')
887 );
888 $this->ctrl->clearParametersByClass('ilmailformgui');
889
890 $buttons[] = $forwardButton;
891 }
892 }
893
898 protected function addPrintRowAction(array $mail, array &$buttons) : void
899 {
900 if (!$this->isDraftFolder()) {
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
904 ->link()
905 ->standard(
906 $this->lng->txt('print'),
907 $this->ctrl->getLinkTarget($this->getParentObject(), 'printMail')
908 )->withOpenInNewViewport(true);
909 $this->ctrl->clearParameters($this->getParentObject());
910
911 $buttons[] = $printButton;
912 }
913 }
914
918 public function getHTML()
919 {
920 $this->ctrl->setParameter($this->getParentObject(), 'mobj_id', $this->_currentFolderId);
921 $html = parent::getHTML();
922 $this->ctrl->clearParameters($this->getParentObject());
923
924 return $html;
925 }
926}
$result
user()
Definition: user.php:4
if(! $in) $columns
Definition: Utf8Test.php:45
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
const IL_CAL_DATETIME
This class represents a checkbox property in a property form.
input GUI for a time span (start and end date)
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
@classDescription Date and time handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getMailBoxListData()
_getMailBoxListData
__construct( $a_parent_obj, $a_current_folder_id, $a_parent_cmd, bool $isTrashFolder, bool $isSentFolder, bool $isDraftsFolder, Factory $uiFactory=null, Renderer $uiRenderer=null)
Constructor.
setTitleData(string $folderLabel, int $mailCount, int $unreadCount, string $imgFolder)
addForwardRowAction(array $mail, array &$buttons)
writeFilterToSession()
Write filter values to session.
fillRow($a_set)
Standard Version of Fill Row.Most likely to be overwritten by derived class.
setSelectedItems(array $a_selected_items)
addViewRowAction(array $mail, array &$buttons)
setNumberOfMails(int $a_number_of_mails)
addReplyRowAction(array $mail, array &$buttons)
addPrintRowAction(array $mail, array &$buttons)
prepareHTML()
Call this before using getHTML()
static getUserObjectById($usr_id)
static preloadUserObjects(array $usr_ids)
Class ilTable2GUI.
getSelectedColumns()
Get selected columns.
setExternalSorting($a_val)
Set external sorting.
getParentObject()
Get parent object.
setPrefix($a_prefix)
set prefix for sort and offset fields (if you have two or more tables on a page that you want to sort...
determineOffsetAndOrder($a_omit_offset=false)
Determine offset and order.
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.
setData($a_data)
set table data @access public
setResetCommand($a_val, $a_caption=null)
Set reset filter command.
setEnableTitle($a_enabletitle)
Set Enable Title.
getLimit()
Get limit.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
resetOffset($a_in_determination=false)
Reset offset.
addMultiCommand($a_cmd, $a_text)
Add Command button.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
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.
getOffset()
Get offset.
setExternalSegmentation($a_val)
Set external segmentation.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setFilterCommand($a_val, $a_caption=null)
Set filter command.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
getOrderDirection()
Get order direction.
setMaxCount($a_max_count)
set max.
special template class to simplify handling of ITX/PEAR
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
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.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
const ANONYMOUS_USER_ID
Definition: constants.php:25
filter()
Definition: filter.php:2
global $DIC
Definition: goto.php:24
This is how the factory for UI elements looks.
Definition: Factory.php:18
An entity that renders components to a string output.
Definition: Renderer.php:15
$index
Definition: metadata.php:128
$i
Definition: metadata.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc