ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilMailFolderTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
6 
13 {
14  protected $_folderNode = [];
15  protected $_parentObject = null;
16  protected $_currentFolderId = 0;
17  protected $_number_of_mails = 0;
18  protected $_selectedItems = [];
19  protected $_isTrashFolder = false;
20  protected $_isDraftsFolder = false;
21  protected $_isSentFolder = false;
22 
24  protected $user;
25 
27  protected $filter = [];
28 
30  protected $sub_filter = [];
31 
33  protected $visibleOptionalColumns = [];
34 
36  protected $optionalColumns = [];
37 
39  protected $optional_filter = [];
40 
42  private $uiFactory;
43 
45  private $uiRenderer;
46 
55  public function __construct(
56  $a_parent_obj,
57  $a_current_folder_id,
58  $a_parent_cmd = '',
59  Factory $uiFactory = null,
60  Renderer $uiRenderer = null
61  ) {
62  global $DIC;
63 
64  $this->user = $DIC->user();
65 
66  if (null === $uiFactory) {
67  $uiFactory = $DIC->ui()->factory();
68  }
69  if (null === $uiRenderer) {
70  $uiRenderer = $DIC->ui()->renderer();
71  }
72  $this->uiFactory = $uiFactory;
73  $this->uiRenderer = $uiRenderer;
74 
75  $this->_currentFolderId = $a_current_folder_id;
76  $this->_parentObject = $a_parent_obj;
77  if (null === $uiFactory) {
78  $uiFactory = $DIC->ui()->factory();
79  }
80  if (null === $uiRenderer) {
81  $uiRenderer = $DIC->ui()->renderer();
82  }
83  $this->uiFactory = $uiFactory;
84  $this->uiRenderer = $uiRenderer;
85 
86  $this->setId('mail_folder_tbl_' . $a_current_folder_id);
87  $this->setPrefix('mtable');
88 
89  $this->setExternalSorting(true);
90  $this->setExternalSegmentation(true);
91  $this->setDefaultOrderField('send_time');
92  $this->setDefaultOrderDirection('desc');
93 
94  parent::__construct($a_parent_obj, $a_parent_cmd);
95 
96  $this->ctrl->setParameter($this->getParentObject(), 'mobj_id', $this->_currentFolderId);
97  $this->setFormAction($this->ctrl->getFormAction($this->getParentObject(), 'showFolder'));
98  $this->ctrl->clearParameters($this->getParentObject());
99 
100  $this->setEnableTitle(true);
101  $this->setSelectAllCheckbox('mail_id[]');
102  $this->setRowTemplate('tpl.mail_folder_row.html', 'Services/Mail');
103 
104  $this->setFilterCommand('applyFilter');
105  $this->setResetCommand('resetFilter');
106  }
107 
111  public function getSelectableColumns()
112  {
113  $optionalColumns = array_filter($this->getColumnDefinition(), function ($column) {
114  return isset($column['optional']) && $column['optional'];
115  });
116 
117  $columns = array();
118  foreach ($optionalColumns as $index => $column) {
119  $columns[$column['field']] = $column;
120  }
121 
122  return $columns;
123  }
124 
129  protected function isColumnVisible(int $index) : bool
130  {
131  $columnDefinition = $this->getColumnDefinition();
132  if (array_key_exists($index, $columnDefinition)) {
133  $column = $columnDefinition[$index];
134  if (isset($column['optional']) && !$column['optional']) {
135  return true;
136  }
137  if (
138  is_array($this->visibleOptionalColumns) &&
139  array_key_exists($column['field'], $this->visibleOptionalColumns)
140  ) {
141  return true;
142  }
143  }
144 
145  return false;
146  }
147 
150  final protected function fillRow($a_set)
151  {
152  foreach ($this->removeInvisibleFields($a_set) as $key => $value) {
153  $this->tpl->setVariable(strtoupper($key), $value);
154  }
155  }
156 
161  protected function removeInvisibleFields(array $row) : array
162  {
163  if (is_array($this->visibleOptionalColumns)) {
164  if (!array_key_exists('attachments', $this->visibleOptionalColumns)) {
165  unset($row['attachment_indicator']);
166  }
167 
168  if (!array_key_exists('personal_picture', $this->visibleOptionalColumns)) {
169  unset($row['img_sender']);
170  unset($row['alt_sender']);
171  }
172  }
173 
174  return $row;
175  }
176 
180  protected function getColumnDefinition() : array
181  {
182  $i = 0;
183 
184  $columns = [];
185 
186  $columns[++$i] = [
187  'field' => 'chb',
188  'txt' => '',
189  'default' => true,
190  'optional' => false,
191  'sortable' => false,
192  'is_checkbox' => true,
193  'width' => '1%'
194  ];
195 
196  $columns[++$i] = [
197  'field' => 'attachments',
198  'txt' => $this->lng->txt('mail_tbl_head_attachments'),
199  'default' => false,
200  'optional' => true,
201  'sortable' => false,
202  'width' => '5%'
203  ];
204 
205  if (!$this->isDraftFolder() && !$this->isSentFolder()) {
206  $columns[++$i] = [
207  'field' => 'personal_picture',
208  'txt' => $this->lng->txt('personal_picture'),
209  'default' => true,
210  'optional' => true,
211  'sortable' => false,
212  'width' => '5%'
213  ];
214  }
215 
216  if ($this->isDraftFolder() || $this->isSentFolder()) {
217  $columns[++$i] = [
218  'field' => 'rcp_to',
219  'txt' => $this->lng->txt('recipient'),
220  'default' => true,
221  'optional' => false,
222  'sortable' => true,
223  'width' => '35%'
224  ];
225  } else {
226  $columns[++$i] = [
227  'field' => 'from',
228  'txt' => $this->lng->txt('sender'),
229  'default' => true,
230  'optional' => false,
231  'sortable' => true,
232  'width' => '20%'
233  ];
234  }
235 
236  if ($this->isLuceneSearchEnabled()) {
237  $columns[++$i] = [
238  'field' => 'search_content',
239  'txt' => $this->lng->txt('search_content'),
240  'default' => true,
241  'optional' => false,
242  'sortable' => false,
243  'width' => '35%'
244  ];
245  } else {
246  $columns[++$i] = [
247  'field' => 'm_subject',
248  'txt' => $this->lng->txt('subject'),
249  'default' => true,
250  'optional' => false,
251  'sortable' => true,
252  'width' => '35%'
253  ];
254  }
255 
256  $columns[++$i] = [
257  'field' => 'send_time',
258  'txt' => $this->lng->txt('date'),
259  'default' => true,
260  'optional' => false,
261  'sortable' => true,
262  'width' => '20%'
263  ];
264 
265  $columns[++$i] = [
266  'field' => 'actions',
267  'txt' => $this->lng->txt('actions'),
268  'default' => true,
269  'optional' => false,
270  'sortable' => false,
271  'width' => '5%'
272  ];
273 
274  return $columns;
275  }
276 
282  final public function prepareHTML() : self
283  {
284  $columns = $this->getColumnDefinition();
285  $this->optionalColumns = (array) $this->getSelectableColumns();
286  $this->visibleOptionalColumns = (array) $this->getSelectedColumns();
287  foreach ($columns as $index => $column) {
288  if ($this->isColumnVisible($index)) {
289  $this->addColumn(
290  $column['txt'],
291  isset($column['sortable']) && $column['sortable'] ? $column['field'] : '',
292  isset($column['width']) ? $column['width'] : '',
293  isset($column['is_checkbox']) ? (bool) $column['is_checkbox'] : false
294  );
295  }
296  }
297 
298  $mtree = new \ilTree($this->user->getId());
299  $mtree->setTableNames('mail_tree', 'mail_obj_data');
300  $this->_folderNode = $mtree->getNodeData($this->_currentFolderId);
301 
302  $this->fetchTableData();
303 
304  $this->initCommandButtons();
305  $this->initMultiCommands($this->_parentObject->mbox->getActions($this->_currentFolderId));
306 
307  return $this;
308  }
309 
315  public function isDraftFolder(bool $a_bool = null)
316  {
317  if (null === $a_bool) {
318  return $this->_isDraftsFolder;
319  }
320 
321  $this->_isDraftsFolder = $a_bool;
322 
323  return $this;
324  }
325 
331  public function isSentFolder(bool $a_bool = null)
332  {
333  if (null === $a_bool) {
334  return $this->_isSentFolder;
335  }
336 
337  $this->_isSentFolder = $a_bool;
338 
339  return $this;
340  }
341 
347  public function isTrashFolder(bool $a_bool = null)
348  {
349  if (null === $a_bool) {
350  return $this->_isTrashFolder;
351  }
352 
353  $this->_isTrashFolder = $a_bool;
354 
355  return $this;
356  }
357 
361  private function initCommandButtons() : self
362  {
363  if ($this->_folderNode['m_type'] === 'trash' && $this->getNumberOfMails() > 0) {
364  $this->addCommandButton('confirmEmptyTrash', $this->lng->txt('mail_empty_trash'));
365  }
366 
367  return $this;
368  }
369 
374  private function initMultiCommands(array $actions) : self
375  {
376  foreach ($actions as $key => $action) {
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') . ')' : '');
384  $this->addMultiCommand($key . '_' . $folder['obj_id'], $label);
385  } else {
386  $this->addMultiCommand($key . '_' . $folder['obj_id'], $action . ' ' . $folder['title']);
387  }
388  }
389  }
390  } else {
391  if ($key !== 'deleteMails' || $this->isTrashFolder()) {
392  $this->addMultiCommand($key, $action);
393  }
394  }
395  }
396 
397  return $this;
398  }
399 
404  public function setSelectedItems(array $a_selected_items) : self
405  {
406  $this->_selectedItems = $a_selected_items;
407 
408  return $this;
409  }
410 
414  public function getSelectedItems() : array
415  {
416  return $this->_selectedItems;
417  }
418 
422  protected function isLuceneSearchEnabled() : bool
423  {
424  if (ilSearchSettings::getInstance()->enabledLucene() && strlen($this->filter['mail_filter'])) {
425  return true;
426  }
427 
428  return false;
429  }
430 
435  protected function fetchTableData() : self
436  {
437  if ($this->_folderNode['m_type'] == 'user_folder') {
438  $txt_folder = $this->_folderNode['title'];
439  $img_folder = 'icon_user_folder.png';
440  } else {
441  $txt_folder = $this->lng->txt('mail_' . $this->_folderNode['title']);
442  $img_folder = 'icon' . substr($this->_folderNode['title'], 1) . '.png';
443  }
444 
445  try {
446  if ($this->isLuceneSearchEnabled()) {
447  $query_parser = new ilMailLuceneQueryParser($this->filter['mail_filter']);
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']
454  ));
455  $query_parser->parse();
456 
457  $result = new ilMailSearchResult();
458  $searcher = new ilMailLuceneSearcher($query_parser, $result);
459  $searcher->search($this->user->getId(), $this->_currentFolderId);
460 
461  if (!$result->getIds()) {
462  throw new ilException('mail_search_empty_result');
463  }
464 
467  'mail_filter_only_unread' => $this->filter['mail_filter_only_unread'],
468  'mail_filter_only_with_attachments' => $this->filter['mail_filter_only_with_attachments'],
469  ];
470  } else {
471  ilMailBoxQuery::$filter = (array) $this->filter;
472  }
473 
474  if ($this->isDraftFolder() || $this->isSentFolder() && isset(ilMailBoxQuery::$filter['mail_filter_only_unread'])) {
475  unset(ilMailBoxQuery::$filter['mail_filter_only_unread']);
476  }
477 
478  if ($this->isDraftFolder() && isset(ilMailBoxQuery::$filter['mail_filter_only_with_attachments'])) {
479  unset(ilMailBoxQuery::$filter['mail_filter_only_with_attachments']);
480  }
481 
482  $this->determineOffsetAndOrder();
483 
485  ilMailBoxQuery::$userId = $this->user->getId();
486  ilMailBoxQuery::$limit = $this->getLimit();
491 
492  if (!count($data['set']) && $this->getOffset() > 0) {
493  $this->resetOffset();
494 
495  ilMailBoxQuery::$limit = $this->getLimit();
498  }
499  } catch (Exception $e) {
500  if ('mail_search_empty_result' === $e->getMessage()) {
501  $data['set'] = array();
502  $data['cnt'] = 0;
503  $data['cnt_unread'] = 0;
504  } else {
505  throw $e;
506  }
507  }
508 
509  if (!$this->isDraftFolder() && !$this->isSentFolder()) {
510  $user_ids = array();
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'];
514  }
515  }
516 
518  }
519 
520  $counter = 0;
521  foreach ($data['set'] as $key => $mail) {
522  ++$counter;
523 
524  if (is_array($this->getSelectedItems()) && in_array($mail['mail_id'], $this->getSelectedItems())) {
525  $mail['checked'] = ' checked="checked" ';
526  }
527 
528  if ($this->isDraftFolder() || $this->isSentFolder()) {
529  $mail['rcp_to'] = $mail['mail_login'] = ilUtil::htmlencodePlainString(
530  $this->_parentObject->umail->formatNamesForOutput($mail['rcp_to']),
531  false
532  );
533  } else {
534  if ($mail['sender_id'] == ANONYMOUS_USER_ID) {
535  $mail['img_sender'] = ilUtil::getImagePath('HeaderIconAvatar.svg');
536  $mail['from'] = $mail['mail_login'] = $mail['alt_sender'] = htmlspecialchars(ilMail::_getIliasMailerName());
537  } else {
538  $user = ilMailUserCache::getUserObjectById($mail['sender_id']);
539 
540  if ($user) {
541  $mail['img_sender'] = $user->getPersonalPicturePath('xxsmall');
542  $mail['from'] = $mail['mail_login'] = $mail['alt_sender'] = htmlspecialchars($user->getPublicName());
543  } else {
544  $mail['img_sender'] = '';
545  $mail['from'] = $mail['mail_login'] = $mail['import_name'] . ' (' . $this->lng->txt('user_deleted') . ')';
546  }
547  }
548  }
549 
550  if ($this->isDraftFolder()) {
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');
556  } else {
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');
560  $this->ctrl->clearParameters($this->getParentObject());
561  }
562  $css_class = $mail['m_status'] == 'read' ? 'mailread' : 'mailunread';
563 
564  if ($this->isLuceneSearchEnabled()) {
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];
571  } else {
572  $search_result[] = $content[1];
573  }
574  }
575  $mail['msr_data'] = implode('', array_map(function ($value) {
576  return '<p>' . $value . '</p>';
577  }, $search_result));
578 
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']);
583  }
584  } else {
585  $mail['mail_link_read'] = $link_mark_as_read;
586  $mail['mailclass'] = $css_class;
587  $mail['mail_subject'] = htmlspecialchars($mail['m_subject']);
588  }
589 
590  $mail['mail_date'] = ilDatePresentation::formatDate(new ilDateTime($mail['send_time'], IL_CAL_DATETIME));
591 
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']);
595  if ($this->isDraftFolder()) {
596  $this->ctrl->setParameter($this->getParentObject(), 'type', 'draft');
597  }
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')
602  )
603  );
604  $this->ctrl->clearParameters($this->getParentObject());
605  }
606 
607  $mail['actions'] = $this->formatActionsDropDown($mail);
608 
609  $data['set'][$key] = $mail;
610  }
611 
612  $this->setData($data['set']);
613  $this->setMaxCount((int) $data['cnt']);
614  $this->setNumberOfMails((int) $data['cnt']);
615 
616  $this->setTitleData($txt_folder, (int) $data['cnt'], (int) $data['cnt_unread'], $img_folder);
617 
618  return $this;
619  }
620 
629  protected function setTitleData(string $folderLabel, int $mailCount, int $unreadCount, string $imgFolder) : self
630  {
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'));
637 
638  parent::setTitle($titleTemplate->get(), $imgFolder);
639 
640  return $this;
641  }
642 
647  public function setNumberOfMails(int $a_number_of_mails) : self
648  {
649  $this->_number_of_mails = $a_number_of_mails;
650 
651  return $this;
652  }
653 
657  public function getNumberOfMails() : int
658  {
660  }
661 
665  public function initFilter()
666  {
667  $this->filter = [];
668 
669  $quickFilter = new ilMailQuickFilterInputGUI($this->lng->txt('mail_filter'), 'mail_filter');
670  $quickFilter->setSubmitFormOnEnter(false);
671  $this->addFilterItem($quickFilter);
672  $quickFilter->readFromSession();
673  $this->filter['mail_filter'] = $quickFilter->getValue();
674 
675  if ($this->isDraftFolder() || $this->isSentFolder()) {
676  $this->sub_filter[] = $subFilterInRecipients = new ilCheckboxInputGUI(
677  $this->lng->txt('mail_filter_recipients'),
678  'mail_filter_recipients'
679  );
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();
686  } else {
687  $this->sub_filter[] = $subFilterInSender = new ilCheckboxInputGUI(
688  $this->lng->txt('mail_filter_sender'),
689  'mail_filter_sender'
690  );
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();
697  }
698 
699  $this->sub_filter[] = $subFilterInSubject = new ilCheckboxInputGUI(
700  $this->lng->txt('mail_filter_subject'),
701  'mail_filter_subject'
702  );
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();
709 
710  $this->sub_filter[] = $subFilterInBody = new ilCheckboxInputGUI(
711  $this->lng->txt('mail_filter_body'),
712  'mail_filter_body'
713  );
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();
720 
721  $this->sub_filter[] = $subFilterInAttachments = new ilCheckboxInputGUI(
722  $this->lng->txt('mail_filter_attach'),
723  'mail_filter_attach'
724  );
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();
731 
732  if (!$this->isDraftFolder() && !$this->isSentFolder()) {
733  $onlyUnread = new ilCheckboxInputGUI(
734  $this->lng->txt('mail_filter_only_unread'),
735  'mail_filter_only_unread'
736  );
737  $onlyUnread->setValue(1);
738  $this->addFilterItem($onlyUnread);
739  $onlyUnread->readFromSession();
740  $this->filter['mail_filter_only_unread'] = (int) $onlyUnread->getChecked();
741  }
742 
743  if (!$this->isDraftFolder()) {
744  $onlyWithAttachments = new ilCheckboxInputGUI(
745  $this->lng->txt('mail_filter_only_with_attachments'),
746  'mail_filter_only_with_attachments'
747  );
748  $onlyWithAttachments->setValue(1);
749  $this->addFilterItem($onlyWithAttachments);
750  $onlyWithAttachments->readFromSession();
751  $this->filter['mail_filter_only_with_attachments'] = (int) $onlyWithAttachments->getChecked();
752  }
753 
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'));
758  $duration->setStart(new ilDateTime(null, IL_CAL_UNIX));
759  $duration->setEnd(new ilDateTime(null, IL_CAL_UNIX));
760  $duration->setShowTime(false);
761  $this->addFilterItem($duration);
762  $duration->readFromSession();
763  $this->filter['period'] = $duration->getValue();
764  }
765 
769  public function writeFilterToSession()
770  {
771  parent::writeFilterToSession();
772 
773  foreach ($this->sub_filter as $item) {
774  if ($item->checkInput()) {
775  $item->setValueByArray($_POST);
776  $item->writeToSession();
777  }
778  }
779  }
780 
784  public function resetFilter()
785  {
786  parent::resetFilter();
787 
788  foreach ($this->sub_filter as $item) {
789  if ($item->checkInput()) {
790  $item->setValueByArray($_POST);
791  $item->clearFromSession();
792  }
793  }
794  }
795 
800  protected function formatActionsDropDown(array $mail) : string
801  {
802  $buttons = [];
803 
804  $this->addViewRowAction($mail, $buttons);
805  $this->addReplyRowAction($mail, $buttons);
806  $this->addForwardRowAction($mail, $buttons);
807  $this->addPrintRowAction($mail, $buttons);
808 
809  $dropDown = $this->uiFactory
810  ->dropdown()
811  ->standard($buttons)
812  ->withLabel($this->lng->txt('actions'));
813 
814  return $this->uiRenderer->render([$dropDown]);
815  }
816 
821  protected function addViewRowAction(array $mail, array &$buttons)
822  {
823  if ($this->isDraftFolder()) {
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
828  ->button()
829  ->shy(
830  $this->lng->txt('view'),
831  $this->ctrl->getLinkTargetByClass('ilmailformgui')
832  );
833  $this->ctrl->clearParametersByClass('ilmailformgui');
834  } else {
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
838  ->button()
839  ->shy(
840  $this->lng->txt('view'),
841  $this->ctrl->getLinkTarget($this->getParentObject(), 'showMail')
842  );
843  $this->ctrl->clearParameters($this->getParentObject());
844  }
845 
846  $buttons[] = $viewButton;
847  }
848 
853  protected function addReplyRowAction(array $mail, array &$buttons)
854  {
855  if (!$this->isDraftFolder()) {
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
861  ->button()
862  ->shy(
863  $this->lng->txt('reply'),
864  $this->ctrl->getLinkTargetByClass('ilmailformgui')
865  );
866  $this->ctrl->clearParametersByClass('ilmailformgui');
867 
868  $buttons[] = $replyButton;
869  }
870  }
871  }
872 
877  protected function addForwardRowAction(array $mail, array &$buttons)
878  {
879  if (!$this->isDraftFolder()) {
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
884  ->button()
885  ->shy(
886  $this->lng->txt('forward'),
887  $this->ctrl->getLinkTargetByClass('ilmailformgui')
888  );
889  $this->ctrl->clearParametersByClass('ilmailformgui');
890 
891  $buttons[] = $forwardButton;
892  }
893  }
894 
899  protected function addPrintRowAction(array $mail, array &$buttons)
900  {
901  if (!$this->isDraftFolder()) {
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
905  ->button()
906  ->shy(
907  $this->lng->txt('print'),
908  $this->ctrl->getLinkTarget($this->getParentObject(), 'printMail')
909  );
910  $this->ctrl->clearParameters($this->getParentObject());
911 
912  $buttons[] = $printButton;
913  }
914  }
915 
919  public function getHTML()
920  {
921  $this->ctrl->setParameter($this->getParentObject(), 'mobj_id', $this->_currentFolderId);
922  $html = parent::getHTML();
923  $this->ctrl->clearParameters($this->getParentObject());
924 
925  return $html;
926  }
927 }
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)
$action
global $DIC
Definition: saml.php:7
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.
This class represents a checkbox property in a property form.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
$index
Definition: metadata.php:60
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
isSentFolder(bool $a_bool=null)
Setter/Getter for folder status.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
addViewRowAction(array $mail, array &$buttons)
Class ilTable2GUI.
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:15
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)
isDraftFolder(bool $a_bool=null)
Setter/Getter for folder status.
setValue($a_value)
Set Value.
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)
setPrefix($a_prefix)
Date and time handling
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.
$row
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)
$i
Definition: disco.tpl.php:19
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
$key
Definition: croninfo.php:18
$_POST["username"]
$html
Definition: example_001.php:87
__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.