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