ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilMailFolderGUI.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/User/classes/class.ilObjUser.php';
25 require_once "Services/Mail/classes/class.ilMailbox.php";
26 require_once "Services/Mail/classes/class.ilMail.php";
27 
37 {
38  private $tpl = null;
39  private $ctrl = null;
40  private $lng = null;
41 
42  private $umail = null;
43  private $mbox = null;
44 
45  private $errorDelete = false;
46 
47  public function __construct()
48  {
49  global $tpl, $ilCtrl, $lng, $ilUser;
50 
51  $this->tpl = $tpl;
52  $this->ctrl = $ilCtrl;
53  $this->lng = $lng;
54 
55  $this->ctrl->saveParameter($this, "mobj_id");
56 
57  $this->umail = new ilMail($ilUser->getId());
58  $this->mbox = new ilMailBox($ilUser->getId());
59 
60  if(isset($_POST['mobj_id']) && (int)$_POST['mobj_id'])
61  {
62  $_GET['mobj_id'] = $_POST['mobj_id'];
63  }
64  // IF THERE IS NO OBJ_ID GIVEN GET THE ID OF MAIL ROOT NODE
65  if(!$_GET["mobj_id"])
66  {
67  $_GET["mobj_id"] = $this->mbox->getInboxFolder();
68  }
69  }
70 
71  public function executeCommand()
72  {
73  /* User views mail and wants to delete it */
74  if ($_GET["action"] == "deleteMails" &&
75  $_GET["mail_id"])
76  {
77  $_GET["cmd"] = "editFolder";
78  $_POST["action"] = "deleteMails";
79  $_POST["mail_id"] = array($_GET["mail_id"]);
80  }
81 
82  $forward_class = $this->ctrl->getNextClass($this);
83  switch($forward_class)
84  {
85  case 'ilmailaddressbookgui':
86  include_once 'Services/Mail/classes/class.ilMailAddressbookGUI.php';
87 
88  $this->ctrl->forwardCommand(new ilMailAddressbookGUI());
89  break;
90 
91  case 'ilmailoptionsgui':
92  include_once 'Services/Mail/classes/class.ilMailOptionsGUI.php';
93 
94  $this->ctrl->forwardCommand(new ilMailOptionsGUI());
95  break;
96 
97  case 'ilpublicuserprofilegui':
98  include_once("./Services/User/classes/class.ilPublicUserProfileGUI.php");
99  $profile_gui = new ilPublicUserProfileGUI($_GET["user"]);
100  $ret = $this->ctrl->forwardCommand($profile_gui);
101  break;
102 
103  default:
104  if (!($cmd = $this->ctrl->getCmd()))
105  {
106  $cmd = "showFolder";
107  }
108  $this->$cmd();
109  break;
110  }
111  return true;
112  }
113 
114  public function add()
115  {
116  global $lng, $ilUser;
117 
118  if($_GET["mail_id"] != "")
119  {
120  if (is_array($mail_data = $this->umail->getMail($_GET["mail_id"])))
121  {
122  require_once "Services/Mail/classes/class.ilAddressbook.php";
123  $abook = new ilAddressbook($ilUser->getId());
124 
125  $tmp_user = new ilObjUser($mail_data["sender_id"]);
126  if ($abook->checkEntryByLogin($tmp_user->getLogin()) > 0)
127  {
128  ilUtil::sendInfo($lng->txt("mail_entry_exists"));
129  }
130  else
131  {
132  $abook->addEntry($tmp_user->getLogin(),
133  $tmp_user->getFirstname(),
134  $tmp_user->getLastname(),
135  $tmp_user->getEmail());
136  ilUtil::sendInfo($lng->txt("mail_entry_added"));
137  }
138  }
139  }
140 
141  $this->showMail();
142 
143  }
144 
145  public function cancelEmptyTrash()
146  {
147  $this->showFolder();
148  }
149 
150  public function performEmptyTrash()
151  {
152  $this->umail->deleteMailsOfFolder($_GET["mobj_id"]);
153 
154  ilUtil::sendInfo($this->lng->txt("mail_deleted"));
155  $this->showFolder();
156 
157  return true;
158  }
159 
160  public function askForEmptyTrash()
161  {
162  if ($this->umail->countMailsOfFolder($_GET["mobj_id"]))
163  {
164  ilUtil::sendInfo($this->lng->txt("mail_empty_trash_confirmation"));
165  $this->askForConfirmation = true;
166  }
167 
168  $this->showFolder();
169 
170  return true;
171  }
172 
173  public function showUser()
174  {
175  global $ilCtrl;
176 
177  $this->tpl->setVariable("HEADER", $this->lng->txt("mail"));
178 
179  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
180 
181  $this->tpl->setCurrentBlock("btn_cell");
182  $this->ctrl->setParameter($this, "mail_id", $_GET["mail_id"]);
183  $this->tpl->setVariable("BTN_LINK",$this->ctrl->getLinkTarget($this, "showMail"));
184  $this->tpl->setVariable("BTN_TXT", $this->lng->txt("back"));
185  $this->tpl->parseCurrentBlock();
186 
187 
188  $this->tpl->setVariable("TBL_TITLE", $this->lng->txt("profile_of")." ".
189  ilObjUser::_lookupLogin($_GET["user"]));
190  $this->tpl->setVariable("TBL_TITLE_IMG",ilUtil::getImagePath("icon_usr.gif"));
191  $this->tpl->setVariable("TBL_TITLE_IMG_ALT", $this->lng->txt("public_profile"));
192 
193  include_once './Services/User/classes/class.ilPublicUserProfileGUI.php';
194  $profile_gui = new ilPublicUserProfileGUI($_GET["user"]);
195  $this->tpl->setContent($ilCtrl->getHTML($profile_gui));
196  $this->tpl->show();
197 
198  return true;
199  }
200 
210  private function getUserInstance($a_usr_id)
211  {
212  static $userObjectCache = array();
213 
214  if(isset($userObjectCache[$a_usr_id])) return $userObjectCache[$a_usr_id];
215 
216  $userObjectCache[$a_usr_id] = new ilObjUser($a_usr_id);
217 
218  return $userObjectCache[$a_usr_id];
219  }
220 
221  public function showFolder()
222  {
223  global $ilUser;
224 
225  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.mail.html", "Services/Mail");
226  $this->tpl->setVariable("HEADER", $this->lng->txt("mail"));
227 
228  $this->ctrl->setParameter($this, "offset", $_GET["offset"]);;
229  $this->tpl->setVariable("ACTION", $this->ctrl->getFormAction($this));
230  $this->ctrl->clearParameters($this);
231 
232  $sentFolderId = $this->mbox->getSentFolder();
233  $draftsFolderId = $this->mbox->getDraftsFolder();
234 
235  $isTrashFolder = $_GET['mobj_id'] == $this->mbox->getTrashFolder();
236  $isSentFolder = $_GET['mobj_id'] == $sentFolderId;
237  $isDraftFolder = $_GET['mobj_id'] == $draftsFolderId;
238 
239  // BEGIN CONFIRM_DELETE
240  if($_POST["action"] == "deleteMails" &&
241  !$this->errorDelete &&
242  $_POST["action"] != "confirm" &&
243  $isTrashFolder)
244  {
245  $this->tpl->setCurrentBlock("CONFIRM_DELETE");
246  $this->tpl->setVariable("BUTTON_CONFIRM",$this->lng->txt("confirm"));
247  $this->tpl->setVariable("BUTTON_CANCEL",$this->lng->txt("cancel"));
248  $this->tpl->parseCurrentBlock();
249  }
250 
251  // BEGIN MAIL ACTIONS
252  $actions = $this->mbox->getActions($_GET["mobj_id"]);
253 
254  $this->tpl->setCurrentBlock("mailactions");
255  foreach($actions as $key => $action)
256  {
257  if($key == 'moveMails')
258  {
259  $folders = $this->mbox->getSubFolders();
260  foreach($folders as $folder)
261  {
262  if ($folder["type"] != 'trash' ||
263  !$isTrashFolder)
264  {
265  $this->tpl->setVariable("MAILACTION_VALUE", $folder["obj_id"]);
266  if($folder["type"] != 'user_folder')
267  {
268  $this->tpl->setVariable("MAILACTION_NAME",$action." ".$this->lng->txt("mail_".$folder["title"]).($folder["type"] == 'trash' ? " (".$this->lng->txt("delete").")" : ""));
269  }
270  else
271  {
272  $this->tpl->setVariable("MAILACTION_NAME",$action." ".$folder["title"]);
273  }
274  $this->tpl->parseCurrentBlock();
275  }
276  }
277  }
278  else
279  {
280  if ($key != 'deleteMails' ||
281  $isTrashFolder)
282  {
283  $this->tpl->setVariable("MAILACTION_NAME", $action);
284  $this->tpl->setVariable("MAILACTION_VALUE", $key);
285  $this->tpl->setVariable("MAILACTION_SELECTED",$_POST["action"] == 'delete' ? 'selected' : '');
286  $this->tpl->parseCurrentBlock();
287  }
288  }
289  }
290  // END MAIL ACTIONS
291 
292 
293  // SHOW_FOLDER ONLY IF viewmode is flatview
294  if(!isset($_SESSION["viewmode"]) ||
295  $_SESSION["viewmode"] == 'flat')
296  {
297  $this->tpl->setCurrentBlock("show_folder");
298  $this->tpl->setCurrentBLock("flat_select");
299 
300  foreach($folders as $folder)
301  {
302  if($folder["obj_id"] == $_GET["mobj_id"])
303  {
304  $this->tpl->setVariable("FLAT_SELECTED","selected");
305  }
306  $this->tpl->setVariable("FLAT_VALUE",$folder["obj_id"]);
307  if($folder["type"] == 'user_folder')
308  {
309  $this->tpl->setVariable("FLAT_NAME", $folder["title"]);
310  }
311  else
312  {
313  $this->tpl->setVariable("FLAT_NAME", $this->lng->txt("mail_".$folder["title"]));
314  }
315  $this->tpl->parseCurrentBlock();
316  }
317  $this->tpl->setVariable("TXT_FOLDERS", $this->lng->txt("mail_change_to_folder"));
318  $this->tpl->setVariable("FOLDER_VALUE",$this->lng->txt("submit"));
319  $this->tpl->parseCurrentBlock();
320 
321  #$this->ctrl->setParameter($this, "offset", $_GET["offset"]);
322  $this->tpl->setVariable("ACTION_FLAT", $this->ctrl->getFormAction($this, 'showFolder'));
323  #$this->ctrl->clearParameters($this);
324  }
325  // END SHOW_FOLDER
326 
327  // BEGIN MAILS
328  $mailData = $this->umail->getMailsOfFolder($_GET["mobj_id"]);
329  $mail_count = count($mailData);
330 
331  if($isTrashFolder && $mail_count > 0)
332  {
333  if ($this->askForConfirmation == true)
334  {
335  $this->tpl->setCurrentBlock("CONFIRM_EMPTY_TRASH");
336  $this->tpl->setVariable("ACTION_EMPTY_TRASH_CONFIRMATION", $this->ctrl->getFormAction($this, 'performEmptyTrash'));
337  $this->tpl->setVariable("BUTTON_CONFIRM_EMPTY_TRASH", $this->lng->txt("confirm"));
338  $this->tpl->setVariable("BUTTON_CANCEL_EMPTY_TRASH", $this->lng->txt("cancel"));
339  $this->tpl->parseCurrentBlock();
340  }
341 
342  $this->tpl->setCurrentBlock("EMPTY_TRASH");
343  $this->tpl->setVariable("LINK_EMPTY_TRASH", $this->ctrl->getLinkTarget($this, "askForEmptyTrash"));
344  $this->tpl->setVariable("TXT_EMPTY_TRASH", $this->lng->txt("mail_empty_trash"));
345  $this->tpl->parseCurrentBlock();
346  }
347 
348  // TODO: READ FROM MAIL_OPTIONS
349  $mail_max_hits = $ilUser->getPref('hits_per_page');
350  $counter = 0;
351  foreach ($mailData as $mail)
352  {
353  /*if($mail["sender_id"] &&
354  !ilObjectFactory::ObjectIdExists($mail["sender_id"]))
355  {
356  --$mail_count;
357  continue;
358  }*/
359  // LINKBAR
360  if($mail_count > $mail_max_hits)
361  {
362  $params = array(
363  "mobj_id" => $_GET["mobj_id"]);
364  }
365  $start = $_GET["offset"];
366  $linkbar = ilUtil::Linkbar($this->ctrl->getLinkTarget($this),$mail_count,$mail_max_hits,$start,$params);
367  if ($linkbar)
368  {
369  $this->tpl->setVariable("LINKBAR", $linkbar);
370  }
371  if($counter >= ($start+$mail_max_hits))
372  {
373  break;
374  }
375  if($counter < $start)
376  {
377  ++$counter;
378  continue;
379  }
380 
381  // END LINKBAR
382  ++$counter;
383  $this->tpl->setCurrentBlock("mails");
384  $this->tpl->setVariable("ROWCOL","tblrow".(($counter % 2)+1));
385  $this->tpl->setVariable("MAIL_ID", $mail["mail_id"]);
386 
387  if(is_array($_POST["mail_id"]))
388  {
389  $this->tpl->setVariable("CHECKBOX_CHECKED",in_array($mail["mail_id"],$_POST["mail_id"]) ? 'checked' : "");
390  }
391 
392  // GET FULLNAME OF SENDER
393  if($isSentFolder || $isDraftFolder)
394  {
395  $this->tpl->setVariable('MAIL_LOGIN', $this->umail->formatNamesForOutput($mail['rcp_to']));
396  }
397  else
398  {
399  if($mail["sender_id"] != ANONYMOUS_USER_ID)
400  {
401  $tmp_user = $this->getUserInstance($mail['sender_id']);
402  if(ilObjUser::_lookupPref($mail['sender_id'], 'public_profile') == 'y')
403  {
404  $this->tpl->setVariable('MAIL_FROM', $tmp_user->getFullname());
405  }
406  if(!($login = $tmp_user->getLogin()))
407  {
408  $login = $mail["import_name"]." (".$this->lng->txt("user_deleted").")";
409  }
410 
411  $this->tpl->setCurrentBlock("pers_image");
412  $this->tpl->setVariable("IMG_SENDER", $tmp_user->getPersonalPicturePath("xxsmall"));
413  $this->tpl->setVariable("ALT_SENDER", $login);
414  $this->tpl->parseCurrentBlock();
415  $this->tpl->setCurrentBlock("mails");
416 
417  $this->tpl->setVariable("MAIL_LOGIN",$login);
418  }
419  else
420  {
421  $tmp_user = $this->getUserInstance(ANONYMOUS_USER_ID);
422 
423  $this->tpl->setCurrentBlock('pers_image');
424  $this->tpl->setVariable('IMG_SENDER', $tmp_user->getPersonalPicturePath('xxsmall'));
425  $this->tpl->setVariable('ALT_SENDER', ilMail::_getAnonymousName());
426  $this->tpl->parseCurrentBlock();
427  $this->tpl->setCurrentBlock('mails');
428 
429  $this->tpl->setVariable('MAIL_LOGIN', ilMail::_getAnonymousName());
430  }
431  }
432  $this->tpl->setVariable("MAILCLASS", $mail["m_status"] == 'read' ? 'mailread' : 'mailunread');
433  // IF ACTUAL FOLDER IS DRAFT BOX, DIRECT TO COMPOSE MESSAGE
434  if($isDraftFolder)
435  {
436  $this->ctrl->setParameterByClass("ilmailformgui", "mail_id", $mail["mail_id"]);
437  $this->ctrl->setParameterByClass("ilmailformgui", "type", "draft");
438  $this->tpl->setVariable("MAIL_LINK_READ", $this->ctrl->getLinkTargetByClass("ilmailformgui"));
439  $this->ctrl->clearParametersByClass("ilmailformgui");
440  }
441  else
442  {
443  $this->ctrl->setParameter($this, "mail_id", $mail["mail_id"]);
444  $this->ctrl->setParameter($this, "cmd", "showMail");
445  $this->tpl->setVariable("MAIL_LINK_READ", $this->ctrl->getLinkTarget($this));
446  $this->ctrl->clearParameters($this);
447  }
448  $this->tpl->setVariable("MAIL_SUBJECT", htmlspecialchars($mail["m_subject"]));
449  $this->tpl->setVariable("MAIL_DATE", ilDatePresentation::formatDate(new ilDateTime($mail['send_time'],IL_CAL_DATETIME)));
450 
451  $this->tpl->parseCurrentBlock();
452  }
453  // END MAILS
454 
455  $mtree = new ilTree($ilUser->getId());
456  $mtree->setTableNames('mail_tree','mail_obj_data');
457  $folder_node = $mtree->getNodeData($_GET[mobj_id]);
458 
459  // folder_image
460  if($folder_node["type"] == 'user_folder')
461  {
462  $this->tpl->setVariable("TXT_FOLDER", $folder_node["title"]);
463  $this->tpl->setVariable("IMG_FOLDER", ilUtil::getImagePath("icon_user_folder.gif"));
464  }
465  else
466  {
467  $this->tpl->setVariable("TXT_FOLDER", $this->lng->txt("mail_".$folder_node["title"]));
468  $this->tpl->setVariable("IMG_FOLDER", ilUtil::getImagePath("icon".substr($folder_node["title"], 1).".gif"));
469  }
470 
471  if ($folder_node["type"] == 'user_folder' || $folder_node["type"] == 'local')
472  {
473  if ($folder_node["type"] == 'user_folder')
474  {
475  $this->ctrl->setParameter($this, "cmd", "enterFolderData");
476  $this->tpl->setVariable("LINK_EDIT_FOLDER", $this->ctrl->getLinkTarget($this));
477  $this->tpl->setVariable("TXT_EDIT_FOLDER", $this->lng->txt("edit"));
478  }
479  $this->tpl->setVariable("TXT_ADD_FOLDER", $this->lng->txt("mail_add_subfolder"));
480  }
481 
482  $this->tpl->setVariable("TXT_MAIL", $this->lng->txt("mail"));
483  $this->tpl->setVariable("TXT_MAIL_S", $this->lng->txt("mail_s"));
484  $this->tpl->setVariable("TXT_UNREAD", $this->lng->txt("unread"));
485  $this->tpl->setVariable("TXT_SUBMIT",$this->lng->txt("submit"));
486  $this->tpl->setVariable("TXT_SELECT_ALL", $this->lng->txt("select_all"));
487  $this->tpl->setVariable("IMGPATH",$this->tpl->tplPath);
488 
489  // MAIL SUMMARY
490  $mail_counter = $this->umail->getMailCounterData();
491  $this->tpl->setVariable("MAIL_COUNT", $mail_counter["total"]);
492  $this->tpl->setVariable("MAIL_COUNT_UNREAD", $mail_counter["unread"]);
493  $this->tpl->setVariable("TXT_UNREAD_MAIL_S",$this->lng->txt("mail_s_unread"));
494  $this->tpl->setVariable("TXT_MAIL_S",$this->lng->txt("mail_s"));
495 
496  //columns headlines
497  if($isSentFolder || $isDraftFolder)
498  {
499  $this->tpl->setVariable("TXT_SENDER", $this->lng->txt("recipient"));
500  }
501  else
502  {
503  $this->tpl->setVariable("TXT_SENDER", $this->lng->txt("sender"));
504  }
505  $this->tpl->setVariable("TXT_SUBJECT", $this->lng->txt("subject"));
506  // $this->tpl->setVariable("MAIL_SORT_SUBJ","link");
507  $this->tpl->setVariable("TXT_DATE",$this->lng->txt("date"));
508  $this->tpl->setVariable("DIRECTION", "up");
509 
510  $this->tpl->show();
511  }
512 
513  public function deleteFolder()
514  {
515  if ($_SESSION["viewmode"] == "tree")
516  {
517  ilUtil::redirect("ilias.php?baseClass=ilMailGUI&mobj_id=".$_GET["mobj_id"]."&type=confirmdelete_folderdata");
518  }
519  else
520  {
521  ilUtil::sendInfo($this->lng->txt("mail_sure_delete_folder"));
522  $this->enterFolderData("saveFolderSettings", true);
523 
524  return true;
525  }
526  }
527 
528  public function confirmDeleteFolder()
529  {
530  ilUtil::sendInfo($this->lng->txt("mail_sure_delete_folder"));
531  $this->enterFolderData("saveFolderSettings", true);
532 
533  return true;
534  }
535 
536  public function performDeleteFolder()
537  {
538  $new_parent = $this->mbox->getParentFolderId($_GET["mobj_id"]);
539 
540  if ($this->mbox->deleteFolder($_GET["mobj_id"]))
541  {
542  ilUtil::sendInfo($this->lng->txt("mail_folder_deleted"),true);
543  ilUtil::redirect("ilias.php?baseClass=ilMailGUI");
544  }
545  else
546  {
547  if ($_SESSION["viewmode"] == "tree")
548  {
549  ilUtil::sendInfo($this->lng->txt("mail_error_delete"), true);
550  ilUtil::redirect("ilias.php?baseClass=ilMailGUI&mobj_id=".$_GET["mobj_id"]."&type=confirmdelete_folderdata");
551  }
552  else
553  {
554  ilUtil::sendInfo($this->lng->txt("mail_error_delete"));
555  $this->enterFolderData();
556 
557  return true;
558  }
559  }
560  }
561 
562  public function cancelDeleteFolder()
563  {
564  if ($_SESSION["viewmode"] == "tree")
565  {
566  ilUtil::redirect("ilias.php?baseClass=ilMailGUI&mobj_id=".$_GET["mobj_id"]."&type=enter_folderdata");
567  }
568  else
569  {
570  $this->enterFolderData();
571  return true;
572  }
573  }
574 
575  public function cancelEnterFolderData()
576  {
577  if ($_SESSION["viewmode"] == "tree")
578  {
579  ilUtil::redirect("ilias.php?baseClass=ilMailGUI&mobj_id=".$_GET["mobj_id"]."&target=ilmailfoldergui");
580  }
581  else
582  {
583  $this->showFolder();
584  return true;
585  }
586  }
587 
588  public function saveFolderSettings()
589  {
590  if (isset($_POST["folder_name_add"]) && $_SESSION["viewmode"] == "tree") $_SESSION["folder_name_add"] = $_POST['folder_name_add'];
591 
592  $tmp_data = $this->mbox->getFolderData($_GET["mobj_id"]);
593  if ($tmp_data["title"] != $_POST["folder_name_add"])
594  {
595  if ($_POST["folder_name_add"] == "")
596  {
597  if ($_SESSION["viewmode"] == "tree")
598  {
599  ilUtil::sendInfo($this->lng->txt("mail_insert_folder_name"), true);
600  ilUtil::redirect("ilias.php?baseClass=ilMailGUI&mobj_id=".$_GET["mobj_id"]."&type=enter_folderdata");
601  }
602  else
603  {
604  ilUtil::sendInfo($this->lng->txt("mail_insert_folder_name"));
605  $this->enterFolderData();
606  return true;
607  }
608  }
609  else
610  {
611  if ($this->mbox->renameFolder($_GET["mobj_id"], ilUtil::stripSlashes($_POST["folder_name_add"])))
612  {
613  ilUtil::sendInfo($this->lng->txt("mail_folder_name_changed"), true);
614  unset($_SESSION["folder_name_add"]);
615  }
616  else
617  {
618  if ($_SESSION["viewmode"] == "tree")
619  {
620  ilUtil::sendInfo($this->lng->txt("mail_folder_exists"), true);
621  ilUtil::redirect("ilias.php?baseClass=ilMailGUI&mobj_id=".$_GET["mobj_id"]."&type=enter_folderdata");
622  }
623  else
624  {
625  ilUtil::sendInfo($this->lng->txt("mail_folder_exists"));
626  $this->enterFolderData();
627  return true;
628  }
629  }
630  }
631  }
632 
633  if ($_SESSION["viewmode"] == "tree")
634  {
635  ilUtil::redirect("ilias.php?baseClass=ilMailGUI&mobj_id=".$_GET["mobj_id"]."&type=enter_folderdata");
636  }
637  else
638  {
639  $this->enterFolderData();
640  return true;
641  }
642  }
643 
644  public function saveSubFolderSettings()
645  {
646  if (isset($_POST["folder_name_add"]) && $_SESSION["viewmode"] == "tree") $_SESSION["folder_name_add"] = ilUtil::stripSlashes($_POST['folder_name_add']);
647 
648  if (empty($_POST['folder_name_add']))
649  {
650  if ($_SESSION["viewmode"] == "tree")
651  {
652  ilUtil::sendInfo($this->lng->txt("mail_insert_folder_name"), true);
653  ilUtil::redirect("ilias.php?baseClass=ilMailGUI&mobj_id=".$_GET["mobj_id"]."&type=add_subfolder");
654  }
655  else
656  {
657  ilUtil::sendInfo($this->lng->txt("mail_insert_folder_name"));
658  $this->addSubFolder();
659  return true;
660  }
661  }
662  else if ($_GET["mobj_id"] = $this->mbox->addFolder($_GET["mobj_id"], ilUtil::stripSlashes($_POST["folder_name_add"])))
663  {
664  unset($_SESSION["folder_name_add"]);
665 
666  if ($_SESSION["viewmode"] == "tree")
667  {
668  ilUtil::sendInfo($this->lng->txt("mail_folder_created"), true);
669  ilUtil::redirect("ilias.php?baseClass=ilMailGUI&mobj_id=".$_GET["mobj_id"]);
670  }
671  else
672  {
673  ilUtil::sendInfo($this->lng->txt("mail_folder_created"));
674  $this->enterFolderData();
675  return true;
676  }
677  }
678  else
679  {
680  if ($_SESSION["viewmode"] == "tree")
681  {
682  ilUtil::sendInfo($this->lng->txt("mail_folder_exists"), true);
683  ilUtil::redirect("ilias.php?baseClass=ilMailGUI&mobj_id=".$_GET["mobj_id"]."&type=add_subfolder");
684  }
685  else
686  {
687  ilUtil::sendInfo($this->lng->txt("mail_folder_exists"));
688  $this->addSubFolder();
689  return true;
690  }
691  }
692  }
693 
694  function addSubFolder()
695  {
696  $this->enterFolderData("saveSubFolderSettings");
697 
698  return true;
699  }
700 
701  public function enterFolderData($cmd = "saveFolderSettings", $confirmDelete = false)
702  {
703  global $ilUser;
704 
705  $mtree = new ilTree($ilUser->getId());
706  $mtree->setTableNames('mail_tree','mail_obj_data');
707  $folder_node = $mtree->getNodeData($_GET[mobj_id]);
708 
709  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.mail_edit_user_folder.html",'Services/Mail');
710 
711  if ($confirmDelete)
712  {
713  $this->tpl->setCurrentBlock("confirm_delete");
714  $this->ctrl->setParameter($this, "cmd", "post");
715  $this->tpl->setVariable("ACTION_DELETE", $this->ctrl->getFormAction($this));
716  $this->tpl->setVariable("FRAME_DELETE", ilFrameTargetInfo::_getFrame("MainContent"));
717  $this->ctrl->clearParameters($this);
718  $this->tpl->setVariable("TXT_DELETE_CONFIRM",$this->lng->txt("confirm"));
719  $this->tpl->setVariable("TXT_DELETE_CANCEL",$this->lng->txt("cancel"));
720  $this->tpl->parseCurrentBlock();
721  }
722 
723  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
724 
725  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
726  $this->tpl->setVariable("FRAME_ADD", ilFrameTargetInfo::_getFrame("MainContent"));
727 
728  if ($cmd == "saveFolderSettings")
729  {
730  $this->tpl->setVariable("TXT_HEADLINE", $this->lng->txt('mail_folder_edit'));
731  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt('name'));
732  $this->tpl->setVariable("TXT_DELETE", $this->lng->txt('delete'));
733 
734  if (isset($_SESSION["folder_name_add"])) $title_value = ilUtil::prepareFormOutput($_SESSION["folder_name_add"], true);
735  else if (isset($_POST["folder_name_add"])) $title_value = ilUtil::prepareFormOutput($_POST["folder_name_add"], true);
736  else $title_value = ilUtil::stripSlashes($folder_node["title"]);
737  }
738  else
739  {
740  $this->tpl->setVariable("TXT_HEADLINE", $this->lng->txt('mail_add_subfolder'));
741  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt('name'));
742 
743  if (isset($_SESSION["folder_name_add"])) $title_value = ilUtil::prepareFormOutput($_SESSION["folder_name_add"], true);
744  else if (isset($_POST["folder_name_add"])) $title_value = ilUtil::prepareFormOutput($_POST["folder_name_add"], true);
745  }
746 
747  unset($_SESSION["folder_name_add"]);
748 
749  $this->tpl->setVariable("CMD_SUBMIT", $cmd);
750  $this->tpl->setVariable("TXT_SUBMIT", ($cmd == "saveSubFolderSettings" ? $this->lng->txt('save') : $this->lng->txt('rename')));
751  $this->tpl->setVariable("TITLE_VALUE", $title_value);
752  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt('cancel'));
753 
754  $this->tpl->show();
755 
756  return true;
757  }
758 
759  public function changeFolder()
760  {
761  switch ($_POST["action"])
762  {
763  default:
764  if ($this->umail->moveMailsToFolder(array($_GET["mail_id"]), $_POST["action"]))
765  {
766  ilUtil::sendInfo($this->lng->txt("mail_moved"), true);
767  $this->ctrl->redirectByClass("ilMailGUI");
768  }
769  else
770  {
771  ilUtil::sendInfo($this->lng->txt("mail_move_error"));
772  }
773  break;
774  }
775 
776  $this->showMail();
777 
778  return true;
779  }
780 
781  public function editFolder()
782  {
783  switch ($_POST["action"])
784  {
785  case 'markMailsRead':
786  if(is_array($_POST["mail_id"]))
787  {
788  $this->umail->markRead($_POST["mail_id"]);
789  }
790  else
791  {
792  ilUtil::sendInfo($this->lng->txt("mail_select_one"));
793  }
794  break;
795  case 'markMailsUnread':
796  if(is_array($_POST["mail_id"]))
797  {
798  $this->umail->markUnread($_POST["mail_id"]);
799  }
800  else
801  {
802  ilUtil::sendInfo($this->lng->txt("mail_select_one"));
803  }
804  break;
805 
806  case 'deleteMails':
807  // IF MAILBOX IS TRASH ASK TO CONFIRM
808  if($this->mbox->getTrashFolder() == $_GET["mobj_id"])
809  {
810  if(!is_array($_POST["mail_id"]))
811  {
812  ilUtil::sendInfo($this->lng->txt("mail_select_one"));
813  $this->errorDelete = true;
814  }
815  else
816  {
817  ilUtil::sendInfo($this->lng->txt("mail_sure_delete"));
818  }
819  } // END IF MAILBOX IS TRASH FOLDER
820  else
821  {
822  // MOVE MAILS TO TRASH
823  if(!is_array($_POST["mail_id"]))
824  {
825  ilUtil::sendInfo($this->lng->txt("mail_select_one"));
826  }
827  else if($this->umail->moveMailsToFolder($_POST["mail_id"], $this->mbox->getTrashFolder()))
828  {
829  $_GET["offset"] = 0;
830  ilUtil::sendInfo($this->lng->txt("mail_moved_to_trash"));
831  }
832  else
833  {
834  ilUtil::sendInfo($this->lng->txt("mail_move_error"));
835  }
836  }
837  break;
838 
839  case 'add':
840  $this->ctrl->setParameterByClass("ilmailoptionsgui", "cmd", "add");
841  $this->ctrl->redirectByClass("ilmailoptionsgui");
842 
843  case 'moveMails':
844  default:
845  if(!is_array($_POST["mail_id"]))
846  {
847  ilUtil::sendInfo($this->lng->txt("mail_select_one"));
848  }
849  else if($this->umail->moveMailsToFolder($_POST["mail_id"],$_POST["action"]))
850  {
851  ilUtil::sendInfo($this->lng->txt("mail_moved"));
852  }
853  else
854  {
855  ilUtil::sendInfo($this->lng->txt("mail_move_error"));
856  }
857  break;
858  }
859 
860  $this->showFolder();
861  }
862 
863  public function confirmDeleteMails()
864  {
865  // ONLY IF FOLDER IS TRASH, IT WAS ASKED FOR CONFIRMATION
866  if($this->mbox->getTrashFolder() == $_GET["mobj_id"])
867  {
868  if(!is_array($_POST["mail_id"]))
869  {
870  ilUtil::sendInfo($this->lng->txt("mail_select_one"));
871  }
872  else if($this->umail->deleteMails($_POST["mail_id"]))
873  {
874  $_GET["offset"] = 0;
875  ilUtil::sendInfo($this->lng->txt("mail_deleted"));
876  }
877  else
878  {
879  ilUtil::sendInfo($this->lng->txt("mail_delete_error"));
880  }
881  }
882 
883  $this->showFolder();
884  }
885 
886  public function cancelDeleteMails()
887  {
888  $this->ctrl->setParameter($this, "offset", $_GET["offset"]);
889  $this->ctrl->redirect($this);
890  }
891 
892  public function showMail()
893  {
894  global $ilUser;
895 
896  if ($_SESSION["mail_id"])
897  {
898  $_GET["mail_id"] = $_SESSION["mail_id"];
899  $_SESSION["mail_id"] = "";
900  }
901 
902  $this->umail->markRead(array($_GET["mail_id"]));
903 
904  $mailData = $this->umail->getMail($_GET["mail_id"]);
905 
906  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.mail_read.html", "Services/Mail");
907  $this->tpl->setVariable("HEADER",$this->lng->txt("mail_mails_of"));
908 
909  //buttons
910  $tplbtn = new ilTemplate("tpl.buttons.html", true, true);
911  if($mailData["sender_id"] &&
912  $mailData["sender_id"] != ANONYMOUS_USER_ID)
913  {
914  $tplbtn->setCurrentBlock("btn_cell");
915  $this->ctrl->setParameterByClass("ilmailformgui", "mail_id", $_GET["mail_id"]);
916  $this->ctrl->setParameterByClass("ilmailformgui", "type", "reply");
917  $tplbtn->setVariable("BTN_LINK", $this->ctrl->getLinkTargetByClass("ilmailformgui"));
918  $this->ctrl->clearParametersByClass("iliasmailformgui");
919  $tplbtn->setVariable("BTN_TXT", $this->lng->txt("reply"));
920  $tplbtn->parseCurrentBlock();
921  }
922  $tplbtn->setCurrentBlock("btn_cell");
923  $this->ctrl->setParameterByClass("ilmailformgui", "mail_id", $_GET["mail_id"]);
924  $this->ctrl->setParameterByClass("ilmailformgui", "type", "forward");
925  $tplbtn->setVariable("BTN_LINK", $this->ctrl->getLinkTargetByClass("ilmailformgui"));
926  $this->ctrl->clearParametersByClass("iliasmailformgui");
927  $tplbtn->setVariable("BTN_TXT", $this->lng->txt("forward"));
928  $tplbtn->parseCurrentBlock();
929  $tplbtn->setCurrentBlock("btn_cell");
930  $this->ctrl->setParameter($this, "mail_id", $_GET["mail_id"]);
931  $this->ctrl->setParameter($this, "cmd", "printMail");
932  $tplbtn->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this));
933  $this->ctrl->clearParameters($this);
934  $tplbtn->setVariable("BTN_TXT", $this->lng->txt("print"));
935  $tplbtn->setVariable("BTN_TARGET","target=\"_blank\"");
936  $tplbtn->parseCurrentBlock();
937 
938  $tplbtn->setCurrentBlock("btn_cell");
939  $this->ctrl->setParameter($this, "mail_id", $_GET["mail_id"]);
940  $this->ctrl->setParameter($this, "action", "deleteMails");
941  $tplbtn->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this));
942  $this->ctrl->clearParameters($this);
943  $tplbtn->setVariable("BTN_TXT", $this->lng->txt("delete"));
944  $tplbtn->parseCurrentBlock();
945 
946  $tplbtn->setCurrentBlock("btn_row");
947  $tplbtn->parseCurrentBlock();
948 
949  $this->tpl->setVariable("BUTTONS2",$tplbtn->get());
950  $this->ctrl->setParameter($this, "mail_id", $_GET["mail_id"]);
951  $this->tpl->setVariable("ACTION", $this->ctrl->getFormAction($this));
952  $this->ctrl->clearParameters($this);
953 
954  if ($mailData["sender_id"] &&
955  $mailData["sender_id"] != $ilUser->getId() &&
956  $mailData["sender_id"] != ANONYMOUS_USER_ID)
957  {
958  require_once "Services/Mail/classes/class.ilAddressbook.php";
959  $abook = new ilAddressbook($ilUser->getId());
960 
961  $tmp_user = new ilObjUser($mailData["sender_id"]);
962  if ($abook->checkEntryByLogin($tmp_user->getLogin()) == 0)
963  {
964  $tplbtn = new ilTemplate("tpl.buttons.html", true, true);
965 
966  $tplbtn->setCurrentBlock("btn_cell");
967  $this->ctrl->setParameter($this, "mail_id", $_GET["mail_id"]);
968  $this->ctrl->setParameter($this, "cmd", "add");
969  $tplbtn->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this));
970  $this->ctrl->clearParameters($this);
971  $tplbtn->setVariable("BTN_TXT", $this->lng->txt("mail_add_to_addressbook"));
972  $tplbtn->parseCurrentBlock();
973 
974  $this->tpl->setVariable("ADD_USER_BTN",$tplbtn->get());
975  }
976  }
977 
978  // SET MAIL DATA
979  $counter = 1;
980 
981  // FROM
982  if($mailData["sender_id"] != ANONYMOUS_USER_ID)
983  {
984  $tmp_user = new ilObjUser($mailData['sender_id']);
985  $this->ctrl->setParameter($this, 'mail_id', $_GET['mail_id']);
986  $this->ctrl->setParameter($this, 'user', $tmp_user->getId());
987  if(ilObjUser::_lookupPref($mailData['sender_id'], 'public_profile') == 'y')
988  {
989  $this->tpl->setVariable('PROFILE_LINK_FROM', $this->ctrl->getLinkTarget($this, 'showUser'));
990  $this->tpl->setVariable('FROM', $tmp_user->getFullname());
991  }
992  $this->tpl->setCurrentBlock("pers_image");
993  $this->tpl->setVariable("IMG_SENDER", $tmp_user->getPersonalPicturePath("xsmall"));
994  $this->tpl->setVariable("ALT_SENDER", $tmp_user->getFullname());
995  $this->tpl->parseCurrentBlock();
996  $this->tpl->setCurrentBlock("adm_content");
997  if(!($login = $tmp_user->getLogin()))
998  {
999  $login = $mailData["import_name"]." (".$this->lng->txt("user_deleted").")";
1000  }
1001  $this->tpl->setVariable("MAIL_LOGIN",$login);
1002  $this->tpl->setVariable("CSSROW_FROM", (++$counter) % 2 ? 'tblrow1' : 'tblrow2');
1003  }
1004  else
1005  {
1006  $tmp_user = new ilObjUser(ANONYMOUS_USER_ID);
1007  $this->tpl->setVariable('MAIL_LOGIN', ilMail::_getAnonymousName());
1008  $this->tpl->setCurrentBlock('pers_image');
1009  $this->tpl->setVariable('IMG_SENDER', $tmp_user->getPersonalPicturePath('xsmall'));
1010  $this->tpl->setVariable('ALT_SENDER', ilMail::_getAnonymousName());
1011  $this->tpl->parseCurrentBlock();
1012  }
1013 
1014  // TO
1015  $this->tpl->setVariable('TXT_TO', $this->lng->txt('mail_to'));
1016  // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
1017  $this->tpl->setVariable('TO', ilUtil::htmlencodePlainString($this->umail->formatNamesForOutput($mailData['rcp_to']), false));
1018  $this->tpl->setVariable('CSSROW_TO', (++$counter) % 2 ? 'tblrow1' : 'tblrow2');
1019 
1020  // CC
1021  if($mailData['rcp_cc'])
1022  {
1023  $this->tpl->setCurrentBlock('cc');
1024  $this->tpl->setVariable('TXT_CC',$this->lng->txt('cc'));
1025  // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
1026  $this->tpl->setVariable('CC', ilUtil::htmlencodePlainString($this->umail->formatNamesForOutput($mailData['rcp_cc']), false));
1027  $this->tpl->setVariable('CSSROW_CC', (++$counter) % 2 ? 'tblrow1' : 'tblrow2');
1028  $this->tpl->parseCurrentBlock();
1029  }
1030 
1031  // SUBJECT
1032  $this->tpl->setVariable('TXT_SUBJECT', $this->lng->txt('subject'));
1033  // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
1034  $this->tpl->setVariable('SUBJECT', ilUtil::htmlencodePlainString($mailData['m_subject'], true));
1035  $this->tpl->setVariable('CSSROW_SUBJ', (++$counter) % 2 ? 'tblrow1' : 'tblrow2');
1036 
1037  // DATE
1038  $this->tpl->setVariable('TXT_DATE', $this->lng->txt('date'));
1039  $this->tpl->setVariable('DATE',ilDatePresentation::formatDate(new ilDateTime($mailData['send_time'],IL_CAL_DATETIME)));
1040  $this->tpl->setVariable('CSSROW_DATE', (++$counter) % 2 ? 'tblrow1' : 'tblrow2');
1041 
1042  // ATTACHMENTS
1043  if($mailData["attachments"])
1044  {
1045  $this->tpl->setCurrentBlock("attachment");
1046  $this->tpl->setCurrentBlock("a_row");
1047  $counter = 1;
1048  foreach($mailData["attachments"] as $file)
1049  {
1050  $this->tpl->setVariable("A_CSSROW",++$counter%2 ? 'tblrow1' : 'tblrow2');
1051  $this->tpl->setVariable("FILE",md5($file));
1052  $this->tpl->setVariable("FILE_NAME",$file);
1053  $this->tpl->parseCurrentBlock();
1054  }
1055  $this->tpl->setVariable("TXT_ATTACHMENT",$this->lng->txt("attachments"));
1056  $this->tpl->setVariable("TXT_DOWNLOAD",$this->lng->txt("download"));
1057  $this->tpl->parseCurrentBlock();
1058  }
1059 
1060  // MESSAGE
1061  $this->tpl->setVariable("TXT_MESSAGE", $this->lng->txt("message"));
1062 
1063  // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
1064  $this->tpl->setVariable("MAIL_MESSAGE", ilUtil::htmlencodePlainString($mailData["m_message"], true));
1065 
1066  $isTrashFolder = false;
1067  if ($this->mbox->getTrashFolder() == $_GET["mobj_id"])
1068  {
1069  $isTrashFolder = true;
1070  }
1071  $actions = $this->mbox->getActions($_GET["mobj_id"]);
1072  foreach($actions as $key => $action)
1073  {
1074  if($key == 'moveMails')
1075  {
1076  $folders = $this->mbox->getSubFolders();
1077  foreach($folders as $folder)
1078  {
1079  if ($folder["type"] != 'trash' ||
1080  !$isTrashFolder)
1081  {
1082  $this->tpl->setCurrentBlock("movemail");
1083  $this->tpl->setVariable("MOVEMAIL_VALUE", $folder["obj_id"]);
1084  if($folder["type"] != 'user_folder')
1085  {
1086  $this->tpl->setVariable("MOVEMAIL_NAME",$action." ".$this->lng->txt("mail_".$folder["title"]).($folder["type"] == 'trash' ? " (".$this->lng->txt("delete").")" : ""));
1087  }
1088  else
1089  {
1090  $this->tpl->setVariable("MOVEMAIL_NAME",$action." ".$folder["title"]);
1091  }
1092  $this->tpl->parseCurrentBlock();
1093  }
1094  }
1095  }
1096  }
1097  if ($_SESSION["viewmode"] == "tree") $this->tpl->setVariable("FORM_TARGET", ilFrameTargetInfo::_getFrame("MainContent"));
1098  $this->tpl->setVariable("TXT_MOVEMAIL_SEND", $this->lng->txt('submit'));
1099 
1100  // PREV- & NEXT-BUTTON
1101 
1102  $prevMail = $this->umail->getPreviousMail($_GET["mail_id"]);
1103  $nextMail = $this->umail->getNextMail($_GET["mail_id"]);
1104 
1105  if (is_array($prevMail) || is_array($nextMail))
1106  {
1107  $show = false;
1108 
1109  $tplbtn = new ilTemplate("tpl.buttons.html", true, true);
1110 
1111  if ($prevMail["mail_id"])
1112  {
1113  $show = true;
1114 
1115  $tplbtn->setCurrentBlock("btn_cell");
1116  $this->ctrl->setParameter($this, "mail_id", $prevMail["mail_id"]);
1117  $this->ctrl->setParameter($this, "cmd", "showMail");
1118  $tplbtn->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this));
1119  $this->ctrl->clearParameters($this);
1120  $tplbtn->setVariable("BTN_TXT", $this->lng->txt("previous"));
1121  $tplbtn->parseCurrentBlock();
1122  }
1123 
1124  if ($nextMail["mail_id"])
1125  {
1126  $show = true;
1127 
1128  $tplbtn->setCurrentBlock("btn_cell");
1129  $this->ctrl->setParameter($this, "mail_id", $nextMail["mail_id"]);
1130  $this->ctrl->setParameter($this, "cmd", "showMail");
1131  $tplbtn->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this));
1132  $this->ctrl->clearParameters($this);
1133  $tplbtn->setVariable("BTN_TXT", $this->lng->txt("next"));
1134  $tplbtn->parseCurrentBlock();
1135  }
1136 
1137  if ($show == true)$this->tpl->setVariable("NAV_BUTTONS", $tplbtn->get());
1138  }
1139 
1140  $this->tpl->show();
1141  }
1142 
1143  public function printMail()
1144  {
1145  $tplprint = new ilTemplate("Services/Mail/templates/default/tpl.mail_print.html",true,true,true);
1146  $tplprint->setVariable("JSPATH",$tpl->tplPath);
1147 
1148  //get the mail from user
1149  $mailData = $this->umail->getMail($_GET["mail_id"]);
1150 
1151  // SET MAIL DATA
1152  // FROM
1153  if($mailData["sender_id"] != ANONYMOUS_USER_ID)
1154  {
1155  $tmp_user = new ilObjUser($mailData["sender_id"]);
1156  if(!($login = $tmp_user->getFullname()))
1157  {
1158  $login = $mailData["import_name"]." (".$this->lng->txt("user_deleted").")";
1159  }
1160  $tplprint->setVariable("FROM", $login);
1161  }
1162  else
1163  {
1164  $tplprint->setVariable('FROM', ilMail::_getAnonymousName());
1165  }
1166 
1167  // TO
1168  $tplprint->setVariable("TXT_TO", $this->lng->txt("mail_to"));
1169  $tplprint->setVariable("TO", $mailData["rcp_to"]);
1170 
1171  // CC
1172  if($mailData["rcp_cc"])
1173  {
1174  $tplprint->setCurrentBlock("cc");
1175  $tplprint->setVariable("TXT_CC",$this->lng->txt("cc"));
1176  $tplprint->setVariable("CC",$mailData["rcp_cc"]);
1177  $tplprint->parseCurrentBlock();
1178  }
1179  // SUBJECT
1180  $tplprint->setVariable("TXT_SUBJECT",$this->lng->txt("subject"));
1181  $tplprint->setVariable("SUBJECT",htmlspecialchars($mailData["m_subject"]));
1182 
1183  // DATE
1184  $tplprint->setVariable("TXT_DATE", $this->lng->txt("date"));
1185  $tplprint->setVariable("DATE", ilDatePresentation::formatDate(new ilDateTime($mailData["send_time"],IL_CAL_DATETIME)));
1186 
1187 
1188  // MESSAGE
1189  $tplprint->setVariable("TXT_MESSAGE", $this->lng->txt("message"));
1190  $tplprint->setVariable("MAIL_MESSAGE", nl2br(htmlspecialchars($mailData["m_message"])));
1191 
1192 
1193  $tplprint->show();
1194  }
1195 
1196  function deliverFile()
1197  {
1198  if ($_SESSION["mail_id"])
1199  {
1200  $_GET["mail_id"] = $_SESSION["mail_id"];
1201  }
1202  $_SESSION["mail_id"] = "";
1203 
1204  $filename = ($_SESSION["filename"]
1205  ? $_SESSION["filename"]
1206  : ($_POST["filename"]
1207  ? $_POST["filename"]
1208  : $_GET["filename"]));
1209  $_SESSION["filename"] = "";
1210 
1211  if ($filename != "")
1212  {
1213  require_once "classes/class.ilFileDataMail.php";
1214 
1215  // secure filename
1216  $filename = str_replace("..", "", $filename);
1217 
1218  $mfile = new ilFileDataMail($_SESSION["AccountId"]);
1219  if(!is_array($file = $mfile->getAttachmentPathByMD5Filename($filename, $_GET['mail_id'])))
1220  {
1221  ilUtil::sendInfo($this->lng->txt('mail_error_reading_attachment'));
1222  $this->showMail();
1223  }
1224  else
1225  {
1226  ilUtil::deliverFile($file['path'], $file['filename']);
1227  }
1228  }
1229  else
1230  {
1231  ilUtil::sendInfo($this->lng->txt('mail_select_attachment'));
1232  $this->showMail();
1233  }
1234  }
1235 
1236 }
1237 ?>