ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilMailGUI Class Reference
+ Collaboration diagram for ilMailGUI:

Public Member Functions

 __construct ()
 ilMailGUI constructor. More...
 
 executeCommand ()
 

Data Fields

const VIEWMODE_SESSION_KEY = 'mail_viewmode'
 
 $umail
 
 $mbox
 

Protected Member Functions

 initFolder ()
 

Private Member Functions

 setViewMode ()
 
 showHeader ()
 
 isMailDetailCommand (string $cmd)
 
 showExplorer ()
 

Private Attributes

 $tpl
 
 $ctrl
 
 $lng
 
 $forwardClass = ''
 
 $httpRequest
 
 $currentFolderId = 0
 
 $user
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilMailGUI::__construct ( )

ilMailGUI constructor.

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

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

48  {
49  global $DIC;
50 
51  $this->tpl = $DIC->ui()->mainTemplate();
52  $this->ctrl = $DIC->ctrl();
53  $this->lng = $DIC->language();
54  $this->user = $DIC->user();
55  $this->httpRequest = $DIC->http()->request();
56 
57  $this->lng->loadLanguageModule('mail');
58 
59  $this->mbox = new ilMailbox($this->user->getId());
60  $this->umail = new \ilMail($this->user->getId());
61  if (!$DIC->rbac()->system()->checkAccess('internal_mail', $this->umail->getMailObjectReferenceId())) {
62  $DIC['ilErr']->raiseError($this->lng->txt("permission_denied"), $DIC['ilErr']->WARNING);
63  }
64 
65  $this->initFolder();
66  }
global $DIC
Definition: saml.php:7
user()
Definition: user.php:4
Mail Box class Base class for creating and handling mail boxes.
+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilMailGUI::executeCommand ( )

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

References $type, ilSession\get(), ilMailFormCall\getRecipients(), ilSession\set(), ilMailFormCall\setRecipients(), showExplorer(), showHeader(), ilMailFormCall\storeReferer(), and ilUtil\stripSlashes().

87  {
88  $type = $this->httpRequest->getQueryParams()['type'] ?? '';
89  $mailId = (int) ($this->httpRequest->getQueryParams()['mail_id'] ?? 0);
90 
91  $this->ctrl->setParameterByClass('ilmailformgui', 'mobj_id', $this->currentFolderId);
92  $this->ctrl->setParameterByClass('ilmailfoldergui', 'mobj_id', $this->currentFolderId);
93 
94  if ('search_res' === $type) {
95  \ilMailFormCall::storeReferer($this->httpRequest->getQueryParams());
96  $this->ctrl->redirectByClass('ilmailformgui', 'searchResults');
97  } elseif ('attach' === $type) {
98  ilMailFormCall::storeReferer($this->httpRequest->getQueryParams());
99  $this->ctrl->redirectByClass('ilmailformgui', 'mailAttachment');
100  } elseif ('new' === $type) {
101  $to = $this->httpRequest->getQueryParams()['rcp_to'] ?? '';
102  \ilSession::set('rcp_to', \ilUtil::stripSlashes($to));
103  if (!strlen(\ilSession::get('rcp_to')) && ($recipients = \ilMailFormCall::getRecipients())) {
104  \ilSession::set('rcp_to', implode(',', $recipients));
106  }
107 
108  $cc = $this->httpRequest->getQueryParams()['rcp_cc'] ?? '';
109  $bcc = $this->httpRequest->getQueryParams()['rcp_bcc'] ?? '';
110  \ilSession::set('rcp_cc', \ilUtil::stripSlashes($cc));
111  \ilSession::set('rcp_bcc', \ilUtil::stripSlashes($bcc));
112 
113  ilMailFormCall::storeReferer($this->httpRequest->getQueryParams());
114  $this->ctrl->redirectByClass('ilmailformgui', 'mailUser');
115  } elseif ('reply' === $type) {
116  \ilSession::set('mail_id', $mailId);
117  $this->ctrl->redirectByClass('ilmailformgui', 'replyMail');
118  } elseif ('read' === $type) {
119  \ilSession::set('mail_id', $mailId);
120  $this->ctrl->redirectByClass('ilmailfoldergui', 'showMail');
121  } elseif ('deliverFile' === $type) {
122  \ilSession::set('mail_id', $mailId);
123 
124  $fileName = '';
125  if (isset($this->httpRequest->getParsedBody()['filename'])) {
126  $fileName = $this->httpRequest->getParsedBody()['filename'];
127  } elseif (isset($this->httpRequest->getQueryParams()['filename'])) {
128  $fileName = $this->httpRequest->getQueryParams()['filename'];
129  }
130  \ilSession::set('filename', \ilUtil::stripSlashes($fileName));
131  ;
132  $this->ctrl->redirectByClass('ilmailfoldergui', 'deliverFile');
133  } elseif ('message_sent' === $type) {
134  \ilUtil::sendSuccess($this->lng->txt('mail_message_send'), true);
135  $this->ctrl->redirectByClass('ilmailfoldergui');
136  } elseif ('role' === $type) {
137  $roles = $this->httpRequest->getParsedBody()['roles'] ?? [];
138  if (is_array($roles) && count($roles) > 0) {
139  \ilSession::set('mail_roles', $roles);
140  } elseif (isset($this->httpRequest->getQueryParams()['role'])) {
141  \ilSession::set('mail_roles', [$this->httpRequest->getQueryParams()['role']]);
142  }
143 
144  \ilMailFormCall::storeReferer($this->httpRequest->getQueryParams());
145  $this->ctrl->redirectByClass('ilmailformgui', 'mailRole');
146  }
147 
148  if ('my_courses' === $this->httpRequest->getQueryParams()['view']) {
149  \ilSession::set('search_crs', \ilUtil::stripSlashes($this->httpRequest->getQueryParams()['search_crs']));
150  $this->ctrl->redirectByClass('ilmailformgui', 'searchCoursesTo');
151  }
152 
153  if (isset($this->httpRequest->getQueryParams()['viewmode'])) {
154  \ilSession::set(self::VIEWMODE_SESSION_KEY, $this->httpRequest->getQueryParams()['viewmode']);
155  $this->ctrl->setCmd('setViewMode');
156  }
157 
158  $this->forwardClass = $this->ctrl->getNextClass($this);
159  $this->showHeader();
160 
161  if ('tree' === ilSession::get(self::VIEWMODE_SESSION_KEY) && $this->ctrl->getCmd() !== 'showExplorer') {
162  $this->showExplorer();
163  }
164 
165  switch ($this->forwardClass) {
166  case 'ilmailformgui':
167  $this->ctrl->forwardCommand(new \ilMailFormGUI());
168  break;
169 
170  case 'ilcontactgui':
171  $this->tpl->setTitle($this->lng->txt('mail_addressbook'));
172  $this->ctrl->forwardCommand(new \ilContactGUI());
173  break;
174 
175  case 'ilmailoptionsgui':
176  $this->tpl->setTitle($this->lng->txt('mail'));
177  $this->ctrl->forwardCommand(new \ilMailOptionsGUI());
178  break;
179 
180  case 'ilmailfoldergui':
181  $this->ctrl->forwardCommand(new \ilMailFolderGUI());
182  break;
183 
184  default:
185  if (!($cmd = $this->ctrl->getCmd()) || !method_exists($this, $cmd)) {
186  $cmd = 'setViewMode';
187  }
188 
189  $this->{$cmd}();
190  break;
191  }
192  }
$type
static get($a_var)
Get a value.
static set($a_var, $a_val)
Set a value.
static storeReferer($request_params)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static setRecipients(array $recipients)
+ Here is the call graph for this function:

◆ initFolder()

ilMailGUI::initFolder ( )
protected

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

Referenced by __construct().

72  {
73  $folderId = $this->httpRequest->getParsedBody()['mobj_id'] ?? 0;
74  if (!is_numeric($folderId) || 0 == $folderId) {
75  $folderId = $this->httpRequest->getQueryParams()['mobj_id'] ?? 0;
76  }
77  if (!is_numeric($folderId) || 0 == $folderId || !$this->mbox->isOwnedFolder($folderId)) {
78  $folderId = $this->mbox->getInboxFolder();
79  }
80  $this->currentFolderId = (int) $folderId;
81  }
+ Here is the caller graph for this function:

◆ isMailDetailCommand()

ilMailGUI::isMailDetailCommand ( string  $cmd)
private
Parameters
string$cmd
Returns
bool

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

Referenced by showHeader().

303  : bool
304  {
305  $mailId = $this->httpRequest->getQueryParams()['mail_id'] ?? 0;
306  if (!is_numeric($mailId) || 0 == $mailId) {
307  return false;
308  }
309 
310  return in_array(strtolower($cmd), ['showmail']);
311  }
+ Here is the caller graph for this function:

◆ setViewMode()

ilMailGUI::setViewMode ( )
private

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

References $type.

198  {
199  $targetClass = $this->httpRequest->getQueryParams()['target'] ?? 'ilmailfoldergui';
200  $type = $this->httpRequest->getQueryParams()['type'] ?? '';
201  $mailId = (int) ($this->httpRequest->getQueryParams()['mail_id'] ?? 0);
202 
203  $this->ctrl->setParameterByClass($targetClass, 'mobj_id', $this->currentFolderId);
204 
205  if ('redirect_to_read' === $type) {
206  $this->ctrl->setParameterByClass(
207  'ilMailFolderGUI',
208  'mail_id',
209  $mailId
210  );
211  $this->ctrl->setParameterByClass('ilmailfoldergui', 'mobj_id', $this->currentFolderId);
212  $this->ctrl->redirectByClass('ilMailFolderGUI', 'showMail');
213  } elseif ('add_subfolder' === $type) {
214  $this->ctrl->redirectByClass($targetClass, 'addSubFolder');
215  } elseif ('enter_folderdata' === $type) {
216  $this->ctrl->redirectByClass($targetClass, 'enterFolderData');
217  } elseif ('confirmdelete_folderdata' === $type) {
218  $this->ctrl->redirectByClass($targetClass, 'confirmDeleteFolder');
219  } else {
220  $this->ctrl->redirectByClass($targetClass);
221  }
222  }
$type

◆ showExplorer()

ilMailGUI::showExplorer ( )
private

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

References user().

Referenced by executeCommand().

317  {
318  $exp = new \ilMailExplorer($this, 'showExplorer', $this->user->getId());
319  if (!$exp->handleCommand()) {
320  $this->tpl->setLeftNavContent($exp->getHTML());
321  }
322  }
user()
Definition: user.php:4
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showHeader()

ilMailGUI::showHeader ( )
private

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

References $DIC, ilSession\get(), ilUtil\getImagePath(), ilUtil\infoPanel(), and isMailDetailCommand().

Referenced by executeCommand().

228  {
229  global $DIC;
230 
231  $DIC['ilHelp']->setScreenIdComponent("mail");
232  $DIC['ilMainMenu']->setActive("mail");
233 
234  $this->tpl->getStandardTemplate();
235  $this->tpl->setTitleIcon(\ilUtil::getImagePath("icon_mail.svg"));
236 
238 
239  $this->ctrl->setParameterByClass('ilmailfoldergui', 'mobj_id', $this->currentFolderId);
240  $DIC->tabs()->addTarget('fold', $this->ctrl->getLinkTargetByClass('ilmailfoldergui'));
241  $this->ctrl->clearParametersByClass('ilmailformgui');
242 
243  $this->ctrl->setParameterByClass('ilmailformgui', 'type', 'new');
244  $this->ctrl->setParameterByClass('ilmailformgui', 'mobj_id', $this->currentFolderId);
245  $DIC->tabs()->addTarget('compose', $this->ctrl->getLinkTargetByClass('ilmailformgui'));
246  $this->ctrl->clearParametersByClass('ilmailformgui');
247 
248  $this->ctrl->setParameterByClass('ilcontactgui', 'mobj_id', $this->currentFolderId);
249  $DIC->tabs()->addTarget('mail_addressbook', $this->ctrl->getLinkTargetByClass('ilcontactgui'));
250  $this->ctrl->clearParametersByClass('ilcontactgui');
251 
252  if ($DIC->settings()->get('show_mail_settings')) {
253  $this->ctrl->setParameterByClass('ilmailoptionsgui', 'mobj_id', $this->currentFolderId);
254  $DIC->tabs()->addTarget('options', $this->ctrl->getLinkTargetByClass('ilmailoptionsgui'));
255  $this->ctrl->clearParametersByClass('ilmailoptionsgui');
256  }
257 
258  switch ($this->forwardClass) {
259  case 'ilmailformgui':
260  $DIC->tabs()->setTabActive('compose');
261  break;
262 
263  case 'ilcontactgui':
264  $DIC->tabs()->setTabActive('mail_addressbook');
265  break;
266 
267  case 'ilmailoptionsgui':
268  $DIC->tabs()->setTabActive('options');
269  break;
270 
271  case 'ilmailfoldergui':
272  default:
273  $DIC->tabs()->setTabActive('fold');
274  break;
275  }
276 
277  if (isset($this->httpRequest->getQueryParams()['message_sent'])) {
278  $DIC->tabs()->setTabActive('fold');
279  }
280 
281  $folderTreeState = 'flat';
282  if ('tree' !== ilSession::get(self::VIEWMODE_SESSION_KEY)) {
283  $folderTreeState = 'tree';
284  }
285 
286  if ($this->isMailDetailCommand($this->ctrl->getCmd())) {
287  $this->ctrl->setParameter($this, 'mail_id', (int) $this->httpRequest->getQueryParams()['mail_id']);
288  $this->ctrl->setParameter($this, 'type', 'redirect_to_read');
289  }
290  $this->ctrl->setParameter($this, 'mobj_id', $this->currentFolderId);
291  $this->ctrl->setParameter($this, 'viewmode', $folderTreeState);
292  $this->tpl->setTreeFlatIcon($this->ctrl->getLinkTarget($this), $folderTreeState);
293  $this->ctrl->clearParameters($this);
294 
295  $this->tpl->setCurrentBlock('tree_icons');
296  $this->tpl->parseCurrentBlock();
297  }
global $DIC
Definition: saml.php:7
static get($a_var)
Get a value.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static infoPanel($a_keep=true)
isMailDetailCommand(string $cmd)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilMailGUI::$ctrl
private

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

◆ $currentFolderId

ilMailGUI::$currentFolderId = 0
private

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

◆ $forwardClass

ilMailGUI::$forwardClass = ''
private

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

◆ $httpRequest

ilMailGUI::$httpRequest
private

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

◆ $lng

ilMailGUI::$lng
private

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

◆ $mbox

ilMailGUI::$mbox

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

◆ $tpl

ilMailGUI::$tpl
private

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

◆ $umail

ilMailGUI::$umail

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

◆ $user

ilMailGUI::$user
private

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

◆ VIEWMODE_SESSION_KEY

const ilMailGUI::VIEWMODE_SESSION_KEY = 'mail_viewmode'

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