ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilMailGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 require_once "Services/Mail/classes/class.ilMail.php";
25 require_once 'Services/Mail/classes/class.ilMailFormCall.php';
26 
35 class ilMailGUI
36 {
40  const VIEWMODE_SESSION_KEY = 'mail_viewmode';
41 
42  private $tpl = null;
43  private $ctrl = null;
44  private $lng = null;
45  private $tabs_gui = null;
46 
47  private $umail = null;
48  private $exp = null;
49  private $output = null;
50  private $mtree = null;
51  private $forwardClass = null;
52 
53  public function __construct()
54  {
55  global $tpl, $ilCtrl, $lng, $rbacsystem, $ilErr, $ilUser;
56 
57  $this->tpl = $tpl;
58  $this->ctrl = $ilCtrl;
59  $this->lng = $lng;
60 
61  if(isset($_POST['mobj_id']) && (int)$_POST['mobj_id'])
62  {
63  $_GET['mobj_id'] = $_POST['mobj_id'];
64  }
65 
66  $this->ctrl->saveParameter($this, "mobj_id");
67  $this->lng->loadLanguageModule("mail");
68 
69  $this->umail = new ilMail($ilUser->getId());
70 
71  // CHECK HACK
72  if (!$rbacsystem->checkAccess("mail_visible", $this->umail->getMailObjectReferenceId()))
73  {
74  $ilErr->raiseError($this->lng->txt("permission_denied"), $ilErr->WARNING);
75  }
76  }
77 
78  public function executeCommand()
79  {
80  global $ilUser;
81 
82  // Check for incomplete profile
83  if($ilUser->getProfileIncomplete())
84  {
85  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
86  }
87 
88  // check whether password of user have to be changed
89  // due to first login or password of user is expired
90  if( $ilUser->isPasswordChangeDemanded() || $ilUser->isPasswordExpired() )
91  {
92  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
93  }
94 
95  if ($_GET["type"] == "search_res")
96  {
97  $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "searchResults");
98  $this->ctrl->redirectByClass("ilmailformgui");
99  }
100 
101  if ($_GET["type"] == "attach")
102  {
104 
105  $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "mailAttachment");
106  $this->ctrl->redirectByClass("ilmailformgui");
107  }
108 
109  if ($_GET["type"] == "new")
110  {
111  $_SESSION['rcp_to'] = $_GET['rcp_to'];
112  $_SESSION['rcp_cc'] = $_GET['rcp_cc'];
113  $_SESSION['rcp_bcc'] = $_GET['rcp_bcc'];
114 
116 
117  $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "mailUser");
118  $this->ctrl->redirectByClass("ilmailformgui");
119  }
120 
121  if ($_GET["type"] == "reply")
122  {
123  $_SESSION['mail_id'] = $_GET['mail_id'];
124  $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "replyMail");
125  $this->ctrl->redirectByClass("ilmailformgui");
126  }
127 
128  if ($_GET["type"] == "read")
129  {
130  $_SESSION['mail_id'] = $_GET['mail_id'];
131  $this->ctrl->setParameterByClass("ilmailfoldergui", "cmd", "showMail");
132  $this->ctrl->redirectByClass("ilmailfoldergui");
133  }
134 
135  if ($_GET["type"] == "deliverFile")
136  {
137  $_SESSION['mail_id'] = $_GET['mail_id'];
138  $_SESSION['filename'] = ($_POST["filename"] ? $_POST["filename"] : $_GET["filename"]);
139  $this->ctrl->setParameterByClass("ilmailfoldergui", "cmd", "deliverFile");
140  $this->ctrl->redirectByClass("ilmailfoldergui");
141  }
142 
143  if ($_GET["type"] == "message_sent")
144  {
145  ilUtil::sendInfo($this->lng->txt('mail_message_send'), true);
146  $this->ctrl->redirectByClass("ilmailfoldergui");
147  }
148 
149  if ($_GET["type"] == "role")
150  {
151  if (is_array($_POST['roles']))
152  {
153  $_SESSION['mail_roles'] = $_POST['roles'];
154  }
155  else if ($_GET["role"])
156  {
157  $_SESSION['mail_roles'] = array($_GET["role"]);
158  }
159 
161 
162  $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "mailRole");
163  $this->ctrl->redirectByClass("ilmailformgui");
164  }
165 
166  if ($_GET["view"] == "my_courses")
167  {
168  $_SESSION['search_crs'] = $_GET['search_crs'];
169  $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "searchCoursesTo");
170  $this->ctrl->redirectByClass("ilmailformgui");
171  }
172 
173  if (isset($_GET["viewmode"]))
174  {
176  $this->ctrl->setCmd("setViewMode");
177  }
178 
179  $this->forwardClass = $this->ctrl->getNextClass($this);
180  if ($this->ctrl->getCmd() != "showMenu" && $this->ctrl->getCmd() != "refresh")
181  {
182  $this->showHeader();
183  }
184 
185  switch($this->forwardClass)
186  {
187  case 'ilmailmenugui':
188  include_once 'Services/Mail/classes/class.ilMailMenuGUI.php';
189 
190  $this->ctrl->forwardCommand(new ilMailMenuGUI());
191  break;
192 
193  case 'ilmailformgui':
194  include_once 'Services/Mail/classes/class.ilMailFormGUI.php';
195 
196  $this->ctrl->forwardCommand(new ilMailFormGUI());
197  break;
198 
199  case 'ilmailaddressbookgui':
200  include_once 'Services/Contact/classes/class.ilMailAddressbookGUI.php';
201 
202  $this->ctrl->forwardCommand(new ilMailAddressbookGUI());
203  break;
204 
205  case 'ilmailoptionsgui':
206  include_once 'Services/Mail/classes/class.ilMailOptionsGUI.php';
207 
208  $this->ctrl->forwardCommand(new ilMailOptionsGUI());
209  break;
210 
211  case 'ilmailfoldergui':
212  include_once 'Services/Mail/classes/class.ilMailFolderGUI.php';
213  $this->ctrl->forwardCommand(new ilMailFolderGUI());
214  break;
215 
216  default:
217  if (!($cmd = $this->ctrl->getCmd()))
218  {
219  $cmd = "setViewMode";
220  }
221 
222  $this->$cmd();
223  break;
224 
225  }
226  return true;
227  }
228 
229  private function setViewMode()
230  {
231  if ($_GET["target"] == "")
232  {
233  $_GET["target"] = "ilmailfoldergui";
234  }
235  if(isset($_SESSION[self::VIEWMODE_SESSION_KEY]) && 'tree' == $_SESSION[self::VIEWMODE_SESSION_KEY])
236  {
237  include_once("Services/Frameset/classes/class.ilFramesetGUI.php");
238  $fs_gui = new ilFramesetGUI();
239  $fs_gui->setFramesetTitle($this->lng->txt("mail"));
240  $fs_gui->setMainFrameName("content");
241  $fs_gui->setSideFrameName("tree");
242 
243  $this->ctrl->setParameter($this, "cmd", "showMenu");
244  $this->ctrl->setParameter($this, "mexpand", 1);
245  $fs_gui->setSideFrameSource($this->ctrl->getLinkTarget($this));
246  $this->ctrl->clearParameters($this);
247 
248  if ($_GET["type"] == "add_subfolder")
249  {
250  $fs_gui->setMainFrameSource($this->ctrl->getLinkTargetByClass($_GET["target"], "addSubFolder"));
251  }
252  else if ($_GET["type"] == "enter_folderdata")
253  {
254  $fs_gui->setMainFrameSource($this->ctrl->getLinkTargetByClass($_GET["target"], "enterFolderData"));
255  }
256  else if ($_GET["type"] == "confirmdelete_folderdata")
257  {
258  $fs_gui->setMainFrameSource($this->ctrl->getLinkTargetByClass($_GET["target"], "confirmDeleteFolder"));
259  }
260  else
261  {
262  $fs_gui->setMainFrameSource($this->ctrl->getLinkTargetByClass($_GET["target"]));
263  }
264  $fs_gui->show();
265  }
266  else
267  {
268 //echo "-".$_GET["target"]."-";
269  $this->ctrl->redirectByClass($_GET["target"]);
270  }
271  }
272 
273  public function refresh()
274  {
275  $this->showMenu();
276  }
277 
278  private function showHeader()
279  {
280  global $ilMainMenu, $ilTabs;
281 
282  $ilMainMenu->setActive("mail");
283 
284 // $this->tpl->getStandardTemplate();
285  $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
286  $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
287  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_mail_b.gif"));
288 
289  // display infopanel if something happened
291 
292  $ilTabs->addTarget('fold', $this->ctrl->getLinkTargetByClass('ilmailfoldergui'));
293  $this->ctrl->setParameterByClass('ilmailformgui', 'type', 'new');
294  $ilTabs->addTarget('compose', $this->ctrl->getLinkTargetByClass('ilmailformgui'));
295  $this->ctrl->clearParametersByClass('ilmailformgui');
296  $ilTabs->addTarget('mail_addressbook', $this->ctrl->getLinkTargetByClass('ilmailaddressbookgui'));
297  $ilTabs->addTarget('options', $this->ctrl->getLinkTargetByClass('ilmailoptionsgui'));
298 
299  switch($this->forwardClass)
300  {
301  case 'ilmailformgui':
302  $ilTabs->setTabActive('compose');
303  break;
304 
305  case 'ilmailaddressbookgui':
306  $ilTabs->setTabActive('mail_addressbook');
307  break;
308 
309  case 'ilmailoptionsgui':
310  $ilTabs->setTabActive('options');
311  break;
312 
313  case 'ilmailfoldergui':
314  default:
315  $ilTabs->setTabActive('fold');
316  break;
317 
318  }
319  if(isset($_GET['message_sent'])) $ilTabs->setTabActive('fold');
320 
321  if(!isset($_SESSION[self::VIEWMODE_SESSION_KEY]) || 'tree' != $_SESSION[self::VIEWMODE_SESSION_KEY])
322  {
323  $this->ctrl->setParameter($this, 'viewmode', 'tree');
324  $this->tpl->setTreeFlatIcon($this->ctrl->getLinkTarget($this), 'tree');
325  }
326  else
327  {
328  $this->ctrl->setParameter($this, 'viewmode', 'flat');
329  $this->tpl->setTreeFlatIcon($this->ctrl->getLinkTarget($this), 'flat');
330  }
331  $this->ctrl->clearParameters($this);
332  $this->tpl->setCurrentBlock("tree_icons");
333  $this->tpl->parseCurrentBlock();
334  }
335 
336  private function showMenu()
337  {
338  global $ilUser;
339 
340  require_once "Services/Mail/classes/class.ilMailExplorer.php";
341 
342  $this->tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
343  $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.gif", false));
344 
345  $this->exp = new ilMailExplorer($this->ctrl->getLinkTargetByClass("ilmailfoldergui"),$ilUser->getId());
346  $this->exp->setTargetGet("mobj_id");
347 
348  if ($_GET["mexpand"] == "")
349  {
350  $this->mtree = new ilTree($ilUser->getId());
351  $this->mtree->setTableNames('mail_tree','mail_obj_data');
352  $expanded = $this->mtree->readRootId();
353  }
354  else
355  $expanded = $_GET["mexpand"];
356 
357  $this->exp->setExpand($expanded);
358 
359  //build html-output
360  $this->exp->setOutput(0);
361  $this->output = $this->exp->getOutput();
362 
363  $this->tpl->setCurrentBlock("content");
364  $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("mail_folders"));
365  $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
366  $this->tpl->setVariable("EXPLORER",$this->output);
367  $this->ctrl->setParameter($this, "mexpand", $_GET["mexpand"]);
368  $this->tpl->setVariable("ACTION", $this->ctrl->getFormAction($this, 'showMenu'));
369  $this->tpl->parseCurrentBlock();
370 
371  $this->tpl->show(false);
372  }
373 }
374 
375 ?>