ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
4require_once "Services/Mail/classes/class.ilMail.php";
5require_once 'Services/Mail/classes/class.ilMailFormCall.php';
6
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 $tpl, $ilCtrl, $lng, $rbacsystem, $ilErr, $ilUser;
36
37 $this->tpl = $tpl;
38 $this->ctrl = $ilCtrl;
39 $this->lng = $lng;
40
41 if(isset($_POST['mobj_id']) && (int)$_POST['mobj_id'])
42 {
43 $_GET['mobj_id'] = $_POST['mobj_id'];
44 }
45 $_GET['mobj_id'] = (int)$_GET['mobj_id'];
46
47 $this->ctrl->saveParameter($this, "mobj_id");
48 $this->lng->loadLanguageModule("mail");
49
50 $this->umail = new ilMail($ilUser->getId());
51
52 // CHECK HACK
53 if (!$rbacsystem->checkAccess('internal_mail', $this->umail->getMailObjectReferenceId()))
54 {
55 $ilErr->raiseError($this->lng->txt("permission_denied"), $ilErr->WARNING);
56 }
57 }
58
59 public function executeCommand()
60 {
61 if ($_GET["type"] == "search_res")
62 {
64
65 $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "searchResults");
66 $this->ctrl->redirectByClass("ilmailformgui");
67 }
68
69 if ($_GET["type"] == "attach")
70 {
72
73 $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "mailAttachment");
74 $this->ctrl->redirectByClass("ilmailformgui");
75 }
76
77 if ($_GET["type"] == "new")
78 {
79 $_SESSION['rcp_to'] = $_GET['rcp_to'];
80 if(!strlen($_SESSION['rcp_to']) && ($recipients = ilMailFormCall::getRecipients()))
81 {
82 $_SESSION['rcp_to'] = implode(',', $recipients);
84 }
85 $_SESSION['rcp_cc'] = $_GET['rcp_cc'];
86 $_SESSION['rcp_bcc'] = $_GET['rcp_bcc'];
87
89
90 $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "mailUser");
91 $this->ctrl->redirectByClass("ilmailformgui");
92 }
93
94 if ($_GET["type"] == "reply")
95 {
96 $_SESSION['mail_id'] = $_GET['mail_id'];
97 $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "replyMail");
98 $this->ctrl->redirectByClass("ilmailformgui");
99 }
100
101 if ($_GET["type"] == "read")
102 {
103 $_SESSION['mail_id'] = $_GET['mail_id'];
104 $this->ctrl->setParameterByClass("ilmailfoldergui", "cmd", "showMail");
105 $this->ctrl->redirectByClass("ilmailfoldergui");
106 }
107
108 if ($_GET["type"] == "deliverFile")
109 {
110 $_SESSION['mail_id'] = $_GET['mail_id'];
111 $_SESSION['filename'] = ($_POST["filename"] ? $_POST["filename"] : $_GET["filename"]);
112 $this->ctrl->setParameterByClass("ilmailfoldergui", "cmd", "deliverFile");
113 $this->ctrl->redirectByClass("ilmailfoldergui");
114 }
115
116 if ($_GET["type"] == "message_sent")
117 {
118 ilUtil::sendInfo($this->lng->txt('mail_message_send'), true);
119 $this->ctrl->redirectByClass("ilmailfoldergui");
120 }
121
122 if ($_GET["type"] == "role")
123 {
124 if (is_array($_POST['roles']))
125 {
126 $_SESSION['mail_roles'] = $_POST['roles'];
127 }
128 else if ($_GET["role"])
129 {
130 $_SESSION['mail_roles'] = array($_GET["role"]);
131 }
132
134
135 $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "mailRole");
136 $this->ctrl->redirectByClass("ilmailformgui");
137 }
138
139 if ($_GET["view"] == "my_courses")
140 {
141 $_SESSION['search_crs'] = $_GET['search_crs'];
142 $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "searchCoursesTo");
143 $this->ctrl->redirectByClass("ilmailformgui");
144 }
145
146 if (isset($_GET["viewmode"]))
147 {
148 ilSession::set(self::VIEWMODE_SESSION_KEY, $_GET["viewmode"]);
149 $this->ctrl->setCmd("setViewMode");
150 }
151
152 $this->forwardClass = $this->ctrl->getNextClass($this);
153
154 $this->showHeader();
155
156 if('tree' == ilSession::get(self::VIEWMODE_SESSION_KEY) &&
157 $this->ctrl->getCmd() != "showExplorer")
158 {
159 $this->showExplorer();
160 }
161
162 switch($this->forwardClass)
163 {
164 case 'ilmailformgui':
165 include_once 'Services/Mail/classes/class.ilMailFormGUI.php';
166
167 $this->ctrl->forwardCommand(new ilMailFormGUI());
168 break;
169
170 case 'ilcontactgui':
171 require_once 'Services/Contact/classes/class.ilContactGUI.php';
172 $this->tpl->setTitle($this->lng->txt('mail_addressbook'));
173 $this->ctrl->forwardCommand(new ilContactGUI());
174 break;
175
176 case 'ilmailoptionsgui':
177 include_once 'Services/Mail/classes/class.ilMailOptionsGUI.php';
178
179 $this->ctrl->forwardCommand(new ilMailOptionsGUI());
180 break;
181
182 case 'ilmailfoldergui':
183 include_once 'Services/Mail/classes/class.ilMailFolderGUI.php';
184 $this->ctrl->forwardCommand(new ilMailFolderGUI());
185 break;
186
187 default:
188 if (!($cmd = $this->ctrl->getCmd()))
189 {
190 $cmd = "setViewMode";
191 }
192
193 $this->$cmd();
194 break;
195
196 }
197 return true;
198 }
199
200 private function setViewMode()
201 {
202 if ($_GET["target"] == "")
203 {
204 $_GET["target"] = "ilmailfoldergui";
205 }
206
207 if($_GET['type'] == 'redirect_to_read')
208 {
209 $this->ctrl->setParameterByClass('ilMailFolderGUI', 'mail_id', (int)$_GET['mail_id']);
210 $this->ctrl->redirectByClass('ilMailFolderGUI', 'showMail');
211 }
212 else if ($_GET["type"] == "add_subfolder")
213 {
214 $this->ctrl->redirectByClass($_GET["target"], "addSubFolder");
215 }
216 else if ($_GET["type"] == "enter_folderdata")
217 {
218 $this->ctrl->redirectByClass($_GET["target"], "enterFolderData");
219 }
220 else if ($_GET["type"] == "confirmdelete_folderdata")
221 {
222 $this->ctrl->redirectByClass($_GET["target"], "confirmDeleteFolder");
223 }
224 else
225 {
226 $this->ctrl->redirectByClass($_GET["target"]);
227 }
228 }
229
230 private function showHeader()
231 {
232 global $ilMainMenu, $ilTabs, $ilHelp;
233
234 $ilHelp->setScreenIdComponent("mail");
235
236 $ilMainMenu->setActive("mail");
237
238 $this->tpl->getStandardTemplate();
239
240 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_mail.svg"));
241
242 // display infopanel if something happened
244
245 $ilTabs->addTarget('fold', $this->ctrl->getLinkTargetByClass('ilmailfoldergui'));
246 $this->ctrl->setParameterByClass('ilmailformgui', 'type', 'new');
247 $ilTabs->addTarget('compose', $this->ctrl->getLinkTargetByClass('ilmailformgui'));
248 $this->ctrl->clearParametersByClass('ilmailformgui');
249 $ilTabs->addTarget('mail_addressbook', $this->ctrl->getLinkTargetByClass('ilcontactgui'));
250 $ilTabs->addTarget('options', $this->ctrl->getLinkTargetByClass('ilmailoptionsgui'));
251
252 switch($this->forwardClass)
253 {
254 case 'ilmailformgui':
255 $ilTabs->setTabActive('compose');
256 break;
257
258 case 'ilcontactgui':
259 $ilTabs->setTabActive('mail_addressbook');
260 break;
261
262 case 'ilmailoptionsgui':
263 $ilTabs->setTabActive('options');
264 break;
265
266 case 'ilmailfoldergui':
267 default:
268 $ilTabs->setTabActive('fold');
269 break;
270
271 }
272 if(isset($_GET['message_sent'])) $ilTabs->setTabActive('fold');
273
274 if('tree' != ilSession::get(self::VIEWMODE_SESSION_KEY))
275 {
276 $tree_state = 'tree';
277 }
278 else
279 {
280 $tree_state = 'flat';
281 }
282
283 if($this->isMailDetailCommand($this->ctrl->getCmd()))
284 {
285 $this->ctrl->setParameter($this, 'mail_id', (int)$_GET['mail_id']);
286 $this->ctrl->setParameter($this, 'type', 'redirect_to_read');
287 }
288
289 $this->ctrl->setParameter($this, 'viewmode', $tree_state);
290 $this->tpl->setTreeFlatIcon($this->ctrl->getLinkTarget($this), $tree_state);
291
292 $this->ctrl->clearParameters($this);
293 $this->tpl->setCurrentBlock("tree_icons");
294 $this->tpl->parseCurrentBlock();
295 }
296
301 private function isMailDetailCommand($cmd)
302 {
303 return in_array(strtolower($cmd), array('showmail')) && isset($_GET['mail_id']) && (int)$_GET['mail_id'];
304 }
305
306 private function showExplorer()
307 {
308 global $ilUser;
309
310 require_once "Services/Mail/classes/class.ilMailExplorer.php";
311 $exp = new ilMailExplorer($this, "showExplorer", $ilUser->getId());
312 if (!$exp->handleCommand())
313 {
314 $this->tpl->setLeftNavContent($exp->getHTML());
315 }
316 }
317}
318
319?>
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
Class Mail Explorer class for explorer view for mailboxes.
static storeReferer($request_params)
static setRecipients(array $recipients)
isMailDetailCommand($cmd)
const VIEWMODE_SESSION_KEY
This class handles base functions for mail handling.
static set($a_var, $a_val)
Set a value.
static get($a_var)
Get a value.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static infoPanel($a_keep=true)
global $ilCtrl
Definition: ilias.php:18
global $ilErr
Definition: raiseError.php:16
$cmd
Definition: sahs_server.php:35
$ilUser
Definition: imgupload.php:18