ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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{
23
24 private $tpl = null;
25 private $ctrl = null;
26 private $lng = null;
27
28 public $umail = null;
29 public $mbox = null;
30
31 private $errorDelete = false;
32
33 public function __construct()
34 {
35 global $tpl, $ilCtrl, $lng, $ilUser;
36
37 $this->tpl = $tpl;
38 $this->ctrl = $ilCtrl;
39 $this->lng = $lng;
40
41 $this->umail = new ilMail($ilUser->getId());
42 $this->mbox = new ilMailBox($ilUser->getId());
43
44 if(isset($_POST['mobj_id']) && (int)$_POST['mobj_id'])
45 {
46 $_GET['mobj_id'] = $_POST['mobj_id'];
47 }
48 // IF THERE IS NO OBJ_ID GIVEN GET THE ID OF MAIL ROOT NODE
49 if(!(int)$_GET['mobj_id'])
50 {
51 $_GET['mobj_id'] = $this->mbox->getInboxFolder();
52 }
53 $_GET['mobj_id'] = (int)$_GET['mobj_id'];
54 $ilCtrl->saveParameter($this, 'mobj_id');
55 $ilCtrl->setParameter($this, 'mobj_id', $_GET['mobj_id']);
56
57 }
58
59 public function executeCommand()
60 {
61 if ($_POST["select_cmd"])
62 {
63 $_GET["cmd"] = 'editFolder';
64
65 // lower menubar execute-button
66 $this->current_select_cmd = $_POST['select_cmd'];
67 $this->current_selected_cmd = $_POST['selected_cmd'];
68 }
69 else if ($_POST["select_cmd2"])
70 {
71 // upper menubar execute-button
72 $_GET["cmd"] = 'editFolder';
73 $this->current_select_cmd = $_POST['select_cmd2'];
74 $this->current_selected_cmd = $_POST['selected_cmd2'];
75 }
76
77 /* Fix: User views mail and wants to delete it...
78 mjansen: The mail system needs a revision :-)
79 */
80 if ($_GET['selected_cmd'] == "deleteMails" && $_GET["mail_id"])
81 {
82 $_GET["cmd"] = "editFolder";
83 $this->current_selected_cmd = "deleteMails";
84 $_POST["mail_id"] = array($_GET["mail_id"]);
85 }
86
87 /* Fix: User views mail and wants to move it...
88 mjansen: The mail system needs a revision :-)
89 */
90 $cmd = $this->ctrl->getCmd();
91 if($cmd == 'changeFolder' &&
92 is_numeric($_POST['selected_cmd']) &&
93 $_GET["mail_id"])
94 {
95 $this->current_selected_cmd = (int)$_POST['selected_cmd'];
96 }
97
98 $forward_class = $this->ctrl->getNextClass($this);
99 switch($forward_class)
100 {
101 case 'ilcontactgui':
102 require_once 'Services/Contact/classes/class.ilContactGUI.php';
103 $this->ctrl->forwardCommand(new ilContactGUI());
104 break;
105
106 case 'ilmailoptionsgui':
107 include_once 'Services/Mail/classes/class.ilMailOptionsGUI.php';
108
109 $this->ctrl->forwardCommand(new ilMailOptionsGUI());
110 break;
111
112 case 'ilpublicuserprofilegui':
113 include_once("Services/User/classes/class.ilPublicUserProfileGUI.php");
114 $this->tpl->setTitle($this->lng->txt("mail"));
115 $this->ctrl->saveParameter($this, "mail_id");
116 $profile_gui = new ilPublicUserProfileGUI($_GET["user"]);
117 $profile_gui->setBackUrl($this->ctrl->getLinkTarget($this, "showMail"));
118 $ret = $this->ctrl->forwardCommand($profile_gui);
119 if ($ret != "")
120 {
121 $this->tpl->setContent($ret);
122 $this->tpl->show();
123 }
124 break;
125
126 default:
127 if (!($cmd = $this->ctrl->getCmd()))
128 {
129 $cmd = "showFolder";
130 }
131 $this->$cmd();
132 break;
133 }
134 return true;
135 }
136
140 public function cancelEmptyTrash()
141 {
142 $this->showFolder();
143 }
144
148 public function performEmptyTrash()
149 {
150 $this->umail->deleteMailsOfFolder($_GET['mobj_id']);
151 ilUtil::sendInfo($this->lng->txt('mail_deleted'));
152 $this->showFolder();
153 }
154
158 public function askForEmptyTrash()
159 {
160 if($this->umail->countMailsOfFolder((int)$_GET['mobj_id']))
161 {
162 $this->askForConfirmation = true;
163 }
164
165 $this->showFolder();
166
167 return true;
168 }
169
170 public function showUser()
171 {
172 global $ilCtrl, $ilToolbar;
173
174 $this->ctrl->setParameter($this, "mail_id", $_GET["mail_id"]);
175
176 $this->tpl->setTitle($this->lng->txt("mail"));
177 //$ilToolbar->addButton($this->lng->txt("back"), $this->ctrl->getLinkTarget($this, "showMail"));
178
179 $this->tpl->setVariable("TBL_TITLE", $this->lng->txt("profile_of")." ".
181 $this->tpl->setVariable("TBL_TITLE_IMG",ilUtil::getImagePath("icon_usr.svg"));
182 $this->tpl->setVariable("TBL_TITLE_IMG_ALT", $this->lng->txt("public_profile"));
183
184 include_once './Services/User/classes/class.ilPublicUserProfileGUI.php';
185 $profile_gui = new ilPublicUserProfileGUI($_GET["user"]);
186 $profile_gui->setBackUrl($this->ctrl->getLinkTarget($this, "showMail"));
187 $this->tpl->setContent($ilCtrl->getHTML($profile_gui));
188 $this->tpl->show();
189
190 return true;
191 }
192
193 public function addSubfolderCommands($check_uf = false)
194 {
195 global $ilToolbar;
196
198 {
199 $ilToolbar->addSeparator();
200 }
201
202 $ilToolbar->addButton($this->lng->txt('mail_add_subfolder'), $this->ctrl->getLinkTarget($this, 'addSubFolder'));
203
204 if($check_uf == true)
205 {
206 $ilToolbar->addButton($this->lng->txt('rename'), $this->ctrl->getLinkTarget($this, 'renameSubFolder'));
207 $ilToolbar->addButton($this->lng->txt('delete'), $this->ctrl->getLinkTarget($this, 'deleteSubFolder'));
208 }
209 return true;
210 }
214 public function showFolder($a_show_confirmation = false)
215 {
220 global $ilUser, $ilToolbar;
221
222 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.mail.html', 'Services/Mail');
223 $this->tpl->setTitle($this->lng->txt('mail'));
224
225 $sentFolderId = $this->mbox->getSentFolder();
226 $draftsFolderId = $this->mbox->getDraftsFolder();
227
228 $isTrashFolder = $_GET['mobj_id'] == $this->mbox->getTrashFolder();
229 $isSentFolder = $_GET['mobj_id'] == $sentFolderId;
230 $isDraftFolder = $_GET['mobj_id'] == $draftsFolderId;
231
232 if($this->current_selected_cmd == 'deleteMails' &&
233 !$this->errorDelete &&
234 $this->current_selected_cmd != 'confirm' &&
235 $isTrashFolder)
236 {
237 if(isset($_REQUEST['mail_id']) && !is_array($_REQUEST['mail_id'])) $_REQUEST['mail_id'] = array($_REQUEST['mail_id']);
238 $confirmation = new ilConfirmationGUI();
239 $confirmation->setHeaderText($this->lng->txt('mail_sure_delete'));
240 $this->ctrl->setParameter($this, 'mail_id', implode(',', (array)$_REQUEST['mail_id']));
241 $confirmation->setFormAction($this->ctrl->getFormAction($this, 'confirmDeleteMails'));
242 $confirmation->setConfirm($this->lng->txt('confirm'), 'confirmDeleteMails');
243 $confirmation->setCancel($this->lng->txt('cancel'), 'cancelDeleteMails');
244 $this->tpl->setVariable('CONFIRMATION', $confirmation->getHTML());
245 $a_show_confirmation = true;
246 }
247
248 $folders = $this->mbox->getSubFolders();
249 $mtree = new ilTree($ilUser->getId());
250 $mtree->setTableNames('mail_tree', 'mail_obj_data');
251
252 $check_uf = false;
253 $check_local = false;
254
256 {
257 $folder_d = $mtree->getNodeData($_GET['mobj_id']);
258 if($folder_d['m_type'] == 'user_folder')
259 {
260 $check_uf = true;
261 }
262 else if($folder_d['m_type'] == 'local')
263 {
264 $check_local = true;
265 }
266 }
267
268 $mailtable = new ilMailFolderTableGUI($this, (int)$_GET['mobj_id'], 'showFolder');
269 $mailtable->isSentFolder($isSentFolder)
270 ->isDraftFolder($isDraftFolder)
271 ->isTrashFolder($isTrashFolder)
272 ->initFilter();
273 $mailtable->setSelectedItems($_POST['mail_id']);
274
275 try
276 {
277 $mailtable->prepareHTML();
278 }
279 catch(Exception $e)
280 {
282 $this->lng->txt($e->getMessage()) != '-'.$e->getMessage().'-' ?
283 $this->lng->txt($e->getMessage()) :
284 $e->getMessage()
285 );
286 }
287
288 $table_html = $mailtable->getHtml();
289
290 $folder_options = array();
292 {
293 foreach($folders as $folder)
294 {
295 $folder_d = $mtree->getNodeData($folder['obj_id']);
296
297 if($folder['obj_id'] == $_GET['mobj_id'])
298 {
299 if($folder['type'] == 'user_folder')
300 {
301 $check_uf = true;
302 }
303 else if($folder['type'] == 'local')
304 {
305 $check_local = true;
306 $check_uf = false;
307 }
308 }
309
310 if($folder['type'] == 'user_folder')
311 {
312 $pre = '';
313 for ($i = 2; $i < $folder_d['depth'] - 1; $i++)
314 {
315 $pre .= '&nbsp;';
316 }
317
318 if ($folder_d['depth'] > 1)
319 {
320 $pre .= '+';
321 }
322
323 $folder_options[$folder['obj_id']] = $pre.' '.$folder['title'];
324 }
325 else
326 {
327 $folder_options[$folder['obj_id']] = $this->lng->txt('mail_'.$folder['title']);
328 }
329 }
330 }
331
332 if($a_show_confirmation == false && $this->askForConfirmation == false)
333 {
335 {
336 $ilToolbar->addText($this->lng->txt('mail_change_to_folder'));
337 include_once './Services/Form/classes/class.ilSelectInputGUI.php';
338 $si = new ilSelectInputGUI("", "mobj_id");
339 $si->setOptions($folder_options);
340 $si->setValue($_GET['mobj_id']);
341 $ilToolbar->addInputItem($si);
342
343 $ilToolbar->addFormButton($this->lng->txt('change'),'showFolder');
344 $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 'showFolder'));
345 }
346 if($check_local == true || $check_uf == true)
347 {
348 $this->addSubfolderCommands($check_uf);
349 }
350 }
351 // END SHOW_FOLDER
352
353 if($mailtable->isTrashFolder() &&
354 $mailtable->getNumerOfMails() > 0 &&
355 $this->askForConfirmation)
356 {
357 $confirmation = new ilConfirmationGUI();
358 $confirmation->setHeaderText($this->lng->txt('mail_empty_trash_confirmation'));
359 $confirmation->setFormAction($this->ctrl->getFormAction($this, 'performEmptyTrash'));
360 $confirmation->setConfirm($this->lng->txt('confirm'), 'performEmptyTrash');
361 $confirmation->setCancel($this->lng->txt('cancel'), 'cancelEmptyTrash');
362 $this->tpl->setVariable('CONFIRMATION', $confirmation->getHTML());
363 }
364
365 $this->tpl->setVariable('MAIL_TABLE', $table_html);
366 $this->tpl->show();
367 }
368
369 public function deleteSubfolder($a_show_confirm = true)
370 {
371 if($a_show_confirm)
372 {
373 include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
374 $oConfirmationGUI = new ilConfirmationGUI();
375
376 // set confirm/cancel commands
377 $oConfirmationGUI->setFormAction($this->ctrl->getFormAction($this,"showFolder"));
378 $oConfirmationGUI->setHeaderText($this->lng->txt("mail_sure_delete_folder"));
379 $oConfirmationGUI->setCancel($this->lng->txt("cancel"), "showFolder");
380 $oConfirmationGUI->setConfirm($this->lng->txt("confirm"), "performDeleteSubfolder");
381 $this->tpl->setVariable('CONFIRMATION',$oConfirmationGUI->getHTML());
382
383 return $this->showFolder(true);
384 }
385 else
386 return $this->showFolder(false);
387 }
388
389 public function performDeleteSubFolder()
390 {
391 $new_parent = $this->mbox->getParentFolderId((int)$_GET['mobj_id']);
392 if($this->mbox->deleteFolder((int)$_GET['mobj_id']))
393 {
394 ilUtil::sendInfo($this->lng->txt('mail_folder_deleted'), true);
395 $this->ctrl->setParameterByClass('ilMailGUI', 'mobj_id', (int)$new_parent);
396 $this->ctrl->redirectByClass('ilMailGUI');
397 }
398 else
399 {
400 ilUtil::sendFailure($this->lng->txt('mail_error_delete'));
401 $this->showFolder();
402 return;
403 }
404 }
405
406 public function performAddSubFolder()
407 {
408 if (isset($_POST["subfolder_title"]) && 'tree' == ilSession::get(ilMailGUI::VIEWMODE_SESSION_KEY)) $_SESSION["subfolder_title"] = ilUtil::stripSlashes($_POST['subfolder_title']);
409
410 if (empty($_POST['subfolder_title']))
411 {
412 ilUtil::sendInfo($this->lng->txt("mail_insert_folder_name"));
413 return $this->addSubFolder();
414 }
415 else if ($mobj_id = $this->mbox->addFolder($_GET["mobj_id"], ilUtil::stripSlashes($_POST["subfolder_title"])))
416 {
417 unset($_SESSION["subfolder_title"]);
418 ilUtil::sendInfo($this->lng->txt("mail_folder_created"), true);
419
420 $this->ctrl->setParameterByClass("ilMailGUI", 'mobj_id', $mobj_id);
421 $this->ctrl->redirectByClass("ilMailGUI");
422 }
423 else
424 {
425 ilUtil::sendFailure($this->lng->txt("mail_folder_exists"));
426 $this->addSubFolder();
427 return;
428 }
429 }
430
431 public function addSubFolder()
432 {
437 global $ilCtrl, $tpl;
438
439 include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
440
441 $tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.mail.html', 'Services/Mail');
442 $tpl->setTitle($this->lng->txt('mail'));
443
444 $oForm = new ilPropertyFormGUI();
445 $oForm->setFormAction($ilCtrl->getFormAction($this, 'performAddSubFolder'));
446 $oForm->setTitle($this->lng->txt('mail_add_folder'));
447
448 //title
449 $oTitle = new ilTextInputGUI();
450 $oTitle->setTitle($this->lng->txt('title'));
451 $oTitle->setPostVar('subfolder_title');
452 $oForm->addItem($oTitle);
453
454 $oForm->addCommandButton('performAddSubFolder', $this->lng->txt('save'));
455 $oForm->addCommandButton('showFolder', $this->lng->txt('cancel'));
456
457 $tpl->setVariable('FORM', $oForm->getHTML());
458 $tpl->show();
459
460 return true;
461 }
462
463 public function renameSubFolder()
464 {
469 global $ilCtrl, $tpl;
470
471 include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
472
473 $tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.mail.html', 'Services/Mail');
474 $tpl->setTitle($this->lng->txt('mail'));
475
476 $oForm = new ilPropertyFormGUI();
477 $oForm->setFormAction($ilCtrl->getFormAction($this, 'performRenameSubFolder'));
478 $oForm->setTitle($this->lng->txt('mail_rename_folder'));
479
480 //title
481 $oTitle = new ilTextInputGUI();
482 $oTitle->setTitle($this->lng->txt('title'));
483 $tmp_data = $this->mbox->getFolderData($_GET["mobj_id"]);
484 $oTitle->setValue($tmp_data["title"]);
485 $oTitle->setPostVar('subfolder_title');
486 $oForm->addItem($oTitle);
487
488 $oForm->addCommandButton('performRenameSubFolder', $this->lng->txt('save'));
489 $oForm->addCommandButton('showFolder', $this->lng->txt('cancel'));
490 $tpl->setVariable('FORM', $oForm->getHTML());
491 $tpl->show();
492
493 return true;
494 }
495
496 public function performRenameSubFolder()
497 {
498 if (isset($_POST["subfolder_title"]) && 'tree' == ilSession::get(ilMailGUI::VIEWMODE_SESSION_KEY)) $_SESSION["subfolder_title"] = $_POST['subfolder_title'];
499
500 $tmp_data = $this->mbox->getFolderData($_GET["mobj_id"]);
501 if ($tmp_data["title"] != $_POST["subfolder_title"])
502 {
503 if ($_POST["subfolder_title"] == "")
504 {
505 ilUtil::sendInfo($this->lng->txt("mail_insert_folder_name"));
506 return $this->renameSubFolder();
507 }
508 else
509 {
510 if ($this->mbox->renameFolder($_GET["mobj_id"], ilUtil::stripSlashes($_POST["subfolder_title"])))
511 {
512 ilUtil::sendInfo($this->lng->txt("mail_folder_name_changed"), true);
513 unset($_SESSION["subfolder_title"]);
514 $this->ctrl->redirectByClass("ilMailGUI");
515 }
516 else
517 {
518 ilUtil::sendFailure($this->lng->txt("mail_folder_exists"));
519 return $this->renameSubFolder();
520 }
521 }
522 }
523 return $this->showFolder();
524 }
525
526 public function changeFolder()
527 {
528 switch ($this->current_selected_cmd)
529 {
530 default:
531 if(!(int)$_GET["mail_id"] || !(int)$this->current_selected_cmd)
532 {
533 ilUtil::sendInfo($this->lng->txt("mail_move_error"));
534 return $this->showMail();
535 }
536
537 if ($this->umail->moveMailsToFolder(array($_GET["mail_id"]), $this->current_selected_cmd))
538 {
539 ilUtil::sendInfo($this->lng->txt("mail_moved"), true);
540 $this->ctrl->redirectByClass("ilMailGUI");
541 }
542 else
543 {
544 ilUtil::sendInfo($this->lng->txt("mail_move_error"));
545 }
546 break;
547 }
548
549 $this->showMail();
550
551 return true;
552 }
553
554 public function editFolder()
555 {
556 switch ($this->current_selected_cmd)
557 {
558 case 'markMailsRead':
559 if(is_array($_POST["mail_id"]))
560 {
561 $this->umail->markRead($_POST["mail_id"]);
562 }
563 else
564 {
565 ilUtil::sendInfo($this->lng->txt("mail_select_one"));
566 }
567 break;
568 case 'markMailsUnread':
569 if(is_array($_POST["mail_id"]))
570 {
571 $this->umail->markUnread($_POST["mail_id"]);
572 }
573 else
574 {
575 ilUtil::sendInfo($this->lng->txt("mail_select_one"));
576 }
577 break;
578
579 case 'deleteMails':
580 // IF MAILBOX IS TRASH ASK TO CONFIRM
581 if($this->mbox->getTrashFolder() == $_GET["mobj_id"])
582 {
583 if(!is_array($_POST["mail_id"]))
584 {
585 ilUtil::sendInfo($this->lng->txt("mail_select_one"));
586 $this->errorDelete = true;
587 }
588 } // END IF MAILBOX IS TRASH FOLDER
589 else
590 {
591 // MOVE MAILS TO TRASH
592 if(!is_array($_POST["mail_id"]))
593 {
594 ilUtil::sendInfo($this->lng->txt("mail_select_one"));
595 }
596 else if($this->umail->moveMailsToFolder($_POST["mail_id"], $this->mbox->getTrashFolder()))
597 {
598 $_GET["offset"] = 0;
599 ilUtil::sendInfo($this->lng->txt("mail_moved_to_trash"));
600 }
601 else
602 {
603 ilUtil::sendInfo($this->lng->txt("mail_move_error"));
604 }
605 }
606 break;
607
608 case 'add':
609 $this->ctrl->setParameterByClass("ilmailoptionsgui", "cmd", "add");
610 $this->ctrl->redirectByClass("ilmailoptionsgui");
611
612 case 'moveMails':
613 default:
614 if(!is_array($_POST["mail_id"]))
615 {
616 ilUtil::sendInfo($this->lng->txt("mail_select_one"));
617 }
618 else if($this->umail->moveMailsToFolder($_POST["mail_id"],$this->current_selected_cmd))
619 {
620 ilUtil::sendInfo($this->lng->txt("mail_moved"));
621 }
622 else
623 {
624 ilUtil::sendInfo($this->lng->txt("mail_move_error"));
625 }
626 break;
627 }
628
629 $this->showFolder();
630 }
631
635 public function confirmDeleteMails()
636 {
637 if($this->mbox->getTrashFolder() == $_GET['mobj_id'])
638 {
639 $_POST['mail_id'] = $mail_ids = explode(',', $_GET['mail_id']);
640 if(!is_array($mail_ids))
641 {
642 ilUtil::sendInfo($this->lng->txt('mail_select_one'));
643 }
644 else if($this->umail->deleteMails($mail_ids))
645 {
646 $_GET['offset'] = 0;
647 ilUtil::sendInfo($this->lng->txt('mail_deleted'));
648 }
649 else
650 {
651 ilUtil::sendInfo($this->lng->txt('mail_delete_error'));
652 }
653 }
654
655 $this->showFolder();
656 }
657
658 public function cancelDeleteMails()
659 {
660 $this->ctrl->redirect($this);
661 }
662
666 public function showMail()
667 {
673 global $ilUser, $ilToolbar, $ilTabs;
674
675 if($_SESSION['mail_id'])
676 {
677 $_GET['mail_id'] = $_SESSION['mail_id'];
678 $_SESSION['mail_id'] = '';
679 }
680
681 $ilTabs->clearTargets();
682 $ilTabs->setBackTarget($this->lng->txt('back_to_folder'), $this->ctrl->getFormAction($this, 'showFolder'));
683
684 $this->umail->markRead(array((int)$_GET['mail_id']));
685 $mailData = $this->umail->getMail((int)$_GET['mail_id']);
686
687 $this->tpl->setTitle($this->lng->txt('mail_mails_of'));
688
689 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
690
691 $form = new ilPropertyFormGUI();
692 $form->setPreventDoubleSubmission(false);
693 $form->setTableWidth('100%');
694 $this->ctrl->setParameter($this, 'mail_id', (int)$_GET['mail_id']);
695 $form->setFormAction($this->ctrl->getFormAction($this, 'showMail'));
696 $this->ctrl->clearParameters($this);
697 $form->setTitle($this->lng->txt('mail_mails_of'));
698
700 {
701 $this->tpl->setVariable('FORM_TARGET', ilFrameTargetInfo::_getFrame('MainContent'));
702 }
703
704 include_once 'Services/Accessibility/classes/class.ilAccessKeyGUI.php';
705
709 $sender = ilObjectFactory::getInstanceByObjId($mailData['sender_id'], false);
710
711 if($sender && $sender->getId() && $sender->getId() != ANONYMOUS_USER_ID)
712 {
713 $this->ctrl->setParameterByClass('ilmailformgui', 'mail_id', (int)$_GET['mail_id']);
714 $this->ctrl->setParameterByClass('ilmailformgui', 'type', 'reply');
715 $this->ctrl->clearParametersByClass('iliasmailformgui');
716 $ilToolbar->addButton($this->lng->txt('reply'), $this->ctrl->getLinkTargetByClass('ilmailformgui'), '', ilAccessKey::REPLY);
717 $this->ctrl->clearParameters($this);
718 }
719
720 $this->ctrl->setParameterByClass('ilmailformgui', 'mail_id', (int)$_GET['mail_id']);
721 $this->ctrl->setParameterByClass('ilmailformgui', 'type', 'forward');
722 $this->ctrl->clearParametersByClass('iliasmailformgui');
723 $ilToolbar->addButton($this->lng->txt('forward'), $this->ctrl->getLinkTargetByClass('ilmailformgui'), '', ilAccessKey::FORWARD_MAIL);
724 $this->ctrl->clearParameters($this);
725
726 $this->ctrl->setParameter($this, 'mail_id', (int)$_GET['mail_id']);
727 $ilToolbar->addButton($this->lng->txt('print'), $this->ctrl->getLinkTarget($this, 'printMail'), '_blank');
728 $this->ctrl->clearParameters($this);
729
730 $this->ctrl->setParameter($this, 'mail_id', (int)$_GET['mail_id']);
731 $this->ctrl->setParameter($this, 'selected_cmd', 'deleteMails');
732 $ilToolbar->addButton($this->lng->txt('delete'), $this->ctrl->getLinkTarget($this), '', ilAccessKey::DELETE);
733 $this->ctrl->clearParameters($this);
734
735 if($sender && $sender->getId() && $sender->getId() != ANONYMOUS_USER_ID)
736 {
737 $linked_fullname = $sender->getPublicName();
738 $picture = ilUtil::img($sender->getPersonalPicturePath('xsmall'), $sender->getPublicName());
739 $add_to_addb_button = '';
740
741 if(in_array(ilObjUser::_lookupPref($sender->getId(), 'public_profile'), array('y', 'g')))
742 {
743 $this->ctrl->setParameter($this, 'mail_id', (int)$_GET['mail_id']);
744 $this->ctrl->setParameter($this, 'user', $sender->getId());
745 $linked_fullname = '<br /><a href="' . $this->ctrl->getLinkTarget($this, 'showUser') . '" title="'.$linked_fullname.'">' . $linked_fullname . '</a>';
746 $this->ctrl->clearParameters($this);
747 }
748
749 $from = new ilCustomInputGUI($this->lng->txt('from'));
750 $from->setHtml($picture . ' ' . $linked_fullname . $add_to_addb_button);
751 $form->addItem($from);
752 }
753 else if(!$sender || !$sender->getId())
754 {
755 $from = new ilCustomInputGUI($this->lng->txt('from'));
756 $from->setHtml($mailData['import_name'] . ' (' . $this->lng->txt('user_deleted') . ')');
757 $form->addItem($from);
758 }
759 else
760 {
761 $from = new ilCustomInputGUI($this->lng->txt('from'));
762 $from->setHtml(ilUtil::img(ilUtil::getImagePath('HeaderIconAvatar.svg'), ilMail::_getIliasMailerName()) . '<br />' . ilMail::_getIliasMailerName());
763 $form->addItem($from);
764 }
765
766 $to = new ilCustomInputGUI($this->lng->txt('mail_to'));
767 $to->setHtml(ilUtil::htmlencodePlainString($this->umail->formatNamesForOutput($mailData['rcp_to']), false));
768 $form->addItem($to);
769
770 if($mailData['rcp_cc'])
771 {
772 $cc = new ilCustomInputGUI($this->lng->txt('cc'));
773 $cc->setHtml(ilUtil::htmlencodePlainString($this->umail->formatNamesForOutput($mailData['rcp_cc']), false));
774 $form->addItem($cc);
775 }
776
777 if($mailData['rcp_bcc'])
778 {
779 $bcc = new ilCustomInputGUI($this->lng->txt('bc'));
780 $bcc->setHtml(ilUtil::htmlencodePlainString($this->umail->formatNamesForOutput($mailData['rcp_bcc']), false));
781 $form->addItem($bcc);
782 }
783
784 $subject = new ilCustomInputGUI($this->lng->txt('subject'));
785 $subject->setHtml(ilUtil::htmlencodePlainString($mailData['m_subject'], true));
786 $form->addItem($subject);
787
788 $date = new ilCustomInputGUI($this->lng->txt('date'));
789 $date->setHtml(ilDatePresentation::formatDate(new ilDateTime($mailData['send_time'], IL_CAL_DATETIME)));
790 $form->addItem($date);
791
792 $message = new ilCustomInputGUI($this->lng->txt('message'));
793 $message->setHtml(ilUtil::htmlencodePlainString($mailData['m_message'], true));
794 $form->addItem($message);
795
796 if($mailData['attachments'])
797 {
798 $att = new ilCustomInputGUI($this->lng->txt('attachments'));
799
800 $radiog = new ilRadioGroupInputGUI('', 'filename');
801
802 foreach($mailData['attachments'] as $file)
803 {
804 $radiog->addOption(new ilRadioOption($file, md5($file)));
805 }
806
807 $att->setHtml($radiog->render());
808 $form->addCommandButton('deliverFile', $this->lng->txt('download'));
809 $form->addItem($att);
810 }
811
812 $isTrashFolder = false;
813 if($this->mbox->getTrashFolder() == $_GET['mobj_id'])
814 {
815 $isTrashFolder = true;
816 }
817
818 $current_folder_data = $this->mbox->getFolderData((int)$_GET['mobj_id']);
819
820 $selectOptions = array();
821 $actions = $this->mbox->getActions((int)$_GET["mobj_id"]);
822 foreach($actions as $key => $action)
823 {
824 if($key == 'moveMails')
825 {
826 $folders = $this->mbox->getSubFolders();
827 foreach($folders as $folder)
828 {
829 if(
830 ($folder["type"] != 'trash' || !$isTrashFolder) &&
831 $folder['obj_id'] != $current_folder_data['obj_id']
832 )
833 {
834 $optionText = '';
835 if($folder['type'] != 'user_folder')
836 {
837 $optionText = $action . ' ' . $this->lng->txt('mail_' . $folder['title']) . ($folder['type'] == 'trash' ? ' (' . $this->lng->txt('delete') . ')' : '');
838 }
839 else
840 {
841 $optionText = $action . ' ' . $folder['title'];
842 }
843
844 $selectOptions[$folder['obj_id']] = $optionText;
845 }
846 }
847 }
848 }
849
850 if($current_folder_data['type'] == 'user_folder')
851 {
852 $txt_folder = $current_folder_data['title'];
853 }
854 else
855 {
856 $txt_folder = $this->lng->txt('mail_' . $current_folder_data['title']);
857 }
858 $ilToolbar->addSeparator();
859 $ilToolbar->addText(sprintf($this->lng->txt('current_folder'), $txt_folder));
860
861 if(is_array($selectOptions) && count($selectOptions))
862 {
863 include_once 'Services/Form/classes/class.ilSelectInputGUI.php';
864 $actions = new ilSelectInputGUI('', 'selected_cmd');
865 $actions->setOptions($selectOptions);
866 $this->ctrl->setParameter($this, 'mail_id', (int)$_GET['mail_id']);
867 $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 'showMail'));
868 $ilToolbar->addInputItem($actions);
869 $ilToolbar->addFormButton($this->lng->txt('submit'), 'changeFolder');
870 }
871
872 // Navigation
873 $prevMail = $this->umail->getPreviousMail((int)$_GET['mail_id']);
874 $nextMail = $this->umail->getNextMail((int)$_GET['mail_id']);
875 if(is_array($prevMail) || is_array($nextMail))
876 {
877 $ilToolbar->addSeparator();
878
879 if($prevMail['mail_id'])
880 {
881 $this->ctrl->setParameter($this, 'mail_id', $prevMail['mail_id']);
882 $ilToolbar->addButton($this->lng->txt('previous'), $this->ctrl->getLinkTarget($this, 'showMail'));
883 $this->ctrl->clearParameters($this);
884 }
885
886 if($nextMail['mail_id'])
887 {
888 $this->ctrl->setParameter($this, 'mail_id', $nextMail['mail_id']);
889 $ilToolbar->addButton($this->lng->txt('next'), $this->ctrl->getLinkTarget($this, 'showMail'));
890 $this->ctrl->clearParameters($this);
891 }
892 }
893
894 $this->tpl->setContent($form->getHTML());
895 $this->tpl->show();
896 }
897
901 public function printMail()
902 {
906 global $tpl;
907
908 $tplprint = new ilTemplate('tpl.mail_print.html', true, true, 'Services/Mail');
909 $tplprint->setVariable('JSPATH', $tpl->tplPath);
910
911 $mailData = $this->umail->getMail((int)$_GET['mail_id']);
912
916 $sender = ilObjectFactory::getInstanceByObjId($mailData['sender_id'], false);
917
918 $tplprint->setVariable('TXT_FROM', $this->lng->txt('from'));
919 if($sender && $sender->getId() && $sender->getId() != ANONYMOUS_USER_ID)
920 {
921 $tplprint->setVariable('FROM', $sender->getPublicName());
922 }
923 else if(!$sender || !$sender->getId())
924 {
925 $tplprint->setVariable('FROM', $mailData['import_name'] . ' (' . $this->lng->txt('user_deleted') . ')');
926 }
927 else
928 {
929 $tplprint->setVariable('FROM', ilMail::_getIliasMailerName());
930 }
931
932 $tplprint->setVariable('TXT_TO', $this->lng->txt('mail_to'));
933 $tplprint->setVariable('TO', $mailData['rcp_to']);
934
935 if($mailData['rcp_cc'])
936 {
937 $tplprint->setCurrentBlock('cc');
938 $tplprint->setVariable('TXT_CC', $this->lng->txt('cc'));
939 $tplprint->setVariable('CC', $mailData['rcp_cc']);
940 $tplprint->parseCurrentBlock();
941 }
942
943 if($mailData['rcp_bcc'])
944 {
945 $tplprint->setCurrentBlock('bcc');
946 $tplprint->setVariable('TXT_BCC', $this->lng->txt('bc'));
947 $tplprint->setVariable('BCC', $mailData['rcp_bcc']);
948 $tplprint->parseCurrentBlock();
949 }
950
951 $tplprint->setVariable('TXT_SUBJECT', $this->lng->txt('subject'));
952 $tplprint->setVariable('SUBJECT', htmlspecialchars($mailData['m_subject']));
953
954 $tplprint->setVariable('TXT_DATE', $this->lng->txt('date'));
955 $tplprint->setVariable('DATE', ilDatePresentation::formatDate(new ilDateTime($mailData['send_time'], IL_CAL_DATETIME)));
956
957 $tplprint->setVariable('TXT_MESSAGE', $this->lng->txt('message'));
958 $tplprint->setVariable('MAIL_MESSAGE', nl2br(htmlspecialchars($mailData['m_message'])));
959
960 $tplprint->show();
961 }
962
963 function deliverFile()
964 {
965 if ($_SESSION["mail_id"])
966 {
967 $_GET["mail_id"] = $_SESSION["mail_id"];
968 }
969 $_SESSION["mail_id"] = "";
970
971 $filename = ($_SESSION["filename"]
972 ? $_SESSION["filename"]
973 : ($_POST["filename"]
974 ? $_POST["filename"]
975 : $_GET["filename"]));
976 $_SESSION["filename"] = "";
977
978 if ($filename != "")
979 {
980 require_once "./Services/Mail/classes/class.ilFileDataMail.php";
981
982 // secure filename
983 $filename = str_replace("..", "", $filename);
984
985 $mfile = new ilFileDataMail($_SESSION["AccountId"]);
986 if(!is_array($file = $mfile->getAttachmentPathByMD5Filename($filename, $_GET['mail_id'])))
987 {
988 ilUtil::sendInfo($this->lng->txt('mail_error_reading_attachment'));
989 $this->showMail();
990 }
991 else
992 {
993 ilUtil::deliverFile($file['path'], $file['filename']);
994 }
995 }
996 else
997 {
998 ilUtil::sendInfo($this->lng->txt('mail_select_attachment'));
999 $this->showMail();
1000 }
1001 }
1002
1006 public function applyFilter()
1007 {
1008 $sentFolderId = $this->mbox->getSentFolder();
1009 $draftsFolderId = $this->mbox->getDraftsFolder();
1010
1011 $isTrashFolder = $_GET['mobj_id'] == $this->mbox->getTrashFolder();
1012 $isSentFolder = $_GET['mobj_id'] == $sentFolderId;
1013 $isDraftFolder = $_GET['mobj_id'] == $draftsFolderId;
1014
1015 $table = new ilMailFolderTableGUI($this, (int)$_GET['mobj_id'], 'showFolder');
1016 $table->isSentFolder($isSentFolder)
1017 ->isDraftFolder($isDraftFolder)
1018 ->isTrashFolder($isTrashFolder)
1019 ->initFilter();
1020 $table->resetOffset();
1021 $table->writeFilterToSession();
1022
1023 $this->showFolder();
1024 }
1025
1029 public function resetFilter()
1030 {
1031 $sentFolderId = $this->mbox->getSentFolder();
1032 $draftsFolderId = $this->mbox->getDraftsFolder();
1033
1034 $isTrashFolder = $_GET['mobj_id'] == $this->mbox->getTrashFolder();
1035 $isSentFolder = $_GET['mobj_id'] == $sentFolderId;
1036 $isDraftFolder = $_GET['mobj_id'] == $draftsFolderId;
1037
1038 $table = new ilMailFolderTableGUI($this, (int)$_GET['mobj_id'], 'showFolder');
1039 $table->isSentFolder($isSentFolder)
1040 ->isDraftFolder($isDraftFolder)
1041 ->isTrashFolder($isTrashFolder)
1042 ->initFilter();
1043 $table->resetOffset();
1044 $table->resetFilter();
1045
1046 $this->showFolder();
1047 }
1048}
1049?>
print $file
$filename
Definition: buildRTE.php:89
$_GET["client_id"]
$_SESSION["AccountId"]
const IL_CAL_DATETIME
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.
static _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
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