ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 ()
 
 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 12 of file class.ilMailFolderGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilMailFolderGUI::__construct ( )

ilMailFolderGUI constructor.

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

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

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

459 {
460 if (null === $form) {
461 $form = $this->getSubFolderForm();
462 }
463
464 $this->tpl->setTitle($this->lng->txt('mail'));
465 $this->tpl->setContent($form->getHTML());
466 $this->tpl->show();
467 }
getSubFolderForm(string $mode='create')
if(isset($_POST['submit'])) $form

References $form, and 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 215 of file class.ilMailFolderGUI.php.

216 {
218 $this->toolbar->addSeparator();
219 }
220
221 $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
222 $this->toolbar->addButton($this->lng->txt('mail_add_subfolder'), $this->ctrl->getLinkTarget($this, 'addSubFolder'));
223
224 if ($isUserSubFolder) {
225 $this->toolbar->addButton($this->lng->txt('rename'), $this->ctrl->getLinkTarget($this, 'renameSubFolder'));
226 $this->toolbar->addButton($this->lng->txt('delete'), $this->ctrl->getLinkTarget($this, 'deleteSubFolder'));
227 }
228 $this->ctrl->clearParameters($this);
229 }
const VIEWMODE_SESSION_KEY
static get($a_var)
Get a value.

References ilSession\get(), and ilMailGUI\VIEWMODE_SESSION_KEY.

Referenced by showFolder().

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

◆ applyFilter()

ilMailFolderGUI::applyFilter ( )
protected

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

1055 {
1056 $sentFolderId = $this->mbox->getSentFolder();
1057 $draftsFolderId = $this->mbox->getDraftsFolder();
1058
1059 $isTrashFolder = $this->currentFolderId == $this->mbox->getTrashFolder();
1060 $isSentFolder = $this->currentFolderId == $sentFolderId;
1061 $isDraftFolder = $this->currentFolderId == $draftsFolderId;
1062
1063 $table = new ilMailFolderTableGUI($this, $this->currentFolderId, 'showFolder');
1064 $table->isSentFolder($isSentFolder)
1065 ->isDraftFolder($isDraftFolder)
1066 ->isTrashFolder($isTrashFolder)
1067 ->initFilter();
1068 $table->resetOffset();
1069 $table->writeFilterToSession();
1070
1071 $this->showFolder();
1072 }
showFolder(bool $oneConfirmationDialogueRendered=false)
Shows current folder.
if(empty($password)) $table
Definition: pwgen.php:24

References $table, 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 653 of file class.ilMailFolderGUI.php.

654 {
655 $mailIds = $this->getMailIdsFromRequest();
656 if (0 === count($mailIds)) {
657 $this->showFolder();
658 \ilUtil::sendInfo($this->lng->txt('mail_select_one'));
659 return;
660 }
661
662 if ((int) $this->mbox->getTrashFolder() === (int) $this->currentFolderId) {
663 if ($this->umail->deleteMails($mailIds)) {
664 \ilUtil::sendSuccess($this->lng->txt('mail_deleted'), true);
665 $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
666 $this->ctrl->redirect($this, 'showFolder');
667 } else {
668 \ilUtil::sendFailure($this->lng->txt('mail_delete_error'));
669 }
670 }
671
672 $this->showFolder();
673 }
getMailIdsFromRequest(bool $ignoreHttpGet=false)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.

References getMailIdsFromRequest(), ilUtil\sendFailure(), 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 179 of file class.ilMailFolderGUI.php.

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

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

626 {
627 $trashFolderId = (int) $this->mbox->getTrashFolder();
628 $mailIds = $this->getMailIdsFromRequest();
629
630 if ($trashFolderId == $this->currentFolderId) {
631 if (0 === count($mailIds)) {
632 \ilUtil::sendInfo($this->lng->txt('mail_select_one'));
633 $this->errorDelete = true;
634 }
635 } else {
636 if (0 === count($mailIds)) {
637 \ilUtil::sendInfo($this->lng->txt('mail_select_one'));
638 } elseif ($this->umail->moveMailsToFolder($mailIds, $trashFolderId)) {
639 \ilUtil::sendSuccess($this->lng->txt('mail_moved_to_trash'), true);
640 $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
641 $this->ctrl->redirect($this, 'showFolder');
642 } else {
643 \ilUtil::sendFailure($this->lng->txt('mail_move_error'));
644 }
645 }
646
647 $this->showFolder();
648 }

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

372 {
373 if ($a_show_confirm) {
374 $confirmationGui = new \ilConfirmationGUI();
375 $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
376 $confirmationGui->setFormAction($this->ctrl->getFormAction($this, 'showFolder'));
377 $this->ctrl->clearParameters($this);
378 $confirmationGui->setHeaderText($this->lng->txt('mail_sure_delete_folder'));
379 $confirmationGui->setCancel($this->lng->txt('cancel'), 'showFolder');
380 $confirmationGui->setConfirm($this->lng->txt('confirm'), 'performDeleteSubFolder');
381 $this->tpl->setVariable('CONFIRMATION', $confirmationGui->getHTML());
382
383 $this->showFolder(true);
384 } else {
385 $this->showFolder(false);
386 }
387 }

References showFolder().

+ Here is the call graph for this function:

◆ deliverAttachments()

ilMailFolderGUI::deliverAttachments ( )
protected

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

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

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

+ Here is the call graph for this function:

◆ deliverFile()

ilMailFolderGUI::deliverFile ( )
protected

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

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

References $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 123 of file class.ilMailFolderGUI.php.

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

References $ret, and parseCommand().

+ Here is the call graph for this function:

◆ getMailIdsFromRequest()

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

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

518 : array
519 {
520 $mailIds = $this->httpRequest->getParsedBody()['mail_id'] ?? [];
521 if (!is_array($mailIds)) {
522 return [];
523 }
524
525 if (0 === count($mailIds) && !$ignoreHttpGet) {
526 $mailId = $this->httpRequest->getQueryParams()['mail_id'] ?? 0;
527 if (is_numeric($mailId)) {
528 $mailIds = [$mailId];
529 }
530 }
531
532 return array_filter(array_map('intval', $mailIds));
533 }

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

410 {
411 $form = new \ilPropertyFormGUI();
412 $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
413 $form->setFormAction($this->ctrl->getFormAction($this, 'performAddSubFolder'));
414 $this->ctrl->clearParameters($this);
415 if ('edit' === $mode) {
416 $form->addCommandButton('performRenameSubFolder', $this->lng->txt('save'));
417 $form->setTitle($this->lng->txt('mail_rename_folder'));
418 } else {
419 $form->addCommandButton('performAddSubFolder', $this->lng->txt('save'));
420 $form->setTitle($this->lng->txt('mail_add_folder'));
421 }
422 $form->addCommandButton('showFolder', $this->lng->txt('cancel'));
423
424 $title = new \ilTextInputGUI($this->lng->txt('title'), 'subfolder_title');
425 $title->setRequired(true);
426 $form->addItem($title);
427
428 return $form;
429 }
This class represents a property form user interface.

References $form, and $title.

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

+ Here is the caller graph for this function:

◆ initFolder()

ilMailFolderGUI::initFolder ( )
protected

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

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

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

539 {
540 $mailIds = $this->getMailIdsFromRequest();
541 if (count($mailIds) > 0) {
542 $this->umail->markRead($mailIds);
543 \ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
544 } else {
545 \ilUtil::sendInfo($this->lng->txt('mail_select_one'));
546 }
547
548 $this->showFolder();
549 }

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

555 {
556 $mailIds = $this->getMailIdsFromRequest();
557 if (count($mailIds) > 0) {
558 $this->umail->markUnread($mailIds);
559 \ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
560 } else {
561 \ilUtil::sendInfo($this->lng->txt('mail_select_one'));
562 }
563
564 $this->showFolder();
565 }

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

603 {
604 $mailIds = $this->getMailIdsFromRequest();
605 if (0 === count($mailIds)) {
606 $this->showFolder();
607 \ilUtil::sendInfo($this->lng->txt('mail_select_one'));
608 return;
609 }
610
611 $folderId = $this->parseFolderIdFromCommand($this->ctrl->getCmd());
612 if ($this->umail->moveMailsToFolder($mailIds, $folderId)) {
613 \ilUtil::sendSuccess($this->lng->txt('mail_moved'), true);
614 $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
615 $this->ctrl->redirect($this, 'showFolder');
616 } else {
617 \ilUtil::sendFailure($this->lng->txt('mail_move_error'));
618 $this->showFolder();
619 }
620 }
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 570 of file class.ilMailFolderGUI.php.

571 {
572 $mailIds = $this->getMailIdsFromRequest();
573 if (1 !== count($mailIds)) {
574 $this->showMail();
575 \ilUtil::sendInfo($this->lng->txt('mail_select_one'));
576 return;
577 }
578
579 $newFolderId = (int) ($this->httpRequest->getParsedBody()['folder_id'] ?? 0);
580 $redirectFolderId = $newFolderId;
581 foreach ($mailIds as $mailId) {
582 $mailData = $this->umail->getMail($mailId);
583 if (isset($mailData['folder_id']) && is_numeric($mailData['folder_id']) && (int) $mailData['folder_id'] > 0) {
584 $redirectFolderId = $mailData['folder_id'];
585 break;
586 }
587 }
588
589 if ($this->umail->moveMailsToFolder($mailIds, $newFolderId)) {
590 \ilUtil::sendSuccess($this->lng->txt('mail_moved'), true);
591 $this->ctrl->setParameter($this, 'mobj_id', $redirectFolderId);
592 $this->ctrl->redirect($this, 'showFolder');
593 } else {
594 \ilUtil::sendFailure($this->lng->txt('mail_move_error'));
595 $this->showMail();
596 }
597 }

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

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

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

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

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

435 {
436 $form = $this->getSubFolderForm();
437 $isFormValid = $form->checkInput();
438 $form->setValuesByPost();
439 if (!$isFormValid) {
440 $this->addSubFolder($form);
441 return;
442 }
443
444 if ($newFolderId = $this->mbox->addFolder($this->currentFolderId, $form->getInput('subfolder_title'))) {
445 \ilUtil::sendSuccess($this->lng->txt('mail_folder_created'), true);
446 $this->ctrl->setParameterByClass('ilMailGUI', 'mobj_id', $newFolderId);
447 $this->ctrl->redirectByClass('ilMailGUI');
448 }
449
450 \ilUtil::sendFailure($this->lng->txt('mail_folder_exists'));
451 $this->addSubFolder($form);
452 }
addSubFolder(\ilPropertyFormGUI $form=null)
Called if the acting user wants to create a folder.

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

+ Here is the call graph for this function:

◆ performDeleteSubFolder()

ilMailFolderGUI::performDeleteSubFolder ( )
protected
Exceptions
ilInvalidTreeStructureException

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

393 {
394 $parentFolderId = $this->mbox->getParentFolderId($this->currentFolderId);
395 if ($parentFolderId > 0 && $this->mbox->deleteFolder($this->currentFolderId)) {
396 ilUtil::sendInfo($this->lng->txt('mail_folder_deleted'), true);
397 $this->ctrl->setParameterByClass('ilMailGUI', 'mobj_id', (int) $parentFolderId);
398 $this->ctrl->redirectByClass('ilMailGUI');
399 } else {
400 \ilUtil::sendFailure($this->lng->txt('mail_error_delete'));
401 $this->showFolder();
402 }
403 }

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

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

◆ performRenameSubFolder()

ilMailFolderGUI::performRenameSubFolder ( )
protected

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

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

473 {
474 $form = $this->getSubFolderForm('edit');
475 $isFormValid = $form->checkInput();
476 $form->setValuesByPost();
477 if (!$isFormValid) {
478 $this->renameSubFolder($form);
479 return;
480 }
481
482 $folderData = $this->mbox->getFolderData($this->currentFolderId);
483 if ($folderData['title'] === $form->getInput('subfolder_title')) {
484 $this->showFolder();
485 return;
486 }
487
488 if ($this->mbox->renameFolder($this->currentFolderId, $form->getInput('subfolder_title'))) {
489 \ilUtil::sendSuccess($this->lng->txt('mail_folder_name_changed'), true);
490 $this->ctrl->setParameterByClass('ilMailGUI', 'mobj_id', $this->currentFolderId);
491 $this->ctrl->redirectByClass('ilMailGUI');
492 }
493
494 \ilUtil::sendFailure($this->lng->txt('mail_folder_exists'));
495 $this->renameSubFolder($form);
496 }
renameSubFolder(\ilPropertyFormGUI $form=null)
Called if the acting user wants to rename a folder.

References $form, 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 502 of file class.ilMailFolderGUI.php.

503 {
504 if (null === $form) {
505 $form = $this->getSubFolderForm('edit');
506 $form->setValuesByArray(['subfolder_title' => $this->mbox->getFolderData($this->currentFolderId)['title']]);
507 }
508
509 $this->tpl->setTitle($this->lng->txt('mail'));
510 $this->tpl->setContent($form->getHTML());
511 $this->tpl->show();
512 }

References $form, and 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.

1078 {
1079 $sentFolderId = $this->mbox->getSentFolder();
1080 $draftsFolderId = $this->mbox->getDraftsFolder();
1081
1082 $isTrashFolder = $this->currentFolderId == $this->mbox->getTrashFolder();
1083 $isSentFolder = $this->currentFolderId == $sentFolderId;
1084 $isDraftFolder = $this->currentFolderId == $draftsFolderId;
1085
1086 $table = new ilMailFolderTableGUI($this, $this->currentFolderId, 'showFolder');
1087 $table->isSentFolder($isSentFolder)
1088 ->isDraftFolder($isDraftFolder)
1089 ->isTrashFolder($isTrashFolder)
1090 ->initFilter();
1091 $table->resetOffset();
1092 $table->resetFilter();
1093
1094 $this->showFolder();
1095 }

References $table, 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 235 of file class.ilMailFolderGUI.php.

236 {
237 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.mail.html', 'Services/Mail');
238 $this->tpl->setTitle($this->lng->txt('mail'));
239
240 $sentFolderId = $this->mbox->getSentFolder();
241 $draftsFolderId = $this->mbox->getDraftsFolder();
242
243 $isTrashFolder = $this->currentFolderId == $this->mbox->getTrashFolder();
244 $isSentFolder = $this->currentFolderId == $sentFolderId;
245 $isDraftFolder = $this->currentFolderId == $draftsFolderId;
246
247 if ($isTrashFolder && 'deleteMails' === $this->parseCommand($this->ctrl->getCmd()) && !$this->errorDelete) {
248 $confirmationGui = new \ilConfirmationGUI();
249 $confirmationGui->setHeaderText($this->lng->txt('mail_sure_delete'));
250 foreach ($this->getMailIdsFromRequest() as $mailId) {
251 $confirmationGui->addHiddenItem('mail_id[]', $mailId);
252 }
253 $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
254 $confirmationGui->setFormAction($this->ctrl->getFormAction($this, 'showFolder'));
255 $this->ctrl->clearParameters($this);
256 $confirmationGui->setConfirm($this->lng->txt('confirm'), 'confirmDeleteMails');
257 $confirmationGui->setCancel($this->lng->txt('cancel'), 'showFolder');
258 $this->tpl->setVariable('CONFIRMATION', $confirmationGui->getHTML());
259 $oneConfirmationDialogueRendered = true;
260 }
261
262 $folders = $this->mbox->getSubFolders();
263 $mtree = new \ilTree($this->user->getId());
264 $mtree->setTableNames('mail_tree', 'mail_obj_data');
265
266 $isUserSubFolder = false;
267 $isUserRootFolder = false;
268
270 $folder_d = $mtree->getNodeData($this->currentFolderId);
271 if ($folder_d['m_type'] === 'user_folder') {
272 $isUserSubFolder = true;
273 } elseif ($folder_d['m_type'] === 'local') {
274 $isUserRootFolder = true;
275 }
276 }
277
278 $mailtable = new ilMailFolderTableGUI($this, $this->currentFolderId, 'showFolder');
279 $mailtable->isSentFolder($isSentFolder)
280 ->isDraftFolder($isDraftFolder)
281 ->isTrashFolder($isTrashFolder)
282 ->setSelectedItems($this->getMailIdsFromRequest(true))
283 ->initFilter();
284
285 try {
286 $mailtable->prepareHTML();
287 } catch (\Exception $e) {
289 $this->lng->txt($e->getMessage()) != '-' . $e->getMessage() . '-' ?
290 $this->lng->txt($e->getMessage()) :
291 $e->getMessage()
292 );
293 }
294
295 $table_html = $mailtable->getHtml();
296
297 $folder_options = array();
299 foreach ($folders as $folder) {
300 $folder_d = $mtree->getNodeData($folder['obj_id']);
301
302 if ($folder['obj_id'] == $this->currentFolderId) {
303 if ($folder['type'] === 'user_folder') {
304 $isUserSubFolder = true;
305 } else {
306 if ($folder['type'] === 'local') {
307 $isUserRootFolder = true;
308 $isUserSubFolder = false;
309 }
310 }
311 }
312
313 $folder_options[$folder['obj_id']] = sprintf(
314 $this->lng->txt('mail_change_to_folder'),
315 $this->lng->txt('mail_' . $folder['title'])
316 );
317 if ($folder['type'] === 'user_folder') {
318 $pre = '';
319 for ($i = 2; $i < $folder_d['depth'] - 1; $i++) {
320 $pre .= '&nbsp;';
321 }
322
323 if ($folder_d['depth'] > 1) {
324 $pre .= '+';
325 }
326
327 $folder_options[$folder['obj_id']] = sprintf(
328 $this->lng->txt('mail_change_to_folder'),
329 $pre . ' ' . $folder['title']
330 );
331 }
332 }
333 }
334
335 if ($oneConfirmationDialogueRendered === false && $this->confirmTrashDeletion === false) {
337 $si = new \ilSelectInputGUI('', 'mobj_id');
338 $si->setOptions($folder_options);
339 $si->setValue($this->currentFolderId);
340 $this->toolbar->addStickyItem($si);
341
343 $btn->setCaption('change');
344 $btn->setCommand('showFolder');
345 $this->toolbar->addStickyItem($btn);
346 $this->toolbar->setFormAction($this->ctrl->getFormAction($this, 'showFolder'));
347 }
348 if ($isUserRootFolder == true || $isUserSubFolder == true) {
349 $this->addSubFolderCommands($isUserSubFolder);
350 }
351 }
352
353 if ($mailtable->isTrashFolder() && $mailtable->getNumberOfMails() > 0 && $this->confirmTrashDeletion === true) {
354 $confirmationGui = new \ilConfirmationGUI();
355 $confirmationGui->setHeaderText($this->lng->txt('mail_empty_trash_confirmation'));
356 $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
357 $confirmationGui->setFormAction($this->ctrl->getFormAction($this, 'performEmptyTrash'));
358 $this->ctrl->clearParameters($this);
359 $confirmationGui->setConfirm($this->lng->txt('confirm'), 'performEmptyTrash');
360 $confirmationGui->setCancel($this->lng->txt('cancel'), 'showFolder');
361 $this->tpl->setVariable('CONFIRMATION', $confirmationGui->getHTML());
362 }
363
364 $this->tpl->setVariable('MAIL_TABLE', $table_html);
365 $this->tpl->show();
366 }
addSubFolderCommands(bool $isUserSubFolder=false)
static getInstance()
Factory.
$i
Definition: disco.tpl.php:19

References $i, $si, addSubFolderCommands(), ilSession\get(), ilSubmitButton\getInstance(), getMailIdsFromRequest(), parseCommand(), ilUtil\sendFailure(), user(), and ilMailGUI\VIEWMODE_SESSION_KEY.

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

192 {
193 $this->tpl->setVariable('TBL_TITLE', implode(' ', [
194 $this->lng->txt('profile_of'),
195 \ilObjUser::_lookupLogin((int) ($this->httpRequest->getQueryParams()['user'] ?? 0))
196 ]));
197 $this->tpl->setVariable('TBL_TITLE_IMG', ilUtil::getImagePath('icon_usr.svg'));
198 $this->tpl->setVariable('TBL_TITLE_IMG_ALT', $this->lng->txt('public_profile'));
199
200 $profile_gui = new \ilPublicUserProfileGUI((int) ($this->httpRequest->getQueryParams()['user'] ?? 0));
201
202 $this->ctrl->setParameter($this, 'mail_id', (int) $this->httpRequest->getQueryParams()['mail_id']);
203 $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
204 $profile_gui->setBackUrl($this->ctrl->getLinkTarget($this, 'showMail'));
205 $this->ctrl->clearParameters($this);
206
207 $this->tpl->setTitle($this->lng->txt('mail'));
208 $this->tpl->setContent($this->ctrl->getHTML($profile_gui));
209 $this->tpl->show();
210 }
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 15 of file class.ilMailFolderGUI.php.

◆ $ctrl

ilMailFolderGUI::$ctrl
private

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

◆ $currentFolderId

ilMailFolderGUI::$currentFolderId = 0
private

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

◆ $errorDelete

ilMailFolderGUI::$errorDelete = false
private

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

◆ $httpRequest

ilMailFolderGUI::$httpRequest
private

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

◆ $lng

ilMailFolderGUI::$lng
private

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

◆ $mbox

ilMailFolderGUI::$mbox

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

◆ $tabs

ilMailFolderGUI::$tabs
private

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

◆ $toolbar

ilMailFolderGUI::$toolbar
private

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

◆ $tpl

ilMailFolderGUI::$tpl
private

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

◆ $umail

ilMailFolderGUI::$umail

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

◆ $user

ilMailFolderGUI::$user
private

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


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