ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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 ()
 
 deliverFile ()
 
 deliverAttachments ()
 
 getMailFolderTable ()
 
 applyFilter ()
 
 resetFilter ()
 

Private Attributes

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

Detailed Description

Author
Jens Conze
Version
$Id$

ilMailFolderGUI: ilPublicUserProfileGUI

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

Constructor & Destructor Documentation

◆ __construct()

ilMailFolderGUI::__construct ( )

Definition at line 48 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().

49  {
50  global $DIC;
51 
52  $this->tpl = $DIC->ui()->mainTemplate();
53  $this->ctrl = $DIC->ctrl();
54  $this->lng = $DIC->language();
55  $this->toolbar = $DIC->toolbar();
56  $this->user = $DIC->user();
57  $this->tabs = $DIC->tabs();
58  $this->http = $DIC->http();
59  $this->refinery = $DIC->refinery();
60  $this->error = $DIC['ilErr'];
61 
62  $this->umail = new ilMail($this->user->getId());
63  $this->mbox = new ilMailbox($this->user->getId());
64 
65  $this->initFolder();
66  }
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 374 of file class.ilMailFolderGUI.php.

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

Referenced by performAddSubFolder().

374  : void
375  {
376  if (null === $form) {
377  $form = $this->getSubFolderForm();
378  }
379 
380  $this->tpl->setTitle($this->lng->txt('mail'));
381  $this->tpl->setContent($form->getHTML());
382  $this->tpl->printToStdout();
383  }
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 204 of file class.ilMailFolderGUI.php.

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

Referenced by showFolder().

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

◆ applyFilter()

ilMailFolderGUI::applyFilter ( )
protected

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

References getMailFolderTable(), and showFolder().

1029  : void
1030  {
1031  $table = $this->getMailFolderTable();
1032  $table->resetOffset();
1033  $table->writeFilterToSession();
1034 
1035  $this->showFolder();
1036  }
showFolder(bool $oneConfirmationDialogueRendered=false)
+ Here is the call graph for this function:

◆ confirmDeleteMails()

ilMailFolderGUI::confirmDeleteMails ( )
protected

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

References $currentFolderId, ILIAS\LTI\ToolProvider\$key, $message, ilObjUser\_lookupPref(), ILIAS\Repository\ctrl(), ilDatePresentation\formatDate(), ilUtil\getImagePath(), ilSubmitButton\getInstance(), ilLinkButton\getInstance(), 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(), and ILIAS\Repository\toolbar().

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

◆ confirmEmptyTrash()

ilMailFolderGUI::confirmEmptyTrash ( )
protected

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

References showFolder().

158  : void
159  {
160  if ($this->umail->countMailsOfFolder($this->currentFolderId)) {
161  $this->confirmTrashDeletion = true;
162  }
163 
164  $this->showFolder();
165  }
showFolder(bool $oneConfirmationDialogueRendered=false)
+ Here is the call graph for this function:

◆ deleteMails()

ilMailFolderGUI::deleteMails ( )
protected

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

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

542  : void
543  {
544  $trashFolderId = $this->mbox->getTrashFolder();
545  $mailIds = $this->getMailIdsFromRequest();
546 
547  if ($trashFolderId === $this->currentFolderId) {
548  if ($mailIds === []) {
549  $this->tpl->setOnScreenMessage('info', $this->lng->txt('mail_select_one'));
550  $this->errorDelete = true;
551  }
552  } elseif ($mailIds === []) {
553  $this->tpl->setOnScreenMessage('info', $this->lng->txt('mail_select_one'));
554  } elseif ($this->umail->moveMailsToFolder($mailIds, $trashFolderId)) {
555  $this->tpl->setOnScreenMessage('success', $this->lng->txt('mail_moved_to_trash'), true);
556  $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
557  $this->ctrl->redirect($this, 'showFolder');
558  } else {
559  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('mail_move_error'));
560  }
561 
562  $this->showFolder();
563  }
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 297 of file class.ilMailFolderGUI.php.

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

297  : void
298  {
299  if ($a_show_confirm) {
300  $confirmationGui = new ilConfirmationGUI();
301  $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
302  $confirmationGui->setFormAction($this->ctrl->getFormAction($this, 'showFolder'));
303  $this->ctrl->clearParameters($this);
304  $confirmationGui->setHeaderText($this->lng->txt('mail_sure_delete_folder'));
305  $confirmationGui->setCancel($this->lng->txt('cancel'), 'showFolder');
306  $confirmationGui->setConfirm($this->lng->txt('confirm'), 'performDeleteSubFolder');
307  $this->tpl->setVariable('CONFIRMATION', $confirmationGui->getHTML());
308 
309  $this->showFolder(true);
310  } else {
311  $this->showFolder();
312  }
313  }
showFolder(bool $oneConfirmationDialogueRendered=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ deliverAttachments()

ilMailFolderGUI::deliverAttachments ( )
protected

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

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

958  : void
959  {
960  try {
961  $mailId = 0;
962  if ($this->http->wrapper()->query()->has('mail_id')) {
963  $mailId = $this->http->wrapper()->query()->retrieve('mail_id', $this->refinery->kindlyTo()->int());
964  }
965 
966  $mailData = $this->umail->getMail((int) $mailId);
967  if (null === $mailData || 0 === count((array) $mailData['attachments'])) {
968  throw new ilException('mail_error_reading_attachment');
969  }
970 
971  $type = '';
972  if ($this->http->wrapper()->query()->has('type')) {
973  $type = $this->http->wrapper()->query()->retrieve('type', $this->refinery->kindlyTo()->string());
974  }
975 
976  $mailFileData = new ilFileDataMail($this->user->getId());
977  if (count($mailData['attachments']) === 1) {
978  $attachment = current($mailData['attachments']);
979 
980  try {
981  if ('draft' === $type) {
982  if (!$mailFileData->checkFilesExist([$attachment])) {
983  throw new OutOfBoundsException('');
984  }
985  $pathToFile = $mailFileData->getAbsoluteAttachmentPoolPathByFilename($attachment);
986  $fileName = $attachment;
987  } else {
988  $file = $mailFileData->getAttachmentPathAndFilenameByMd5Hash(
989  md5($attachment),
990  (int) $mailId
991  );
992  $pathToFile = $file['path'];
993  $fileName = $file['filename'];
994  }
995  ilFileDelivery::deliverFileLegacy($pathToFile, $fileName);
996  } catch (OutOfBoundsException $e) {
997  throw new ilException('mail_error_reading_attachment');
998  }
999  } else {
1000  $mailFileData->deliverAttachmentsAsZip(
1001  $mailData['m_subject'],
1002  (int) $mailId,
1003  $mailData['attachments'],
1004  'draft' === $type
1005  );
1006  }
1007  } catch (Exception $e) {
1008  $this->tpl->setOnScreenMessage('failure', $this->lng->txt($e->getMessage()), true);
1009  $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
1010  $this->ctrl->redirect($this);
1011  }
1012  }
$type
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 913 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().

913  : void
914  {
915  $mailId = 0;
916  if ($this->http->wrapper()->query()->has('mail_id')) {
917  $mailId = $this->http->wrapper()->query()->retrieve('mail_id', $this->refinery->kindlyTo()->int());
918  }
919 
920  if ($mailId <= 0) {
921  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
922  }
923 
924  $filename = '';
925  if ($this->http->wrapper()->post()->has('filename')) {
926  $filename = $this->http->wrapper()->post()->retrieve('filename', $this->refinery->kindlyTo()->string());
927  }
928 
929  if (is_string(ilSession::get('filename')) && ilSession::get('filename') !== '') {
930  $filename = ilSession::get('filename');
931  ilSession::set('filename', null);
932  }
933 
934  try {
935  if ($mailId > 0 && $filename !== '') {
936  while (strpos($filename, '..') !== false) {
937  $filename = str_replace('..', '', $filename);
938  }
939 
940  $mailFileData = new ilFileDataMail($this->user->getId());
941  try {
942  $file = $mailFileData->getAttachmentPathAndFilenameByMd5Hash($filename, (int) $mailId);
943  ilFileDelivery::deliverFileLegacy($file['path'], $file['filename']);
944  } catch (OutOfBoundsException $e) {
945  throw new ilException('mail_error_reading_attachment');
946  }
947  } else {
948  $this->tpl->setOnScreenMessage('info', $this->lng->txt('mail_select_attachment'));
949  $this->showMail();
950  }
951  } catch (Exception $e) {
952  $this->tpl->setOnScreenMessage('failure', $this->lng->txt($e->getMessage()), true);
953  $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
954  $this->ctrl->redirect($this);
955  }
956  }
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 109 of file class.ilMailFolderGUI.php.

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

109  : void
110  {
111  $cmd = $this->parseCommand(
112  $this->ctrl->getCmd()
113  );
114 
115  $nextClass = $this->ctrl->getNextClass($this);
116  switch (strtolower($nextClass)) {
117  case strtolower(ilContactGUI::class):
118  $this->ctrl->forwardCommand(new ilContactGUI());
119  break;
120 
121  case strtolower(ilPublicUserProfileGUI::class):
122  $this->tpl->setTitle($this->lng->txt('mail'));
123  $userId = 0;
124  if ($this->http->wrapper()->query()->has('user')) {
125  $userId = $this->http->wrapper()->query()->retrieve('user', $this->refinery->kindlyTo()->int());
126  }
127  $profileGui = new ilPublicUserProfileGUI($userId);
128 
129  $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
130  $profileGui->setBackUrl($this->ctrl->getLinkTarget($this, 'showMail'));
131  $this->ctrl->clearParameters($this);
132 
133  $ret = $this->ctrl->forwardCommand($profileGui);
134  if ($ret !== '') {
135  $this->tpl->setContent($ret);
136  }
137  $this->tpl->printToStdout();
138  break;
139 
140  default:
141  if (!method_exists($this, $cmd)) {
142  $cmd = 'showFolder';
143  }
144  $this->{$cmd}();
145  break;
146  }
147  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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 1014 of file class.ilMailFolderGUI.php.

References ilMailFolderTableGUI\initFilter().

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

1015  {
1016  $table = new ilMailFolderTableGUI(
1017  $this,
1018  $this->currentFolderId,
1019  'showFolder',
1020  $this->currentFolderId === $this->mbox->getTrashFolder(),
1021  $this->currentFolderId === $this->mbox->getSentFolder(),
1022  $this->currentFolderId === $this->mbox->getDraftsFolder()
1023  );
1024  $table->initFilter();
1025 
1026  return $table;
1027  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMailIdsFromRequest()

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

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

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

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

434  : array
435  {
436  $mailIds = [];
437  if ($this->http->wrapper()->post()->has('mail_id')) {
438  $mailIds = $this->http->wrapper()->post()->retrieve(
439  'mail_id',
440  $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
441  );
442  }
443 
444  if ($mailIds === [] && !$ignoreHttpGet) {
445  $mailId = 0;
446  if ($this->http->wrapper()->query()->has('mail_id')) {
447  $mailId = $this->http->wrapper()->query()->retrieve('mail_id', $this->refinery->kindlyTo()->int());
448  }
449  if (is_numeric($mailId)) {
450  $mailIds = [$mailId];
451  }
452  }
453 
454  return array_filter(array_map('intval', $mailIds));
455  }
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 331 of file class.ilMailFolderGUI.php.

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

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

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

◆ initFolder()

ilMailFolderGUI::initFolder ( )
protected

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

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

Referenced by __construct().

68  : void
69  {
70  if ($this->http->wrapper()->post()->has('mobj_id')) {
71  $folderId = $this->http->wrapper()->post()->retrieve('mobj_id', $this->refinery->kindlyTo()->int());
72  } elseif ($this->http->wrapper()->query()->has('mobj_id')) {
73  $folderId = $this->http->wrapper()->query()->retrieve('mobj_id', $this->refinery->kindlyTo()->int());
74  } else {
75  $folderId = $this->refinery->byTrying([
76  $this->refinery->kindlyTo()->int(),
77  $this->refinery->always($this->currentFolderId),
78  ])->transform(ilSession::get('mobj_id'));
79  }
80 
81  if (0 === $folderId || !$this->mbox->isOwnedFolder($folderId)) {
82  $folderId = $this->mbox->getInboxFolder();
83  }
84 
85  $this->currentFolderId = $folderId;
86  }
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 457 of file class.ilMailFolderGUI.php.

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

457  : void
458  {
459  $mailIds = $this->getMailIdsFromRequest();
460  if ($mailIds !== []) {
461  $this->umail->markRead($mailIds);
462  $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'));
463  } else {
464  $this->tpl->setOnScreenMessage('info', $this->lng->txt('mail_select_one'));
465  }
466 
467  $this->showFolder();
468  }
getMailIdsFromRequest(bool $ignoreHttpGet=false)
showFolder(bool $oneConfirmationDialogueRendered=false)
+ Here is the call graph for this function:

◆ markMailsUnread()

ilMailFolderGUI::markMailsUnread ( )
protected

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

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

470  : void
471  {
472  $mailIds = $this->getMailIdsFromRequest();
473  if ($mailIds !== []) {
474  $this->umail->markUnread($mailIds);
475  $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'));
476  } else {
477  $this->tpl->setOnScreenMessage('info', $this->lng->txt('mail_select_one'));
478  }
479 
480  $this->showFolder();
481  }
getMailIdsFromRequest(bool $ignoreHttpGet=false)
showFolder(bool $oneConfirmationDialogueRendered=false)
+ Here is the call graph for this function:

◆ moveMails()

ilMailFolderGUI::moveMails ( )
protected

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

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

522  : void
523  {
524  $mailIds = $this->getMailIdsFromRequest();
525  if ($mailIds === []) {
526  $this->showFolder();
527  $this->tpl->setOnScreenMessage('info', $this->lng->txt('mail_select_one'));
528  return;
529  }
530 
531  $folderId = $this->parseFolderIdFromCommand($this->ctrl->getCmd());
532  if ($this->umail->moveMailsToFolder($mailIds, $folderId)) {
533  $this->tpl->setOnScreenMessage('success', $this->lng->txt('mail_moved'), true);
534  $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
535  $this->ctrl->redirect($this, 'showFolder');
536  } else {
537  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('mail_move_error'));
538  $this->showFolder();
539  }
540  }
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 483 of file class.ilMailFolderGUI.php.

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

483  : void
484  {
485  $mailIds = $this->getMailIdsFromRequest();
486  if (1 !== count($mailIds)) {
487  $this->showMail();
488  $this->tpl->setOnScreenMessage('info', $this->lng->txt('mail_select_one'));
489  return;
490  }
491 
492  $newFolderId = 0;
493  if ($this->http->wrapper()->post()->has('folder_id')) {
494  $newFolderId = $this->http->wrapper()->post()->retrieve(
495  'folder_id',
496  $this->refinery->kindlyTo()->int()
497  );
498  }
499  $redirectFolderId = $newFolderId;
500 
501  foreach ($mailIds as $mailId) {
502  $mailData = $this->umail->getMail($mailId);
503  if (isset($mailData['folder_id']) &&
504  is_numeric($mailData['folder_id']) &&
505  (int) $mailData['folder_id'] > 0
506  ) {
507  $redirectFolderId = (int) $mailData['folder_id'];
508  break;
509  }
510  }
511 
512  if ($this->umail->moveMailsToFolder($mailIds, $newFolderId)) {
513  $this->tpl->setOnScreenMessage('success', $this->lng->txt('mail_moved'), true);
514  $this->ctrl->setParameter($this, 'mobj_id', $redirectFolderId);
515  $this->ctrl->redirect($this, 'showFolder');
516  } else {
517  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('mail_move_error'));
518  $this->showMail();
519  }
520  }
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 88 of file class.ilMailFolderGUI.php.

Referenced by executeCommand(), and showFolder().

88  : string
89  {
90  if (preg_match('/^([a-zA-Z0-9]+?)_(\d+?)$/', $originalCommand, $matches) && 3 === count($matches)) {
91  $originalCommand = $matches[1];
92  }
93 
94  return $originalCommand;
95  }
+ Here is the caller graph for this function:

◆ parseFolderIdFromCommand()

ilMailFolderGUI::parseFolderIdFromCommand ( string  $command)
protected

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

Referenced by moveMails().

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

◆ performAddSubFolder()

ilMailFolderGUI::performAddSubFolder ( )
protected

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

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

353  : void
354  {
355  $form = $this->getSubFolderForm();
356  $isFormValid = $form->checkInput();
357  $form->setValuesByPost();
358  if (!$isFormValid) {
359  $this->addSubFolder($form);
360  return;
361  }
362 
363  $newFolderId = $this->mbox->addFolder($this->currentFolderId, $form->getInput('subfolder_title'));
364  if ($newFolderId > 0) {
365  $this->tpl->setOnScreenMessage('success', $this->lng->txt('mail_folder_created'), true);
366  $this->ctrl->setParameterByClass(ilMailGUI::class, 'mobj_id', $newFolderId);
367  $this->ctrl->redirectByClass(ilMailGUI::class);
368  }
369 
370  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('mail_folder_exists'));
371  $this->addSubFolder($form);
372  }
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 318 of file class.ilMailFolderGUI.php.

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

318  : void
319  {
320  $parentFolderId = $this->mbox->getParentFolderId($this->currentFolderId);
321  if ($parentFolderId > 0 && $this->mbox->deleteFolder($this->currentFolderId)) {
322  $this->tpl->setOnScreenMessage('info', $this->lng->txt('mail_folder_deleted'), true);
323  $this->ctrl->setParameterByClass(ilMailGUI::class, 'mobj_id', $parentFolderId);
324  $this->ctrl->redirectByClass(ilMailGUI::class);
325  } else {
326  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('mail_error_delete'));
327  $this->showFolder();
328  }
329  }
showFolder(bool $oneConfirmationDialogueRendered=false)
+ Here is the call graph for this function:

◆ performEmptyTrash()

ilMailFolderGUI::performEmptyTrash ( )
protected

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

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

149  : void
150  {
151  $this->umail->deleteMailsOfFolder($this->currentFolderId);
152 
153  $this->tpl->setOnScreenMessage('success', $this->lng->txt('mail_deleted'), true);
154  $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
155  $this->ctrl->redirect($this, 'showFolder');
156  }
+ Here is the call graph for this function:

◆ performRenameSubFolder()

ilMailFolderGUI::performRenameSubFolder ( )
protected

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

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

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

◆ renameSubFolder()

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

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

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

Referenced by performRenameSubFolder().

417  : void
418  {
419  if (null === $form) {
420  $form = $this->getSubFolderForm('edit');
421  $form->setValuesByArray(
422  ['subfolder_title' => $this->mbox->getFolderData($this->currentFolderId)['title'] ?? '']
423  );
424  }
425 
426  $this->tpl->setTitle($this->lng->txt('mail'));
427  $this->tpl->setContent($form->getHTML());
428  $this->tpl->printToStdout();
429  }
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 1038 of file class.ilMailFolderGUI.php.

References getMailFolderTable(), and showFolder().

1038  : void
1039  {
1040  $table = $this->getMailFolderTable();
1041  $table->resetOffset();
1042  $table->resetFilter();
1043 
1044  $this->showFolder();
1045  }
showFolder(bool $oneConfirmationDialogueRendered=false)
+ Here is the call graph for this function:

◆ showFolder()

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

Definition at line 225 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().

225  : void
226  {
227  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.mail.html', 'Services/Mail');
228  $this->tpl->setTitle($this->lng->txt('mail'));
229 
230  $isTrashFolder = $this->currentFolderId === $this->mbox->getTrashFolder();
231 
232  if (!$this->errorDelete && $isTrashFolder && 'deleteMails' === $this->parseCommand($this->ctrl->getCmd())) {
233  $confirmationGui = new ilConfirmationGUI();
234  $confirmationGui->setHeaderText($this->lng->txt('mail_sure_delete'));
235  foreach ($this->getMailIdsFromRequest() as $mailId) {
236  $confirmationGui->addHiddenItem('mail_id[]', (string) $mailId);
237  }
238  $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
239  $confirmationGui->setFormAction($this->ctrl->getFormAction($this, 'showFolder'));
240  $this->ctrl->clearParameters($this);
241  $confirmationGui->setConfirm($this->lng->txt('confirm'), 'confirmDeleteMails');
242  $confirmationGui->setCancel($this->lng->txt('cancel'), 'showFolder');
243  $this->tpl->setVariable('CONFIRMATION', $confirmationGui->getHTML());
244  $oneConfirmationDialogueRendered = true;
245  }
246 
247  $folders = $this->mbox->getSubFolders();
248  $mtree = new ilTree($this->user->getId());
249  $mtree->setTableNames('mail_tree', 'mail_obj_data');
250 
251  $isUserSubFolder = false;
252  $isUserRootFolder = false;
253 
254  $folder_d = $mtree->getNodeData($this->currentFolderId);
255  if ($folder_d['m_type'] === 'user_folder') {
256  $isUserSubFolder = true;
257  } elseif ($folder_d['m_type'] === 'local') {
258  $isUserRootFolder = true;
259  }
260 
261  $mailtable = $this->getMailFolderTable();
262  $mailtable->setSelectedItems($this->getMailIdsFromRequest(true));
263 
264  try {
265  $mailtable->prepareHTML();
266  } catch (Exception $e) {
267  $this->tpl->setOnScreenMessage('failure', $this->lng->txt($e->getMessage()) !== '-' . $e->getMessage() . '-' ?
268  $this->lng->txt($e->getMessage()) :
269  $e->getMessage());
270  }
271 
272  $table_html = $mailtable->getHTML();
273 
274  if ($oneConfirmationDialogueRendered === false && $this->confirmTrashDeletion === false) {
275  $this->toolbar->setFormAction($this->ctrl->getFormAction($this, 'showFolder'));
276 
277  if ($isUserRootFolder || $isUserSubFolder) {
278  $this->addSubFolderCommands($isUserSubFolder);
279  }
280  }
281 
282  if ($this->confirmTrashDeletion && $mailtable->isTrashFolder() && $mailtable->getNumberOfMails() > 0) {
283  $confirmationGui = new ilConfirmationGUI();
284  $confirmationGui->setHeaderText($this->lng->txt('mail_empty_trash_confirmation'));
285  $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
286  $confirmationGui->setFormAction($this->ctrl->getFormAction($this, 'performEmptyTrash'));
287  $this->ctrl->clearParameters($this);
288  $confirmationGui->setConfirm($this->lng->txt('confirm'), 'performEmptyTrash');
289  $confirmationGui->setCancel($this->lng->txt('cancel'), 'showFolder');
290  $this->tpl->setVariable('CONFIRMATION', $confirmationGui->getHTML());
291  }
292 
293  $this->tpl->setVariable('MAIL_TABLE', $table_html);
294  $this->tpl->printToStdout();
295  }
getMailIdsFromRequest(bool $ignoreHttpGet=false)
addSubFolderCommands(bool $isUserSubFolder=false)
parseCommand(string $originalCommand)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ 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 170 of file class.ilMailFolderGUI.php.

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

170  : void
171  {
172  $userId = 0;
173  if ($this->http->wrapper()->query()->has('user')) {
174  $userId = $this->http->wrapper()->query()->retrieve('user', $this->refinery->kindlyTo()->int());
175  }
176  $this->tpl->setVariable('TBL_TITLE', implode(' ', [
177  $this->lng->txt('profile_of'),
178  ilObjUser::_lookupLogin($userId),
179  ]));
180  $this->tpl->setVariable('TBL_TITLE_IMG', ilUtil::getImagePath('icon_usr.svg'));
181  $this->tpl->setVariable('TBL_TITLE_IMG_ALT', $this->lng->txt('public_profile'));
182 
183  $profile_gui = new ilPublicUserProfileGUI($userId);
184 
185  $mailId = 0;
186  if ($this->http->wrapper()->query()->has('mail_id')) {
187  $mailId = $this->http->wrapper()->query()->retrieve('mail_id', $this->refinery->kindlyTo()->int());
188  }
189 
190  $this->ctrl->setParameter(
191  $this,
192  'mail_id',
193  $mailId
194  );
195  $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
196  $profile_gui->setBackUrl($this->ctrl->getLinkTarget($this, 'showMail'));
197  $this->ctrl->clearParameters($this);
198 
199  $this->tpl->setTitle($this->lng->txt('mail'));
200  $this->tpl->setContent($this->ctrl->getHTML($profile_gui));
201  $this->tpl->printToStdout();
202  }
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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 32 of file class.ilMailFolderGUI.php.

◆ $ctrl

ilCtrlInterface ilMailFolderGUI::$ctrl
private

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

◆ $currentFolderId

int ilMailFolderGUI::$currentFolderId = 0
private

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

Referenced by confirmDeleteMails().

◆ $error

ilErrorHandling ilMailFolderGUI::$error
private

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

◆ $errorDelete

bool ilMailFolderGUI::$errorDelete = false
private

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

◆ $http

GlobalHttpState ilMailFolderGUI::$http
private

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

◆ $lng

ilLanguage ilMailFolderGUI::$lng
private

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

◆ $mbox

ilMailbox ilMailFolderGUI::$mbox

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

◆ $refinery

Refinery ilMailFolderGUI::$refinery
private

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

◆ $tabs

ilTabsGUI ilMailFolderGUI::$tabs
private

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

◆ $toolbar

ilToolbarGUI ilMailFolderGUI::$toolbar
private

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

◆ $tpl

ilGlobalTemplateInterface ilMailFolderGUI::$tpl
private

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

◆ $umail

ilMail ilMailFolderGUI::$umail

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

◆ $user

ilObjUser ilMailFolderGUI::$user
private

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


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