ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 $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  {
63  $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "searchResults");
64  $this->ctrl->redirectByClass("ilmailformgui");
65  }
66 
67  if ($_GET["type"] == "attach")
68  {
70 
71  $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "mailAttachment");
72  $this->ctrl->redirectByClass("ilmailformgui");
73  }
74 
75  if ($_GET["type"] == "new")
76  {
77  $_SESSION['rcp_to'] = $_GET['rcp_to'];
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  {
89  $_SESSION['mail_id'] = $_GET['mail_id'];
90  $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "replyMail");
91  $this->ctrl->redirectByClass("ilmailformgui");
92  }
93 
94  if ($_GET["type"] == "read")
95  {
96  $_SESSION['mail_id'] = $_GET['mail_id'];
97  $this->ctrl->setParameterByClass("ilmailfoldergui", "cmd", "showMail");
98  $this->ctrl->redirectByClass("ilmailfoldergui");
99  }
100 
101  if ($_GET["type"] == "deliverFile")
102  {
103  $_SESSION['mail_id'] = $_GET['mail_id'];
104  $_SESSION['filename'] = ($_POST["filename"] ? $_POST["filename"] : $_GET["filename"]);
105  $this->ctrl->setParameterByClass("ilmailfoldergui", "cmd", "deliverFile");
106  $this->ctrl->redirectByClass("ilmailfoldergui");
107  }
108 
109  if ($_GET["type"] == "message_sent")
110  {
111  ilUtil::sendInfo($this->lng->txt('mail_message_send'), true);
112  $this->ctrl->redirectByClass("ilmailfoldergui");
113  }
114 
115  if ($_GET["type"] == "role")
116  {
117  if (is_array($_POST['roles']))
118  {
119  $_SESSION['mail_roles'] = $_POST['roles'];
120  }
121  else if ($_GET["role"])
122  {
123  $_SESSION['mail_roles'] = array($_GET["role"]);
124  }
125 
127 
128  $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "mailRole");
129  $this->ctrl->redirectByClass("ilmailformgui");
130  }
131 
132  if ($_GET["view"] == "my_courses")
133  {
134  $_SESSION['search_crs'] = $_GET['search_crs'];
135  $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "searchCoursesTo");
136  $this->ctrl->redirectByClass("ilmailformgui");
137  }
138 
139  if (isset($_GET["viewmode"]))
140  {
141  ilSession::set(self::VIEWMODE_SESSION_KEY, $_GET["viewmode"]);
142  $this->ctrl->setCmd("setViewMode");
143  }
144 
145  $this->forwardClass = $this->ctrl->getNextClass($this);
146 
147  $this->showHeader();
148 
149  if('tree' == ilSession::get(self::VIEWMODE_SESSION_KEY) &&
150  $this->ctrl->getCmd() != "showExplorer")
151  {
152  $this->showExplorer();
153  }
154 
155  include_once "Services/jQuery/classes/class.iljQueryUtil.php";
157 
158  switch($this->forwardClass)
159  {
160  case 'ilmailformgui':
161  include_once 'Services/Mail/classes/class.ilMailFormGUI.php';
162 
163  $this->ctrl->forwardCommand(new ilMailFormGUI());
164  break;
165 
166  case 'ilmailaddressbookgui':
167  include_once 'Services/Contact/classes/class.ilMailAddressbookGUI.php';
168 
169  $this->ctrl->forwardCommand(new ilMailAddressbookGUI());
170  break;
171 
172  case 'ilmailoptionsgui':
173  include_once 'Services/Mail/classes/class.ilMailOptionsGUI.php';
174 
175  $this->ctrl->forwardCommand(new ilMailOptionsGUI());
176  break;
177 
178  case 'ilmailfoldergui':
179  include_once 'Services/Mail/classes/class.ilMailFolderGUI.php';
180  $this->ctrl->forwardCommand(new ilMailFolderGUI());
181  break;
182 
183  default:
184  if (!($cmd = $this->ctrl->getCmd()))
185  {
186  $cmd = "setViewMode";
187  }
188 
189  $this->$cmd();
190  break;
191 
192  }
193  return true;
194  }
195 
196  private function setViewMode()
197  {
198  if ($_GET["target"] == "")
199  {
200  $_GET["target"] = "ilmailfoldergui";
201  }
202 
203  if($_GET['type'] == 'redirect_to_read')
204  {
205  $this->ctrl->setParameterByClass('ilMailFolderGUI', 'mail_id', (int)$_GET['mail_id']);
206  $this->ctrl->redirectByClass('ilMailFolderGUI', 'showMail');
207  }
208  else if ($_GET["type"] == "add_subfolder")
209  {
210  $this->ctrl->redirectByClass($_GET["target"], "addSubFolder");
211  }
212  else if ($_GET["type"] == "enter_folderdata")
213  {
214  $this->ctrl->redirectByClass($_GET["target"], "enterFolderData");
215  }
216  else if ($_GET["type"] == "confirmdelete_folderdata")
217  {
218  $this->ctrl->redirectByClass($_GET["target"], "confirmDeleteFolder");
219  }
220  else
221  {
222  $this->ctrl->redirectByClass($_GET["target"]);
223  }
224  }
225 
226  private function showHeader()
227  {
228  global $ilMainMenu, $ilTabs, $ilHelp;
229 
230  $ilHelp->setScreenIdComponent("mail");
231 
232  $ilMainMenu->setActive("mail");
233 
234 // $this->tpl->getStandardTemplate();
235  $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
236  $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
237  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_mail_b.png"));
238 
239  // display infopanel if something happened
241 
242  $ilTabs->addTarget('fold', $this->ctrl->getLinkTargetByClass('ilmailfoldergui'));
243  $this->ctrl->setParameterByClass('ilmailformgui', 'type', 'new');
244  $ilTabs->addTarget('compose', $this->ctrl->getLinkTargetByClass('ilmailformgui'));
245  $this->ctrl->clearParametersByClass('ilmailformgui');
246  $ilTabs->addTarget('mail_addressbook', $this->ctrl->getLinkTargetByClass('ilmailaddressbookgui'));
247  $ilTabs->addTarget('options', $this->ctrl->getLinkTargetByClass('ilmailoptionsgui'));
248 
249  switch($this->forwardClass)
250  {
251  case 'ilmailformgui':
252  $ilTabs->setTabActive('compose');
253  break;
254 
255  case 'ilmailaddressbookgui':
256  $ilTabs->setTabActive('mail_addressbook');
257  break;
258 
259  case 'ilmailoptionsgui':
260  $ilTabs->setTabActive('options');
261  break;
262 
263  case 'ilmailfoldergui':
264  default:
265  $ilTabs->setTabActive('fold');
266  break;
267 
268  }
269  if(isset($_GET['message_sent'])) $ilTabs->setTabActive('fold');
270 
271  if('tree' != ilSession::get(self::VIEWMODE_SESSION_KEY))
272  {
273  $tree_state = 'tree';
274  }
275  else
276  {
277  $tree_state = 'flat';
278  }
279 
280  if($this->isMailDetailCommand($this->ctrl->getCmd()))
281  {
282  $this->ctrl->setParameter($this, 'mail_id', (int)$_GET['mail_id']);
283  $this->ctrl->setParameter($this, 'type', 'redirect_to_read');
284  }
285 
286  $this->ctrl->setParameter($this, 'viewmode', $tree_state);
287  $this->tpl->setTreeFlatIcon($this->ctrl->getLinkTarget($this), $tree_state);
288 
289  $this->ctrl->clearParameters($this);
290  $this->tpl->setCurrentBlock("tree_icons");
291  $this->tpl->parseCurrentBlock();
292  }
293 
298  private function isMailDetailCommand($cmd)
299  {
300  return in_array(strtolower($cmd), array('showmail')) && isset($_GET['mail_id']) && (int)$_GET['mail_id'];
301  }
302 
303  private function showExplorer()
304  {
305  global $ilUser;
306 
307  require_once "Services/Mail/classes/class.ilMailExplorer.php";
308  $exp = new ilMailExplorer($this, "showExplorer", $ilUser->getId());
309  if (!$exp->handleCommand())
310  {
311  $this->tpl->setLeftNavContent($exp->getHTML());
312  }
313  }
314 }
315 
316 ?>