ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilMailFolderGUI Class Reference
+ Collaboration diagram for ilMailFolderGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 

Data Fields

ilMail $umail
 
ilMailbox $mbox
 

Protected Member Functions

 initFolder ()
 
 parseCommand (string $originalCommand)
 
 parseFolderIdFromCommand (string $command)
 
 performEmptyTrash ()
 
 confirmEmptyTrash ()
 
 showUser ()
 
 addSubFolderCommands (bool $isUserSubFolder=false)
 
 showFolder (bool $oneConfirmationDialogueRendered=false)
 
 deleteSubFolder (bool $a_show_confirm=true)
 
 performDeleteSubFolder ()
 
 getSubFolderForm (string $mode='create')
 
 performAddSubFolder ()
 
 addSubFolder (ilPropertyFormGUI $form=null)
 
 performRenameSubFolder ()
 
 renameSubFolder (ilPropertyFormGUI $form=null)
 
 getMailIdsFromRequest (bool $ignoreHttpGet=false)
 
 markMailsRead ()
 
 markMailsUnread ()
 
 moveSingleMail ()
 
 moveMails ()
 
 deleteMails ()
 
 confirmDeleteMails ()
 
 printMail ()
 
 deliverFile ()
 
 deliverAttachments ()
 
 getMailFolderTable ()
 
 applyFilter ()
 
 resetFilter ()
 

Protected Attributes

readonly Factory $ui_factory
 
readonly Renderer $ui_renderer
 

Private Attributes

bool $confirmTrashDeletion = false
 
bool $errorDelete = false
 
readonly ilGlobalTemplateInterface $tpl
 
readonly ilCtrlInterface $ctrl
 
readonly ilLanguage $lng
 
readonly ilToolbarGUI $toolbar
 
readonly ilTabsGUI $tabs
 
readonly ilObjUser $user
 
readonly GlobalHttpState $http
 
readonly Refinery $refinery
 
int $currentFolderId = 0
 
readonly ilErrorHandling $error
 

Detailed Description

Author
Jens Conze
Version
$Id$

ilMailFolderGUI: ilPublicUserProfileGUI

Definition at line 32 of file class.ilMailFolderGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilMailFolderGUI::__construct ( )

Definition at line 52 of file class.ilMailFolderGUI.php.

References $DIC, ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), initFolder(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), ILIAS\Repository\tabs(), ILIAS\Repository\toolbar(), and ILIAS\Repository\user().

53  {
54  global $DIC;
55 
56  $this->tpl = $DIC->ui()->mainTemplate();
57  $this->ctrl = $DIC->ctrl();
58  $this->lng = $DIC->language();
59  $this->toolbar = $DIC->toolbar();
60  $this->user = $DIC->user();
61  $this->tabs = $DIC->tabs();
62  $this->http = $DIC->http();
63  $this->refinery = $DIC->refinery();
64  $this->error = $DIC['ilErr'];
65  $this->ui_factory = $DIC->ui()->factory();
66  $this->ui_renderer = $DIC->ui()->renderer();
67 
68  $this->umail = new ilMail($this->user->getId());
69  $this->mbox = new ilMailbox($this->user->getId());
70 
71  $this->initFolder();
72  }
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.
Mail Box class Base class for creating and handling mail boxes.
+ Here is the call graph for this function:

Member Function Documentation

◆ addSubFolder()

ilMailFolderGUI::addSubFolder ( ilPropertyFormGUI  $form = null)
protected

Definition at line 381 of file class.ilMailFolderGUI.php.

References getSubFolderForm(), and ILIAS\Repository\lng().

Referenced by performAddSubFolder().

381  : void
382  {
383  if (null === $form) {
384  $form = $this->getSubFolderForm();
385  }
386 
387  $this->tpl->setTitle($this->lng->txt('mail'));
388  $this->tpl->setContent($form->getHTML());
389  $this->tpl->printToStdout();
390  }
getSubFolderForm(string $mode='create')
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addSubFolderCommands()

ilMailFolderGUI::addSubFolderCommands ( bool  $isUserSubFolder = false)
protected

Definition at line 210 of file class.ilMailFolderGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

Referenced by showFolder().

210  : void
211  {
212  $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
213  $this->toolbar->addButton(
214  $this->lng->txt('mail_add_subfolder'),
215  $this->ctrl->getLinkTarget($this, 'addSubFolder')
216  );
217 
218  if ($isUserSubFolder) {
219  $this->toolbar->addButton(
220  $this->lng->txt('rename'),
221  $this->ctrl->getLinkTarget($this, 'renameSubFolder')
222  );
223  $this->toolbar->addButton(
224  $this->lng->txt('delete'),
225  $this->ctrl->getLinkTarget($this, 'deleteSubFolder')
226  );
227  }
228  $this->ctrl->clearParameters($this);
229  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applyFilter()

ilMailFolderGUI::applyFilter ( )
protected

Definition at line 1090 of file class.ilMailFolderGUI.php.

References getMailFolderTable(), and showFolder().

1090  : void
1091  {
1092  $table = $this->getMailFolderTable();
1093  $table->resetOffset();
1094  $table->writeFilterToSession();
1095 
1096  $this->showFolder();
1097  }
showFolder(bool $oneConfirmationDialogueRendered=false)
+ Here is the call graph for this function:

◆ confirmDeleteMails()

ilMailFolderGUI::confirmDeleteMails ( )
protected

Definition at line 572 of file class.ilMailFolderGUI.php.

References $currentFolderId, $id, $message, ilMail\_getIliasMailerName(), ilObjUser\_lookupPref(), ILIAS\Repository\ctrl(), ilDatePresentation\formatDate(), ilUtil\getImagePath(), ilObjectFactory\getInstanceByObjId(), getMailIdsFromRequest(), ilUtil\htmlencodePlainString(), ILIAS\FileDelivery\http(), IL_CAL_DATETIME, ilUtil\img(), ILIAS\Repository\lng(), ilMailFormGUI\MAIL_FORM_TYPE_FORWARD, ilMailFormGUI\MAIL_FORM_TYPE_REPLY, ILIAS\Repository\refinery(), ilCustomInputGUI\setHtml(), showFolder(), ILIAS\Repository\tabs(), ILIAS\Repository\toolbar(), and ILIAS\UI\Implementation\Component\withOnLoadCode().

572  : void
573  {
574  $mailIds = $this->getMailIdsFromRequest();
575  if ($mailIds === []) {
576  $this->showFolder();
577  $this->tpl->setOnScreenMessage('info', $this->lng->txt('mail_select_one'));
578  return;
579  }
580 
581  if ($this->mbox->getTrashFolder() === $this->currentFolderId) {
582  $this->umail->deleteMails($mailIds);
583  $this->tpl->setOnScreenMessage('success', $this->lng->txt('mail_deleted'), true);
584  $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
585  $this->ctrl->redirect($this, 'showFolder');
586  }
587 
588  $this->showFolder();
589  }
getMailIdsFromRequest(bool $ignoreHttpGet=false)
showFolder(bool $oneConfirmationDialogueRendered=false)
+ Here is the call graph for this function:

◆ confirmEmptyTrash()

ilMailFolderGUI::confirmEmptyTrash ( )
protected

Definition at line 164 of file class.ilMailFolderGUI.php.

References showFolder().

164  : void
165  {
166  if ($this->umail->countMailsOfFolder($this->currentFolderId) !== 0) {
167  $this->confirmTrashDeletion = true;
168  }
169 
170  $this->showFolder();
171  }
showFolder(bool $oneConfirmationDialogueRendered=false)
+ Here is the call graph for this function:

◆ deleteMails()

ilMailFolderGUI::deleteMails ( )
protected

Definition at line 549 of file class.ilMailFolderGUI.php.

References ILIAS\Repository\ctrl(), getMailIdsFromRequest(), ILIAS\Repository\lng(), and showFolder().

549  : void
550  {
551  $trashFolderId = $this->mbox->getTrashFolder();
552  $mailIds = $this->getMailIdsFromRequest();
553 
554  if ($trashFolderId === $this->currentFolderId) {
555  if ($mailIds === []) {
556  $this->tpl->setOnScreenMessage('info', $this->lng->txt('mail_select_one'));
557  $this->errorDelete = true;
558  }
559  } elseif ($mailIds === []) {
560  $this->tpl->setOnScreenMessage('info', $this->lng->txt('mail_select_one'));
561  } elseif ($this->umail->moveMailsToFolder($mailIds, $trashFolderId)) {
562  $this->tpl->setOnScreenMessage('success', $this->lng->txt('mail_moved_to_trash'), true);
563  $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
564  $this->ctrl->redirect($this, 'showFolder');
565  } else {
566  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('mail_move_error'));
567  }
568 
569  $this->showFolder();
570  }
getMailIdsFromRequest(bool $ignoreHttpGet=false)
showFolder(bool $oneConfirmationDialogueRendered=false)
+ Here is the call graph for this function:

◆ deleteSubFolder()

ilMailFolderGUI::deleteSubFolder ( bool  $a_show_confirm = true)
protected

Definition at line 304 of file class.ilMailFolderGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and showFolder().

304  : void
305  {
306  if ($a_show_confirm) {
307  $confirmationGui = new ilConfirmationGUI();
308  $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
309  $confirmationGui->setFormAction($this->ctrl->getFormAction($this, 'showFolder'));
310  $this->ctrl->clearParameters($this);
311  $confirmationGui->setHeaderText($this->lng->txt('mail_sure_delete_folder'));
312  $confirmationGui->setCancel($this->lng->txt('cancel'), 'showFolder');
313  $confirmationGui->setConfirm($this->lng->txt('confirm'), 'performDeleteSubFolder');
314  $this->tpl->setVariable('CONFIRMATION', $confirmationGui->getHTML());
315 
316  $this->showFolder(true);
317  } else {
318  $this->showFolder();
319  }
320  }
showFolder(bool $oneConfirmationDialogueRendered=false)
+ Here is the call graph for this function:

◆ deliverAttachments()

ilMailFolderGUI::deliverAttachments ( )
protected

Definition at line 1020 of file class.ilMailFolderGUI.php.

References Vendor\Package\$e, ILIAS\Repository\ctrl(), ilFileDelivery\deliverFileLegacy(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ILIAS\Repository\user().

1020  : void
1021  {
1022  try {
1023  $mailId = 0;
1024  if ($this->http->wrapper()->query()->has('mail_id')) {
1025  $mailId = $this->http->wrapper()->query()->retrieve('mail_id', $this->refinery->kindlyTo()->int());
1026  }
1027 
1028  $mailData = $this->umail->getMail((int) $mailId);
1029  if (null === $mailData || [] === (array) $mailData['attachments']) {
1030  throw new ilMailException('mail_error_reading_attachment');
1031  }
1032 
1033  $type = '';
1034  if ($this->http->wrapper()->query()->has('type')) {
1035  $type = $this->http->wrapper()->query()->retrieve('type', $this->refinery->kindlyTo()->string());
1036  }
1037 
1038  $mailFileData = new ilFileDataMail($this->user->getId());
1039  if (count($mailData['attachments']) === 1) {
1040  $attachment = current($mailData['attachments']);
1041 
1042  try {
1043  if ('draft' === $type) {
1044  if (!$mailFileData->checkFilesExist([$attachment])) {
1045  throw new OutOfBoundsException('');
1046  }
1047  $pathToFile = $mailFileData->getAbsoluteAttachmentPoolPathByFilename($attachment);
1048  $fileName = $attachment;
1049  } else {
1050  $file = $mailFileData->getAttachmentPathAndFilenameByMd5Hash(
1051  md5($attachment),
1052  (int) $mailId
1053  );
1054  $pathToFile = $file['path'];
1055  $fileName = $file['filename'];
1056  }
1057  ilFileDelivery::deliverFileLegacy($pathToFile, $fileName);
1058  } catch (OutOfBoundsException $e) {
1059  throw new ilMailException('mail_error_reading_attachment', $e->getCode(), $e);
1060  }
1061  } else {
1062  $mailFileData->deliverAttachmentsAsZip(
1063  $mailData['m_subject'],
1064  (int) $mailId,
1065  $mailData['attachments'],
1066  'draft' === $type
1067  );
1068  }
1069  } catch (Exception $e) {
1070  $this->tpl->setOnScreenMessage('failure', $this->lng->txt($e->getMessage()), true);
1071  $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
1072  $this->ctrl->redirect($this);
1073  }
1074  }
This class handles all operations on files (attachments) in directory ilias_data/mail.
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:

◆ deliverFile()

ilMailFolderGUI::deliverFile ( )
protected

Definition at line 975 of file class.ilMailFolderGUI.php.

References Vendor\Package\$e, $filename, ILIAS\Repository\ctrl(), ilFileDelivery\deliverFileLegacy(), ilSession\get(), ilFileDataMail\getAttachmentPathAndFilenameByMd5Hash(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), ilSession\set(), and ILIAS\Repository\user().

975  : void
976  {
977  $mailId = 0;
978  if ($this->http->wrapper()->query()->has('mail_id')) {
979  $mailId = $this->http->wrapper()->query()->retrieve('mail_id', $this->refinery->kindlyTo()->int());
980  }
981 
982  if ($mailId <= 0) {
983  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
984  }
985 
986  $filename = '';
987  if ($this->http->wrapper()->post()->has('filename')) {
988  $filename = $this->http->wrapper()->post()->retrieve('filename', $this->refinery->kindlyTo()->string());
989  }
990 
991  if (is_string(ilSession::get('filename')) && ilSession::get('filename') !== '') {
992  $filename = ilSession::get('filename');
993  ilSession::set('filename', null);
994  }
995 
996  try {
997  if ($mailId > 0 && $filename !== '') {
998  while (str_contains((string) $filename, '..')) {
999  $filename = str_replace('..', '', $filename);
1000  }
1001 
1002  $mailFileData = new ilFileDataMail($this->user->getId());
1003  try {
1004  $file = $mailFileData->getAttachmentPathAndFilenameByMd5Hash($filename, (int) $mailId);
1005  ilFileDelivery::deliverFileLegacy($file['path'], $file['filename']);
1006  } catch (OutOfBoundsException $e) {
1007  throw new ilMailException('mail_error_reading_attachment', $e->getCode(), $e);
1008  }
1009  } else {
1010  $this->tpl->setOnScreenMessage('info', $this->lng->txt('mail_select_attachment'));
1011  $this->showMail();
1012  }
1013  } catch (Exception $e) {
1014  $this->tpl->setOnScreenMessage('failure', $this->lng->txt($e->getMessage()), true);
1015  $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
1016  $this->ctrl->redirect($this);
1017  }
1018  }
getAttachmentPathAndFilenameByMd5Hash(string $md5FileHash, int $mailId)
static get(string $a_var)
This class handles all operations on files (attachments) in directory ilias_data/mail.
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
static http()
Fetches the global http state from ILIAS.
$filename
Definition: buildRTE.php:78
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:

◆ executeCommand()

ilMailFolderGUI::executeCommand ( )

Definition at line 115 of file class.ilMailFolderGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), parseCommand(), and ILIAS\Repository\refinery().

115  : void
116  {
117  $cmd = $this->parseCommand(
118  $this->ctrl->getCmd()
119  );
120 
121  $nextClass = $this->ctrl->getNextClass($this);
122  switch (strtolower($nextClass)) {
123  case strtolower(ilContactGUI::class):
124  $this->ctrl->forwardCommand(new ilContactGUI());
125  break;
126 
127  case strtolower(ilPublicUserProfileGUI::class):
128  $this->tpl->setTitle($this->lng->txt('mail'));
129  $userId = 0;
130  if ($this->http->wrapper()->query()->has('user')) {
131  $userId = $this->http->wrapper()->query()->retrieve('user', $this->refinery->kindlyTo()->int());
132  }
133  $profileGui = new ilPublicUserProfileGUI($userId);
134 
135  $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
136  $profileGui->setBackUrl($this->ctrl->getLinkTarget($this, 'showMail'));
137  $this->ctrl->clearParameters($this);
138 
139  $ret = $this->ctrl->forwardCommand($profileGui);
140  if ($ret !== '') {
141  $this->tpl->setContent($ret);
142  }
143  $this->tpl->printToStdout();
144  break;
145 
146  default:
147  if (!method_exists($this, $cmd)) {
148  $cmd = 'showFolder';
149  }
150  $this->{$cmd}();
151  break;
152  }
153  }
GUI class for public user profile presentation.
static http()
Fetches the global http state from ILIAS.
parseCommand(string $originalCommand)
+ Here is the call graph for this function:

◆ getMailFolderTable()

ilMailFolderGUI::getMailFolderTable ( )
protected

Definition at line 1076 of file class.ilMailFolderGUI.php.

Referenced by applyFilter(), resetFilter(), and showFolder().

1077  {
1078  $table = new ilMailFolderTableGUI(
1079  $this,
1080  $this->currentFolderId,
1081  'showFolder',
1082  $this->currentFolderId === $this->mbox->getTrashFolder(),
1083  $this->currentFolderId === $this->mbox->getSentFolder(),
1084  $this->currentFolderId === $this->mbox->getDraftsFolder()
1085  );
1086 
1087  return $table;
1088  }
+ Here is the caller graph for this function:

◆ getMailIdsFromRequest()

ilMailFolderGUI::getMailIdsFromRequest ( bool  $ignoreHttpGet = false)
protected
Returns
int[]

Definition at line 441 of file class.ilMailFolderGUI.php.

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by confirmDeleteMails(), deleteMails(), markMailsRead(), markMailsUnread(), moveMails(), moveSingleMail(), and showFolder().

441  : array
442  {
443  $mailIds = [];
444  if ($this->http->wrapper()->post()->has('mail_id')) {
445  $mailIds = $this->http->wrapper()->post()->retrieve(
446  'mail_id',
447  $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
448  );
449  }
450 
451  if ($mailIds === [] && !$ignoreHttpGet) {
452  $mailId = 0;
453  if ($this->http->wrapper()->query()->has('mail_id')) {
454  $mailId = $this->http->wrapper()->query()->retrieve('mail_id', $this->refinery->kindlyTo()->int());
455  }
456  if (is_numeric($mailId)) {
457  $mailIds = [$mailId];
458  }
459  }
460 
461  return array_filter(array_map('intval', $mailIds));
462  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSubFolderForm()

ilMailFolderGUI::getSubFolderForm ( string  $mode = 'create')
protected

Definition at line 338 of file class.ilMailFolderGUI.php.

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

Referenced by addSubFolder(), performAddSubFolder(), performRenameSubFolder(), and renameSubFolder().

339  {
340  $form = new ilPropertyFormGUI();
341  $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
342  $form->setFormAction($this->ctrl->getFormAction($this, 'performAddSubFolder'));
343  $this->ctrl->clearParameters($this);
344  if ('edit' === $mode) {
345  $form->addCommandButton('performRenameSubFolder', $this->lng->txt('save'));
346  $form->setTitle($this->lng->txt('mail_rename_folder'));
347  } else {
348  $form->addCommandButton('performAddSubFolder', $this->lng->txt('save'));
349  $form->setTitle($this->lng->txt('mail_add_folder'));
350  }
351  $form->addCommandButton('showFolder', $this->lng->txt('cancel'));
352 
353  $title = new ilTextInputGUI($this->lng->txt('title'), 'subfolder_title');
354  $title->setRequired(true);
355  $form->addItem($title);
356 
357  return $form;
358  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initFolder()

ilMailFolderGUI::initFolder ( )
protected

Definition at line 74 of file class.ilMailFolderGUI.php.

References ilSession\get(), ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by __construct().

74  : void
75  {
76  if ($this->http->wrapper()->post()->has('mobj_id')) {
77  $folderId = $this->http->wrapper()->post()->retrieve('mobj_id', $this->refinery->kindlyTo()->int());
78  } elseif ($this->http->wrapper()->query()->has('mobj_id')) {
79  $folderId = $this->http->wrapper()->query()->retrieve('mobj_id', $this->refinery->kindlyTo()->int());
80  } else {
81  $folderId = $this->refinery->byTrying([
82  $this->refinery->kindlyTo()->int(),
83  $this->refinery->always($this->currentFolderId),
84  ])->transform(ilSession::get('mobj_id'));
85  }
86 
87  if (0 === $folderId || !$this->mbox->isOwnedFolder($folderId)) {
88  $folderId = $this->mbox->getInboxFolder();
89  }
90 
91  $this->currentFolderId = $folderId;
92  }
static get(string $a_var)
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ markMailsRead()

ilMailFolderGUI::markMailsRead ( )
protected

Definition at line 464 of file class.ilMailFolderGUI.php.

References getMailIdsFromRequest(), ILIAS\Repository\lng(), and showFolder().

464  : void
465  {
466  $mailIds = $this->getMailIdsFromRequest();
467  if ($mailIds !== []) {
468  $this->umail->markRead($mailIds);
469  $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'));
470  } else {
471  $this->tpl->setOnScreenMessage('info', $this->lng->txt('mail_select_one'));
472  }
473 
474  $this->showFolder();
475  }
getMailIdsFromRequest(bool $ignoreHttpGet=false)
showFolder(bool $oneConfirmationDialogueRendered=false)
+ Here is the call graph for this function:

◆ markMailsUnread()

ilMailFolderGUI::markMailsUnread ( )
protected

Definition at line 477 of file class.ilMailFolderGUI.php.

References getMailIdsFromRequest(), ILIAS\Repository\lng(), and showFolder().

477  : void
478  {
479  $mailIds = $this->getMailIdsFromRequest();
480  if ($mailIds !== []) {
481  $this->umail->markUnread($mailIds);
482  $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'));
483  } else {
484  $this->tpl->setOnScreenMessage('info', $this->lng->txt('mail_select_one'));
485  }
486 
487  $this->showFolder();
488  }
getMailIdsFromRequest(bool $ignoreHttpGet=false)
showFolder(bool $oneConfirmationDialogueRendered=false)
+ Here is the call graph for this function:

◆ moveMails()

ilMailFolderGUI::moveMails ( )
protected

Definition at line 529 of file class.ilMailFolderGUI.php.

References ILIAS\Repository\ctrl(), getMailIdsFromRequest(), ILIAS\Repository\lng(), parseFolderIdFromCommand(), and showFolder().

529  : void
530  {
531  $mailIds = $this->getMailIdsFromRequest();
532  if ($mailIds === []) {
533  $this->showFolder();
534  $this->tpl->setOnScreenMessage('info', $this->lng->txt('mail_select_one'));
535  return;
536  }
537 
538  $folderId = $this->parseFolderIdFromCommand($this->ctrl->getCmd());
539  if ($this->umail->moveMailsToFolder($mailIds, $folderId)) {
540  $this->tpl->setOnScreenMessage('success', $this->lng->txt('mail_moved'), true);
541  $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
542  $this->ctrl->redirect($this, 'showFolder');
543  } else {
544  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('mail_move_error'));
545  $this->showFolder();
546  }
547  }
getMailIdsFromRequest(bool $ignoreHttpGet=false)
parseFolderIdFromCommand(string $command)
showFolder(bool $oneConfirmationDialogueRendered=false)
+ Here is the call graph for this function:

◆ moveSingleMail()

ilMailFolderGUI::moveSingleMail ( )
protected

Definition at line 490 of file class.ilMailFolderGUI.php.

References ILIAS\Repository\ctrl(), getMailIdsFromRequest(), ILIAS\FileDelivery\http(), ILIAS\Repository\int(), ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

490  : void
491  {
492  $mailIds = $this->getMailIdsFromRequest();
493  if (1 !== count($mailIds)) {
494  $this->showMail();
495  $this->tpl->setOnScreenMessage('info', $this->lng->txt('mail_select_one'));
496  return;
497  }
498 
499  $newFolderId = 0;
500  if ($this->http->wrapper()->query()->has('folder_id')) {
501  $newFolderId = $this->http->wrapper()->query()->retrieve(
502  'folder_id',
503  $this->refinery->kindlyTo()->int()
504  );
505  }
506  $redirectFolderId = $newFolderId;
507 
508  foreach ($mailIds as $mailId) {
509  $mailData = $this->umail->getMail($mailId);
510  if (isset($mailData['folder_id']) &&
511  is_numeric($mailData['folder_id']) &&
512  (int) $mailData['folder_id'] > 0
513  ) {
514  $redirectFolderId = (int) $mailData['folder_id'];
515  break;
516  }
517  }
518 
519  if ($this->umail->moveMailsToFolder($mailIds, $newFolderId)) {
520  $this->tpl->setOnScreenMessage('success', $this->lng->txt('mail_moved'), true);
521  $this->ctrl->setParameter($this, 'mobj_id', $redirectFolderId);
522  $this->ctrl->redirect($this, 'showFolder');
523  } else {
524  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('mail_move_error'));
525  $this->showMail();
526  }
527  }
getMailIdsFromRequest(bool $ignoreHttpGet=false)
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:

◆ parseCommand()

ilMailFolderGUI::parseCommand ( string  $originalCommand)
protected

Definition at line 94 of file class.ilMailFolderGUI.php.

Referenced by executeCommand(), and showFolder().

94  : string
95  {
96  if (preg_match('/^([a-zA-Z0-9]+?)_(\d+?)$/', $originalCommand, $matches) && 3 === count($matches)) {
97  $originalCommand = $matches[1];
98  }
99 
100  return $originalCommand;
101  }
+ Here is the caller graph for this function:

◆ parseFolderIdFromCommand()

ilMailFolderGUI::parseFolderIdFromCommand ( string  $command)
protected

Definition at line 103 of file class.ilMailFolderGUI.php.

Referenced by moveMails().

103  : int
104  {
105  if (
106  preg_match('/^([a-zA-Z0-9]+?)_(\d+?)$/', $command, $matches) &&
107  3 === count($matches) && is_numeric($matches[2])
108  ) {
109  return (int) $matches[2];
110  }
111 
112  throw new InvalidArgumentException("Cannot parse a numeric folder id from command string!");
113  }
+ Here is the caller graph for this function:

◆ performAddSubFolder()

ilMailFolderGUI::performAddSubFolder ( )
protected

Definition at line 360 of file class.ilMailFolderGUI.php.

References addSubFolder(), ILIAS\Repository\ctrl(), getSubFolderForm(), and ILIAS\Repository\lng().

360  : void
361  {
362  $form = $this->getSubFolderForm();
363  $isFormValid = $form->checkInput();
364  $form->setValuesByPost();
365  if (!$isFormValid) {
366  $this->addSubFolder($form);
367  return;
368  }
369 
370  $newFolderId = $this->mbox->addFolder($this->currentFolderId, $form->getInput('subfolder_title'));
371  if ($newFolderId > 0) {
372  $this->tpl->setOnScreenMessage('success', $this->lng->txt('mail_folder_created'), true);
373  $this->ctrl->setParameterByClass(ilMailGUI::class, 'mobj_id', $newFolderId);
374  $this->ctrl->redirectByClass(ilMailGUI::class);
375  }
376 
377  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('mail_folder_exists'));
378  $this->addSubFolder($form);
379  }
addSubFolder(ilPropertyFormGUI $form=null)
getSubFolderForm(string $mode='create')
+ Here is the call graph for this function:

◆ performDeleteSubFolder()

ilMailFolderGUI::performDeleteSubFolder ( )
protected
Exceptions
ilInvalidTreeStructureException

Definition at line 325 of file class.ilMailFolderGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and showFolder().

325  : void
326  {
327  $parentFolderId = $this->mbox->getParentFolderId($this->currentFolderId);
328  if ($parentFolderId > 0 && $this->mbox->deleteFolder($this->currentFolderId)) {
329  $this->tpl->setOnScreenMessage('info', $this->lng->txt('mail_folder_deleted'), true);
330  $this->ctrl->setParameterByClass(ilMailGUI::class, 'mobj_id', $parentFolderId);
331  $this->ctrl->redirectByClass(ilMailGUI::class);
332  } else {
333  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('mail_error_delete'));
334  $this->showFolder();
335  }
336  }
showFolder(bool $oneConfirmationDialogueRendered=false)
+ Here is the call graph for this function:

◆ performEmptyTrash()

ilMailFolderGUI::performEmptyTrash ( )
protected

Definition at line 155 of file class.ilMailFolderGUI.php.

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

155  : void
156  {
157  $this->umail->deleteMailsOfFolder($this->currentFolderId);
158 
159  $this->tpl->setOnScreenMessage('success', $this->lng->txt('mail_deleted'), true);
160  $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
161  $this->ctrl->redirect($this, 'showFolder');
162  }
+ Here is the call graph for this function:

◆ performRenameSubFolder()

ilMailFolderGUI::performRenameSubFolder ( )
protected

Definition at line 392 of file class.ilMailFolderGUI.php.

References ILIAS\Repository\ctrl(), getSubFolderForm(), ILIAS\Repository\lng(), renameSubFolder(), and showFolder().

392  : void
393  {
394  $form = $this->getSubFolderForm('edit');
395  $isFormValid = $form->checkInput();
396  $form->setValuesByPost();
397  if (!$isFormValid) {
398  $this->renameSubFolder($form);
399  return;
400  }
401 
402  $folderData = $this->mbox->getFolderData($this->currentFolderId);
403  if ($folderData === null) {
404  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('mail_operation_on_invalid_folder'), true);
405  $this->ctrl->setParameterByClass(ilMailGUI::class, 'mobj_id', $this->mbox->getInboxFolder());
406  $this->ctrl->redirectByClass(ilMailGUI::class);
407  }
408 
409  if ($folderData['title'] === $form->getInput('subfolder_title')) {
410  $this->showFolder();
411  return;
412  }
413 
414  if ($this->mbox->renameFolder($this->currentFolderId, $form->getInput('subfolder_title'))) {
415  $this->tpl->setOnScreenMessage('success', $this->lng->txt('mail_folder_name_changed'), true);
416  $this->ctrl->setParameterByClass(ilMailGUI::class, 'mobj_id', $this->currentFolderId);
417  $this->ctrl->redirectByClass(ilMailGUI::class);
418  }
419 
420  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('mail_folder_exists'));
421  $this->renameSubFolder($form);
422  }
getSubFolderForm(string $mode='create')
renameSubFolder(ilPropertyFormGUI $form=null)
showFolder(bool $oneConfirmationDialogueRendered=false)
+ Here is the call graph for this function:

◆ printMail()

ilMailFolderGUI::printMail ( )
protected

Definition at line 919 of file class.ilMailFolderGUI.php.

References ilMail\_getIliasMailerName(), ilDatePresentation\formatDate(), ilObjectFactory\getInstanceByObjId(), ILIAS\FileDelivery\http(), IL_CAL_DATETIME, ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

919  : void
920  {
921  $tplprint = new ilTemplate('tpl.mail_print.html', true, true, 'Services/Mail');
922 
923  $mailId = 0;
924  if ($this->http->wrapper()->query()->has('mail_id')) {
925  $mailId = $this->http->wrapper()->query()->retrieve('mail_id', $this->refinery->kindlyTo()->int());
926  }
927  $mailData = $this->umail->getMail($mailId);
928 
929  $sender = ilObjectFactory::getInstanceByObjId($mailData['sender_id'], false);
930 
931  $tplprint->setVariable('TXT_FROM', $this->lng->txt('from'));
932  if ($sender instanceof ilObjUser && $sender->getId() !== 0 && !$sender->isAnonymous()) {
933  $tplprint->setVariable('FROM', $sender->getPublicName());
934  } elseif (!$sender instanceof ilObjUser || 0 === $sender->getId()) {
935  $tplprint->setVariable(
936  'FROM',
937  trim(($mailData['import_name'] ?? '') . ' (' . $this->lng->txt('user_deleted') . ')')
938  );
939  } else {
940  $tplprint->setVariable('FROM', ilMail::_getIliasMailerName());
941  }
942 
943  $tplprint->setVariable('TXT_TO', $this->lng->txt('mail_to'));
944  $tplprint->setVariable('TO', $mailData['rcp_to']);
945 
946  if ($mailData['rcp_cc']) {
947  $tplprint->setCurrentBlock('cc');
948  $tplprint->setVariable('TXT_CC', $this->lng->txt('mail_cc'));
949  $tplprint->setVariable('CC', $mailData['rcp_cc']);
950  $tplprint->parseCurrentBlock();
951  }
952 
953  if ($mailData['rcp_bcc']) {
954  $tplprint->setCurrentBlock('bcc');
955  $tplprint->setVariable('TXT_BCC', $this->lng->txt('mail_bcc'));
956  $tplprint->setVariable('BCC', $mailData['rcp_bcc']);
957  $tplprint->parseCurrentBlock();
958  }
959 
960  $tplprint->setVariable('TXT_SUBJECT', $this->lng->txt('subject'));
961  $tplprint->setVariable('SUBJECT', htmlspecialchars($mailData['m_subject']));
962 
963  $tplprint->setVariable('TXT_DATE', $this->lng->txt('date'));
964  $tplprint->setVariable(
965  'DATE',
966  ilDatePresentation::formatDate(new ilDateTime($mailData['send_time'], IL_CAL_DATETIME))
967  );
968 
969  $tplprint->setVariable('TXT_MESSAGE', $this->lng->txt('message'));
970  $tplprint->setVariable('MAIL_MESSAGE', nl2br(htmlspecialchars($mailData['m_message'])));
971 
972  $tplprint->show();
973  }
const IL_CAL_DATETIME
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
static _getIliasMailerName()
static http()
Fetches the global http state from ILIAS.
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
+ Here is the call graph for this function:

◆ renameSubFolder()

ilMailFolderGUI::renameSubFolder ( ilPropertyFormGUI  $form = null)
protected

Definition at line 424 of file class.ilMailFolderGUI.php.

References getSubFolderForm(), and ILIAS\Repository\lng().

Referenced by performRenameSubFolder().

424  : void
425  {
426  if (null === $form) {
427  $form = $this->getSubFolderForm('edit');
428  $form->setValuesByArray(
429  ['subfolder_title' => $this->mbox->getFolderData($this->currentFolderId)['title'] ?? '']
430  );
431  }
432 
433  $this->tpl->setTitle($this->lng->txt('mail'));
434  $this->tpl->setContent($form->getHTML());
435  $this->tpl->printToStdout();
436  }
getSubFolderForm(string $mode='create')
setValuesByArray(array $a_values, bool $a_restrict_to_value_keys=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetFilter()

ilMailFolderGUI::resetFilter ( )
protected

Definition at line 1099 of file class.ilMailFolderGUI.php.

References getMailFolderTable(), and showFolder().

1099  : void
1100  {
1101  $table = $this->getMailFolderTable();
1102  $table->resetOffset();
1103  $table->resetFilter();
1104 
1105  $this->showFolder();
1106  }
showFolder(bool $oneConfirmationDialogueRendered=false)
+ Here is the call graph for this function:

◆ showFolder()

ilMailFolderGUI::showFolder ( bool  $oneConfirmationDialogueRendered = false)
protected

Definition at line 231 of file class.ilMailFolderGUI.php.

References Vendor\Package\$e, addSubFolderCommands(), ILIAS\Repository\ctrl(), getMailFolderTable(), getMailIdsFromRequest(), ILIAS\Repository\lng(), parseCommand(), ILIAS\Repository\toolbar(), and ILIAS\Repository\user().

Referenced by applyFilter(), confirmDeleteMails(), confirmEmptyTrash(), deleteMails(), deleteSubFolder(), markMailsRead(), markMailsUnread(), moveMails(), performDeleteSubFolder(), performRenameSubFolder(), and resetFilter().

231  : void
232  {
233  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.mail.html', 'Services/Mail');
234  $this->tpl->setTitle($this->lng->txt('mail'));
235 
236  $isTrashFolder = $this->currentFolderId === $this->mbox->getTrashFolder();
237 
238  $selected_mail_ids = $this->getMailIdsFromRequest(true);
239  if (!$this->errorDelete && $isTrashFolder && 'deleteMails' === $this->parseCommand($this->ctrl->getCmd())) {
240  $confirmationGui = new ilConfirmationGUI();
241  $confirmationGui->setHeaderText($this->lng->txt('mail_sure_delete'));
242  $selected_mail_ids = $this->getMailIdsFromRequest();
243  foreach ($selected_mail_ids as $mailId) {
244  $confirmationGui->addHiddenItem('mail_id[]', (string) $mailId);
245  }
246  $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
247  $confirmationGui->setFormAction($this->ctrl->getFormAction($this, 'showFolder'));
248  $this->ctrl->clearParameters($this);
249  $confirmationGui->setConfirm($this->lng->txt('confirm'), 'confirmDeleteMails');
250  $confirmationGui->setCancel($this->lng->txt('cancel'), 'showFolder');
251  $this->tpl->setVariable('CONFIRMATION', $confirmationGui->getHTML());
252  $oneConfirmationDialogueRendered = true;
253  }
254 
255  $mtree = new ilTree($this->user->getId());
256  $mtree->setTableNames('mail_tree', 'mail_obj_data');
257 
258  $isUserSubFolder = false;
259  $isUserRootFolder = false;
260 
261  $folder_d = $mtree->getNodeData($this->currentFolderId);
262  if ($folder_d['m_type'] === 'user_folder') {
263  $isUserSubFolder = true;
264  } elseif ($folder_d['m_type'] === 'local') {
265  $isUserRootFolder = true;
266  }
267 
268  $mailtable = $this->getMailFolderTable();
269  $mailtable->setSelectedItems($selected_mail_ids);
270 
271  try {
272  $mailtable->prepareHTML();
273  } catch (Exception $e) {
274  $this->tpl->setOnScreenMessage('failure', $this->lng->txt($e->getMessage()) !== '-' . $e->getMessage() . '-' ?
275  $this->lng->txt($e->getMessage()) :
276  $e->getMessage());
277  }
278 
279  $table_html = $mailtable->getHTML();
280 
281  if (!$oneConfirmationDialogueRendered && !$this->confirmTrashDeletion) {
282  $this->toolbar->setFormAction($this->ctrl->getFormAction($this, 'showFolder'));
283 
284  if ($isUserRootFolder || $isUserSubFolder) {
285  $this->addSubFolderCommands($isUserSubFolder);
286  }
287  }
288 
289  if ($this->confirmTrashDeletion && $mailtable->isTrashFolder() && $mailtable->getNumberOfMails() > 0) {
290  $confirmationGui = new ilConfirmationGUI();
291  $confirmationGui->setHeaderText($this->lng->txt('mail_empty_trash_confirmation'));
292  $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
293  $confirmationGui->setFormAction($this->ctrl->getFormAction($this, 'performEmptyTrash'));
294  $this->ctrl->clearParameters($this);
295  $confirmationGui->setConfirm($this->lng->txt('confirm'), 'performEmptyTrash');
296  $confirmationGui->setCancel($this->lng->txt('cancel'), 'showFolder');
297  $this->tpl->setVariable('CONFIRMATION', $confirmationGui->getHTML());
298  }
299 
300  $this->tpl->setVariable('MAIL_TABLE', $table_html);
301  $this->tpl->printToStdout();
302  }
getMailIdsFromRequest(bool $ignoreHttpGet=false)
addSubFolderCommands(bool $isUserSubFolder=false)
parseCommand(string $originalCommand)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showUser()

ilMailFolderGUI::showUser ( )
protected
Exceptions
ilCtrlException

Definition at line 176 of file class.ilMailFolderGUI.php.

References ilObjUser\_lookupLogin(), ILIAS\Repository\ctrl(), ilUtil\getImagePath(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

176  : void
177  {
178  $userId = 0;
179  if ($this->http->wrapper()->query()->has('user')) {
180  $userId = $this->http->wrapper()->query()->retrieve('user', $this->refinery->kindlyTo()->int());
181  }
182  $this->tpl->setVariable('TBL_TITLE', implode(' ', [
183  $this->lng->txt('profile_of'),
184  ilObjUser::_lookupLogin($userId),
185  ]));
186  $this->tpl->setVariable('TBL_TITLE_IMG', ilUtil::getImagePath('standard/icon_usr.svg'));
187  $this->tpl->setVariable('TBL_TITLE_IMG_ALT', $this->lng->txt('public_profile'));
188 
189  $profile_gui = new ilPublicUserProfileGUI($userId);
190 
191  $mailId = 0;
192  if ($this->http->wrapper()->query()->has('mail_id')) {
193  $mailId = $this->http->wrapper()->query()->retrieve('mail_id', $this->refinery->kindlyTo()->int());
194  }
195 
196  $this->ctrl->setParameter(
197  $this,
198  'mail_id',
199  $mailId
200  );
201  $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
202  $profile_gui->setBackUrl($this->ctrl->getLinkTarget($this, 'showMail'));
203  $this->ctrl->clearParameters($this);
204 
205  $this->tpl->setTitle($this->lng->txt('mail'));
206  $this->tpl->setContent($this->ctrl->getHTML($profile_gui));
207  $this->tpl->printToStdout();
208  }
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
GUI class for public user profile presentation.
static http()
Fetches the global http state from ILIAS.
static _lookupLogin(int $a_user_id)
+ Here is the call graph for this function:

Field Documentation

◆ $confirmTrashDeletion

bool ilMailFolderGUI::$confirmTrashDeletion = false
private

Definition at line 34 of file class.ilMailFolderGUI.php.

◆ $ctrl

readonly ilCtrlInterface ilMailFolderGUI::$ctrl
private

Definition at line 38 of file class.ilMailFolderGUI.php.

◆ $currentFolderId

int ilMailFolderGUI::$currentFolderId = 0
private

Definition at line 47 of file class.ilMailFolderGUI.php.

Referenced by confirmDeleteMails().

◆ $error

readonly ilErrorHandling ilMailFolderGUI::$error
private

Definition at line 48 of file class.ilMailFolderGUI.php.

◆ $errorDelete

bool ilMailFolderGUI::$errorDelete = false
private

Definition at line 35 of file class.ilMailFolderGUI.php.

◆ $http

readonly GlobalHttpState ilMailFolderGUI::$http
private

Definition at line 45 of file class.ilMailFolderGUI.php.

◆ $lng

readonly ilLanguage ilMailFolderGUI::$lng
private

Definition at line 39 of file class.ilMailFolderGUI.php.

◆ $mbox

ilMailbox ilMailFolderGUI::$mbox

Definition at line 44 of file class.ilMailFolderGUI.php.

◆ $refinery

readonly Refinery ilMailFolderGUI::$refinery
private

Definition at line 46 of file class.ilMailFolderGUI.php.

◆ $tabs

readonly ilTabsGUI ilMailFolderGUI::$tabs
private

Definition at line 41 of file class.ilMailFolderGUI.php.

◆ $toolbar

readonly ilToolbarGUI ilMailFolderGUI::$toolbar
private

Definition at line 40 of file class.ilMailFolderGUI.php.

◆ $tpl

readonly ilGlobalTemplateInterface ilMailFolderGUI::$tpl
private

Definition at line 37 of file class.ilMailFolderGUI.php.

◆ $ui_factory

readonly Factory ilMailFolderGUI::$ui_factory
protected

Definition at line 49 of file class.ilMailFolderGUI.php.

◆ $ui_renderer

readonly Renderer ilMailFolderGUI::$ui_renderer
protected

Definition at line 50 of file class.ilMailFolderGUI.php.

◆ $umail

ilMail ilMailFolderGUI::$umail

Definition at line 43 of file class.ilMailFolderGUI.php.

◆ $user

readonly ilObjUser ilMailFolderGUI::$user
private

Definition at line 42 of file class.ilMailFolderGUI.php.


The documentation for this class was generated from the following file: