ILIAS  Release_4_1_x_branch Revision 61804
 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 {
37  private $tpl = null;
38  private $ctrl = null;
39  private $lng = null;
40  private $tabs_gui = null;
41 
42  private $umail = null;
43  private $exp = null;
44  private $output = null;
45  private $mtree = null;
46  private $forwardClass = null;
47 
48  public function __construct()
49  {
50  global $tpl, $ilCtrl, $lng, $rbacsystem, $ilErr, $ilUser;
51 
52  $this->tpl = $tpl;
53  $this->ctrl = $ilCtrl;
54  $this->lng = $lng;
55 
56  if(isset($_POST['mobj_id']) && (int)$_POST['mobj_id'])
57  {
58  $_GET['mobj_id'] = $_POST['mobj_id'];
59  }
60 
61  $this->ctrl->saveParameter($this, "mobj_id");
62  $this->lng->loadLanguageModule("mail");
63 
64  $this->umail = new ilMail($ilUser->getId());
65 
66  // CHECK HACK
67  if (!$rbacsystem->checkAccess("mail_visible", $this->umail->getMailObjectReferenceId()))
68  {
69  $ilErr->raiseError($this->lng->txt("permission_denied"), $ilErr->WARNING);
70  }
71  }
72 
73  public function executeCommand()
74  {
75  global $ilUser;
76 
77  // Check for incomplete profile
78  if($ilUser->getProfileIncomplete())
79  {
80  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
81  }
82 
83  // check whether password of user have to be changed
84  // due to first login or password of user is expired
85  if( $ilUser->isPasswordChangeDemanded() || $ilUser->isPasswordExpired() )
86  {
87  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
88  }
89 
90  if ($_GET["type"] == "search_res")
91  {
92  $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "searchResults");
93  $this->ctrl->redirectByClass("ilmailformgui");
94  }
95 
96  if ($_GET["type"] == "attach")
97  {
99 
100  $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "mailAttachment");
101  $this->ctrl->redirectByClass("ilmailformgui");
102  }
103 
104  if ($_GET["type"] == "new")
105  {
106  $_SESSION['rcp_to'] = $_GET['rcp_to'];
107  $_SESSION['rcp_cc'] = $_GET['rcp_cc'];
108  $_SESSION['rcp_bcc'] = $_GET['rcp_bcc'];
109 
111 
112  $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "mailUser");
113  $this->ctrl->redirectByClass("ilmailformgui");
114  }
115 
116  if ($_GET["type"] == "reply")
117  {
118  $_SESSION['mail_id'] = $_GET['mail_id'];
119  $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "replyMail");
120  $this->ctrl->redirectByClass("ilmailformgui");
121  }
122 
123  if ($_GET["type"] == "read")
124  {
125  $_SESSION['mail_id'] = $_GET['mail_id'];
126  $this->ctrl->setParameterByClass("ilmailfoldergui", "cmd", "showMail");
127  $this->ctrl->redirectByClass("ilmailfoldergui");
128  }
129 
130  if ($_GET["type"] == "deliverFile")
131  {
132  $_SESSION['mail_id'] = $_GET['mail_id'];
133  $_SESSION['filename'] = ($_POST["filename"] ? $_POST["filename"] : $_GET["filename"]);
134  $this->ctrl->setParameterByClass("ilmailfoldergui", "cmd", "deliverFile");
135  $this->ctrl->redirectByClass("ilmailfoldergui");
136  }
137 
138  if ($_GET["type"] == "message_sent")
139  {
140  ilUtil::sendInfo($this->lng->txt('mail_message_send'), true);
141  $this->ctrl->redirectByClass("ilmailfoldergui");
142  }
143 
144  if ($_GET["type"] == "role")
145  {
146  if (is_array($_POST['roles']))
147  {
148  $_SESSION['mail_roles'] = $_POST['roles'];
149  }
150  else if ($_GET["role"])
151  {
152  $_SESSION['mail_roles'] = array($_GET["role"]);
153  }
154 
156 
157  $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "mailRole");
158  $this->ctrl->redirectByClass("ilmailformgui");
159  }
160 
161  if ($_GET["view"] == "my_courses")
162  {
163  $_SESSION['search_crs'] = $_GET['search_crs'];
164  $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "searchCoursesTo");
165  $this->ctrl->redirectByClass("ilmailformgui");
166  }
167 
168  if (isset($_GET["viewmode"]))
169  {
170  $_SESSION["viewmode"] = $_GET["viewmode"];
171  $this->ctrl->setCmd("setViewMode");
172  }
173 
174  $this->forwardClass = $this->ctrl->getNextClass($this);
175  if ($this->ctrl->getCmd() != "showMenu" && $this->ctrl->getCmd() != "refresh")
176  {
177  $this->showHeader();
178  }
179 
180  switch($this->forwardClass)
181  {
182  case 'ilmailmenugui':
183  include_once 'Services/Mail/classes/class.ilMailMenuGUI.php';
184 
185  $this->ctrl->forwardCommand(new ilMailMenuGUI());
186  break;
187 
188  case 'ilmailformgui':
189  include_once 'Services/Mail/classes/class.ilMailFormGUI.php';
190 
191  $this->ctrl->forwardCommand(new ilMailFormGUI());
192  break;
193 
194  case 'ilmailaddressbookgui':
195  include_once 'Services/Contact/classes/class.ilMailAddressbookGUI.php';
196 
197  $this->ctrl->forwardCommand(new ilMailAddressbookGUI());
198  break;
199 
200  case 'ilmailoptionsgui':
201  include_once 'Services/Mail/classes/class.ilMailOptionsGUI.php';
202 
203  $this->ctrl->forwardCommand(new ilMailOptionsGUI());
204  break;
205 
206  case 'ilmailfoldergui':
207  include_once 'Services/Mail/classes/class.ilMailFolderGUI.php';
208  $this->ctrl->forwardCommand(new ilMailFolderGUI());
209  break;
210 
211  default:
212  if (!($cmd = $this->ctrl->getCmd()))
213  {
214  $cmd = "setViewMode";
215  }
216 
217  $this->$cmd();
218  break;
219 
220  }
221  return true;
222  }
223 
224  private function setViewMode()
225  {
226  if ($_GET["target"] == "")
227  {
228  $_GET["target"] = "ilmailfoldergui";
229  }
230  if ($_SESSION["viewmode"] == "tree")
231  {
232  include_once("Services/Frameset/classes/class.ilFramesetGUI.php");
233  $fs_gui = new ilFramesetGUI();
234  $fs_gui->setFramesetTitle($this->lng->txt("mail"));
235  $fs_gui->setMainFrameName("content");
236  $fs_gui->setSideFrameName("tree");
237 
238  $this->ctrl->setParameter($this, "cmd", "showMenu");
239  $this->ctrl->setParameter($this, "mexpand", 1);
240  $fs_gui->setSideFrameSource($this->ctrl->getLinkTarget($this));
241  $this->ctrl->clearParameters($this);
242 
243  if ($_GET["type"] == "add_subfolder")
244  {
245  $fs_gui->setMainFrameSource($this->ctrl->getLinkTargetByClass($_GET["target"], "addSubFolder"));
246  }
247  else if ($_GET["type"] == "enter_folderdata")
248  {
249  $fs_gui->setMainFrameSource($this->ctrl->getLinkTargetByClass($_GET["target"], "enterFolderData"));
250  }
251  else if ($_GET["type"] == "confirmdelete_folderdata")
252  {
253  $fs_gui->setMainFrameSource($this->ctrl->getLinkTargetByClass($_GET["target"], "confirmDeleteFolder"));
254  }
255  else
256  {
257  $fs_gui->setMainFrameSource($this->ctrl->getLinkTargetByClass($_GET["target"]));
258  }
259  $fs_gui->show();
260  }
261  else
262  {
263 //echo "-".$_GET["target"]."-";
264  $this->ctrl->redirectByClass($_GET["target"]);
265  }
266  }
267 
268  public function refresh()
269  {
270  $this->showMenu();
271  }
272 
273  private function showHeader()
274  {
275  global $ilMainMenu, $ilTabs;
276 
277  $ilMainMenu->setActive("mail");
278 
279  $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
280  $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
281  $this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_mail_b.gif"));
282 
283  // display infopanel if something happened
285 
286  $ilTabs->addTarget('fold', $this->ctrl->getLinkTargetByClass('ilmailfoldergui'));
287  $this->ctrl->setParameterByClass('ilmailformgui', 'type', 'new');
288  $ilTabs->addTarget('compose', $this->ctrl->getLinkTargetByClass('ilmailformgui'));
289  $this->ctrl->clearParametersByClass('ilmailformgui');
290  $ilTabs->addTarget('mail_addressbook', $this->ctrl->getLinkTargetByClass('ilmailaddressbookgui'));
291  $ilTabs->addTarget('options', $this->ctrl->getLinkTargetByClass('ilmailoptionsgui'));
292 
293  switch($this->forwardClass)
294  {
295  case 'ilmailformgui':
296  $ilTabs->setTabActive('compose');
297  break;
298 
299  case 'ilmailaddressbookgui':
300  $ilTabs->setTabActive('mail_addressbook');
301  break;
302 
303  case 'ilmailoptionsgui':
304  $ilTabs->setTabActive('options');
305  break;
306 
307  case 'ilmailfoldergui':
308  default:
309  $ilTabs->setTabActive('fold');
310  break;
311 
312  }
313  if(isset($_GET['message_sent'])) $ilTabs->setTabActive('fold');
314 
315  // FLATVIEW <-> TREEVIEW
316  if (!isset($_SESSION["viewmode"]) or $_SESSION["viewmode"] == "flat")
317  {
318  $this->ctrl->setParameter($this, "viewmode", "tree");
319  $this->tpl->setTreeFlatIcon(
320  $this->ctrl->getLinkTarget($this),
321  "tree");
322  //$this->tpl->setVariable("IMG_TREE", ilUtil::getImagePath("ic_treeview.gif"));
323  //$this->tpl->parseCurrentBlock();
324  }
325  else
326  {
327  $this->ctrl->setParameter($this, "viewmode", "flat");
328  $this->tpl->setTreeFlatIcon(
329  $this->ctrl->getLinkTarget($this),
330  "flat");
331  //$this->tpl->parseCurrentBlock();
332  }
333  $this->ctrl->clearParameters($this);
334  $this->tpl->setCurrentBlock("tree_icons");
335  $this->tpl->parseCurrentBlock();
336  }
337 
338  private function showMenu()
339  {
340  global $ilUser;
341 
342  require_once "Services/Mail/classes/class.ilMailExplorer.php";
343 
344  $this->tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
345  $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.gif", false));
346 
347  $this->exp = new ilMailExplorer($this->ctrl->getLinkTargetByClass("ilmailfoldergui"),$ilUser->getId());
348  $this->exp->setTargetGet("mobj_id");
349 
350  if ($_GET["mexpand"] == "")
351  {
352  $this->mtree = new ilTree($ilUser->getId());
353  $this->mtree->setTableNames('mail_tree','mail_obj_data');
354  $expanded = $this->mtree->readRootId();
355  }
356  else
357  $expanded = $_GET["mexpand"];
358 
359  $this->exp->setExpand($expanded);
360 
361  //build html-output
362  $this->exp->setOutput(0);
363  $this->output = $this->exp->getOutput();
364 
365  $this->tpl->setCurrentBlock("content");
366  $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("mail_folders"));
367  $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
368  $this->tpl->setVariable("EXPLORER",$this->output);
369  $this->ctrl->setParameter($this, "mexpand", $_GET["mexpand"]);
370  $this->tpl->setVariable("ACTION", $this->ctrl->getFormAction($this, 'showMenu'));
371  $this->tpl->parseCurrentBlock();
372 
373  $this->tpl->show(false);
374  }
375 }
376 
377 ?>