ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilMailGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once "Services/Mail/classes/class.ilMail.php";
5 require_once 'Services/Mail/classes/class.ilMailFormCall.php';
6 
15 class ilMailGUI
16 {
20  const VIEWMODE_SESSION_KEY = 'mail_viewmode';
21 
22  private $tpl = null;
23  private $ctrl = null;
24  private $lng = null;
25  private $tabs_gui = null;
26 
27  private $umail = null;
28  private $exp = null;
29  private $output = null;
30  private $mtree = null;
31  private $forwardClass = null;
32 
33  public function __construct()
34  {
35  global $DIC;
36 
37  $this->tpl = $DIC->ui()->mainTemplate();
38  $this->ctrl = $DIC->ctrl();
39  $this->lng = $DIC->language();
40 
41  if (isset($_POST['mobj_id']) && (int) $_POST['mobj_id']) {
42  $_GET['mobj_id'] = $_POST['mobj_id'];
43  }
44  $_GET['mobj_id'] = (int) $_GET['mobj_id'];
45 
46  $this->ctrl->saveParameter($this, "mobj_id");
47  $this->lng->loadLanguageModule("mail");
48 
49  $this->umail = new ilMail($DIC->user()->getId());
50 
51  if (!$DIC->rbac()->system()->checkAccess('internal_mail', $this->umail->getMailObjectReferenceId())) {
52  $DIC['ilErr']->raiseError($this->lng->txt("permission_denied"), $DIC['ilErr']->WARNING);
53  }
54  }
55 
56  public function executeCommand()
57  {
58  if ($_GET["type"] == "search_res") {
60 
61  $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "searchResults");
62  $this->ctrl->redirectByClass("ilmailformgui");
63  }
64 
65  if ($_GET["type"] == "attach") {
67 
68  $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "mailAttachment");
69  $this->ctrl->redirectByClass("ilmailformgui");
70  }
71 
72  if ($_GET["type"] == "new") {
73  $_SESSION['rcp_to'] = $_GET['rcp_to'];
74  if (!strlen($_SESSION['rcp_to']) && ($recipients = ilMailFormCall::getRecipients())) {
75  $_SESSION['rcp_to'] = implode(',', $recipients);
77  }
78  $_SESSION['rcp_cc'] = $_GET['rcp_cc'];
79  $_SESSION['rcp_bcc'] = $_GET['rcp_bcc'];
80 
82 
83  $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "mailUser");
84  $this->ctrl->redirectByClass("ilmailformgui");
85  }
86 
87  if ($_GET["type"] == "reply") {
88  $_SESSION['mail_id'] = $_GET['mail_id'];
89  $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "replyMail");
90  $this->ctrl->redirectByClass("ilmailformgui");
91  }
92 
93  if ($_GET["type"] == "read") {
94  $_SESSION['mail_id'] = $_GET['mail_id'];
95  $this->ctrl->setParameterByClass("ilmailfoldergui", "cmd", "showMail");
96  $this->ctrl->redirectByClass("ilmailfoldergui");
97  }
98 
99  if ($_GET["type"] == "deliverFile") {
100  $_SESSION['mail_id'] = $_GET['mail_id'];
101  $_SESSION['filename'] = ($_POST["filename"] ? $_POST["filename"] : $_GET["filename"]);
102  $this->ctrl->setParameterByClass("ilmailfoldergui", "cmd", "deliverFile");
103  $this->ctrl->redirectByClass("ilmailfoldergui");
104  }
105 
106  if ($_GET["type"] == "message_sent") {
107  ilUtil::sendInfo($this->lng->txt('mail_message_send'), true);
108  $this->ctrl->redirectByClass("ilmailfoldergui");
109  }
110 
111  if ($_GET["type"] == "role") {
112  if (is_array($_POST['roles'])) {
113  $_SESSION['mail_roles'] = $_POST['roles'];
114  } elseif ($_GET["role"]) {
115  $_SESSION['mail_roles'] = array($_GET["role"]);
116  }
117 
119 
120  $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "mailRole");
121  $this->ctrl->redirectByClass("ilmailformgui");
122  }
123 
124  if ($_GET["view"] == "my_courses") {
125  $_SESSION['search_crs'] = $_GET['search_crs'];
126  $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "searchCoursesTo");
127  $this->ctrl->redirectByClass("ilmailformgui");
128  }
129 
130  if (isset($_GET["viewmode"])) {
131  ilSession::set(self::VIEWMODE_SESSION_KEY, $_GET["viewmode"]);
132  $this->ctrl->setCmd("setViewMode");
133  }
134 
135  $this->forwardClass = $this->ctrl->getNextClass($this);
136 
137  $this->showHeader();
138 
139  if ('tree' == ilSession::get(self::VIEWMODE_SESSION_KEY) &&
140  $this->ctrl->getCmd() != "showExplorer") {
141  $this->showExplorer();
142  }
143 
144  switch ($this->forwardClass) {
145  case 'ilmailformgui':
146  include_once 'Services/Mail/classes/class.ilMailFormGUI.php';
147 
148  $this->ctrl->forwardCommand(new ilMailFormGUI());
149  break;
150 
151  case 'ilcontactgui':
152  require_once 'Services/Contact/classes/class.ilContactGUI.php';
153  $this->tpl->setTitle($this->lng->txt('mail_addressbook'));
154  $this->ctrl->forwardCommand(new ilContactGUI());
155  break;
156 
157  case 'ilmailoptionsgui':
158  $this->tpl->setTitle($this->lng->txt('mail'));
159  include_once 'Services/Mail/classes/class.ilMailOptionsGUI.php';
160 
161  $this->ctrl->forwardCommand(new ilMailOptionsGUI());
162  break;
163 
164  case 'ilmailfoldergui':
165  include_once 'Services/Mail/classes/class.ilMailFolderGUI.php';
166  $this->ctrl->forwardCommand(new ilMailFolderGUI());
167  break;
168 
169  default:
170  if (!($cmd = $this->ctrl->getCmd())) {
171  $cmd = "setViewMode";
172  }
173 
174  $this->$cmd();
175  break;
176 
177  }
178  return true;
179  }
180 
181  private function setViewMode()
182  {
183  if ($_GET["target"] == "") {
184  $_GET["target"] = "ilmailfoldergui";
185  }
186 
187  if ($_GET['type'] == 'redirect_to_read') {
188  $this->ctrl->setParameterByClass('ilMailFolderGUI', 'mail_id', (int) $_GET['mail_id']);
189  $this->ctrl->redirectByClass('ilMailFolderGUI', 'showMail');
190  } elseif ($_GET["type"] == "add_subfolder") {
191  $this->ctrl->redirectByClass($_GET["target"], "addSubFolder");
192  } elseif ($_GET["type"] == "enter_folderdata") {
193  $this->ctrl->redirectByClass($_GET["target"], "enterFolderData");
194  } elseif ($_GET["type"] == "confirmdelete_folderdata") {
195  $this->ctrl->redirectByClass($_GET["target"], "confirmDeleteFolder");
196  } else {
197  $this->ctrl->redirectByClass($_GET["target"]);
198  }
199  }
200 
201  private function showHeader()
202  {
203  global $DIC;
204 
205  $DIC['ilHelp']->setScreenIdComponent("mail");
206  $DIC['ilMainMenu']->setActive("mail");
207 
208  $this->tpl->getStandardTemplate();
209 
210  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_mail.svg"));
211 
212  // display infopanel if something happened
214 
215  $DIC->tabs()->addTarget('fold', $this->ctrl->getLinkTargetByClass('ilmailfoldergui'));
216  $this->ctrl->setParameterByClass('ilmailformgui', 'type', 'new');
217  $DIC->tabs()->addTarget('compose', $this->ctrl->getLinkTargetByClass('ilmailformgui'));
218  $this->ctrl->clearParametersByClass('ilmailformgui');
219  $DIC->tabs()->addTarget('mail_addressbook', $this->ctrl->getLinkTargetByClass('ilcontactgui'));
220  $DIC->tabs()->addTarget('options', $this->ctrl->getLinkTargetByClass('ilmailoptionsgui'));
221 
222  switch ($this->forwardClass) {
223  case 'ilmailformgui':
224  $DIC->tabs()->setTabActive('compose');
225  break;
226 
227  case 'ilcontactgui':
228  $DIC->tabs()->setTabActive('mail_addressbook');
229  break;
230 
231  case 'ilmailoptionsgui':
232  $DIC->tabs()->setTabActive('options');
233  break;
234 
235  case 'ilmailfoldergui':
236  default:
237  $DIC->tabs()->setTabActive('fold');
238  break;
239  }
240 
241  if (isset($_GET['message_sent'])) {
242  $DIC->tabs()->setTabActive('fold');
243  }
244 
245  if ('tree' != ilSession::get(self::VIEWMODE_SESSION_KEY)) {
246  $tree_state = 'tree';
247  } else {
248  $tree_state = 'flat';
249  }
250 
251  if ($this->isMailDetailCommand($this->ctrl->getCmd())) {
252  $this->ctrl->setParameter($this, 'mail_id', (int) $_GET['mail_id']);
253  $this->ctrl->setParameter($this, 'type', 'redirect_to_read');
254  }
255 
256  $this->ctrl->setParameter($this, 'viewmode', $tree_state);
257  $this->tpl->setTreeFlatIcon($this->ctrl->getLinkTarget($this), $tree_state);
258 
259  $this->ctrl->clearParameters($this);
260  $this->tpl->setCurrentBlock("tree_icons");
261  $this->tpl->parseCurrentBlock();
262  }
263 
268  private function isMailDetailCommand($cmd)
269  {
270  return in_array(strtolower($cmd), array('showmail')) && isset($_GET['mail_id']) && (int) $_GET['mail_id'];
271  }
272 
273  private function showExplorer()
274  {
275  global $DIC;
276 
277  require_once "Services/Mail/classes/class.ilMailExplorer.php";
278  $exp = new ilMailExplorer($this, "showExplorer", $DIC->user()->getId());
279  if (!$exp->handleCommand()) {
280  $this->tpl->setLeftNavContent($exp->getHTML());
281  }
282  }
283 }
isMailDetailCommand($cmd)
$_SESSION["AccountId"]
global $DIC
Definition: saml.php:7
$_GET["client_id"]
static get($a_var)
Get a value.
static set($a_var, $a_val)
Set a value.
const VIEWMODE_SESSION_KEY
static storeReferer($request_params)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
Class Mail Explorer class for explorer view for mailboxes.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
This class handles base functions for mail handling.
static infoPanel($a_keep=true)
Create styles array
The data for the language used.
static setRecipients(array $recipients)
$_POST["username"]