ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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
5require_once 'Services/User/classes/class.ilObjUser.php';
6require_once 'Services/Mail/classes/class.ilMailbox.php';
7require_once 'Services/Mail/classes/class.ilMail.php';
8require_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
9include_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")." ".
215 $this->tpl->setVariable("TBL_TITLE_IMG",ilUtil::getImagePath("icon_usr.svg"));
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 $a_show_confirmation = true;
280 }
281
282 $folders = $this->mbox->getSubFolders();
283 $mtree = new ilTree($ilUser->getId());
284 $mtree->setTableNames('mail_tree', 'mail_obj_data');
285
286 $check_uf = false;
287 $check_local = false;
288
290 {
291 $folder_d = $mtree->getNodeData($_GET['mobj_id']);
292 if($folder_d['m_type'] == 'user_folder')
293 {
294 $check_uf = true;
295 }
296 else if($folder_d['m_type'] == 'local')
297 {
298 $check_local = true;
299 }
300 }
301
302 $mailtable = new ilMailFolderTableGUI($this, (int)$_GET['mobj_id'], 'showFolder');
303 $mailtable->isSentFolder($isSentFolder)
304 ->isDraftFolder($isDraftFolder)
305 ->isTrashFolder($isTrashFolder)
306 ->initFilter();
307 $mailtable->setSelectedItems($_POST['mail_id']);
308
309 try
310 {
311 $mailtable->prepareHTML();
312 }
313 catch(Exception $e)
314 {
316 $this->lng->txt($e->getMessage()) != '-'.$e->getMessage().'-' ?
317 $this->lng->txt($e->getMessage()) :
318 $e->getMessage()
319 );
320 }
321
322 $table_html = $mailtable->getHtml();
323
324 $folder_options = array();
326 {
327 foreach($folders as $folder)
328 {
329 $folder_d = $mtree->getNodeData($folder['obj_id']);
330
331 if($folder['obj_id'] == $_GET['mobj_id'])
332 {
333 if($folder['type'] == 'user_folder')
334 {
335 $check_uf = true;
336 }
337 else if($folder['type'] == 'local')
338 {
339 $check_local = true;
340 $check_uf = false;
341 }
342 }
343
344 if($folder['type'] == 'user_folder')
345 {
346 $pre = '';
347 for ($i = 2; $i < $folder_d['depth'] - 1; $i++)
348 {
349 $pre .= '&nbsp';
350 }
351
352 if ($folder_d['depth'] > 1)
353 {
354 $pre .= '+';
355 }
356
357 $folder_options[$folder['obj_id']] = $pre.' '.$folder['title'];
358 }
359 else
360 {
361 $folder_options[$folder['obj_id']] = $this->lng->txt('mail_'.$folder['title']);
362 }
363 }
364 }
365
366 if($a_show_confirmation == false && $this->askForConfirmation == false)
367 {
369 {
370 $ilToolbar->addText($this->lng->txt('mail_change_to_folder'));
371 include_once './Services/Form/classes/class.ilSelectInputGUI.php';
372 $si = new ilSelectInputGUI("", "mobj_id");
373 $si->setOptions($folder_options);
374 $si->setValue($_GET['mobj_id']);
375 $ilToolbar->addInputItem($si);
376
377 $ilToolbar->addFormButton($this->lng->txt('change'),'showFolder');
378 $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 'showFolder'));
379 }
380 if($check_local == true || $check_uf == true)
381 {
382 $this->addSubfolderCommands($check_uf);
383 }
384 }
385 // END SHOW_FOLDER
386
387 if($mailtable->isTrashFolder() &&
388 $mailtable->getNumerOfMails() > 0 &&
389 $this->askForConfirmation)
390 {
391 $confirmation = new ilConfirmationGUI();
392 $confirmation->setHeaderText($this->lng->txt('mail_empty_trash_confirmation'));
393 $confirmation->setFormAction($this->ctrl->getFormAction($this, 'performEmptyTrash'));
394 $confirmation->setConfirm($this->lng->txt('confirm'), 'performEmptyTrash');
395 $confirmation->setCancel($this->lng->txt('cancel'), 'cancelEmptyTrash');
396 $this->tpl->setVariable('CONFIRMATION', $confirmation->getHTML());
397 }
398
399 $this->tpl->setVariable('MAIL_TABLE', $table_html);
400 $this->tpl->show();
401 }
402
403 public function deleteSubfolder($a_show_confirm = true)
404 {
405 if($a_show_confirm)
406 {
407 include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
408 $oConfirmationGUI = new ilConfirmationGUI();
409
410 // set confirm/cancel commands
411 $oConfirmationGUI->setFormAction($this->ctrl->getFormAction($this,"showFolder"));
412 $oConfirmationGUI->setHeaderText($this->lng->txt("mail_sure_delete_folder"));
413 $oConfirmationGUI->setCancel($this->lng->txt("cancel"), "showFolder");
414 $oConfirmationGUI->setConfirm($this->lng->txt("confirm"), "performDeleteSubfolder");
415 $this->tpl->setVariable('CONFIRMATION',$oConfirmationGUI->getHTML());
416
417 return $this->showFolder(true);
418 }
419 else
420 return $this->showFolder(false);
421 }
422
423 public function performDeleteSubFolder()
424 {
425 $new_parent = $this->mbox->getParentFolderId($_GET["mobj_id"]);
426
427 if ($this->mbox->deleteFolder($_GET["mobj_id"]))
428 {
429 ilUtil::sendInfo($this->lng->txt("mail_folder_deleted"),true);
430
431 $this->ctrl->setParameterByClass("ilMailGUI", "mobj_id", $new_parent);
432 $this->ctrl->redirectByClass("ilMailGUI");
433 }
434 else
435 {
436 ilUtil::sendFailure($this->lng->txt("mail_error_delete"));
437 return $this->showFolder();
438 }
439 }
440
441 public function performAddSubFolder()
442 {
443 if (isset($_POST["subfolder_title"]) && 'tree' == ilSession::get(ilMailGUI::VIEWMODE_SESSION_KEY)) $_SESSION["subfolder_title"] = ilUtil::stripSlashes($_POST['subfolder_title']);
444
445 if (empty($_POST['subfolder_title']))
446 {
447 ilUtil::sendInfo($this->lng->txt("mail_insert_folder_name"));
448 return $this->addSubFolder();
449 }
450 else if ($mobj_id = $this->mbox->addFolder($_GET["mobj_id"], ilUtil::stripSlashes($_POST["subfolder_title"])))
451 {
452 unset($_SESSION["subfolder_title"]);
453 ilUtil::sendInfo($this->lng->txt("mail_folder_created"), true);
454
455 $this->ctrl->setParameterByClass("ilMailGUI", 'mobj_id', $mobj_id);
456 $this->ctrl->redirectByClass("ilMailGUI");
457 }
458 else
459 {
460 ilUtil::sendFailure($this->lng->txt("mail_folder_exists"));
461 return $this->addSubFolder();
462 }
463 }
464
465 public function addSubFolder()
466 {
471 global $ilCtrl, $tpl;
472
473 include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
474
475 $tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.mail.html', 'Services/Mail');
476 $tpl->setTitle($this->lng->txt('mail'));
477
478 $oForm = new ilPropertyFormGUI();
479 $oForm->setFormAction($ilCtrl->getFormAction($this, 'performAddSubFolder'));
480 $oForm->setTitle($this->lng->txt('mail_add_folder'));
481
482 //title
483 $oTitle = new ilTextInputGUI();
484 $oTitle->setTitle($this->lng->txt('title'));
485 $oTitle->setPostVar('subfolder_title');
486 $oForm->addItem($oTitle);
487
488 $oForm->addCommandButton('performAddSubFolder', $this->lng->txt('save'));
489 $oForm->addCommandButton('showFolder', $this->lng->txt('cancel'));
490
491 $tpl->setVariable('FORM', $oForm->getHTML());
492 $tpl->show();
493
494 return true;
495 }
496
497 public function renameSubFolder()
498 {
503 global $ilCtrl, $tpl;
504
505 include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
506
507 $tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.mail.html', 'Services/Mail');
508 $tpl->setTitle($this->lng->txt('mail'));
509
510 $oForm = new ilPropertyFormGUI();
511 $oForm->setFormAction($ilCtrl->getFormAction($this, 'performRenameSubFolder'));
512 $oForm->setTitle($this->lng->txt('mail_rename_folder'));
513
514 //title
515 $oTitle = new ilTextInputGUI();
516 $oTitle->setTitle($this->lng->txt('title'));
517 $tmp_data = $this->mbox->getFolderData($_GET["mobj_id"]);
518 $oTitle->setValue($tmp_data["title"]);
519 $oTitle->setPostVar('subfolder_title');
520 $oForm->addItem($oTitle);
521
522 $oForm->addCommandButton('performRenameSubFolder', $this->lng->txt('save'));
523 $oForm->addCommandButton('showFolder', $this->lng->txt('cancel'));
524 $tpl->setVariable('FORM', $oForm->getHTML());
525 $tpl->show();
526
527 return true;
528 }
529
530 public function performRenameSubFolder()
531 {
532 if (isset($_POST["subfolder_title"]) && 'tree' == ilSession::get(ilMailGUI::VIEWMODE_SESSION_KEY)) $_SESSION["subfolder_title"] = $_POST['subfolder_title'];
533
534 $tmp_data = $this->mbox->getFolderData($_GET["mobj_id"]);
535 if ($tmp_data["title"] != $_POST["subfolder_title"])
536 {
537 if ($_POST["subfolder_title"] == "")
538 {
539 ilUtil::sendInfo($this->lng->txt("mail_insert_folder_name"));
540 return $this->renameSubFolder();
541 }
542 else
543 {
544 if ($this->mbox->renameFolder($_GET["mobj_id"], ilUtil::stripSlashes($_POST["subfolder_title"])))
545 {
546 ilUtil::sendInfo($this->lng->txt("mail_folder_name_changed"), true);
547 unset($_SESSION["subfolder_title"]);
548 $this->ctrl->redirectByClass("ilMailGUI");
549 }
550 else
551 {
552 ilUtil::sendFailure($this->lng->txt("mail_folder_exists"));
553 return $this->renameSubFolder();
554 }
555 }
556 }
557 return $this->showFolder();
558 }
559
560 public function changeFolder()
561 {
562 switch ($this->current_selected_cmd)
563 {
564 default:
565 if(!(int)$_GET["mail_id"] || !(int)$this->current_selected_cmd)
566 {
567 ilUtil::sendInfo($this->lng->txt("mail_move_error"));
568 return $this->showMail();
569 }
570
571 if ($this->umail->moveMailsToFolder(array($_GET["mail_id"]), $this->current_selected_cmd))
572 {
573 ilUtil::sendInfo($this->lng->txt("mail_moved"), true);
574 $this->ctrl->redirectByClass("ilMailGUI");
575 }
576 else
577 {
578 ilUtil::sendInfo($this->lng->txt("mail_move_error"));
579 }
580 break;
581 }
582
583 $this->showMail();
584
585 return true;
586 }
587
588 public function editFolder()
589 {
590 switch ($this->current_selected_cmd)
591 {
592 case 'markMailsRead':
593 if(is_array($_POST["mail_id"]))
594 {
595 $this->umail->markRead($_POST["mail_id"]);
596 }
597 else
598 {
599 ilUtil::sendInfo($this->lng->txt("mail_select_one"));
600 }
601 break;
602 case 'markMailsUnread':
603 if(is_array($_POST["mail_id"]))
604 {
605 $this->umail->markUnread($_POST["mail_id"]);
606 }
607 else
608 {
609 ilUtil::sendInfo($this->lng->txt("mail_select_one"));
610 }
611 break;
612
613 case 'deleteMails':
614 // IF MAILBOX IS TRASH ASK TO CONFIRM
615 if($this->mbox->getTrashFolder() == $_GET["mobj_id"])
616 {
617 if(!is_array($_POST["mail_id"]))
618 {
619 ilUtil::sendInfo($this->lng->txt("mail_select_one"));
620 $this->errorDelete = true;
621 }
622 } // END IF MAILBOX IS TRASH FOLDER
623 else
624 {
625 // MOVE MAILS TO TRASH
626 if(!is_array($_POST["mail_id"]))
627 {
628 ilUtil::sendInfo($this->lng->txt("mail_select_one"));
629 }
630 else if($this->umail->moveMailsToFolder($_POST["mail_id"], $this->mbox->getTrashFolder()))
631 {
632 $_GET["offset"] = 0;
633 ilUtil::sendInfo($this->lng->txt("mail_moved_to_trash"));
634 }
635 else
636 {
637 ilUtil::sendInfo($this->lng->txt("mail_move_error"));
638 }
639 }
640 break;
641
642 case 'add':
643 $this->ctrl->setParameterByClass("ilmailoptionsgui", "cmd", "add");
644 $this->ctrl->redirectByClass("ilmailoptionsgui");
645
646 case 'moveMails':
647 default:
648 if(!is_array($_POST["mail_id"]))
649 {
650 ilUtil::sendInfo($this->lng->txt("mail_select_one"));
651 }
652 else if($this->umail->moveMailsToFolder($_POST["mail_id"],$this->current_selected_cmd))
653 {
654 ilUtil::sendInfo($this->lng->txt("mail_moved"));
655 }
656 else
657 {
658 ilUtil::sendInfo($this->lng->txt("mail_move_error"));
659 }
660 break;
661 }
662
663 $this->showFolder();
664 }
665
669 public function confirmDeleteMails()
670 {
671 if($this->mbox->getTrashFolder() == $_GET['mobj_id'])
672 {
673 $_POST['mail_id'] = $mail_ids = explode(',', $_GET['mail_id']);
674 if(!is_array($mail_ids))
675 {
676 ilUtil::sendInfo($this->lng->txt('mail_select_one'));
677 }
678 else if($this->umail->deleteMails($mail_ids))
679 {
680 $_GET['offset'] = 0;
681 ilUtil::sendInfo($this->lng->txt('mail_deleted'));
682 }
683 else
684 {
685 ilUtil::sendInfo($this->lng->txt('mail_delete_error'));
686 }
687 }
688
689 $this->showFolder();
690 }
691
692 public function cancelDeleteMails()
693 {
694 $this->ctrl->redirect($this);
695 }
696
700 public function showMail()
701 {
707 global $ilUser, $ilToolbar, $ilTabs;
708
709 if($_SESSION['mail_id'])
710 {
711 $_GET['mail_id'] = $_SESSION['mail_id'];
712 $_SESSION['mail_id'] = '';
713 }
714
715 $ilTabs->clearTargets();
716 $ilTabs->setBackTarget($this->lng->txt('back_to_folder'), $this->ctrl->getFormAction($this, 'showFolder'));
717
718 $this->umail->markRead(array((int)$_GET['mail_id']));
719 $mailData = $this->umail->getMail((int)$_GET['mail_id']);
720
721 $this->tpl->setTitle($this->lng->txt('mail_mails_of'));
722
723 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
724
725 $form = new ilPropertyFormGUI();
726 $form->setPreventDoubleSubmission(false);
727 $form->setTableWidth('100%');
728 $this->ctrl->setParameter($this, 'mail_id', (int)$_GET['mail_id']);
729 $form->setFormAction($this->ctrl->getFormAction($this, 'showMail'));
730 $this->ctrl->clearParameters($this);
731 $form->setTitle($this->lng->txt('mail_mails_of'));
732
734 {
735 $this->tpl->setVariable('FORM_TARGET', ilFrameTargetInfo::_getFrame('MainContent'));
736 }
737
738 include_once 'Services/Accessibility/classes/class.ilAccessKeyGUI.php';
739
743 $sender = ilObjectFactory::getInstanceByObjId($mailData['sender_id'], false);
744
745 if($sender && $sender->getId() && $sender->getId() != ANONYMOUS_USER_ID)
746 {
747 $this->ctrl->setParameterByClass('ilmailformgui', 'mail_id', (int)$_GET['mail_id']);
748 $this->ctrl->setParameterByClass('ilmailformgui', 'type', 'reply');
749 $this->ctrl->clearParametersByClass('iliasmailformgui');
750 $ilToolbar->addButton($this->lng->txt('reply'), $this->ctrl->getLinkTargetByClass('ilmailformgui'), '', ilAccessKey::REPLY);
751 $this->ctrl->clearParameters($this);
752 }
753
754 $this->ctrl->setParameterByClass('ilmailformgui', 'mail_id', (int)$_GET['mail_id']);
755 $this->ctrl->setParameterByClass('ilmailformgui', 'type', 'forward');
756 $this->ctrl->clearParametersByClass('iliasmailformgui');
757 $ilToolbar->addButton($this->lng->txt('forward'), $this->ctrl->getLinkTargetByClass('ilmailformgui'), '', ilAccessKey::FORWARD_MAIL);
758 $this->ctrl->clearParameters($this);
759
760 $this->ctrl->setParameter($this, 'mail_id', (int)$_GET['mail_id']);
761 $ilToolbar->addButton($this->lng->txt('print'), $this->ctrl->getLinkTarget($this, 'printMail'), '_blank');
762 $this->ctrl->clearParameters($this);
763
764 $this->ctrl->setParameter($this, 'mail_id', (int)$_GET['mail_id']);
765 $this->ctrl->setParameter($this, 'selected_cmd', 'deleteMails');
766 $ilToolbar->addButton($this->lng->txt('delete'), $this->ctrl->getLinkTarget($this), '', ilAccessKey::DELETE);
767 $this->ctrl->clearParameters($this);
768
769 if($sender && $sender->getId() && $sender->getId() != ANONYMOUS_USER_ID)
770 {
771 $linked_fullname = $sender->getPublicName();
772 $picture = ilUtil::img($sender->getPersonalPicturePath('xsmall'), $sender->getPublicName());
773 $add_to_addb_button = '';
774
775 if(in_array(ilObjUser::_lookupPref($sender->getId(), 'public_profile'), array('y', 'g')))
776 {
777 $this->ctrl->setParameter($this, 'mail_id', (int)$_GET['mail_id']);
778 $this->ctrl->setParameter($this, 'user', $sender->getId());
779 $linked_fullname = '<br /><a href="' . $this->ctrl->getLinkTarget($this, 'showUser') . '" title="'.$linked_fullname.'">' . $linked_fullname . '</a>';
780 $this->ctrl->clearParameters($this);
781 }
782
783 if($sender->getId() != $ilUser->getId())
784 {
785 require_once 'Services/Contact/classes/class.ilAddressbook.php';
786 $abook = new ilAddressbook($ilUser->getId());
787 if($abook->checkEntryByLogin($sender->getLogin()) == 0)
788 {
789 $tplbtn = new ilTemplate('tpl.buttons.html', true, true);
790
791 $tplbtn->setCurrentBlock('btn_cell');
792 $this->ctrl->setParameter($this, 'mail_id', (int)$_GET['mail_id']);
793 $tplbtn->setVariable('BTN_LINK', $this->ctrl->getLinkTarget($this, 'add'));
794 $this->ctrl->clearParameters($this);
795 $tplbtn->setVariable('BTN_TXT', $this->lng->txt('mail_add_to_addressbook'));
796 $tplbtn->parseCurrentBlock();
797
798 $add_to_addb_button = '<br />' . $tplbtn->get();
799 }
800 }
801
802 $from = new ilCustomInputGUI($this->lng->txt('from'));
803 $from->setHtml($picture . ' ' . $linked_fullname . $add_to_addb_button);
804 $form->addItem($from);
805 }
806 else if(!$sender || !$sender->getId())
807 {
808 $from = new ilCustomInputGUI($this->lng->txt('from'));
809 $from->setHtml($mailData['import_name'] . ' (' . $this->lng->txt('user_deleted') . ')');
810 $form->addItem($from);
811 }
812 else
813 {
814 $from = new ilCustomInputGUI($this->lng->txt('from'));
815 $from->setHtml(ilUtil::img(ilUtil::getImagePath('HeaderIconAvatar.svg'), ilMail::_getIliasMailerName()) . '<br />' . ilMail::_getIliasMailerName());
816 $form->addItem($from);
817 }
818
819 $to = new ilCustomInputGUI($this->lng->txt('mail_to'));
820 $to->setHtml(ilUtil::htmlencodePlainString($this->umail->formatNamesForOutput($mailData['rcp_to']), false));
821 $form->addItem($to);
822
823 if($mailData['rcp_cc'])
824 {
825 $cc = new ilCustomInputGUI($this->lng->txt('cc'));
826 $cc->setHtml(ilUtil::htmlencodePlainString($this->umail->formatNamesForOutput($mailData['rcp_cc']), false));
827 $form->addItem($cc);
828 }
829
830 if($mailData['rcp_bcc'])
831 {
832 $bcc = new ilCustomInputGUI($this->lng->txt('bc'));
833 $bcc->setHtml(ilUtil::htmlencodePlainString($this->umail->formatNamesForOutput($mailData['rcp_bcc']), false));
834 $form->addItem($bcc);
835 }
836
837 $subject = new ilCustomInputGUI($this->lng->txt('subject'));
838 $subject->setHtml(ilUtil::htmlencodePlainString($mailData['m_subject'], true));
839 $form->addItem($subject);
840
841 $date = new ilCustomInputGUI($this->lng->txt('date'));
842 $date->setHtml(ilDatePresentation::formatDate(new ilDateTime($mailData['send_time'], IL_CAL_DATETIME)));
843 $form->addItem($date);
844
845 $message = new ilCustomInputGUI($this->lng->txt('message'));
846 $message->setHtml(ilUtil::htmlencodePlainString($mailData['m_message'], true));
847 $form->addItem($message);
848
849 if($mailData['attachments'])
850 {
851 $att = new ilCustomInputGUI($this->lng->txt('attachments'));
852
853 $radiog = new ilRadioGroupInputGUI('', 'filename');
854
855 foreach($mailData['attachments'] as $file)
856 {
857 $radiog->addOption(new ilRadioOption($file, md5($file)));
858 }
859
860 $att->setHtml($radiog->render());
861 $form->addCommandButton('deliverFile', $this->lng->txt('download'));
862 $form->addItem($att);
863 }
864
865 $isTrashFolder = false;
866 if($this->mbox->getTrashFolder() == $_GET['mobj_id'])
867 {
868 $isTrashFolder = true;
869 }
870
871 $current_folder_data = $this->mbox->getFolderData((int)$_GET['mobj_id']);
872
873 $selectOptions = array();
874 $actions = $this->mbox->getActions((int)$_GET["mobj_id"]);
875 foreach($actions as $key => $action)
876 {
877 if($key == 'moveMails')
878 {
879 $folders = $this->mbox->getSubFolders();
880 foreach($folders as $folder)
881 {
882 if(
883 ($folder["type"] != 'trash' || !$isTrashFolder) &&
884 $folder['obj_id'] != $current_folder_data['obj_id']
885 )
886 {
887 $optionText = '';
888 if($folder['type'] != 'user_folder')
889 {
890 $optionText = $action . ' ' . $this->lng->txt('mail_' . $folder['title']) . ($folder['type'] == 'trash' ? ' (' . $this->lng->txt('delete') . ')' : '');
891 }
892 else
893 {
894 $optionText = $action . ' ' . $folder['title'];
895 }
896
897 $selectOptions[$folder['obj_id']] = $optionText;
898 }
899 }
900 }
901 }
902
903 if($current_folder_data['type'] == 'user_folder')
904 {
905 $txt_folder = $current_folder_data['title'];
906 }
907 else
908 {
909 $txt_folder = $this->lng->txt('mail_' . $current_folder_data['title']);
910 }
911 $ilToolbar->addSeparator();
912 $ilToolbar->addText(sprintf($this->lng->txt('current_folder'), $txt_folder));
913
914 if(is_array($selectOptions) && count($selectOptions))
915 {
916 include_once 'Services/Form/classes/class.ilSelectInputGUI.php';
917 $actions = new ilSelectInputGUI('', 'selected_cmd');
918 $actions->setOptions($selectOptions);
919 $this->ctrl->setParameter($this, 'mail_id', (int)$_GET['mail_id']);
920 $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 'showMail'));
921 $ilToolbar->addInputItem($actions);
922 $ilToolbar->addFormButton($this->lng->txt('submit'), 'changeFolder');
923 }
924
925 // Navigation
926 $prevMail = $this->umail->getPreviousMail((int)$_GET['mail_id']);
927 $nextMail = $this->umail->getNextMail((int)$_GET['mail_id']);
928 if(is_array($prevMail) || is_array($nextMail))
929 {
930 $ilToolbar->addSeparator();
931
932 if($prevMail['mail_id'])
933 {
934 $this->ctrl->setParameter($this, 'mail_id', $prevMail['mail_id']);
935 $ilToolbar->addButton($this->lng->txt('previous'), $this->ctrl->getLinkTarget($this, 'showMail'));
936 $this->ctrl->clearParameters($this);
937 }
938
939 if($nextMail['mail_id'])
940 {
941 $this->ctrl->setParameter($this, 'mail_id', $nextMail['mail_id']);
942 $ilToolbar->addButton($this->lng->txt('next'), $this->ctrl->getLinkTarget($this, 'showMail'));
943 $this->ctrl->clearParameters($this);
944 }
945 }
946
947 $this->tpl->setContent($form->getHTML());
948 $this->tpl->show();
949 }
950
954 public function printMail()
955 {
959 global $tpl;
960
961 $tplprint = new ilTemplate('tpl.mail_print.html', true, true, 'Services/Mail');
962 $tplprint->setVariable('JSPATH', $tpl->tplPath);
963
964 $mailData = $this->umail->getMail((int)$_GET['mail_id']);
965
969 $sender = ilObjectFactory::getInstanceByObjId($mailData['sender_id'], false);
970
971 $tplprint->setVariable('TXT_FROM', $this->lng->txt('from'));
972 if($sender && $sender->getId() && $sender->getId() != ANONYMOUS_USER_ID)
973 {
974 $tplprint->setVariable('FROM', $sender->getPublicName());
975 }
976 else if(!$sender || !$sender->getId())
977 {
978 $tplprint->setVariable('FROM', $mailData['import_name'] . ' (' . $this->lng->txt('user_deleted') . ')');
979 }
980 else
981 {
982 $tplprint->setVariable('FROM', ilMail::_getIliasMailerName());
983 }
984
985 $tplprint->setVariable('TXT_TO', $this->lng->txt('mail_to'));
986 $tplprint->setVariable('TO', $mailData['rcp_to']);
987
988 if($mailData['rcp_cc'])
989 {
990 $tplprint->setCurrentBlock('cc');
991 $tplprint->setVariable('TXT_CC', $this->lng->txt('cc'));
992 $tplprint->setVariable('CC', $mailData['rcp_cc']);
993 $tplprint->parseCurrentBlock();
994 }
995
996 if($mailData['rcp_bcc'])
997 {
998 $tplprint->setCurrentBlock('bcc');
999 $tplprint->setVariable('TXT_BCC', $this->lng->txt('bc'));
1000 $tplprint->setVariable('BCC', $mailData['rcp_bcc']);
1001 $tplprint->parseCurrentBlock();
1002 }
1003
1004 $tplprint->setVariable('TXT_SUBJECT', $this->lng->txt('subject'));
1005 $tplprint->setVariable('SUBJECT', htmlspecialchars($mailData['m_subject']));
1006
1007 $tplprint->setVariable('TXT_DATE', $this->lng->txt('date'));
1008 $tplprint->setVariable('DATE', ilDatePresentation::formatDate(new ilDateTime($mailData['send_time'], IL_CAL_DATETIME)));
1009
1010 $tplprint->setVariable('TXT_MESSAGE', $this->lng->txt('message'));
1011 $tplprint->setVariable('MAIL_MESSAGE', nl2br(htmlspecialchars($mailData['m_message'])));
1012
1013 $tplprint->show();
1014 }
1015
1016 function deliverFile()
1017 {
1018 if ($_SESSION["mail_id"])
1019 {
1020 $_GET["mail_id"] = $_SESSION["mail_id"];
1021 }
1022 $_SESSION["mail_id"] = "";
1023
1024 $filename = ($_SESSION["filename"]
1025 ? $_SESSION["filename"]
1026 : ($_POST["filename"]
1027 ? $_POST["filename"]
1028 : $_GET["filename"]));
1029 $_SESSION["filename"] = "";
1030
1031 if ($filename != "")
1032 {
1033 require_once "./Services/Mail/classes/class.ilFileDataMail.php";
1034
1035 // secure filename
1036 $filename = str_replace("..", "", $filename);
1037
1038 $mfile = new ilFileDataMail($_SESSION["AccountId"]);
1039 if(!is_array($file = $mfile->getAttachmentPathByMD5Filename($filename, $_GET['mail_id'])))
1040 {
1041 ilUtil::sendInfo($this->lng->txt('mail_error_reading_attachment'));
1042 $this->showMail();
1043 }
1044 else
1045 {
1046 ilUtil::deliverFile($file['path'], $file['filename']);
1047 }
1048 }
1049 else
1050 {
1051 ilUtil::sendInfo($this->lng->txt('mail_select_attachment'));
1052 $this->showMail();
1053 }
1054 }
1055
1059 public function applyFilter()
1060 {
1061 $sentFolderId = $this->mbox->getSentFolder();
1062 $draftsFolderId = $this->mbox->getDraftsFolder();
1063
1064 $isTrashFolder = $_GET['mobj_id'] == $this->mbox->getTrashFolder();
1065 $isSentFolder = $_GET['mobj_id'] == $sentFolderId;
1066 $isDraftFolder = $_GET['mobj_id'] == $draftsFolderId;
1067
1068 $table = new ilMailFolderTableGUI($this, (int)$_GET['mobj_id'], 'showFolder');
1069 $table->isSentFolder($isSentFolder)
1070 ->isDraftFolder($isDraftFolder)
1071 ->isTrashFolder($isTrashFolder)
1072 ->initFilter();
1073 $table->resetOffset();
1074 $table->writeFilterToSession();
1075
1076 $this->showFolder();
1077 }
1078
1082 public function resetFilter()
1083 {
1084 $sentFolderId = $this->mbox->getSentFolder();
1085 $draftsFolderId = $this->mbox->getDraftsFolder();
1086
1087 $isTrashFolder = $_GET['mobj_id'] == $this->mbox->getTrashFolder();
1088 $isSentFolder = $_GET['mobj_id'] == $sentFolderId;
1089 $isDraftFolder = $_GET['mobj_id'] == $draftsFolderId;
1090
1091 $table = new ilMailFolderTableGUI($this, (int)$_GET['mobj_id'], 'showFolder');
1092 $table->isSentFolder($isSentFolder)
1093 ->isDraftFolder($isDraftFolder)
1094 ->isTrashFolder($isTrashFolder)
1095 ->initFilter();
1096 $table->resetOffset();
1097 $table->resetFilter();
1098
1099 $this->showFolder();
1100 }
1101}
1102?>
print $file
$filename
Definition: buildRTE.php:89
$_GET["client_id"]
const IL_CAL_DATETIME
Mail Box class Base class for creating and handling mail boxes.
Confirmation screen class.
This class represents a custom property in a property form.
static formatDate(ilDateTime $date)
Format a date @access public.
@classDescription Date and time handling
This class handles all operations on files (attachments) in directory ilias_data/mail.
static _getFrame($a_class, $a_type='')
Get content frame name.
addSubfolderCommands($check_uf=false)
cancelEmptyTrash()
cancel Empty Trash Action and return to folder
performEmptyTrash()
empty Trash and return to folder
askForEmptyTrash()
confirmation message for empty trash action
deleteSubfolder($a_show_confirm=true)
const VIEWMODE_SESSION_KEY
Class Mail this class handles base functions for mail handling.
_lookupLogin($a_user_id)
lookup login
_lookupPref($a_usr_id, $a_keyword)
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
This class represents a property form user interface.
GUI class for public user profile presentation.
This class represents a property in a property form.
This class represents an option in a radio group.
This class represents a selection list property in a property form.
static get($a_var)
Get a value.
special template class to simplify handling of ITX/PEAR
This class represents a text property in a property form.
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.
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
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.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
$_POST['username']
Definition: cron.php:12
< 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']
global $ilCtrl
Definition: ilias.php:18
$cmd
Definition: sahs_server.php:35
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
global $ilUser
Definition: imgupload.php:15