ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilMailFolderGUI Class Reference
+ Collaboration diagram for ilMailFolderGUI:

Public Member Functions

 __construct ()
 ilMailFolderGUI constructor. More...
 
 executeCommand ()
 

Data Fields

 $umail
 
 $mbox
 

Protected Member Functions

 initFolder ()
 
 parseCommand (string $originalCommand)
 
 parseFolderIdFromCommand (string $command)
 
 performEmptyTrash ()
 Called if the deletion of all messages in trash was confirmed by the acting user. More...
 
 confirmEmptyTrash ()
 Called if the deletion of messages in trash should be confirmed by the acting user. More...
 
 showUser ()
 
 addSubFolderCommands (bool $isUserSubFolder=false)
 
 showFolder (bool $oneConfirmationDialogueRendered=false)
 Shows current folder. More...
 
 deleteSubFolder ($a_show_confirm=true)
 
 performDeleteSubFolder ()
 
 getSubFolderForm (string $mode='create')
 
 performAddSubFolder ()
 Called if a folder is created by the action user. More...
 
 addSubFolder (ilPropertyFormGUI $form=null)
 Called if the acting user wants to create a folder. More...
 
 performRenameSubFolder ()
 Called if the folder title is renamed by the acting user. More...
 
 renameSubFolder (ilPropertyFormGUI $form=null)
 Called if the acting user wants to rename a folder. More...
 
 getMailIdsFromRequest (bool $ignoreHttpGet=false)
 
 markMailsRead ()
 Called if multiple messages should be marked as read in the list view. More...
 
 markMailsUnread ()
 Called if multiple messages should be marked as un-read in the list view. More...
 
 moveSingleMail ()
 Called if a single message should be be moved in the detail view. More...
 
 moveMails ()
 Called if a single message or multiple messages should be be moved in the list view. More...
 
 deleteMails ()
 Called if a single message or multiple messages should be deleted. More...
 
 confirmDeleteMails ()
 Called if the final deletion of selected messages was confirmed by the acting user. More...
 
 deliverFile ()
 
 deliverAttachments ()
 
 getMailFolderTable ()
 
 applyFilter ()
 
 resetFilter ()
 

Private Attributes

 $confirmTrashDeletion = false
 
 $errorDelete = false
 
 $tpl
 
 $ctrl
 
 $lng
 
 $toolbar
 
 $tabs
 
 $user
 
 $httpRequest
 
 $currentFolderId = 0
 

Detailed Description

Author
Jens Conze
Version
$Id$

@ilCtrl_Calls ilMailFolderGUI: ilMailOptionsGUI, ilMailAttachmentGUI, ilMailSearchGUI @ilCtrl_Calls ilMailFolderGUI: ilPublicUserProfileGUI

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

Constructor & Destructor Documentation

◆ __construct()

ilMailFolderGUI::__construct ( )

ilMailFolderGUI constructor.

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

56 {
57 global $DIC;
58
59 $this->tpl = $DIC->ui()->mainTemplate();
60 $this->ctrl = $DIC->ctrl();
61 $this->lng = $DIC->language();
62 $this->toolbar = $DIC->toolbar();
63 $this->user = $DIC->user();
64 $this->tabs = $DIC->tabs();
65 $this->httpRequest = $DIC->http()->request();
66
67 $this->umail = new ilMail($this->user->getId());
68 $this->mbox = new ilMailbox($this->user->getId());
69
70 $this->initFolder();
71 }
user()
Definition: user.php:4
Mail Box class Base class for creating and handling mail boxes.
$DIC
Definition: xapitoken.php:46

References $DIC, initFolder(), and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ addSubFolder()

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

Called if the acting user wants to create a folder.

Parameters
ilPropertyFormGUI | null$form

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

435 : void
436 {
437 if (null === $form) {
438 $form = $this->getSubFolderForm();
439 }
440
441 $this->tpl->setTitle($this->lng->txt('mail'));
442 $this->tpl->setContent($form->getHTML());
443 $this->tpl->printToStdout();
444 }
getSubFolderForm(string $mode='create')

References getSubFolderForm().

Referenced by performAddSubFolder().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addSubFolderCommands()

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

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

217 : void
218 {
219 $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
220 $this->toolbar->addButton(
221 $this->lng->txt('mail_add_subfolder'),
222 $this->ctrl->getLinkTarget($this, 'addSubFolder')
223 );
224
225 if ($isUserSubFolder) {
226 $this->toolbar->addButton($this->lng->txt('rename'), $this->ctrl->getLinkTarget($this, 'renameSubFolder'));
227 $this->toolbar->addButton($this->lng->txt('delete'), $this->ctrl->getLinkTarget($this, 'deleteSubFolder'));
228 }
229 $this->ctrl->clearParameters($this);
230 }

Referenced by showFolder().

+ Here is the caller graph for this function:

◆ applyFilter()

ilMailFolderGUI::applyFilter ( )
protected

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

1065 : void
1066 {
1067 $table = $this->getMailFolderTable();
1068 $table->resetOffset();
1069 $table->writeFilterToSession();
1070
1071 $this->showFolder();
1072 }
showFolder(bool $oneConfirmationDialogueRendered=false)
Shows current folder.

References getMailFolderTable(), and showFolder().

+ Here is the call graph for this function:

◆ confirmDeleteMails()

ilMailFolderGUI::confirmDeleteMails ( )
protected

Called if the final deletion of selected messages was confirmed by the acting user.

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

630 : void
631 {
632 $mailIds = $this->getMailIdsFromRequest();
633 if (0 === count($mailIds)) {
634 $this->showFolder();
635 ilUtil::sendInfo($this->lng->txt('mail_select_one'));
636 return;
637 }
638
639 if ((int) $this->mbox->getTrashFolder() === (int) $this->currentFolderId) {
640 $this->umail->deleteMails($mailIds);
641 ilUtil::sendSuccess($this->lng->txt('mail_deleted'), true);
642 $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
643 $this->ctrl->redirect($this, 'showFolder');
644 }
645
646 $this->showFolder();
647 }
getMailIdsFromRequest(bool $ignoreHttpGet=false)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.

References getMailIdsFromRequest(), ilUtil\sendInfo(), and showFolder().

+ Here is the call graph for this function:

◆ confirmEmptyTrash()

ilMailFolderGUI::confirmEmptyTrash ( )
protected

Called if the deletion of messages in trash should be confirmed by the acting user.

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

181 : void
182 {
183 if ($this->umail->countMailsOfFolder($this->currentFolderId)) {
184 $this->confirmTrashDeletion = true;
185 }
186
187 $this->showFolder();
188 }

References showFolder().

+ Here is the call graph for this function:

◆ deleteMails()

ilMailFolderGUI::deleteMails ( )
protected

Called if a single message or multiple messages should be deleted.

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

602 : void
603 {
604 $trashFolderId = (int) $this->mbox->getTrashFolder();
605 $mailIds = $this->getMailIdsFromRequest();
606
607 if ($trashFolderId == $this->currentFolderId) {
608 if (0 === count($mailIds)) {
609 ilUtil::sendInfo($this->lng->txt('mail_select_one'));
610 $this->errorDelete = true;
611 }
612 } else {
613 if (0 === count($mailIds)) {
614 ilUtil::sendInfo($this->lng->txt('mail_select_one'));
615 } elseif ($this->umail->moveMailsToFolder($mailIds, $trashFolderId)) {
616 ilUtil::sendSuccess($this->lng->txt('mail_moved_to_trash'), true);
617 $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
618 $this->ctrl->redirect($this, 'showFolder');
619 } else {
620 ilUtil::sendFailure($this->lng->txt('mail_move_error'));
621 }
622 }
623
624 $this->showFolder();
625 }
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.

References getMailIdsFromRequest(), ilUtil\sendFailure(), ilUtil\sendInfo(), and showFolder().

+ Here is the call graph for this function:

◆ deleteSubFolder()

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

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

347 : void
348 {
349 if ($a_show_confirm) {
350 $confirmationGui = new ilConfirmationGUI();
351 $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
352 $confirmationGui->setFormAction($this->ctrl->getFormAction($this, 'showFolder'));
353 $this->ctrl->clearParameters($this);
354 $confirmationGui->setHeaderText($this->lng->txt('mail_sure_delete_folder'));
355 $confirmationGui->setCancel($this->lng->txt('cancel'), 'showFolder');
356 $confirmationGui->setConfirm($this->lng->txt('confirm'), 'performDeleteSubFolder');
357 $this->tpl->setVariable('CONFIRMATION', $confirmationGui->getHTML());
358
359 $this->showFolder(true);
360 } else {
361 $this->showFolder(false);
362 }
363 }
Confirmation screen class.

References showFolder().

+ Here is the call graph for this function:

◆ deliverAttachments()

ilMailFolderGUI::deliverAttachments ( )
protected

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

994 : void
995 {
996 try {
997 $mailId = $this->httpRequest->getQueryParams()['mail_id'] ?? 0;
998
999 $mailData = $this->umail->getMail((int) $mailId);
1000 if (null === $mailData || 0 === count((array) $mailData['attachments'])) {
1001 throw new ilException('mail_error_reading_attachment');
1002 }
1003
1004 $type = $this->httpRequest->getQueryParams()['type'] ?? '';
1005
1006 $mailFileData = new ilFileDataMail($this->user->getId());
1007 if (count($mailData['attachments']) === 1) {
1008 $attachment = current($mailData['attachments']);
1009
1010 try {
1011 if ('draft' === $type) {
1012 if (!$mailFileData->checkFilesExist([$attachment])) {
1013 throw new OutOfBoundsException('');
1014 }
1015 $pathToFile = $mailFileData->getAbsoluteAttachmentPoolPathByFilename($attachment);
1016 $fileName = $attachment;
1017 } else {
1018 $file = $mailFileData->getAttachmentPathAndFilenameByMd5Hash(
1019 md5($attachment),
1020 (int) $mailId
1021 );
1022 $pathToFile = $file['path'];
1023 $fileName = $file['filename'];
1024 }
1025 ilUtil::deliverFile($pathToFile, $fileName);
1026 } catch (OutOfBoundsException $e) {
1027 throw new ilException('mail_error_reading_attachment');
1028 }
1029 } else {
1030 $mailFileData->deliverAttachmentsAsZip(
1031 $mailData['m_subject'],
1032 (int) $mailId,
1033 $mailData['attachments'],
1034 'draft' === $type
1035 );
1036 }
1037 } catch (Exception $e) {
1038 ilUtil::sendFailure($this->lng->txt($e->getMessage()), true);
1039 $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
1040 $this->ctrl->redirect($this);
1041 }
1042 }
Base class for ILIAS Exception handling.
Class ilFileDataMail.
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
$type

References Vendor\Package\$e, $type, ilUtil\deliverFile(), ilUtil\sendFailure(), and user().

+ Here is the call graph for this function:

◆ deliverFile()

ilMailFolderGUI::deliverFile ( )
protected

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

956 : void
957 {
958 $mailId = $this->httpRequest->getQueryParams()['mail_id'] ?? 0;
959 if ((int) ilSession::get('mail_id') > 0) {
960 $mailId = ilSession::get('mail_id');
961 ilSession::set('mail_id', null);
962 }
963
964 $filename = $this->httpRequest->getParsedBody()['filename'] ?? '';
965 if (is_string(ilSession::get('filename')) && strlen(ilSession::get('filename')) > 0) {
966 $filename = ilSession::get('filename');
967 ilSession::set('filename', null);
968 }
969
970 try {
971 if ($mailId > 0 && $filename !== '') {
972 while (strpos($filename, '..') !== false) {
973 $filename = str_replace('..', '', $filename);
974 }
975
976 $mailFileData = new ilFileDataMail($this->user->getId());
977 try {
978 $file = $mailFileData->getAttachmentPathAndFilenameByMd5Hash($filename, (int) $mailId);
979 ilUtil::deliverFile($file['path'], $file['filename']);
980 } catch (OutOfBoundsException $e) {
981 throw new ilException('mail_error_reading_attachment');
982 }
983 } else {
984 ilUtil::sendInfo($this->lng->txt('mail_select_attachment'));
985 $this->showMail();
986 }
987 } catch (Exception $e) {
988 ilUtil::sendFailure($this->lng->txt($e->getMessage()), true);
989 $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
990 $this->ctrl->redirect($this);
991 }
992 }
$filename
Definition: buildRTE.php:89
static set($a_var, $a_val)
Set a value.
static get($a_var)
Get a value.

References Vendor\Package\$e, $filename, ilUtil\deliverFile(), ilSession\get(), ilUtil\sendFailure(), ilUtil\sendInfo(), ilSession\set(), and user().

+ Here is the call graph for this function:

◆ executeCommand()

ilMailFolderGUI::executeCommand ( )

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

125 : void
126 {
127 $cmd = $this->parseCommand(
128 $this->ctrl->getCmd()
129 );
130
131 $nextClass = $this->ctrl->getNextClass($this);
132 switch ($nextClass) {
133 case 'ilcontactgui':
134 $this->ctrl->forwardCommand(new ilContactGUI());
135 break;
136
137 case 'ilmailoptionsgui':
138 $this->tpl->setTitle($this->lng->txt('mail'));
139 $this->ctrl->forwardCommand(new ilMailOptionsGUI());
140 break;
141
142 case 'ilpublicuserprofilegui':
143 $this->tpl->setTitle($this->lng->txt('mail'));
144 $profileGui = new ilPublicUserProfileGUI((int) ($this->httpRequest->getQueryParams()['user'] ?? 0));
145
146 $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
147 $profileGui->setBackUrl($this->ctrl->getLinkTarget($this, 'showMail'));
148 $this->ctrl->clearParameters($this);
149
150 $ret = $this->ctrl->forwardCommand($profileGui);
151 if ($ret != '') {
152 $this->tpl->setContent($ret);
153 }
154 $this->tpl->printToStdout();
155 break;
156
157 default:
158 if (!method_exists($this, $cmd)) {
159 $cmd = 'showFolder';
160 }
161 $this->{$cmd}();
162 break;
163 }
164 }
parseCommand(string $originalCommand)
GUI class for public user profile presentation.
$ret
Definition: parser.php:6

References $ret, and parseCommand().

+ Here is the call graph for this function:

◆ getMailFolderTable()

ilMailFolderGUI::getMailFolderTable ( )
protected
Returns
ilMailFolderTableGUI

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

1048 {
1049 $table = new ilMailFolderTableGUI(
1050 $this,
1051 $this->currentFolderId,
1052 'showFolder',
1053 $this->currentFolderId == $this->mbox->getTrashFolder(),
1054 $this->currentFolderId == $this->mbox->getSentFolder(),
1055 $this->currentFolderId == $this->mbox->getDraftsFolder()
1056 );
1057 $table->initFilter();
1058
1059 return $table;
1060 }

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

+ Here is the caller graph for this function:

◆ getMailIdsFromRequest()

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

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

495 : array
496 {
497 $mailIds = $this->httpRequest->getParsedBody()['mail_id'] ?? [];
498 if (!is_array($mailIds)) {
499 return [];
500 }
501
502 if (0 === count($mailIds) && !$ignoreHttpGet) {
503 $mailId = $this->httpRequest->getQueryParams()['mail_id'] ?? 0;
504 if (is_numeric($mailId)) {
505 $mailIds = [$mailId];
506 }
507 }
508
509 return array_filter(array_map('intval', $mailIds));
510 }

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

+ Here is the caller graph for this function:

◆ getSubFolderForm()

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

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

386 {
387 $form = new ilPropertyFormGUI();
388 $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
389 $form->setFormAction($this->ctrl->getFormAction($this, 'performAddSubFolder'));
390 $this->ctrl->clearParameters($this);
391 if ('edit' === $mode) {
392 $form->addCommandButton('performRenameSubFolder', $this->lng->txt('save'));
393 $form->setTitle($this->lng->txt('mail_rename_folder'));
394 } else {
395 $form->addCommandButton('performAddSubFolder', $this->lng->txt('save'));
396 $form->setTitle($this->lng->txt('mail_add_folder'));
397 }
398 $form->addCommandButton('showFolder', $this->lng->txt('cancel'));
399
400 $title = new ilTextInputGUI($this->lng->txt('title'), 'subfolder_title');
401 $title->setRequired(true);
402 $form->addItem($title);
403
404 return $form;
405 }
This class represents a property form user interface.
This class represents a text property in a property form.

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

+ Here is the caller graph for this function:

◆ initFolder()

ilMailFolderGUI::initFolder ( )
protected

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

76 : void
77 {
78 $folderId = (int) ($this->httpRequest->getParsedBody()['mobj_id'] ?? 0);
79 if (0 === $folderId) {
80 $folderId = (int) ($this->httpRequest->getQueryParams()['mobj_id'] ?? 0);
81 }
82
83 if (0 === $folderId || !$this->mbox->isOwnedFolder($folderId)) {
84 $folderId = $this->mbox->getInboxFolder();
85 }
86
87 $this->currentFolderId = (int) $folderId;
88 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ markMailsRead()

ilMailFolderGUI::markMailsRead ( )
protected

Called if multiple messages should be marked as read in the list view.

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

515 : void
516 {
517 $mailIds = $this->getMailIdsFromRequest();
518 if (count($mailIds) > 0) {
519 $this->umail->markRead($mailIds);
520 ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
521 } else {
522 ilUtil::sendInfo($this->lng->txt('mail_select_one'));
523 }
524
525 $this->showFolder();
526 }

References getMailIdsFromRequest(), ilUtil\sendInfo(), and showFolder().

+ Here is the call graph for this function:

◆ markMailsUnread()

ilMailFolderGUI::markMailsUnread ( )
protected

Called if multiple messages should be marked as un-read in the list view.

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

531 : void
532 {
533 $mailIds = $this->getMailIdsFromRequest();
534 if (count($mailIds) > 0) {
535 $this->umail->markUnread($mailIds);
536 ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
537 } else {
538 ilUtil::sendInfo($this->lng->txt('mail_select_one'));
539 }
540
541 $this->showFolder();
542 }

References getMailIdsFromRequest(), ilUtil\sendInfo(), and showFolder().

+ Here is the call graph for this function:

◆ moveMails()

ilMailFolderGUI::moveMails ( )
protected

Called if a single message or multiple messages should be be moved in the list view.

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

579 : void
580 {
581 $mailIds = $this->getMailIdsFromRequest();
582 if (0 === count($mailIds)) {
583 $this->showFolder();
584 ilUtil::sendInfo($this->lng->txt('mail_select_one'));
585 return;
586 }
587
588 $folderId = $this->parseFolderIdFromCommand($this->ctrl->getCmd());
589 if ($this->umail->moveMailsToFolder($mailIds, $folderId)) {
590 ilUtil::sendSuccess($this->lng->txt('mail_moved'), true);
591 $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
592 $this->ctrl->redirect($this, 'showFolder');
593 } else {
594 ilUtil::sendFailure($this->lng->txt('mail_move_error'));
595 $this->showFolder();
596 }
597 }
parseFolderIdFromCommand(string $command)

References getMailIdsFromRequest(), parseFolderIdFromCommand(), ilUtil\sendFailure(), ilUtil\sendInfo(), and showFolder().

+ Here is the call graph for this function:

◆ moveSingleMail()

ilMailFolderGUI::moveSingleMail ( )
protected

Called if a single message should be be moved in the detail view.

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

547 : void
548 {
549 $mailIds = $this->getMailIdsFromRequest();
550 if (1 !== count($mailIds)) {
551 $this->showMail();
552 ilUtil::sendInfo($this->lng->txt('mail_select_one'));
553 return;
554 }
555
556 $newFolderId = (int) ($this->httpRequest->getParsedBody()['folder_id'] ?? 0);
557 $redirectFolderId = $newFolderId;
558 foreach ($mailIds as $mailId) {
559 $mailData = $this->umail->getMail($mailId);
560 if (isset($mailData['folder_id']) && is_numeric($mailData['folder_id']) && (int) $mailData['folder_id'] > 0) {
561 $redirectFolderId = $mailData['folder_id'];
562 break;
563 }
564 }
565
566 if ($this->umail->moveMailsToFolder($mailIds, $newFolderId)) {
567 ilUtil::sendSuccess($this->lng->txt('mail_moved'), true);
568 $this->ctrl->setParameter($this, 'mobj_id', $redirectFolderId);
569 $this->ctrl->redirect($this, 'showFolder');
570 } else {
571 ilUtil::sendFailure($this->lng->txt('mail_move_error'));
572 $this->showMail();
573 }
574 }

References getMailIdsFromRequest(), ilUtil\sendFailure(), and ilUtil\sendInfo().

+ Here is the call graph for this function:

◆ parseCommand()

ilMailFolderGUI::parseCommand ( string  $originalCommand)
protected
Parameters
string$originalCommand
Returns
string

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

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

Referenced by executeCommand(), and showFolder().

+ Here is the caller graph for this function:

◆ parseFolderIdFromCommand()

ilMailFolderGUI::parseFolderIdFromCommand ( string  $command)
protected
Parameters
string$command
Returns
int
Exceptions
InvalidArgumentException

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

109 : int
110 {
111 $matches = [];
112 if (
113 preg_match('/^([a-zA-Z0-9]+?)_(\d+?)$/', $command, $matches) &&
114 3 === count($matches) && is_numeric($matches[2])
115 ) {
116 return (int) $matches[2];
117 }
118
119 throw new InvalidArgumentException("Cannot parse a numeric folder id from command string!");
120 }

Referenced by moveMails().

+ Here is the caller graph for this function:

◆ performAddSubFolder()

ilMailFolderGUI::performAddSubFolder ( )
protected

Called if a folder is created by the action user.

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

410 : void
411 {
412 $form = $this->getSubFolderForm();
413 $isFormValid = $form->checkInput();
414 $form->setValuesByPost();
415 if (!$isFormValid) {
416 $this->addSubFolder($form);
417 return;
418 }
419
420 $newFolderId = $this->mbox->addFolder($this->currentFolderId, $form->getInput('subfolder_title'));
421 if ($newFolderId > 0) {
422 ilUtil::sendSuccess($this->lng->txt('mail_folder_created'), true);
423 $this->ctrl->setParameterByClass('ilMailGUI', 'mobj_id', $newFolderId);
424 $this->ctrl->redirectByClass('ilMailGUI');
425 }
426
427 ilUtil::sendFailure($this->lng->txt('mail_folder_exists'));
428 $this->addSubFolder($form);
429 }
addSubFolder(ilPropertyFormGUI $form=null)
Called if the acting user wants to create a folder.

References addSubFolder(), getSubFolderForm(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ performDeleteSubFolder()

ilMailFolderGUI::performDeleteSubFolder ( )
protected
Exceptions
ilInvalidTreeStructureException

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

368 : void
369 {
370 $parentFolderId = $this->mbox->getParentFolderId($this->currentFolderId);
371 if ($parentFolderId > 0 && $this->mbox->deleteFolder($this->currentFolderId)) {
372 ilUtil::sendInfo($this->lng->txt('mail_folder_deleted'), true);
373 $this->ctrl->setParameterByClass('ilMailGUI', 'mobj_id', (int) $parentFolderId);
374 $this->ctrl->redirectByClass('ilMailGUI');
375 } else {
376 ilUtil::sendFailure($this->lng->txt('mail_error_delete'));
377 $this->showFolder();
378 }
379 }

References ilUtil\sendFailure(), ilUtil\sendInfo(), and showFolder().

+ Here is the call graph for this function:

◆ performEmptyTrash()

ilMailFolderGUI::performEmptyTrash ( )
protected

Called if the deletion of all messages in trash was confirmed by the acting user.

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

169 : void
170 {
171 $this->umail->deleteMailsOfFolder($this->currentFolderId);
172
173 ilUtil::sendSuccess($this->lng->txt('mail_deleted'), true);
174 $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
175 $this->ctrl->redirect($this, 'showFolder');
176 }

◆ performRenameSubFolder()

ilMailFolderGUI::performRenameSubFolder ( )
protected

Called if the folder title is renamed by the acting user.

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

449 : void
450 {
451 $form = $this->getSubFolderForm('edit');
452 $isFormValid = $form->checkInput();
453 $form->setValuesByPost();
454 if (!$isFormValid) {
455 $this->renameSubFolder($form);
456 return;
457 }
458
459 $folderData = $this->mbox->getFolderData($this->currentFolderId);
460 if ($folderData['title'] === $form->getInput('subfolder_title')) {
461 $this->showFolder();
462 return;
463 }
464
465 if ($this->mbox->renameFolder($this->currentFolderId, $form->getInput('subfolder_title'))) {
466 ilUtil::sendSuccess($this->lng->txt('mail_folder_name_changed'), true);
467 $this->ctrl->setParameterByClass('ilMailGUI', 'mobj_id', $this->currentFolderId);
468 $this->ctrl->redirectByClass('ilMailGUI');
469 }
470
471 ilUtil::sendFailure($this->lng->txt('mail_folder_exists'));
472 $this->renameSubFolder($form);
473 }
renameSubFolder(ilPropertyFormGUI $form=null)
Called if the acting user wants to rename a folder.

References getSubFolderForm(), renameSubFolder(), ilUtil\sendFailure(), and showFolder().

+ Here is the call graph for this function:

◆ renameSubFolder()

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

Called if the acting user wants to rename a folder.

Parameters
ilPropertyFormGUI | null$form

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

479 : void
480 {
481 if (null === $form) {
482 $form = $this->getSubFolderForm('edit');
483 $form->setValuesByArray(['subfolder_title' => $this->mbox->getFolderData($this->currentFolderId)['title']]);
484 }
485
486 $this->tpl->setTitle($this->lng->txt('mail'));
487 $this->tpl->setContent($form->getHTML());
488 $this->tpl->printToStdout();
489 }
setValuesByArray($a_values, $a_restrict_to_value_keys=false)
Set form values from an array.

References getSubFolderForm().

Referenced by performRenameSubFolder().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetFilter()

ilMailFolderGUI::resetFilter ( )
protected

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

1077 : void
1078 {
1079 $table = $this->getMailFolderTable();
1080 $table->resetOffset();
1081 $table->resetFilter();
1082
1083 $this->showFolder();
1084 }

References getMailFolderTable(), and showFolder().

+ Here is the call graph for this function:

◆ showFolder()

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

Shows current folder.

Current Folder is determined by $_GET["mobj_id"]

Parameters
bool$oneConfirmationDialogueRendered

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

236 : void
237 {
238 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.mail.html', 'Services/Mail');
239 $this->tpl->setTitle($this->lng->txt('mail'));
240
241 $isTrashFolder = $this->currentFolderId == $this->mbox->getTrashFolder();
242
243 if ($isTrashFolder && 'deleteMails' === $this->parseCommand($this->ctrl->getCmd()) && !$this->errorDelete) {
244 $confirmationGui = new ilConfirmationGUI();
245 $confirmationGui->setHeaderText($this->lng->txt('mail_sure_delete'));
246 foreach ($this->getMailIdsFromRequest() as $mailId) {
247 $confirmationGui->addHiddenItem('mail_id[]', $mailId);
248 }
249 $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
250 $confirmationGui->setFormAction($this->ctrl->getFormAction($this, 'showFolder'));
251 $this->ctrl->clearParameters($this);
252 $confirmationGui->setConfirm($this->lng->txt('confirm'), 'confirmDeleteMails');
253 $confirmationGui->setCancel($this->lng->txt('cancel'), 'showFolder');
254 $this->tpl->setVariable('CONFIRMATION', $confirmationGui->getHTML());
255 $oneConfirmationDialogueRendered = true;
256 }
257
258 $folders = $this->mbox->getSubFolders();
259 $mtree = new ilTree($this->user->getId());
260 $mtree->setTableNames('mail_tree', 'mail_obj_data');
261
262 $isUserSubFolder = false;
263 $isUserRootFolder = false;
264
265 $folder_d = $mtree->getNodeData($this->currentFolderId);
266 if ($folder_d['m_type'] === 'user_folder') {
267 $isUserSubFolder = true;
268 } elseif ($folder_d['m_type'] === 'local') {
269 $isUserRootFolder = true;
270 }
271
272 $mailtable = $this->getMailFolderTable();
273 $mailtable->setSelectedItems($this->getMailIdsFromRequest(true));
274
275 try {
276 $mailtable->prepareHTML();
277 } catch (Exception $e) {
279 $this->lng->txt($e->getMessage()) != '-' . $e->getMessage() . '-' ?
280 $this->lng->txt($e->getMessage()) :
281 $e->getMessage()
282 );
283 }
284
285 $table_html = $mailtable->getHtml();
286
287 $folder_options = [];
288 foreach ($folders as $folder) {
289 $folder_d = $mtree->getNodeData($folder['obj_id']);
290
291 if ($folder['obj_id'] == $this->currentFolderId) {
292 if ($folder['type'] === 'user_folder') {
293 $isUserSubFolder = true;
294 } elseif ($folder['type'] === 'local') {
295 $isUserRootFolder = true;
296 $isUserSubFolder = false;
297 }
298 }
299
300 $folder_options[$folder['obj_id']] = sprintf(
301 $this->lng->txt('mail_change_to_folder'),
302 $this->lng->txt('mail_' . $folder['title'])
303 );
304 if ($folder['type'] === 'user_folder') {
305 $pre = '';
306 for ($i = 2; $i < $folder_d['depth'] - 1; $i++) {
307 $pre .= '&nbsp;';
308 }
309
310 if ($folder_d['depth'] > 1) {
311 $pre .= '+';
312 }
313
314 $folder_options[$folder['obj_id']] = sprintf(
315 $this->lng->txt('mail_change_to_folder'),
316 $pre . ' ' . $folder['title']
317 );
318 }
319 }
320
321 if ($oneConfirmationDialogueRendered === false && $this->confirmTrashDeletion === false) {
322 $this->toolbar->setFormAction($this->ctrl->getFormAction($this, 'showFolder'));
323
324 if ($isUserRootFolder == true || $isUserSubFolder == true) {
325 $this->addSubFolderCommands($isUserSubFolder);
326 }
327 }
328
329 if ($mailtable->isTrashFolder() && $mailtable->getNumberOfMails() > 0 && $this->confirmTrashDeletion === true) {
330 $confirmationGui = new ilConfirmationGUI();
331 $confirmationGui->setHeaderText($this->lng->txt('mail_empty_trash_confirmation'));
332 $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
333 $confirmationGui->setFormAction($this->ctrl->getFormAction($this, 'performEmptyTrash'));
334 $this->ctrl->clearParameters($this);
335 $confirmationGui->setConfirm($this->lng->txt('confirm'), 'performEmptyTrash');
336 $confirmationGui->setCancel($this->lng->txt('cancel'), 'showFolder');
337 $this->tpl->setVariable('CONFIRMATION', $confirmationGui->getHTML());
338 }
339
340 $this->tpl->setVariable('MAIL_TABLE', $table_html);
341 $this->tpl->printToStdout();
342 }
addSubFolderCommands(bool $isUserSubFolder=false)
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
$i
Definition: metadata.php:24

References Vendor\Package\$e, $i, addSubFolderCommands(), getMailFolderTable(), getMailIdsFromRequest(), parseCommand(), ilUtil\sendFailure(), and user().

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

+ 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 193 of file class.ilMailFolderGUI.php.

193 : void
194 {
195 $this->tpl->setVariable('TBL_TITLE', implode(' ', [
196 $this->lng->txt('profile_of'),
197 ilObjUser::_lookupLogin((int) ($this->httpRequest->getQueryParams()['user'] ?? 0))
198 ]));
199 $this->tpl->setVariable('TBL_TITLE_IMG', ilUtil::getImagePath('icon_usr.svg'));
200 $this->tpl->setVariable('TBL_TITLE_IMG_ALT', $this->lng->txt('public_profile'));
201
202 $profile_gui = new ilPublicUserProfileGUI((int) ($this->httpRequest->getQueryParams()['user'] ?? 0));
203
204 $this->ctrl->setParameter($this, 'mail_id', (int) $this->httpRequest->getQueryParams()['mail_id']);
205 $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
206 $profile_gui->setBackUrl($this->ctrl->getLinkTarget($this, 'showMail'));
207 $this->ctrl->clearParameters($this);
208
209 $this->tpl->setTitle($this->lng->txt('mail'));
210 $this->tpl->setContent($this->ctrl->getHTML($profile_gui));
211 $this->tpl->printToStdout();
212 }
static _lookupLogin($a_user_id)
lookup login
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)

References ilObjUser\_lookupLogin(), and ilUtil\getImagePath().

+ Here is the call graph for this function:

Field Documentation

◆ $confirmTrashDeletion

ilMailFolderGUI::$confirmTrashDeletion = false
private

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

◆ $ctrl

ilMailFolderGUI::$ctrl
private

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

◆ $currentFolderId

ilMailFolderGUI::$currentFolderId = 0
private

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

◆ $errorDelete

ilMailFolderGUI::$errorDelete = false
private

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

◆ $httpRequest

ilMailFolderGUI::$httpRequest
private

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

◆ $lng

ilMailFolderGUI::$lng
private

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

◆ $mbox

ilMailFolderGUI::$mbox

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

◆ $tabs

ilMailFolderGUI::$tabs
private

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

◆ $toolbar

ilMailFolderGUI::$toolbar
private

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

◆ $tpl

ilMailFolderGUI::$tpl
private

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

◆ $umail

ilMailFolderGUI::$umail

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

◆ $user

ilMailFolderGUI::$user
private

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


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