ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 
34  protected $visibleOptionalColumns = [];
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,
67  Renderer $uiRenderer = 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  {
319  return $this->_isDraftsFolder;
320  }
321 
322  public function isSentFolder() : bool
323  {
324  return $this->_isSentFolder;
325  }
326 
327  public function isTrashFolder() : bool
328  {
329  return $this->_isTrashFolder;
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  {
390  return $this->_selectedItems;
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 
444  $result = new ilMailSearchResult();
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 
472  $this->determineOffsetAndOrder();
473 
475  ilMailBoxQuery::$userId = $this->user->getId();
476  ilMailBoxQuery::$limit = $this->getLimit();
481 
482  if (!count($data['set']) && $this->getOffset() > 0) {
483  $this->resetOffset();
484 
485  ilMailBoxQuery::$limit = $this->getLimit();
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  if ($this->isDraftFolder() || $this->isSentFolder()) {
519  $mail['rcp_to'] = $mail['mail_login'] = ilUtil::htmlencodePlainString(
520  $this->_parentObject->umail->formatNamesForOutput((string) $mail['rcp_to']),
521  false
522  );
523  } else {
524  if ($mail['sender_id'] == ANONYMOUS_USER_ID) {
525  $mail['img_sender'] = ilUtil::getImagePath('HeaderIconAvatar.svg');
526  $mail['from'] = $mail['mail_login'] = $mail['alt_sender'] = htmlspecialchars(ilMail::_getIliasMailerName());
527  } else {
528  $user = ilMailUserCache::getUserObjectById($mail['sender_id']);
529 
530  if ($user) {
531  $mail['img_sender'] = $user->getPersonalPicturePath('xxsmall');
532  $mail['from'] = $mail['mail_login'] = $mail['alt_sender'] = htmlspecialchars($user->getPublicName());
533  } else {
534  $mail['img_sender'] = '';
535  $mail['from'] = $mail['mail_login'] = $mail['import_name'] . ' (' . $this->lng->txt('user_deleted') . ')';
536  }
537  }
538  }
539 
540  if ($this->isDraftFolder()) {
541  $this->ctrl->setParameterByClass('ilmailformgui', 'mail_id', $mail['mail_id']);
542  $this->ctrl->setParameterByClass('ilmailformgui', 'mobj_id', $this->_currentFolderId);
543  $this->ctrl->setParameterByClass('ilmailformgui', 'type', 'draft');
544  $link_mark_as_read = $this->ctrl->getLinkTargetByClass('ilmailformgui');
545  $this->ctrl->clearParametersByClass('ilmailformgui');
546  } else {
547  $this->ctrl->setParameter($this->getParentObject(), 'mail_id', $mail['mail_id']);
548  $this->ctrl->setParameter($this->getParentObject(), 'mobj_id', $this->_currentFolderId);
549  $link_mark_as_read = $this->ctrl->getLinkTarget($this->getParentObject(), 'showMail');
550  $this->ctrl->clearParameters($this->getParentObject());
551  }
552  $css_class = $mail['m_status'] === 'read' ? 'mailread' : 'mailunread';
553 
554  if ($this->shouldUseLuceneSearch()) {
555  $search_result = array();
556  foreach ($result->getFields($mail['mail_id']) as $content) {
557  if ('title' === $content[0]) {
558  $mail['msr_subject_link_read'] = $link_mark_as_read;
559  $mail['msr_subject_mailclass'] = $css_class;
560  $mail['msr_subject'] = $content[1];
561  } else {
562  $search_result[] = $content[1];
563  }
564  }
565  $mail['msr_data'] = implode('', array_map(function ($value) {
566  return '<p>' . $value . '</p>';
567  }, $search_result));
568 
569  if (!$mail['msr_subject']) {
570  $mail['msr_subject_link_read'] = $link_mark_as_read;
571  $mail['msr_subject_mailclass'] = $css_class;
572  $mail['msr_subject'] = htmlspecialchars($mail['m_subject']);
573  }
574  } else {
575  $mail['mail_link_read'] = $link_mark_as_read;
576  $mail['mailclass'] = $css_class;
577  $mail['mail_subject'] = htmlspecialchars($mail['m_subject']);
578  }
579 
580  $mail['mail_date'] = ilDatePresentation::formatDate(new ilDateTime($mail['send_time'], IL_CAL_DATETIME));
581 
582  $mail['attachment_indicator'] = '';
583  if (is_array($mail['attachments']) && count($mail['attachments']) > 0) {
584  $this->ctrl->setParameter($this->getParentObject(), 'mail_id', (int) $mail['mail_id']);
585  if ($this->isDraftFolder()) {
586  $this->ctrl->setParameter($this->getParentObject(), 'type', 'draft');
587  }
588  $this->ctrl->setParameter($this->getParentObject(), 'mobj_id', $this->_currentFolderId);
589  $mail['attachment_indicator'] = $this->uiRenderer->render(
590  $this->uiFactory->symbol()->glyph()->attachment(
591  $this->ctrl->getLinkTarget($this->getParentObject(), 'deliverAttachments')
592  )
593  );
594  $this->ctrl->clearParameters($this->getParentObject());
595  }
596 
597  $mail['actions'] = $this->formatActionsDropDown($mail);
598 
599  $data['set'][$key] = $mail;
600  }
601 
602  $this->setData($data['set']);
603  $this->setMaxCount((int) $data['cnt']);
604  $this->setNumberOfMails((int) $data['cnt']);
605 
606  $this->setTitleData($txt_folder, (int) $data['cnt'], (int) $data['cnt_unread'], $img_folder);
607 
608  return $this;
609  }
610 
619  protected function setTitleData(string $folderLabel, int $mailCount, int $unreadCount, string $imgFolder) : self
620  {
621  $titleTemplate = new ilTemplate('tpl.mail_folder_title.html', true, true, 'Services/Mail');
622  $titleTemplate->setVariable('TXT_FOLDER', $folderLabel);
623  $titleTemplate->setVariable('MAIL_COUNT', $mailCount);
624  $titleTemplate->setVariable('TXT_MAIL_S', $this->lng->txt('mail_s'));
625  $titleTemplate->setVariable('MAIL_COUNT_UNREAD', $unreadCount);
626  $titleTemplate->setVariable('TXT_UNREAD', $this->lng->txt('unread'));
627 
628  parent::setTitle($titleTemplate->get(), $imgFolder);
629 
630  return $this;
631  }
632 
637  public function setNumberOfMails(int $a_number_of_mails) : self
638  {
639  $this->_number_of_mails = $a_number_of_mails;
640 
641  return $this;
642  }
643 
647  public function getNumberOfMails() : int
648  {
650  }
651 
655  public function initFilter()
656  {
657  $this->filter = [];
658 
659  $quickFilter = new ilMailQuickFilterInputGUI($this->lng->txt('mail_filter'), 'mail_filter');
660  $quickFilter->setSubmitFormOnEnter(false);
661  $this->addFilterItem($quickFilter);
662  $quickFilter->readFromSession();
663  $this->filter['mail_filter'] = $quickFilter->getValue();
664 
665  if ($this->isDraftFolder() || $this->isSentFolder()) {
666  $this->sub_filter[] = $subFilterInRecipients = new ilCheckboxInputGUI(
667  $this->lng->txt('mail_filter_recipients'),
668  'mail_filter_recipients'
669  );
670  $subFilterInRecipients->setOptionTitle($this->lng->txt('mail_filter_recipients'));
671  $subFilterInRecipients->setValue(1);
672  $quickFilter->addSubItem($subFilterInRecipients);
673  $subFilterInRecipients->setParent($this);
674  $subFilterInRecipients->readFromSession();
675  $this->filter['mail_filter_recipients'] = (int) $subFilterInRecipients->getChecked();
676  } else {
677  $this->sub_filter[] = $subFilterInSender = new ilCheckboxInputGUI(
678  $this->lng->txt('mail_filter_sender'),
679  'mail_filter_sender'
680  );
681  $subFilterInSender->setOptionTitle($this->lng->txt('mail_filter_sender'));
682  $subFilterInSender->setValue(1);
683  $quickFilter->addSubItem($subFilterInSender);
684  $subFilterInSender->setParent($this);
685  $subFilterInSender->readFromSession();
686  $this->filter['mail_filter_sender'] = (int) $subFilterInSender->getChecked();
687  }
688 
689  $this->sub_filter[] = $subFilterInSubject = new ilCheckboxInputGUI(
690  $this->lng->txt('mail_filter_subject'),
691  'mail_filter_subject'
692  );
693  $subFilterInSubject->setOptionTitle($this->lng->txt('mail_filter_subject'));
694  $subFilterInSubject->setValue(1);
695  $quickFilter->addSubItem($subFilterInSubject);
696  $subFilterInSubject->setParent($this);
697  $subFilterInSubject->readFromSession();
698  $this->filter['mail_filter_subject'] = (int) $subFilterInSubject->getChecked();
699 
700  $this->sub_filter[] = $subFilterInBody = new ilCheckboxInputGUI(
701  $this->lng->txt('mail_filter_body'),
702  'mail_filter_body'
703  );
704  $subFilterInBody->setOptionTitle($this->lng->txt('mail_filter_body'));
705  $subFilterInBody->setValue(1);
706  $quickFilter->addSubItem($subFilterInBody);
707  $subFilterInBody->setParent($this);
708  $subFilterInBody->readFromSession();
709  $this->filter['mail_filter_body'] = (int) $subFilterInBody->getChecked();
710 
711  if ($this->isLuceneEnabled()) {
712  $this->sub_filter[] = $subFilterInAttachments = new ilCheckboxInputGUI(
713  $this->lng->txt('mail_filter_attach'),
714  'mail_filter_attach'
715  );
716  $subFilterInAttachments->setOptionTitle($this->lng->txt('mail_filter_attach'));
717  $subFilterInAttachments->setValue(1);
718  $quickFilter->addSubItem($subFilterInAttachments);
719  $subFilterInAttachments->setParent($this);
720  $subFilterInAttachments->readFromSession();
721  $this->filter['mail_filter_attach'] = (int) $subFilterInAttachments->getChecked();
722  }
723 
724  if (!$this->isDraftFolder() && !$this->isSentFolder()) {
725  $onlyUnread = new ilCheckboxInputGUI(
726  $this->lng->txt('mail_filter_only_unread'),
727  'mail_filter_only_unread'
728  );
729  $onlyUnread->setValue(1);
730  $this->addFilterItem($onlyUnread);
731  $onlyUnread->readFromSession();
732  $this->filter['mail_filter_only_unread'] = (int) $onlyUnread->getChecked();
733  }
734 
735  if (!$this->isDraftFolder()) {
736  $onlyWithAttachments = new ilCheckboxInputGUI(
737  $this->lng->txt('mail_filter_only_with_attachments'),
738  'mail_filter_only_with_attachments'
739  );
740  $onlyWithAttachments->setValue(1);
741  $this->addFilterItem($onlyWithAttachments);
742  $onlyWithAttachments->readFromSession();
743  $this->filter['mail_filter_only_with_attachments'] = (int) $onlyWithAttachments->getChecked();
744  }
745 
746  $duration = new ilDateDurationInputGUI($this->lng->txt('mail_filter_period'), 'period');
747  $duration->setAllowOpenIntervals(true);
748  $duration->setStartText($this->lng->txt('mail_filter_period_from'));
749  $duration->setEndText($this->lng->txt('mail_filter_period_until'));
750  $duration->setStart(new ilDateTime(null, IL_CAL_UNIX));
751  $duration->setEnd(new ilDateTime(null, IL_CAL_UNIX));
752  $duration->setShowTime(false);
753  $this->addFilterItem($duration);
754  $duration->readFromSession();
755  $this->filter['period'] = $duration->getValue();
756  }
757 
761  public function writeFilterToSession()
762  {
763  parent::writeFilterToSession();
764 
765  foreach ($this->sub_filter as $item) {
766  if ($item->checkInput()) {
767  $item->setValueByArray($_POST);
768  $item->writeToSession();
769  }
770  }
771  }
772 
776  public function resetFilter()
777  {
778  parent::resetFilter();
779 
780  foreach ($this->sub_filter as $item) {
781  if ($item->checkInput()) {
782  $item->setValueByArray($_POST);
783  $item->clearFromSession();
784  }
785  }
786  }
787 
792  protected function formatActionsDropDown(array $mail) : string
793  {
794  $buttons = [];
795 
796  $this->addViewRowAction($mail, $buttons);
797  $this->addReplyRowAction($mail, $buttons);
798  $this->addForwardRowAction($mail, $buttons);
799  $this->addPrintRowAction($mail, $buttons);
800 
801  $dropDown = $this->uiFactory
802  ->dropdown()
803  ->standard($buttons)
804  ->withLabel($this->lng->txt('actions'));
805 
806  return $this->uiRenderer->render([$dropDown]);
807  }
808 
813  protected function addViewRowAction(array $mail, array &$buttons) : void
814  {
815  if ($this->isDraftFolder()) {
816  $this->ctrl->setParameterByClass('ilmailformgui', 'mail_id', (int) $mail['mail_id']);
817  $this->ctrl->setParameterByClass('ilmailformgui', 'mobj_id', $this->_currentFolderId);
818  $this->ctrl->setParameterByClass('ilmailformgui', 'type', 'draft');
819  $viewButton = $this->uiFactory
820  ->link()
821  ->standard(
822  $this->lng->txt('view'),
823  $this->ctrl->getLinkTargetByClass('ilmailformgui')
824  );
825  $this->ctrl->clearParametersByClass('ilmailformgui');
826  } else {
827  $this->ctrl->setParameter($this->getParentObject(), 'mail_id', (int) $mail['mail_id']);
828  $this->ctrl->setParameter($this->getParentObject(), 'mobj_id', $this->_currentFolderId);
829  $viewButton = $this->uiFactory
830  ->link()
831  ->standard(
832  $this->lng->txt('view'),
833  $this->ctrl->getLinkTarget($this->getParentObject(), 'showMail')
834  );
835  $this->ctrl->clearParameters($this->getParentObject());
836  }
837 
838  $buttons[] = $viewButton;
839  }
840 
845  protected function addReplyRowAction(array $mail, array &$buttons) : void
846  {
847  if (!$this->isDraftFolder()) {
848  if (isset($mail['sender_id']) && $mail['sender_id'] > 0 && $mail['sender_id'] != ANONYMOUS_USER_ID) {
849  $this->ctrl->setParameterByClass('ilmailformgui', 'mobj_id', $this->_currentFolderId);
850  $this->ctrl->setParameterByClass('ilmailformgui', 'mail_id', (int) $mail['mail_id']);
851  $this->ctrl->setParameterByClass('ilmailformgui', 'type', 'reply');
852  $replyButton = $this->uiFactory
853  ->link()
854  ->standard(
855  $this->lng->txt('reply'),
856  $this->ctrl->getLinkTargetByClass('ilmailformgui')
857  );
858  $this->ctrl->clearParametersByClass('ilmailformgui');
859 
860  $buttons[] = $replyButton;
861  }
862  }
863  }
864 
869  protected function addForwardRowAction(array $mail, array &$buttons) : void
870  {
871  if (!$this->isDraftFolder()) {
872  $this->ctrl->setParameterByClass('ilmailformgui', 'mobj_id', $this->_currentFolderId);
873  $this->ctrl->setParameterByClass('ilmailformgui', 'mail_id', (int) $mail['mail_id']);
874  $this->ctrl->setParameterByClass('ilmailformgui', 'type', 'forward');
875  $forwardButton = $this->uiFactory
876  ->link()
877  ->standard(
878  $this->lng->txt('forward'),
879  $this->ctrl->getLinkTargetByClass('ilmailformgui')
880  );
881  $this->ctrl->clearParametersByClass('ilmailformgui');
882 
883  $buttons[] = $forwardButton;
884  }
885  }
886 
891  protected function addPrintRowAction(array $mail, array &$buttons) : void
892  {
893  if (!$this->isDraftFolder()) {
894  $this->ctrl->setParameter($this->getParentObject(), 'mobj_id', $this->_currentFolderId);
895  $this->ctrl->setParameter($this->getParentObject(), 'mail_id', (int) $mail['mail_id']);
896  $printButton = $this->uiFactory
897  ->link()
898  ->standard(
899  $this->lng->txt('print'),
900  $this->ctrl->getLinkTarget($this->getParentObject(), 'printMail')
901  )->withOpenInNewViewport(true);
902  $this->ctrl->clearParameters($this->getParentObject());
903 
904  $buttons[] = $printButton;
905  }
906  }
907 
911  public function getHTML()
912  {
913  $this->ctrl->setParameter($this->getParentObject(), 'mobj_id', $this->_currentFolderId);
914  $html = parent::getHTML();
915  $this->ctrl->clearParameters($this->getParentObject());
916 
917  return $html;
918  }
919 }
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.
Definition: Renderer.php:14
setExternalSorting($a_val)
Set external sorting.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
const IL_CAL_DATETIME
$result
addReplyRowAction(array $mail, array &$buttons)
setAllowOpenIntervals(bool $allowOpenInterval)
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.
This class represents a checkbox property in a property form.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
const IL_CAL_UNIX
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.
setId($a_val)
Set id.
user()
Definition: user.php:4
$index
Definition: metadata.php:128
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
addViewRowAction(array $mail, array &$buttons)
input GUI for a time span (start and end date)
__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.
Definition: Factory.php:17
getOffset()
Get offset.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
setSelectedItems(array $a_selected_items)
setValue($a_value)
Set Value.
addMultiCommand($a_cmd, $a_text)
Add Command button.
static preloadUserObjects(array $usr_ids)
static getUserObjectById($usr_id)
setPrefix($a_prefix)
getSelectedColumns()
Get selected columns.
setNumberOfMails(int $a_number_of_mails)
prepareHTML()
Call this before using getHTML()
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)
$DIC
Definition: xapitoken.php:46
getLimit()
Get limit.
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.
setOptionTitle($a_optiontitle)
Set Option Title (optional).
setEnableTitle($a_enabletitle)
Set Enable Title.
if(! $in) $columns
Definition: Utf8Test.php:45
$_POST["username"]
$i
Definition: metadata.php:24
setFilterCommand($a_val, $a_caption=null)
Set filter command.