ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilMailFolderGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 require_once 'Services/User/classes/class.ilObjUser.php';
6 require_once 'Services/Mail/classes/class.ilMailbox.php';
7 require_once 'Services/Mail/classes/class.ilMail.php';
8 require_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
9 include_once 'Services/Mail/classes/class.ilMailFolderTableGUI.php';
10 
20 // removed ilCtrl_Calls
21 // ilMailAddressbookGUI
22 
24 {
27 
28  private $tpl = null;
29  private $ctrl = null;
30  private $lng = null;
31 
32  public $umail = null;
33  public $mbox = null;
34 
35  private $errorDelete = false;
36 
37  public function __construct()
38  {
39  global $tpl, $ilCtrl, $lng, $ilUser;
40 
41  $this->tpl = $tpl;
42  $this->ctrl = $ilCtrl;
43  $this->lng = $lng;
44 
45  $this->umail = new ilMail($ilUser->getId());
46  $this->mbox = new ilMailBox($ilUser->getId());
47 
48  if(isset($_POST['mobj_id']) && (int)$_POST['mobj_id'])
49  {
50  $_GET['mobj_id'] = $_POST['mobj_id'];
51  }
52  // IF THERE IS NO OBJ_ID GIVEN GET THE ID OF MAIL ROOT NODE
53  if(!(int)$_GET['mobj_id'])
54  {
55  $_GET['mobj_id'] = $this->mbox->getInboxFolder();
56  }
57  $_GET['mobj_id'] = (int)$_GET['mobj_id'];
58  $ilCtrl->saveParameter($this, 'mobj_id');
59  $ilCtrl->setParameter($this, 'mobj_id', $_GET['mobj_id']);
60 
61  }
62 
63  public function executeCommand()
64  {
65  if ($_POST["select_cmd"])
66  {
67  $_GET["cmd"] = 'editFolder';
68 
69  // lower menubar execute-button
70  $this->current_select_cmd = $_POST['select_cmd'];
71  $this->current_selected_cmd = $_POST['selected_cmd'];
72  }
73  else if ($_POST["select_cmd2"])
74  {
75  // upper menubar execute-button
76  $_GET["cmd"] = 'editFolder';
77  $this->current_select_cmd = $_POST['select_cmd2'];
78  $this->current_selected_cmd = $_POST['selected_cmd2'];
79  }
80 
81  /* Fix: User views mail and wants to delete it...
82  mjansen: The mail system needs a revision :-)
83  */
84  if ($_GET['selected_cmd'] == "deleteMails" && $_GET["mail_id"])
85  {
86  $_GET["cmd"] = "editFolder";
87  $this->current_selected_cmd = "deleteMails";
88  $_POST["mail_id"] = array($_GET["mail_id"]);
89  }
90 
91  /* Fix: User views mail and wants to move it...
92  mjansen: The mail system needs a revision :-)
93  */
94  $cmd = $this->ctrl->getCmd();
95  if($cmd == 'changeFolder' &&
96  is_numeric($_POST['selected_cmd']) &&
97  $_GET["mail_id"])
98  {
99  $this->current_selected_cmd = (int)$_POST['selected_cmd'];
100  }
101 
102  $forward_class = $this->ctrl->getNextClass($this);
103  switch($forward_class)
104  {
105  case 'ilmailaddressbookgui':
106  include_once 'Services/Contact/classes/class.ilMailAddressbookGUI.php';
107 
108  $this->ctrl->forwardCommand(new ilMailAddressbookGUI());
109  break;
110 
111  case 'ilmailoptionsgui':
112  include_once 'Services/Mail/classes/class.ilMailOptionsGUI.php';
113 
114  $this->ctrl->forwardCommand(new ilMailOptionsGUI());
115  break;
116 
117  case 'ilpublicuserprofilegui':
118  include_once("Services/User/classes/class.ilPublicUserProfileGUI.php");
119  $this->tpl->setTitle($this->lng->txt("mail"));
120  $this->ctrl->saveParameter($this, "mail_id");
121  $profile_gui = new ilPublicUserProfileGUI($_GET["user"]);
122  $profile_gui->setBackUrl($this->ctrl->getLinkTarget($this, "showMail"));
123  $ret = $this->ctrl->forwardCommand($profile_gui);
124  if ($ret != "")
125  {
126  $this->tpl->setContent($ret);
127  $this->tpl->show();
128  }
129  break;
130 
131  default:
132  if (!($cmd = $this->ctrl->getCmd()))
133  {
134  $cmd = "showFolder";
135  }
136  $this->$cmd();
137  break;
138  }
139  return true;
140  }
141 
142  public function add()
143  {
144  global $lng, $ilUser;
145 
146  if($_GET["mail_id"] != "")
147  {
148  if (is_array($mail_data = $this->umail->getMail($_GET["mail_id"])))
149  {
150  require_once "Services/Contact/classes/class.ilAddressbook.php";
151  $abook = new ilAddressbook($ilUser->getId());
152 
153  $tmp_user = new ilObjUser($mail_data["sender_id"]);
154  if ($abook->checkEntryByLogin($tmp_user->getLogin()) > 0)
155  {
156  ilUtil::sendInfo($lng->txt("mail_entry_exists"));
157  }
158  else
159  {
160  $abook->addEntry($tmp_user->getLogin(),
161  $tmp_user->getFirstname(),
162  $tmp_user->getLastname(),
163  $tmp_user->getEmail());
164  ilUtil::sendInfo($lng->txt("mail_entry_added"));
165  }
166  }
167  }
168  $this->showMail();
169  }
170 
174  public function cancelEmptyTrash()
175  {
176  $this->showFolder();
177  }
178 
182  public function performEmptyTrash()
183  {
184  $this->umail->deleteMailsOfFolder($_GET['mobj_id']);
185  ilUtil::sendInfo($this->lng->txt('mail_deleted'));
186  $this->showFolder();
187  }
188 
192  public function askForEmptyTrash()
193  {
194  if($this->umail->countMailsOfFolder((int)$_GET['mobj_id']))
195  {
196  $this->askForConfirmation = true;
197  }
198 
199  $this->showFolder();
200 
201  return true;
202  }
203 
204  public function showUser()
205  {
206  global $ilCtrl, $ilToolbar;
207 
208  $this->ctrl->setParameter($this, "mail_id", $_GET["mail_id"]);
209 
210  $this->tpl->setTitle($this->lng->txt("mail"));
211  //$ilToolbar->addButton($this->lng->txt("back"), $this->ctrl->getLinkTarget($this, "showMail"));
212 
213  $this->tpl->setVariable("TBL_TITLE", $this->lng->txt("profile_of")." ".
214  ilObjUser::_lookupLogin($_GET["user"]));
215  $this->tpl->setVariable("TBL_TITLE_IMG",ilUtil::getImagePath("icon_usr.png"));
216  $this->tpl->setVariable("TBL_TITLE_IMG_ALT", $this->lng->txt("public_profile"));
217 
218  include_once './Services/User/classes/class.ilPublicUserProfileGUI.php';
219  $profile_gui = new ilPublicUserProfileGUI($_GET["user"]);
220  $profile_gui->setBackUrl($this->ctrl->getLinkTarget($this, "showMail"));
221  $this->tpl->setContent($ilCtrl->getHTML($profile_gui));
222  $this->tpl->show();
223 
224  return true;
225  }
226 
227  public function addSubfolderCommands($check_uf = false)
228  {
229  global $ilToolbar;
230 
232  {
233  $ilToolbar->addSeparator();
234  }
235 
236  $ilToolbar->addButton($this->lng->txt('mail_add_subfolder'), $this->ctrl->getLinkTarget($this, 'addSubFolder'));
237 
238  if($check_uf == true)
239  {
240  $ilToolbar->addButton($this->lng->txt('rename'), $this->ctrl->getLinkTarget($this, 'renameSubFolder'));
241  $ilToolbar->addButton($this->lng->txt('delete'), $this->ctrl->getLinkTarget($this, 'deleteSubFolder'));
242  }
243  return true;
244  }
248  public function showFolder($a_show_confirmation = false)
249  {
254  global $ilUser, $ilToolbar;
255 
256  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.mail.html', 'Services/Mail');
257  $this->tpl->setTitle($this->lng->txt('mail'));
258 
259  $sentFolderId = $this->mbox->getSentFolder();
260  $draftsFolderId = $this->mbox->getDraftsFolder();
261 
262  $isTrashFolder = $_GET['mobj_id'] == $this->mbox->getTrashFolder();
263  $isSentFolder = $_GET['mobj_id'] == $sentFolderId;
264  $isDraftFolder = $_GET['mobj_id'] == $draftsFolderId;
265 
266  if($this->current_selected_cmd == 'deleteMails' &&
267  !$this->errorDelete &&
268  $this->current_selected_cmd != 'confirm' &&
269  $isTrashFolder)
270  {
271  if(isset($_REQUEST['mail_id']) && !is_array($_REQUEST['mail_id'])) $_REQUEST['mail_id'] = array($_REQUEST['mail_id']);
272  $confirmation = new ilConfirmationGUI();
273  $confirmation->setHeaderText($this->lng->txt('mail_sure_delete'));
274  $this->ctrl->setParameter($this, 'mail_id', implode(',', (array)$_REQUEST['mail_id']));
275  $confirmation->setFormAction($this->ctrl->getFormAction($this, 'confirmDeleteMails'));
276  $confirmation->setConfirm($this->lng->txt('confirm'), 'confirmDeleteMails');
277  $confirmation->setCancel($this->lng->txt('cancel'), 'cancelDeleteMails');
278  $this->tpl->setVariable('CONFIRMATION', $confirmation->getHTML());
279  }
280 
281  $folders = $this->mbox->getSubFolders();
282  $mtree = new ilTree($ilUser->getId());
283  $mtree->setTableNames('mail_tree', 'mail_obj_data');
284 
285  $check_uf = false;
286  $check_local = false;
287 
289  {
290  $folder_d = $mtree->getNodeData($_GET['mobj_id']);
291  if($folder_d['m_type'] == 'user_folder')
292  {
293  $check_uf = true;
294  }
295  else if($folder_d['m_type'] == 'local')
296  {
297  $check_local = true;
298  }
299  }
300 
301  $mailtable = new ilMailFolderTableGUI($this, (int)$_GET['mobj_id'], 'showFolder');
302  $mailtable->isSentFolder($isSentFolder)
303  ->isDraftFolder($isDraftFolder)
304  ->isTrashFolder($isTrashFolder)
305  ->initFilter();
306  $mailtable->setSelectedItems($_POST['mail_id']);
307 
308  try
309  {
310  $mailtable->prepareHTML();
311  }
312  catch(Exception $e)
313  {
315  $this->lng->txt($e->getMessage()) != '-'.$e->getMessage().'-' ?
316  $this->lng->txt($e->getMessage()) :
317  $e->getMessage()
318  );
319  }
320 
321  $table_html = $mailtable->getHtml();
322 
323  $folder_options = array();
325  {
326  foreach($folders as $folder)
327  {
328  $folder_d = $mtree->getNodeData($folder['obj_id']);
329 
330  if($folder['obj_id'] == $_GET['mobj_id'])
331  {
332  if($folder['type'] == 'user_folder')
333  {
334  $check_uf = true;
335  }
336  else if($folder['type'] == 'local')
337  {
338  $check_local = true;
339  $check_uf = false;
340  }
341  }
342 
343  if($folder['type'] == 'user_folder')
344  {
345  $pre = '';
346  for ($i = 2; $i < $folder_d['depth'] - 1; $i++)
347  {
348  $pre .= '&nbsp';
349  }
350 
351  if ($folder_d['depth'] > 1)
352  {
353  $pre .= '+';
354  }
355 
356  $folder_options[$folder['obj_id']] = $pre.' '.$folder['title'];
357  }
358  else
359  {
360  $folder_options[$folder['obj_id']] = $this->lng->txt('mail_'.$folder['title']);
361  }
362  }
363  }
364 
365  if($a_show_confirmation == false)
366  {
368  {
369  $ilToolbar->addText($this->lng->txt('mail_change_to_folder'));
370  include_once './Services/Form/classes/class.ilSelectInputGUI.php';
371  $si = new ilSelectInputGUI("", "mobj_id");
372  $si->setOptions($folder_options);
373  $si->setValue($_GET['mobj_id']);
374  $ilToolbar->addInputItem($si);
375 
376  $ilToolbar->addFormButton($this->lng->txt('change'),'showFolder');
377  $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 'showFolder'));
378  }
379  if($check_local == true || $check_uf == true)
380  {
381  $this->addSubfolderCommands($check_uf);
382  }
383  }
384  // END SHOW_FOLDER
385 
386  if($mailtable->isTrashFolder() &&
387  $mailtable->getNumerOfMails() > 0 &&
388  $this->askForConfirmation)
389  {
390  $confirmation = new ilConfirmationGUI();
391  $confirmation->setHeaderText($this->lng->txt('mail_empty_trash_confirmation'));
392  $confirmation->setFormAction($this->ctrl->getFormAction($this, 'performEmptyTrash'));
393  $confirmation->setConfirm($this->lng->txt('confirm'), 'performEmptyTrash');
394  $confirmation->setCancel($this->lng->txt('cancel'), 'cancelEmptyTrash');
395  $this->tpl->setVariable('CONFIRMATION', $confirmation->getHTML());
396  }
397 
398  $this->tpl->setVariable('MAIL_TABLE', $table_html);
399  $this->tpl->show();
400  }
401 
402  public function deleteSubfolder($a_show_confirm = true)
403  {
404  if($a_show_confirm)
405  {
406  include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
407  $oConfirmationGUI = new ilConfirmationGUI();
408 
409  // set confirm/cancel commands
410  $oConfirmationGUI->setFormAction($this->ctrl->getFormAction($this,"showFolder"));
411  $oConfirmationGUI->setHeaderText($this->lng->txt("mail_sure_delete_folder"));
412  $oConfirmationGUI->setCancel($this->lng->txt("cancel"), "showFolder");
413  $oConfirmationGUI->setConfirm($this->lng->txt("confirm"), "performDeleteSubfolder");
414  $this->tpl->setVariable('CONFIRMATION',$oConfirmationGUI->getHTML());
415 
416  return $this->showFolder(true);
417  }
418  else
419  return $this->showFolder(false);
420  }
421 
422  public function performDeleteSubFolder()
423  {
424  $new_parent = $this->mbox->getParentFolderId($_GET["mobj_id"]);
425 
426  if ($this->mbox->deleteFolder($_GET["mobj_id"]))
427  {
428  ilUtil::sendInfo($this->lng->txt("mail_folder_deleted"),true);
429 
430  $this->ctrl->setParameterByClass("ilMailGUI", "mobj_id", $new_parent);
431  $this->ctrl->redirectByClass("ilMailGUI");
432  }
433  else
434  {
435  ilUtil::sendFailure($this->lng->txt("mail_error_delete"));
436  return $this->showFolder();
437  }
438  }
439 
440  public function performAddSubFolder()
441  {
442  if (isset($_POST["subfolder_title"]) && 'tree' == ilSession::get(ilMailGUI::VIEWMODE_SESSION_KEY)) $_SESSION["subfolder_title"] = ilUtil::stripSlashes($_POST['subfolder_title']);
443 
444  if (empty($_POST['subfolder_title']))
445  {
446  ilUtil::sendInfo($this->lng->txt("mail_insert_folder_name"));
447  return $this->addSubFolder();
448  }
449  else if ($mobj_id = $this->mbox->addFolder($_GET["mobj_id"], ilUtil::stripSlashes($_POST["subfolder_title"])))
450  {
451  unset($_SESSION["subfolder_title"]);
452  ilUtil::sendInfo($this->lng->txt("mail_folder_created"), true);
453 
454  $this->ctrl->setParameterByClass("ilMailGUI", 'mobj_id', $mobj_id);
455  $this->ctrl->redirectByClass("ilMailGUI");
456  }
457  else
458  {
459  ilUtil::sendFailure($this->lng->txt("mail_folder_exists"));
460  return $this->addSubFolder();
461  }
462  }
463 
464  public function addSubFolder()
465  {
470  global $ilCtrl, $tpl;
471 
472  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
473 
474  $tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.mail.html', 'Services/Mail');
475  $tpl->setTitle($this->lng->txt('mail'));
476 
477  $oForm = new ilPropertyFormGUI();
478  $oForm->setFormAction($ilCtrl->getFormAction($this, 'performAddSubFolder'));
479  $oForm->setTitle($this->lng->txt('mail_add_folder'));
480 
481  //title
482  $oTitle = new ilTextInputGUI();
483  $oTitle->setTitle($this->lng->txt('title'));
484  $oTitle->setPostVar('subfolder_title');
485  $oForm->addItem($oTitle);
486 
487  $oForm->addCommandButton('performAddSubFolder', $this->lng->txt('save'));
488  $oForm->addCommandButton('showFolder', $this->lng->txt('cancel'));
489 
490  $tpl->setVariable('FORM', $oForm->getHTML());
491  $tpl->show();
492 
493  return true;
494  }
495 
496  public function renameSubFolder()
497  {
502  global $ilCtrl, $tpl;
503 
504  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
505 
506  $tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.mail.html', 'Services/Mail');
507  $tpl->setTitle($this->lng->txt('mail'));
508 
509  $oForm = new ilPropertyFormGUI();
510  $oForm->setFormAction($ilCtrl->getFormAction($this, 'performRenameSubFolder'));
511  $oForm->setTitle($this->lng->txt('mail_rename_folder'));
512 
513  //title
514  $oTitle = new ilTextInputGUI();
515  $oTitle->setTitle($this->lng->txt('title'));
516  $tmp_data = $this->mbox->getFolderData($_GET["mobj_id"]);
517  $oTitle->setValue($tmp_data["title"]);
518  $oTitle->setPostVar('subfolder_title');
519  $oForm->addItem($oTitle);
520 
521  $oForm->addCommandButton('performRenameSubFolder', $this->lng->txt('save'));
522  $oForm->addCommandButton('showFolder', $this->lng->txt('cancel'));
523  $tpl->setVariable('FORM', $oForm->getHTML());
524  $tpl->show();
525 
526  return true;
527  }
528 
529  public function performRenameSubFolder()
530  {
531  if (isset($_POST["subfolder_title"]) && 'tree' == ilSession::get(ilMailGUI::VIEWMODE_SESSION_KEY)) $_SESSION["subfolder_title"] = $_POST['subfolder_title'];
532 
533  $tmp_data = $this->mbox->getFolderData($_GET["mobj_id"]);
534  if ($tmp_data["title"] != $_POST["subfolder_title"])
535  {
536  if ($_POST["subfolder_title"] == "")
537  {
538  ilUtil::sendInfo($this->lng->txt("mail_insert_folder_name"));
539  return $this->renameSubFolder();
540  }
541  else
542  {
543  if ($this->mbox->renameFolder($_GET["mobj_id"], ilUtil::stripSlashes($_POST["subfolder_title"])))
544  {
545  ilUtil::sendInfo($this->lng->txt("mail_folder_name_changed"), true);
546  unset($_SESSION["subfolder_title"]);
547  $this->ctrl->redirectByClass("ilMailGUI");
548  }
549  else
550  {
551  ilUtil::sendFailure($this->lng->txt("mail_folder_exists"));
552  return $this->renameSubFolder();
553  }
554  }
555  }
556  return $this->showFolder();
557  }
558 
559  public function changeFolder()
560  {
561  switch ($this->current_selected_cmd)
562  {
563  default:
564  if(!(int)$_GET["mail_id"] || !(int)$this->current_selected_cmd)
565  {
566  ilUtil::sendInfo($this->lng->txt("mail_move_error"));
567  return $this->showMail();
568  }
569 
570  if ($this->umail->moveMailsToFolder(array($_GET["mail_id"]), $this->current_selected_cmd))
571  {
572  ilUtil::sendInfo($this->lng->txt("mail_moved"), true);
573  $this->ctrl->redirectByClass("ilMailGUI");
574  }
575  else
576  {
577  ilUtil::sendInfo($this->lng->txt("mail_move_error"));
578  }
579  break;
580  }
581 
582  $this->showMail();
583 
584  return true;
585  }
586 
587  public function editFolder()
588  {
589  switch ($this->current_selected_cmd)
590  {
591  case 'markMailsRead':
592  if(is_array($_POST["mail_id"]))
593  {
594  $this->umail->markRead($_POST["mail_id"]);
595  }
596  else
597  {
598  ilUtil::sendInfo($this->lng->txt("mail_select_one"));
599  }
600  break;
601  case 'markMailsUnread':
602  if(is_array($_POST["mail_id"]))
603  {
604  $this->umail->markUnread($_POST["mail_id"]);
605  }
606  else
607  {
608  ilUtil::sendInfo($this->lng->txt("mail_select_one"));
609  }
610  break;
611 
612  case 'deleteMails':
613  // IF MAILBOX IS TRASH ASK TO CONFIRM
614  if($this->mbox->getTrashFolder() == $_GET["mobj_id"])
615  {
616  if(!is_array($_POST["mail_id"]))
617  {
618  ilUtil::sendInfo($this->lng->txt("mail_select_one"));
619  $this->errorDelete = true;
620  }
621  } // END IF MAILBOX IS TRASH FOLDER
622  else
623  {
624  // MOVE MAILS TO TRASH
625  if(!is_array($_POST["mail_id"]))
626  {
627  ilUtil::sendInfo($this->lng->txt("mail_select_one"));
628  }
629  else if($this->umail->moveMailsToFolder($_POST["mail_id"], $this->mbox->getTrashFolder()))
630  {
631  $_GET["offset"] = 0;
632  ilUtil::sendInfo($this->lng->txt("mail_moved_to_trash"));
633  }
634  else
635  {
636  ilUtil::sendInfo($this->lng->txt("mail_move_error"));
637  }
638  }
639  break;
640 
641  case 'add':
642  $this->ctrl->setParameterByClass("ilmailoptionsgui", "cmd", "add");
643  $this->ctrl->redirectByClass("ilmailoptionsgui");
644 
645  case 'moveMails':
646  default:
647  if(!is_array($_POST["mail_id"]))
648  {
649  ilUtil::sendInfo($this->lng->txt("mail_select_one"));
650  }
651  else if($this->umail->moveMailsToFolder($_POST["mail_id"],$this->current_selected_cmd))
652  {
653  ilUtil::sendInfo($this->lng->txt("mail_moved"));
654  }
655  else
656  {
657  ilUtil::sendInfo($this->lng->txt("mail_move_error"));
658  }
659  break;
660  }
661 
662  $this->showFolder();
663  }
664 
668  public function confirmDeleteMails()
669  {
670  if($this->mbox->getTrashFolder() == $_GET['mobj_id'])
671  {
672  $_POST['mail_id'] = $mail_ids = explode(',', $_GET['mail_id']);
673  if(!is_array($mail_ids))
674  {
675  ilUtil::sendInfo($this->lng->txt('mail_select_one'));
676  }
677  else if($this->umail->deleteMails($mail_ids))
678  {
679  $_GET['offset'] = 0;
680  ilUtil::sendInfo($this->lng->txt('mail_deleted'));
681  }
682  else
683  {
684  ilUtil::sendInfo($this->lng->txt('mail_delete_error'));
685  }
686  }
687 
688  $this->showFolder();
689  }
690 
691  public function cancelDeleteMails()
692  {
693  $this->ctrl->redirect($this);
694  }
695 
699  public function showMail()
700  {
706  global $ilUser, $ilToolbar, $ilTabs;
707 
708  if($_SESSION['mail_id'])
709  {
710  $_GET['mail_id'] = $_SESSION['mail_id'];
711  $_SESSION['mail_id'] = '';
712  }
713 
714  $ilTabs->clearTargets();
715  $ilTabs->setBackTarget($this->lng->txt('back_to_folder'), $this->ctrl->getFormAction($this, 'showFolder'));
716 
717  $this->umail->markRead(array((int)$_GET['mail_id']));
718  $mailData = $this->umail->getMail((int)$_GET['mail_id']);
719 
720  $this->tpl->setTitle($this->lng->txt('mail_mails_of'));
721 
722  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
723 
724  $form = new ilPropertyFormGUI();
725  $form->setTableWidth('100%');
726  $this->ctrl->setParameter($this, 'mail_id', (int)$_GET['mail_id']);
727  $form->setFormAction($this->ctrl->getFormAction($this, 'showMail'));
728  $this->ctrl->clearParameters($this);
729  $form->setTitle($this->lng->txt('mail_mails_of'));
730 
732  {
733  $this->tpl->setVariable('FORM_TARGET', ilFrameTargetInfo::_getFrame('MainContent'));
734  }
735 
736  include_once 'Services/Accessibility/classes/class.ilAccessKeyGUI.php';
737 
741  $sender = ilObjectFactory::getInstanceByObjId($mailData['sender_id'], false);
742 
743  if($sender && $sender->getId() && $sender->getId() != ANONYMOUS_USER_ID)
744  {
745  $this->ctrl->setParameterByClass('ilmailformgui', 'mail_id', (int)$_GET['mail_id']);
746  $this->ctrl->setParameterByClass('ilmailformgui', 'type', 'reply');
747  $this->ctrl->clearParametersByClass('iliasmailformgui');
748  $ilToolbar->addButton($this->lng->txt('reply'), $this->ctrl->getLinkTargetByClass('ilmailformgui'), '', ilAccessKey::REPLY);
749  $this->ctrl->clearParameters($this);
750  }
751 
752  $this->ctrl->setParameterByClass('ilmailformgui', 'mail_id', (int)$_GET['mail_id']);
753  $this->ctrl->setParameterByClass('ilmailformgui', 'type', 'forward');
754  $this->ctrl->clearParametersByClass('iliasmailformgui');
755  $ilToolbar->addButton($this->lng->txt('forward'), $this->ctrl->getLinkTargetByClass('ilmailformgui'), '', ilAccessKey::FORWARD_MAIL);
756  $this->ctrl->clearParameters($this);
757 
758  $this->ctrl->setParameter($this, 'mail_id', (int)$_GET['mail_id']);
759  $ilToolbar->addButton($this->lng->txt('print'), $this->ctrl->getLinkTarget($this, 'printMail'), '_blank');
760  $this->ctrl->clearParameters($this);
761 
762  $this->ctrl->setParameter($this, 'mail_id', (int)$_GET['mail_id']);
763  $this->ctrl->setParameter($this, 'selected_cmd', 'deleteMails');
764  $ilToolbar->addButton($this->lng->txt('delete'), $this->ctrl->getLinkTarget($this), '', ilAccessKey::DELETE);
765  $this->ctrl->clearParameters($this);
766 
767  if($sender && $sender->getId() && $sender->getId() != ANONYMOUS_USER_ID)
768  {
769  $linked_fullname = $sender->getPublicName();
770  $picture = ilUtil::img($sender->getPersonalPicturePath('xsmall'), $sender->getPublicName());
771  $add_to_addb_button = '';
772 
773  if(in_array(ilObjUser::_lookupPref($sender->getId(), 'public_profile'), array('y', 'g')))
774  {
775  $this->ctrl->setParameter($this, 'mail_id', (int)$_GET['mail_id']);
776  $this->ctrl->setParameter($this, 'user', $sender->getId());
777  $linked_fullname = '<br /><a href="' . $this->ctrl->getLinkTarget($this, 'showUser') . '" title="'.$linked_fullname.'">' . $linked_fullname . '</a>';
778  $this->ctrl->clearParameters($this);
779  }
780 
781  if($sender->getId() != $ilUser->getId())
782  {
783  require_once 'Services/Contact/classes/class.ilAddressbook.php';
784  $abook = new ilAddressbook($ilUser->getId());
785  if($abook->checkEntryByLogin($sender->getLogin()) == 0)
786  {
787  $tplbtn = new ilTemplate('tpl.buttons.html', true, true);
788 
789  $tplbtn->setCurrentBlock('btn_cell');
790  $this->ctrl->setParameter($this, 'mail_id', (int)$_GET['mail_id']);
791  $tplbtn->setVariable('BTN_LINK', $this->ctrl->getLinkTarget($this, 'add'));
792  $this->ctrl->clearParameters($this);
793  $tplbtn->setVariable('BTN_TXT', $this->lng->txt('mail_add_to_addressbook'));
794  $tplbtn->parseCurrentBlock();
795 
796  $add_to_addb_button = '<br />' . $tplbtn->get();
797  }
798  }
799 
800  $from = new ilCustomInputGUI($this->lng->txt('from'));
801  $from->setHtml($picture . ' ' . $linked_fullname . $add_to_addb_button);
802  $form->addItem($from);
803  }
804  else if(!$sender || !$sender->getId())
805  {
806  $from = new ilCustomInputGUI($this->lng->txt('from'));
807  $from->setHtml($mailData['import_name'] . ' (' . $this->lng->txt('user_deleted') . ')');
808  $form->addItem($from);
809  }
810  else
811  {
812  $from = new ilCustomInputGUI($this->lng->txt('from'));
813  $from->setHtml(ilUtil::img(ilUtil::getImagePath('HeaderIconAvatar.png'), ilMail::_getIliasMailerName()) . '<br />' . ilMail::_getIliasMailerName());
814  $form->addItem($from);
815  }
816 
817  $to = new ilCustomInputGUI($this->lng->txt('mail_to'));
818  $to->setHtml(ilUtil::htmlencodePlainString($this->umail->formatNamesForOutput($mailData['rcp_to']), false));
819  $form->addItem($to);
820 
821  if($mailData['rcp_cc'])
822  {
823  $cc = new ilCustomInputGUI($this->lng->txt('cc'));
824  $cc->setHtml(ilUtil::htmlencodePlainString($this->umail->formatNamesForOutput($mailData['rcp_cc']), false));
825  $form->addItem($cc);
826  }
827 
828  if($mailData['rcp_bcc'])
829  {
830  $bcc = new ilCustomInputGUI($this->lng->txt('bc'));
831  $bcc->setHtml(ilUtil::htmlencodePlainString($this->umail->formatNamesForOutput($mailData['rcp_bcc']), false));
832  $form->addItem($bcc);
833  }
834 
835  $subject = new ilCustomInputGUI($this->lng->txt('subject'));
836  $subject->setHtml(ilUtil::htmlencodePlainString($mailData['m_subject'], true));
837  $form->addItem($subject);
838 
839  $date = new ilCustomInputGUI($this->lng->txt('date'));
840  $date->setHtml(ilDatePresentation::formatDate(new ilDateTime($mailData['send_time'], IL_CAL_DATETIME)));
841  $form->addItem($date);
842 
843  $message = new ilCustomInputGUI($this->lng->txt('message'));
844  $message->setHtml(ilUtil::htmlencodePlainString($mailData['m_message'], true));
845  $form->addItem($message);
846 
847  if($mailData['attachments'])
848  {
849  $att = new ilCustomInputGUI($this->lng->txt('attachments'));
850 
851  $radiog = new ilRadioGroupInputGUI('', 'filename');
852 
853  foreach($mailData['attachments'] as $file)
854  {
855  $radiog->addOption(new ilRadioOption($file, md5($file)));
856  }
857 
858  $att->setHtml($radiog->render());
859  $form->addCommandButton('deliverFile', $this->lng->txt('download'));
860  $form->addItem($att);
861  }
862 
863  $isTrashFolder = false;
864  if($this->mbox->getTrashFolder() == $_GET['mobj_id'])
865  {
866  $isTrashFolder = true;
867  }
868 
869  $current_folder_data = $this->mbox->getFolderData((int)$_GET['mobj_id']);
870 
871  $selectOptions = array();
872  $actions = $this->mbox->getActions((int)$_GET["mobj_id"]);
873  foreach($actions as $key => $action)
874  {
875  if($key == 'moveMails')
876  {
877  $folders = $this->mbox->getSubFolders();
878  foreach($folders as $folder)
879  {
880  if(
881  ($folder["type"] != 'trash' || !$isTrashFolder) &&
882  $folder['obj_id'] != $current_folder_data['obj_id']
883  )
884  {
885  $optionText = '';
886  if($folder['type'] != 'user_folder')
887  {
888  $optionText = $action . ' ' . $this->lng->txt('mail_' . $folder['title']) . ($folder['type'] == 'trash' ? ' (' . $this->lng->txt('delete') . ')' : '');
889  }
890  else
891  {
892  $optionText = $action . ' ' . $folder['title'];
893  }
894 
895  $selectOptions[$folder['obj_id']] = $optionText;
896  }
897  }
898  }
899  }
900 
901  if($current_folder_data['type'] == 'user_folder')
902  {
903  $txt_folder = $current_folder_data['title'];
904  }
905  else
906  {
907  $txt_folder = $this->lng->txt('mail_' . $current_folder_data['title']);
908  }
909  $ilToolbar->addSeparator();
910  $ilToolbar->addText(sprintf($this->lng->txt('current_folder'), $txt_folder));
911 
912  if(is_array($selectOptions) && count($selectOptions))
913  {
914  include_once 'Services/Form/classes/class.ilSelectInputGUI.php';
915  $actions = new ilSelectInputGUI('', 'selected_cmd');
916  $actions->setOptions($selectOptions);
917  $this->ctrl->setParameter($this, 'mail_id', (int)$_GET['mail_id']);
918  $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 'showMail'));
919  $ilToolbar->addInputItem($actions);
920  $ilToolbar->addFormButton($this->lng->txt('submit'), 'changeFolder');
921  }
922 
923  // Navigation
924  $prevMail = $this->umail->getPreviousMail((int)$_GET['mail_id']);
925  $nextMail = $this->umail->getNextMail((int)$_GET['mail_id']);
926  if(is_array($prevMail) || is_array($nextMail))
927  {
928  $ilToolbar->addSeparator();
929 
930  if($prevMail['mail_id'])
931  {
932  $this->ctrl->setParameter($this, 'mail_id', $prevMail['mail_id']);
933  $ilToolbar->addButton($this->lng->txt('previous'), $this->ctrl->getLinkTarget($this, 'showMail'));
934  $this->ctrl->clearParameters($this);
935  }
936 
937  if($nextMail['mail_id'])
938  {
939  $this->ctrl->setParameter($this, 'mail_id', $nextMail['mail_id']);
940  $ilToolbar->addButton($this->lng->txt('next'), $this->ctrl->getLinkTarget($this, 'showMail'));
941  $this->ctrl->clearParameters($this);
942  }
943  }
944 
945  $this->tpl->setContent($form->getHTML());
946  $this->tpl->show();
947  }
948 
952  public function printMail()
953  {
957  global $tpl;
958 
959  $tplprint = new ilTemplate('tpl.mail_print.html', true, true, 'Services/Mail');
960  $tplprint->setVariable('JSPATH', $tpl->tplPath);
961 
962  $mailData = $this->umail->getMail((int)$_GET['mail_id']);
963 
967  $sender = ilObjectFactory::getInstanceByObjId($mailData['sender_id'], false);
968 
969  $tplprint->setVariable('TXT_FROM', $this->lng->txt('from'));
970  if($sender && $sender->getId() && $sender->getId() != ANONYMOUS_USER_ID)
971  {
972  $tplprint->setVariable('FROM', $sender->getPublicName());
973  }
974  else if(!$sender || !$sender->getId())
975  {
976  $tplprint->setVariable('FROM', $mailData['import_name'] . ' (' . $this->lng->txt('user_deleted') . ')');
977  }
978  else
979  {
980  $tplprint->setVariable('FROM', ilMail::_getIliasMailerName());
981  }
982 
983  $tplprint->setVariable('TXT_TO', $this->lng->txt('mail_to'));
984  $tplprint->setVariable('TO', $mailData['rcp_to']);
985 
986  if($mailData['rcp_cc'])
987  {
988  $tplprint->setCurrentBlock('cc');
989  $tplprint->setVariable('TXT_CC', $this->lng->txt('cc'));
990  $tplprint->setVariable('CC', $mailData['rcp_cc']);
991  $tplprint->parseCurrentBlock();
992  }
993 
994  if($mailData['rcp_bcc'])
995  {
996  $tplprint->setCurrentBlock('bcc');
997  $tplprint->setVariable('TXT_BCC', $this->lng->txt('bc'));
998  $tplprint->setVariable('BCC', $mailData['rcp_bcc']);
999  $tplprint->parseCurrentBlock();
1000  }
1001 
1002  $tplprint->setVariable('TXT_SUBJECT', $this->lng->txt('subject'));
1003  $tplprint->setVariable('SUBJECT', htmlspecialchars($mailData['m_subject']));
1004 
1005  $tplprint->setVariable('TXT_DATE', $this->lng->txt('date'));
1006  $tplprint->setVariable('DATE', ilDatePresentation::formatDate(new ilDateTime($mailData['send_time'], IL_CAL_DATETIME)));
1007 
1008  $tplprint->setVariable('TXT_MESSAGE', $this->lng->txt('message'));
1009  $tplprint->setVariable('MAIL_MESSAGE', nl2br(htmlspecialchars($mailData['m_message'])));
1010 
1011  $tplprint->show();
1012  }
1013 
1014  function deliverFile()
1015  {
1016  if ($_SESSION["mail_id"])
1017  {
1018  $_GET["mail_id"] = $_SESSION["mail_id"];
1019  }
1020  $_SESSION["mail_id"] = "";
1021 
1022  $filename = ($_SESSION["filename"]
1023  ? $_SESSION["filename"]
1024  : ($_POST["filename"]
1025  ? $_POST["filename"]
1026  : $_GET["filename"]));
1027  $_SESSION["filename"] = "";
1028 
1029  if ($filename != "")
1030  {
1031  require_once "./Services/Mail/classes/class.ilFileDataMail.php";
1032 
1033  // secure filename
1034  $filename = str_replace("..", "", $filename);
1035 
1036  $mfile = new ilFileDataMail($_SESSION["AccountId"]);
1037  if(!is_array($file = $mfile->getAttachmentPathByMD5Filename($filename, $_GET['mail_id'])))
1038  {
1039  ilUtil::sendInfo($this->lng->txt('mail_error_reading_attachment'));
1040  $this->showMail();
1041  }
1042  else
1043  {
1044  ilUtil::deliverFile($file['path'], $file['filename']);
1045  }
1046  }
1047  else
1048  {
1049  ilUtil::sendInfo($this->lng->txt('mail_select_attachment'));
1050  $this->showMail();
1051  }
1052  }
1053 
1057  public function applyFilter()
1058  {
1059  $sentFolderId = $this->mbox->getSentFolder();
1060  $draftsFolderId = $this->mbox->getDraftsFolder();
1061 
1062  $isTrashFolder = $_GET['mobj_id'] == $this->mbox->getTrashFolder();
1063  $isSentFolder = $_GET['mobj_id'] == $sentFolderId;
1064  $isDraftFolder = $_GET['mobj_id'] == $draftsFolderId;
1065 
1066  $table = new ilMailFolderTableGUI($this, (int)$_GET['mobj_id'], 'showFolder');
1067  $table->isSentFolder($isSentFolder)
1068  ->isDraftFolder($isDraftFolder)
1069  ->isTrashFolder($isTrashFolder)
1070  ->initFilter();
1071  $table->resetOffset();
1072  $table->writeFilterToSession();
1073 
1074  $this->showFolder();
1075  }
1076 
1080  public function resetFilter()
1081  {
1082  $sentFolderId = $this->mbox->getSentFolder();
1083  $draftsFolderId = $this->mbox->getDraftsFolder();
1084 
1085  $isTrashFolder = $_GET['mobj_id'] == $this->mbox->getTrashFolder();
1086  $isSentFolder = $_GET['mobj_id'] == $sentFolderId;
1087  $isDraftFolder = $_GET['mobj_id'] == $draftsFolderId;
1088 
1089  $table = new ilMailFolderTableGUI($this, (int)$_GET['mobj_id'], 'showFolder');
1090  $table->isSentFolder($isSentFolder)
1091  ->isDraftFolder($isDraftFolder)
1092  ->isTrashFolder($isTrashFolder)
1093  ->initFilter();
1094  $table->resetOffset();
1095  $table->resetFilter();
1096 
1097  $this->showFolder();
1098  }
1099 }
1100 ?>
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
This class represents an option in a radio group.
print $file
setHtml($a_html)
Set Html.
$_POST['username']
Definition: cron.php:12
const IL_CAL_DATETIME
This class represents a selection list property in a property form.
This class represents a property form user interface.
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="")
Build img tag.
$_GET["client_id"]
This class handles all operations on files (attachments) in directory ilias_data/mail.
$cmd
Definition: sahs_server.php:35
static get($a_var)
Get a value.
Mail Box class Base class for creating and handling mail boxes.
_lookupPref($a_usr_id, $a_keyword)
const VIEWMODE_SESSION_KEY
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
GUI class for public user profile presentation.
addSubfolderCommands($check_uf=false)
This class represents a property in a property form.
askForEmptyTrash()
confirmation message for empty trash action
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
Class Mail this class handles base functions for mail handling.
special template class to simplify handling of ITX/PEAR
This class represents a text property in a property form.
static formatDate(ilDateTime $date)
Format a date public.
Date and time handling
_lookupLogin($a_user_id)
lookup login
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
setTableNames($a_table_tree, $a_table_obj_data, $a_table_obj_reference="")
set table names The primary key of the table containing your object_data must be &#39;obj_id&#39; You may use...
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
cancelEmptyTrash()
cancel Empty Trash Action and return to folder
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$filename
Definition: buildRTE.php:89
deleteSubfolder($a_show_confirm=true)
This class represents a custom property in a property form.
global $ilUser
Definition: imgupload.php:15
static _getFrame($a_class, $a_type='')
Get content frame name.
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
performEmptyTrash()
empty Trash and return to folder
static htmlencodePlainString($a_str, $a_make_links_clickable, $a_detect_goto_links=false)
Encodes a plain text string into HTML for display in a browser.
Confirmation screen class.