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';
43 $this->umail =
new ilMail($ilUser->getId());
44 $this->mbox =
new ilMailBox($ilUser->getId());
48 $_GET[
'mobj_id'] = $_POST[
'mobj_id'];
51 if(!(
int)
$_GET[
'mobj_id'])
53 $_GET[
'mobj_id'] = $this->mbox->getInboxFolder();
56 $ilCtrl->saveParameter($this,
'mobj_id');
57 $ilCtrl->setParameter($this,
'mobj_id',
$_GET[
'mobj_id']);
65 $_GET[
"cmd"] =
'editFolder';
68 $this->current_select_cmd =
$_POST[
'select_cmd'];
69 $this->current_selected_cmd =
$_POST[
'selected_cmd'];
71 else if (
$_POST[
"select_cmd2"])
74 $_GET[
"cmd"] =
'editFolder';
75 $this->current_select_cmd =
$_POST[
'select_cmd2'];
76 $this->current_selected_cmd =
$_POST[
'selected_cmd2'];
82 if (
$_GET[
'selected_cmd'] ==
"deleteMails" &&
$_GET[
"mail_id"])
84 $_GET[
"cmd"] =
"editFolder";
85 $this->current_selected_cmd =
"deleteMails";
92 $cmd = $this->ctrl->getCmd();
93 if(
$cmd ==
'changeFolder' &&
94 is_numeric(
$_POST[
'selected_cmd']) &&
97 $this->current_selected_cmd = (int)
$_POST[
'selected_cmd'];
100 $forward_class = $this->ctrl->getNextClass($this);
101 switch($forward_class)
103 case 'ilmailaddressbookgui':
104 include_once
'Services/Contact/classes/class.ilMailAddressbookGUI.php';
109 case 'ilmailoptionsgui':
110 include_once
'Services/Mail/classes/class.ilMailOptionsGUI.php';
115 case 'ilpublicuserprofilegui':
116 include_once(
"Services/User/classes/class.ilPublicUserProfileGUI.php");
117 $this->tpl->setTitle($this->lng->txt(
"mail"));
118 $this->ctrl->saveParameter($this,
"mail_id");
120 $profile_gui->setBackUrl($this->ctrl->getLinkTarget($this,
"showMail"));
121 $ret = $this->ctrl->forwardCommand($profile_gui);
124 $this->tpl->setContent(
$ret);
130 if (!(
$cmd = $this->ctrl->getCmd()))
144 if(
$_GET[
"mail_id"] !=
"")
146 if (is_array($mail_data = $this->umail->getMail(
$_GET[
"mail_id"])))
148 require_once
"Services/Contact/classes/class.ilAddressbook.php";
151 $tmp_user =
new ilObjUser($mail_data[
"sender_id"]);
152 if ($abook->checkEntryByLogin($tmp_user->getLogin()) > 0)
158 $abook->addEntry($tmp_user->getLogin(),
159 $tmp_user->getFirstname(),
160 $tmp_user->getLastname(),
161 $tmp_user->getEmail());
182 $this->umail->deleteMailsOfFolder(
$_GET[
"mobj_id"]);
195 if($this->umail->countMailsOfFolder((
int)
$_GET[
'mobj_id']))
198 $this->askForConfirmation =
true;
210 $this->ctrl->setParameter($this,
"mail_id",
$_GET[
"mail_id"]);
212 $this->tpl->setTitle($this->lng->txt(
"mail"));
215 $this->tpl->setVariable(
"TBL_TITLE", $this->lng->txt(
"profile_of").
" ".
218 $this->tpl->setVariable(
"TBL_TITLE_IMG_ALT", $this->lng->txt(
"public_profile"));
220 include_once
'./Services/User/classes/class.ilPublicUserProfileGUI.php';
222 $profile_gui->setBackUrl($this->ctrl->getLinkTarget($this,
"showMail"));
223 $this->tpl->setContent($ilCtrl->getHTML($profile_gui));
235 $ilToolbar->addSeparator();
238 $ilToolbar->addButton($this->lng->txt(
'mail_add_subfolder'), $this->ctrl->getLinkTarget($this,
'addSubFolder'));
240 if($check_uf ==
true)
242 $ilToolbar->addButton($this->lng->txt(
'rename'), $this->ctrl->getLinkTarget($this,
'renameSubFolder'));
243 $ilToolbar->addButton($this->lng->txt(
'delete'), $this->ctrl->getLinkTarget($this,
'deleteSubFolder'));
250 public function showFolder($a_show_confirmation =
false)
258 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.mail.html',
'Services/Mail');
259 $this->tpl->setTitle($this->lng->txt(
'mail'));
261 include_once
'Services/Mail/classes/class.ilMailFolderTableGUI.php';
263 $sentFolderId = $this->mbox->getSentFolder();
264 $draftsFolderId = $this->mbox->getDraftsFolder();
266 $isTrashFolder =
$_GET[
'mobj_id'] == $this->mbox->getTrashFolder();
267 $isSentFolder =
$_GET[
'mobj_id'] == $sentFolderId;
268 $isDraftFolder =
$_GET[
'mobj_id'] == $draftsFolderId;
271 if($this->current_selected_cmd ==
'deleteMails' &&
272 !$this->errorDelete &&
273 $this->current_selected_cmd !=
'confirm' &&
277 foreach((array)
$_REQUEST[
'mail_id'] as $id)
279 $this->tpl->setCurrentBlock(
'mail_ids');
280 $this->tpl->setVariable(
'MAIL_ID_VALUE', $id);
281 $this->tpl->parseCurrentBlock();
284 $this->tpl->setCurrentBlock(
'confirm_delete');
285 $this->tpl->setVariable(
'ACTION', $this->ctrl->getFormAction($this,
'confirmDeleteMails'));
286 $this->tpl->setVariable(
'BUTTON_CONFIRM',$this->lng->txt(
'confirm'));
287 $this->tpl->setVariable(
'BUTTON_CANCEL',$this->lng->txt(
'cancel'));
288 $this->tpl->parseCurrentBlock();
291 $folders = $this->mbox->getSubFolders();
292 $mtree =
new ilTree($ilUser->getId());
296 $check_local =
false;
300 $folder_d = $mtree->getNodeData(
$_GET[
'mobj_id']);
301 if($folder_d[
'm_type'] ==
'user_folder')
305 else if($folder_d[
'm_type'] ==
'local')
312 $mailtable->isSentFolder($isSentFolder)
313 ->isDraftFolder($isDraftFolder)
314 ->isTrashFolder($isTrashFolder)
315 ->setSelectedItems(
$_POST[
'mail_id'])
318 $folder_options = array();
321 foreach($folders as $folder)
323 $folder_d = $mtree->getNodeData($folder[
'obj_id']);
325 if($folder[
'obj_id'] ==
$_GET[
'mobj_id'])
327 if($folder[
'type'] ==
'user_folder')
331 else if($folder[
'type'] ==
'local')
338 if($folder[
'type'] ==
'user_folder')
341 for ($i = 2; $i < $folder_d[
'depth'] - 1; $i++)
346 if ($folder_d[
'depth'] > 1)
351 $folder_options[$folder[
'obj_id']] = $pre.
' '.$folder[
'title'];
355 $folder_options[$folder[
'obj_id']] = $this->lng->txt(
'mail_'.$folder[
'title']);
360 if($a_show_confirmation ==
false)
364 $ilToolbar->addText($this->lng->txt(
'mail_change_to_folder'));
365 include_once
'./Services/Form/classes/class.ilSelectInputGUI.php';
367 $si->setOptions($folder_options);
369 $ilToolbar->addInputItem(
$si);
371 $ilToolbar->addFormButton($this->lng->txt(
'change'),
'showFolder');
372 $ilToolbar->setFormAction($this->ctrl->getFormAction($this,
'showFolder'));
374 if($check_local ==
true || $check_uf ==
true)
382 if($mailtable->isTrashFolder() &&
383 $mailtable->getNumerOfMails() > 0)
385 if($this->askForConfirmation ==
true)
387 $this->tpl->setCurrentBlock(
'confirm_empty_trash');
388 $this->tpl->setVariable(
'ACTION_EMPTY_TRASH_CONFIRMATION', $this->ctrl->getFormAction($this,
'performEmptyTrash'));
389 $this->tpl->setVariable(
'BUTTON_CONFIRM_EMPTY_TRASH', $this->lng->txt(
'confirm'));
390 $this->tpl->setVariable(
'BUTTON_CANCEL_EMPTY_TRASH', $this->lng->txt(
'cancel'));
391 $this->tpl->parseCurrentBlock();
396 $this->tpl->setVariable(
'MAIL_TABLE', $mailtable->getHtml());
404 include_once
'./Services/Utilities/classes/class.ilConfirmationGUI.php';
408 $oConfirmationGUI->setFormAction($this->ctrl->getFormAction($this,
"showFolder"));
409 $oConfirmationGUI->setHeaderText($this->lng->txt(
"mail_sure_delete_folder"));
410 $oConfirmationGUI->setCancel($this->lng->txt(
"cancel"),
"showFolder");
411 $oConfirmationGUI->setConfirm($this->lng->txt(
"confirm"),
"performDeleteSubfolder");
412 $this->tpl->setVariable(
'CONFIRMATION',$oConfirmationGUI->getHTML());
414 return $this->showFolder(
true);
417 return $this->showFolder(
false);
422 $new_parent = $this->mbox->getParentFolderId(
$_GET[
"mobj_id"]);
424 if ($this->mbox->deleteFolder(
$_GET[
"mobj_id"]))
432 return $this->showFolder();
442 if (empty(
$_POST[
'subfolder_title']))
445 return $this->addSubFolder();
449 $ilCtrl->saveParameter($this,
'mobj_id');
450 $ilCtrl->setParameter($this,
'mobj_id', $mobj_id);
458 $this->addSubFolder();
460 return $this->showFolder();
463 public function addSubFolder()
471 include_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
473 $tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.mail.html',
'Services/Mail');
474 $tpl->setTitle($this->lng->txt(
'mail'));
477 $oForm->setFormAction($ilCtrl->getFormAction($this,
'performAddSubFolder'));
478 $oForm->setTitle($this->lng->txt(
'mail_add_folder'));
482 $oTitle->setTitle($this->lng->txt(
'title'));
483 $oTitle->setPostVar(
'subfolder_title');
484 $oForm->addItem($oTitle);
486 $oForm->addCommandButton(
'performAddSubFolder', $this->lng->txt(
'save'));
487 $oForm->addCommandButton(
'showFolder', $this->lng->txt(
'cancel'));
489 $tpl->setVariable(
'FORM', $oForm->getHTML());
495 public function renameSubFolder()
503 include_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
505 $tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.mail.html',
'Services/Mail');
506 $tpl->setTitle($this->lng->txt(
'mail'));
509 $oForm->setFormAction($ilCtrl->getFormAction($this,
'performRenameSubFolder'));
510 $oForm->setTitle($this->lng->txt(
'mail_rename_folder'));
514 $oTitle->setTitle($this->lng->txt(
'title'));
515 $tmp_data = $this->mbox->getFolderData(
$_GET[
"mobj_id"]);
516 $oTitle->setValue($tmp_data[
"title"]);
517 $oTitle->setPostVar(
'subfolder_title');
518 $oForm->addItem($oTitle);
520 $oForm->addCommandButton(
'performRenameSubFolder', $this->lng->txt(
'save'));
521 $oForm->addCommandButton(
'showFolder', $this->lng->txt(
'cancel'));
522 $tpl->setVariable(
'FORM', $oForm->getHTML());
532 $tmp_data = $this->mbox->getFolderData(
$_GET[
"mobj_id"]);
533 if ($tmp_data[
"title"] !=
$_POST[
"subfolder_title"])
535 if (
$_POST[
"subfolder_title"] ==
"")
538 return $this->renameSubFolder();
550 return $this->renameSubFolder();
554 return $this->showFolder();
559 switch ($this->current_selected_cmd)
562 if(!(
int)
$_GET[
"mail_id"] || !(
int)$this->current_selected_cmd)
565 return $this->showMail();
568 if ($this->umail->moveMailsToFolder(array(
$_GET[
"mail_id"]), $this->current_selected_cmd))
571 $this->ctrl->redirectByClass(
"ilMailGUI");
587 switch ($this->current_selected_cmd)
589 case 'markMailsRead':
590 if(is_array(
$_POST[
"mail_id"]))
592 $this->umail->markRead(
$_POST[
"mail_id"]);
599 case 'markMailsUnread':
600 if(is_array(
$_POST[
"mail_id"]))
602 $this->umail->markUnread(
$_POST[
"mail_id"]);
612 if($this->mbox->getTrashFolder() ==
$_GET[
"mobj_id"])
614 if(!is_array(
$_POST[
"mail_id"]))
617 $this->errorDelete =
true;
627 if(!is_array(
$_POST[
"mail_id"]))
631 else if($this->umail->moveMailsToFolder(
$_POST[
"mail_id"], $this->mbox->getTrashFolder()))
644 $this->ctrl->setParameterByClass(
"ilmailoptionsgui",
"cmd",
"add");
645 $this->ctrl->redirectByClass(
"ilmailoptionsgui");
649 if(!is_array(
$_POST[
"mail_id"]))
653 else if($this->umail->moveMailsToFolder(
$_POST[
"mail_id"],$this->current_selected_cmd))
670 if($this->mbox->getTrashFolder() ==
$_GET[
"mobj_id"])
672 if(!is_array(
$_POST[
"mail_id"]))
676 else if($this->umail->deleteMails(
$_POST[
"mail_id"]))
693 $this->ctrl->redirect($this);
699 public function showMail()
713 $this->umail->markRead(array((
int)
$_GET[
'mail_id']));
714 $mailData = $this->umail->getMail((
int)$_GET[
'mail_id']);
716 $this->tpl->setTitle($this->lng->txt(
'mail_mails_of'));
718 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
721 $form->setTableWidth(
'100%');
722 $this->ctrl->setParameter($this,
'mail_id', (
int)$_GET[
'mail_id']);
723 $form->setFormAction($this->ctrl->getFormAction($this,
'showMail'));
724 $this->ctrl->clearParameters($this);
725 $form->setTitle($this->lng->txt(
'mail_mails_of'));
732 include_once
'Services/Accessibility/classes/class.ilAccessKeyGUI.php';
739 if($sender && $sender->getId() && $sender->getId() != ANONYMOUS_USER_ID)
741 $this->ctrl->setParameterByClass(
'ilmailformgui',
'mail_id', (
int)$_GET[
'mail_id']);
742 $this->ctrl->setParameterByClass(
'ilmailformgui',
'type',
'reply');
743 $this->ctrl->clearParametersByClass(
'iliasmailformgui');
744 $ilToolbar->addButton($this->lng->txt(
'reply'), $this->ctrl->getLinkTargetByClass(
'ilmailformgui'),
'',
ilAccessKey::REPLY);
745 $this->ctrl->clearParameters($this);
748 $this->ctrl->setParameterByClass(
'ilmailformgui',
'mail_id', (
int)$_GET[
'mail_id']);
749 $this->ctrl->setParameterByClass(
'ilmailformgui',
'type',
'forward');
750 $this->ctrl->clearParametersByClass(
'iliasmailformgui');
751 $ilToolbar->addButton($this->lng->txt(
'forward'), $this->ctrl->getLinkTargetByClass(
'ilmailformgui'),
'',
ilAccessKey::FORWARD_MAIL);
752 $this->ctrl->clearParameters($this);
754 $this->ctrl->setParameter($this,
'mail_id', (
int)$_GET[
'mail_id']);
755 $ilToolbar->addButton($this->lng->txt(
'print'), $this->ctrl->getLinkTarget($this,
'printMail'),
'_blank');
756 $this->ctrl->clearParameters($this);
758 $this->ctrl->setParameter($this,
'mail_id', (
int)$_GET[
'mail_id']);
759 $this->ctrl->setParameter($this,
'selected_cmd',
'deleteMails');
760 $ilToolbar->addButton($this->lng->txt(
'delete'), $this->ctrl->getLinkTarget($this),
'',
ilAccessKey::DELETE);
761 $this->ctrl->clearParameters($this);
763 if($sender && $sender->getId() && $sender->getId() != ANONYMOUS_USER_ID)
765 $linked_fullname = $sender->getPublicName();
766 $picture =
ilUtil::img($sender->getPersonalPicturePath(
'xsmall'), $sender->getPublicName());
767 $add_to_addb_button =
'';
771 $this->ctrl->setParameter($this,
'mail_id', (
int)$_GET[
'mail_id']);
772 $this->ctrl->setParameter($this,
'user', $sender->getId());
773 $linked_fullname =
'<br /><a href="' . $this->ctrl->getLinkTarget($this,
'showUser') .
'" title="'.$linked_fullname.
'">' . $linked_fullname .
'</a>';
774 $this->ctrl->clearParameters($this);
777 if($sender->getId() != $ilUser->getId())
779 require_once
'Services/Contact/classes/class.ilAddressbook.php';
781 if($abook->checkEntryByLogin($sender->getLogin()) == 0)
783 $tplbtn =
new ilTemplate(
'tpl.buttons.html',
true,
true);
785 $tplbtn->setCurrentBlock(
'btn_cell');
786 $this->ctrl->setParameter($this,
'mail_id', (
int)$_GET[
'mail_id']);
787 $tplbtn->setVariable(
'BTN_LINK', $this->ctrl->getLinkTarget($this,
'add'));
788 $this->ctrl->clearParameters($this);
789 $tplbtn->setVariable(
'BTN_TXT', $this->lng->txt(
'mail_add_to_addressbook'));
790 $tplbtn->parseCurrentBlock();
792 $add_to_addb_button =
'<br />' . $tplbtn->get();
797 $from->
setHtml($picture .
' ' . $linked_fullname . $add_to_addb_button);
798 $form->addItem($from);
800 else if(!$sender || !$sender->getId())
803 $from->
setHtml($mailData[
'import_name'] .
' (' . $this->lng->txt(
'user_deleted') .
')');
804 $form->addItem($from);
810 $form->addItem($from);
817 if($mailData[
'rcp_cc'])
824 if($mailData[
'rcp_bcc'])
828 $form->addItem($bcc);
833 $form->addItem($subject);
837 $form->addItem($date);
841 $form->addItem($message);
843 if($mailData[
'attachments'])
849 foreach($mailData[
'attachments'] as
$file)
854 $att->
setHtml($radiog->render());
855 $form->addCommandButton(
'deliverFile', $this->lng->txt(
'download'));
856 $form->addItem($att);
859 $isTrashFolder =
false;
860 if($this->mbox->getTrashFolder() == $_GET[
'mobj_id'])
862 $isTrashFolder =
true;
865 $selectOptions = array();
866 $actions = $this->mbox->getActions((
int)$_GET[
"mobj_id"]);
867 foreach($actions as $key => $action)
869 if($key ==
'moveMails')
871 $folders = $this->mbox->getSubFolders();
872 foreach($folders as $folder)
874 if($folder[
"type"] !=
'trash' ||
879 if($folder[
'type'] !=
'user_folder')
881 $optionText = $action .
' ' . $this->lng->txt(
'mail_' . $folder[
'title']) . ($folder[
'type'] ==
'trash' ?
' (' . $this->lng->txt(
'delete') .
')' :
'');
885 $optionText = $action .
' ' . $folder[
'title'];
888 $selectOptions[$folder[
'obj_id']] = $optionText;
894 if(is_array($selectOptions) && count($selectOptions))
896 include_once
'Services/Form/classes/class.ilSelectInputGUI.php';
898 $actions->setOptions($selectOptions);
899 $this->ctrl->setParameter($this,
'mail_id', (
int)$_GET[
'mail_id']);
900 $ilToolbar->setFormAction($this->ctrl->getFormAction($this,
'showMail'));
901 $ilToolbar->addSeparator();
902 $ilToolbar->addInputItem($actions);
903 $ilToolbar->addFormButton($this->lng->txt(
'submit'),
'changeFolder');
907 $prevMail = $this->umail->getPreviousMail((
int)$_GET[
'mail_id']);
908 $nextMail = $this->umail->getNextMail((
int)$_GET[
'mail_id']);
909 if(is_array($prevMail) || is_array($nextMail))
911 $ilToolbar->addSeparator();
913 if($prevMail[
'mail_id'])
915 $this->ctrl->setParameter($this,
'mail_id', $prevMail[
'mail_id']);
916 $ilToolbar->addButton($this->lng->txt(
'previous'), $this->ctrl->getLinkTarget($this,
'showMail'));
917 $this->ctrl->clearParameters($this);
920 if($nextMail[
'mail_id'])
922 $this->ctrl->setParameter($this,
'mail_id', $nextMail[
'mail_id']);
923 $ilToolbar->addButton($this->lng->txt(
'next'), $this->ctrl->getLinkTarget($this,
'showMail'));
924 $this->ctrl->clearParameters($this);
928 $this->tpl->setContent($form->getHTML());
935 public function printMail()
942 $tplprint =
new ilTemplate(
'tpl.mail_print.html',
true,
true,
'Services/Mail');
943 $tplprint->setVariable(
'JSPATH', $tpl->tplPath);
945 $mailData = $this->umail->getMail((
int)$_GET[
'mail_id']);
952 $tplprint->setVariable(
'TXT_FROM', $this->lng->txt(
'from'));
953 if($sender && $sender->getId() && $sender->getId() != ANONYMOUS_USER_ID)
955 $tplprint->setVariable(
'FROM', $sender->getPublicName());
957 else if(!$sender || !$sender->getId())
959 $tplprint->setVariable(
'FROM', $mailData[
'import_name'] .
' (' . $this->lng->txt(
'user_deleted') .
')');
963 $tplprint->setVariable(
'FROM', ilMail::_getIliasMailerName());
966 $tplprint->setVariable(
'TXT_TO', $this->lng->txt(
'mail_to'));
967 $tplprint->setVariable(
'TO', $mailData[
'rcp_to']);
969 if($mailData[
'rcp_cc'])
971 $tplprint->setCurrentBlock(
'cc');
972 $tplprint->setVariable(
'TXT_CC', $this->lng->txt(
'cc'));
973 $tplprint->setVariable(
'CC', $mailData[
'rcp_cc']);
974 $tplprint->parseCurrentBlock();
977 if($mailData[
'rcp_bcc'])
979 $tplprint->setCurrentBlock(
'bcc');
980 $tplprint->setVariable(
'TXT_BCC', $this->lng->txt(
'bc'));
981 $tplprint->setVariable(
'BCC', $mailData[
'rcp_bcc']);
982 $tplprint->parseCurrentBlock();
985 $tplprint->setVariable(
'TXT_SUBJECT', $this->lng->txt(
'subject'));
986 $tplprint->setVariable(
'SUBJECT', htmlspecialchars($mailData[
'm_subject']));
988 $tplprint->setVariable(
'TXT_DATE', $this->lng->txt(
'date'));
991 $tplprint->setVariable(
'TXT_MESSAGE', $this->lng->txt(
'message'));
992 $tplprint->setVariable(
'MAIL_MESSAGE', nl2br(htmlspecialchars($mailData[
'm_message'])));
1001 $_GET[
"mail_id"] =
$_SESSION[
"mail_id"];
1009 : $_GET[
"filename"]));
1014 require_once
"./Services/Mail/classes/class.ilFileDataMail.php";
1020 if(!is_array($file = $mfile->getAttachmentPathByMD5Filename(
$filename, $_GET[
'mail_id'])))