ILIAS  trunk Revision v11.0_alpha-1811-gd2d5443e411
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilMailGUI Class Reference
+ Inheritance diagram for ilMailGUI:
+ Collaboration diagram for ilMailGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 

Data Fields

ilMail $umail
 
ilMailbox $mbox
 

Protected Member Functions

 initFolder ()
 
 toggleExplorerNodeState ()
 

Private Member Functions

 setViewMode ()
 
 showHeader ()
 

Private Attributes

readonly ilGlobalTemplateInterface $tpl
 
readonly ilCtrlInterface $ctrl
 
readonly ilLanguage $lng
 
string $forwardClass = ''
 
readonly GlobalHttpState $http
 
readonly Refinery $refinery
 
int $currentFolderId = 0
 
readonly ilObjUser $user
 

Detailed Description

Definition at line 31 of file class.ilMailGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilMailGUI::__construct ( )

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

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

45  {
46  global $DIC;
47  $this->tpl = $DIC->ui()->mainTemplate();
48  $this->ctrl = $DIC->ctrl();
49  $this->lng = $DIC->language();
50  $this->user = $DIC->user();
51  $this->http = $DIC->http();
52  $this->refinery = $DIC->refinery();
53 
54  $this->lng->loadLanguageModule('mail');
55 
56  $this->mbox = new ilMailbox($this->user->getId());
57  $this->umail = new ilMail($this->user->getId());
58  if (
59  !$DIC->rbac()->system()->checkAccess(
60  'internal_mail',
61  $this->umail->getMailObjectReferenceId()
62  )
63  ) {
64  $DIC['ilErr']->raiseError($this->lng->txt('permission_denied'), $DIC['ilErr']->WARNING);
65  }
66 
67  $this->initFolder();
68 
69  $toolContext = $DIC->globalScreen()
70  ->tool()
71  ->context()
72  ->current();
73 
74  $additionalDataExists = $toolContext->getAdditionalData()->exists(
75  MailGlobalScreenToolProvider::SHOW_MAIL_FOLDERS_TOOL
76  );
77  if (false === $additionalDataExists) {
78  $toolContext->addAdditionalData(MailGlobalScreenToolProvider::SHOW_MAIL_FOLDERS_TOOL, true);
79  }
80  }
static http()
Fetches the global http state from ILIAS.
Mail Box class Base class for creating and handling mail boxes.
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilMailGUI::executeCommand ( )

Definition at line 100 of file class.ilMailGUI.php.

References ILIAS\Repository\ctrl(), ilSession\get(), ilMailFormCall\getRecipients(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ilMailFormGUI\MAIL_FORM_TYPE_ATTACH, ilMailFormGUI\MAIL_FORM_TYPE_NEW, ilMailFormGUI\MAIL_FORM_TYPE_REPLY, ilMailFormGUI\MAIL_FORM_TYPE_ROLE, ilMailFormGUI\MAIL_FORM_TYPE_SEARCH_RESULT, ILIAS\Repository\refinery(), ilSession\set(), ilMailFormCall\setRecipients(), showHeader(), ilMailFormCall\storeReferer(), and ilUtil\stripSlashes().

100  : void
101  {
102  $type = '';
103  if ($this->http->wrapper()->query()->has('type')) {
104  $type = $this->http->wrapper()->query()->retrieve('type', $this->refinery->kindlyTo()->string());
105  }
106  $mailId = 0;
107  if ($this->http->wrapper()->query()->has('mail_id')) {
108  $mailId = $this->http->wrapper()->query()->retrieve('mail_id', $this->refinery->kindlyTo()->int());
109  }
110 
111  $this->ctrl->setParameterByClass(ilMailFormGUI::class, 'mobj_id', $this->currentFolderId);
112  $this->ctrl->setParameterByClass(ilMailFolderGUI::class, 'mobj_id', $this->currentFolderId);
113 
115  ilMailFormCall::storeReferer($this->http->request()->getQueryParams());
116  $this->ctrl->redirectByClass(ilMailFormGUI::class, 'searchResults');
117  } elseif (ilMailFormGUI::MAIL_FORM_TYPE_ATTACH === $type) {
118  ilMailFormCall::storeReferer($this->http->request()->getQueryParams());
119  $this->ctrl->redirectByClass(ilMailFormGUI::class, 'mailAttachment');
120  } elseif (ilMailFormGUI::MAIL_FORM_TYPE_NEW === $type) {
121  foreach (['to', 'cc', 'bcc'] as $reciepient_type) {
122  $key = 'rcp_' . $reciepient_type;
123 
124  $recipients = '';
125  if ($this->http->wrapper()->query()->has($key)) {
126  $recipients = $this->http->wrapper()->query()->retrieve(
127  $key,
128  $this->refinery->kindlyTo()->string()
129  );
130  }
131 
132  ilSession::set($key, ilUtil::stripSlashes($recipients));
133 
134  if (ilSession::get($key) === '' &&
135  ($recipients = ilMailFormCall::getRecipients($reciepient_type))) {
136  ilSession::set($key, implode(',', $recipients));
137  ilMailFormCall::setRecipients([], $reciepient_type);
138  }
139  }
140  ilMailFormCall::storeReferer($this->http->request()->getQueryParams());
141  $this->ctrl->redirectByClass(ilMailFormGUI::class, 'mailUser');
142  } elseif (ilMailFormGUI::MAIL_FORM_TYPE_REPLY === $type) {
143  $this->ctrl->setParameterByClass(ilMailFormGUI::class, 'mail_id', $mailId);
144  $this->ctrl->redirectByClass(ilMailFormGUI::class, 'replyMail');
145  } elseif ('read' === $type) {
146  $this->ctrl->setParameterByClass(ilMailFolderGUI::class, 'mail_id', $mailId);
147  $this->ctrl->redirectByClass(ilMailFolderGUI::class, 'showMail');
148  } elseif ('deliverFile' === $type) {
149  $fileName = '';
150  if ($this->http->wrapper()->post()->has('filename')) {
151  $fileName = $this->http->wrapper()->post()->retrieve(
152  'filename',
153  $this->refinery->kindlyTo()->string()
154  );
155  } elseif ($this->http->wrapper()->query()->has('filename')) {
156  $fileName = $this->http->wrapper()->query()->retrieve(
157  'filename',
158  $this->refinery->kindlyTo()->string()
159  );
160  }
161 
162  ilSession::set('filename', ilUtil::stripSlashes($fileName));
163  $this->ctrl->setParameterByClass(ilMailFolderGUI::class, 'mail_id', $mailId);
164  $this->ctrl->redirectByClass(ilMailFolderGUI::class, 'deliverFile');
165  } elseif ('message_sent' === $type) {
166  $this->tpl->setOnScreenMessage('success', $this->lng->txt('mail_message_send'), true);
167  $this->ctrl->redirectByClass(ilMailFolderGUI::class);
168  } elseif (ilMailFormGUI::MAIL_FORM_TYPE_ROLE === $type) {
169  $roles = [];
170  if ($this->http->wrapper()->post()->has('roles')) {
171  $roles = $this->http->wrapper()->post()->retrieve(
172  'roles',
173  $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->string())
174  );
175  } elseif ($this->http->wrapper()->query()->has('role')) {
176  $roles = [$this->http->wrapper()->query()->retrieve('role', $this->refinery->kindlyTo()->string())];
177  }
178 
179  if ($roles !== []) {
180  ilSession::set('mail_roles', $roles);
181  }
182 
183  ilMailFormCall::storeReferer($this->http->request()->getQueryParams());
184  $this->ctrl->redirectByClass(ilMailFormGUI::class, 'mailRole');
185  }
186 
187  $view = '';
188  if ($this->http->wrapper()->query()->has('view')) {
189  $view = $this->http->wrapper()->query()->retrieve('view', $this->refinery->kindlyTo()->string());
190  }
191  if ('my_courses' === $view) {
192  $search_crs = '';
193  if ($this->http->wrapper()->query()->has('search_crs')) {
194  $search_crs = ilUtil::stripSlashes(
195  $this->http->wrapper()->query()->retrieve('search_crs', $this->refinery->kindlyTo()->string())
196  );
197  }
198  $this->ctrl->setParameter($this, 'search_crs', $search_crs);
199  $this->ctrl->redirectByClass(ilMailFormGUI::class, 'searchCoursesTo');
200  }
201 
202  $this->forwardClass = (string) $this->ctrl->getNextClass($this);
203  $this->showHeader();
204 
205  switch (strtolower($this->forwardClass)) {
206  case strtolower(ilMailFormGUI::class):
207  $this->ctrl->forwardCommand(new ilMailFormGUI());
208  break;
209 
210  case strtolower(ilContactGUI::class):
211  $this->tpl->setTitle($this->lng->txt('mail_addressbook'));
212  $this->ctrl->forwardCommand(new ilContactGUI());
213  break;
214 
215  case strtolower(ilMailAttachmentGUI::class):
216  $this->tpl->setTitle($this->lng->txt('mail'));
217  $gui = new ilMailAttachmentGUI();
218  $gui->manage();
219  $this->ctrl->forwardCommand($gui);
220  break;
221 
222  case strtolower(ilMailOptionsGUI::class):
223  $this->tpl->setTitle($this->lng->txt('mail'));
224  $this->ctrl->forwardCommand(new ilMailOptionsGUI());
225  break;
226 
227  case strtolower(ilMailFolderGUI::class):
228  $this->ctrl->forwardCommand(new ilMailFolderGUI());
229  break;
230 
231  default:
232  if (!($cmd = $this->ctrl->getCmd()) || !method_exists($this, $cmd)) {
233  $cmd = 'setViewMode';
234  }
235 
236  $this->{$cmd}();
237  break;
238  }
239  }
static get(string $a_var)
static storeReferer(array $queryParameters)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
final const MAIL_FORM_TYPE_SEARCH_RESULT
final const MAIL_FORM_TYPE_REPLY
ilMailFormGUI: ilMailAttachmentGUI, ilMailSearchGUI, ilMailSearchCoursesGUI, ilMailSearchGroupsGUI, ilMailingListsGUI
ilMailFolderGUI:
static http()
Fetches the global http state from ILIAS.
static getRecipients(string $type='to')
static setRecipients(array $recipients, string $type='to')
final const MAIL_FORM_TYPE_ATTACH
final const MAIL_FORM_TYPE_NEW
final const MAIL_FORM_TYPE_ROLE
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:

◆ initFolder()

ilMailGUI::initFolder ( )
protected

Definition at line 82 of file class.ilMailGUI.php.

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

Referenced by __construct().

82  : void
83  {
84  if ($this->http->wrapper()->post()->has('mobj_id')) {
85  $folderId = $this->http->wrapper()->post()->retrieve('mobj_id', $this->refinery->kindlyTo()->int());
86  } elseif ($this->http->wrapper()->query()->has('mobj_id')) {
87  $folderId = $this->http->wrapper()->query()->retrieve('mobj_id', $this->refinery->kindlyTo()->int());
88  } else {
89  $folderId = $this->refinery->byTrying([
90  $this->refinery->kindlyTo()->int(),
91  $this->refinery->always($this->currentFolderId),
92  ])->transform(ilSession::get('mobj_id'));
93  }
94  if (0 === $folderId || !$this->mbox->isOwnedFolder($folderId)) {
95  $folderId = $this->mbox->getInboxFolder();
96  }
97  $this->currentFolderId = $folderId;
98  }
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:

◆ setViewMode()

ilMailGUI::setViewMode ( )
private

Definition at line 241 of file class.ilMailGUI.php.

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

241  : void
242  {
243  $targetClass = ilMailFolderGUI::class;
244  if ($this->http->wrapper()->query()->has('target')) {
245  $targetClass = $this->http->wrapper()->query()->retrieve(
246  'target',
247  $this->refinery->kindlyTo()->string()
248  );
249  }
250  $type = '';
251  if ($this->http->wrapper()->query()->has('type')) {
252  $type = $this->http->wrapper()->query()->retrieve('type', $this->refinery->kindlyTo()->string());
253  }
254  $mailId = 0;
255  if ($this->http->wrapper()->query()->has('mail_id')) {
256  $mailId = $this->http->wrapper()->query()->retrieve('mail_id', $this->refinery->kindlyTo()->int());
257  }
258 
259  $this->ctrl->setParameterByClass($targetClass, 'mobj_id', $this->currentFolderId);
260 
261  if ('redirect_to_read' === $type) {
262  $this->ctrl->setParameterByClass(
263  ilMailFolderGUI::class,
264  'mail_id',
265  $mailId
266  );
267  $this->ctrl->setParameterByClass(
268  ilMailFolderGUI::class,
269  'mobj_id',
270  $this->currentFolderId
271  );
272  $this->ctrl->redirectByClass(ilMailFolderGUI::class, 'showMail');
273  } elseif ('add_subfolder' === $type) {
274  $this->ctrl->redirectByClass($targetClass, 'addSubFolder');
275  } elseif ('enter_folderdata' === $type) {
276  $this->ctrl->redirectByClass($targetClass, 'enterFolderData');
277  } elseif ('confirmdelete_folderdata' === $type) {
278  $this->ctrl->redirectByClass($targetClass, 'confirmDeleteFolder');
279  } else {
280  $this->ctrl->redirectByClass($targetClass);
281  }
282  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:

◆ showHeader()

ilMailGUI::showHeader ( )
private

Definition at line 284 of file class.ilMailGUI.php.

References $DIC, ILIAS\Repository\ctrl(), ilUtil\getImagePath(), ILIAS\FileDelivery\http(), and ilMailFormGUI\MAIL_FORM_TYPE_NEW.

Referenced by executeCommand().

284  : void
285  {
286  global $DIC;
287 
288  $DIC['ilHelp']->setScreenIdComponent('mail');
289 
290  $this->tpl->loadStandardTemplate();
291  $this->tpl->setTitleIcon(ilUtil::getImagePath('standard/icon_mail.svg'));
292 
293  $this->ctrl->setParameterByClass(ilMailFolderGUI::class, 'mobj_id', $this->currentFolderId);
294  $DIC->tabs()->addTarget('fold', $this->ctrl->getLinkTargetByClass(ilMailFolderGUI::class));
295  $this->ctrl->clearParametersByClass(ilMailFormGUI::class);
296 
297  $this->ctrl->setParameterByClass(ilMailFormGUI::class, 'type', ilMailFormGUI::MAIL_FORM_TYPE_NEW);
298  $this->ctrl->setParameterByClass(ilMailFormGUI::class, 'mobj_id', $this->currentFolderId);
299  $DIC->tabs()->addTarget('compose', $this->ctrl->getLinkTargetByClass(ilMailFormGUI::class));
300  $this->ctrl->clearParametersByClass(ilMailFormGUI::class);
301 
302  $this->ctrl->setParameterByClass(ilContactGUI::class, 'mobj_id', $this->currentFolderId);
303  $DIC->tabs()->addTarget(
304  'mail_addressbook',
305  $this->ctrl->getLinkTargetByClass(ilContactGUI::class)
306  );
307  $this->ctrl->clearParametersByClass(ilContactGUI::class);
308 
309  $this->ctrl->setParameterByClass(
310  ilMailAttachmentGUI::class,
311  'mobj_id',
312  $this->currentFolderId
313  );
314  $DIC->tabs()->addTarget(
315  'mail_manage_attachments',
316  $this->ctrl->getLinkTargetByClass([self::class, ilMailAttachmentGUI::class])
317  );
318  $this->ctrl->clearParametersByClass(ilMailAttachmentGUI::class);
319 
320  if ($DIC->settings()->get('show_mail_settings', '0')) {
321  $this->ctrl->setParameterByClass(
322  ilMailOptionsGUI::class,
323  'mobj_id',
324  $this->currentFolderId
325  );
326  $DIC->tabs()->addTarget(
327  'options',
328  $this->ctrl->getLinkTargetByClass(ilMailOptionsGUI::class)
329  );
330  $this->ctrl->clearParametersByClass(ilMailOptionsGUI::class);
331  }
332 
333  match (strtolower($this->forwardClass)) {
334  strtolower(ilMailFormGUI::class) => $DIC->tabs()->setTabActive('compose'),
335  strtolower(ilContactGUI::class) => $DIC->tabs()->setTabActive('mail_addressbook'),
336  strtolower(ilMailOptionsGUI::class) => $DIC->tabs()->setTabActive('options'),
337  strtolower(ilMailAttachmentGUI::class) => $DIC->tabs()->setTabActive('mail_manage_attachments'),
338  default => $DIC->tabs()->setTabActive('fold'),
339  };
340 
341  if ($this->http->wrapper()->query()->has('message_sent')) {
342  $DIC->tabs()->setTabActive('fold');
343  }
344  }
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:22
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
final const MAIL_FORM_TYPE_NEW
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toggleExplorerNodeState()

ilMailGUI::toggleExplorerNodeState ( )
protected

Definition at line 346 of file class.ilMailGUI.php.

References ILIAS\Repository\user().

346  : void
347  {
348  $exp = new ilMailExplorer($this, $this->user->getId());
349  $exp->toggleExplorerNodeState();
350  }
+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

readonly ilCtrlInterface ilMailGUI::$ctrl
private

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

◆ $currentFolderId

int ilMailGUI::$currentFolderId = 0
private

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

◆ $forwardClass

string ilMailGUI::$forwardClass = ''
private

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

◆ $http

readonly GlobalHttpState ilMailGUI::$http
private

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

◆ $lng

readonly ilLanguage ilMailGUI::$lng
private

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

◆ $mbox

ilMailbox ilMailGUI::$mbox

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

◆ $refinery

readonly Refinery ilMailGUI::$refinery
private

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

◆ $tpl

readonly ilGlobalTemplateInterface ilMailGUI::$tpl
private

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

◆ $umail

ilMail ilMailGUI::$umail

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

◆ $user

readonly ilObjUser ilMailGUI::$user
private

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


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