24 require_once
'Services/User/classes/class.ilObjUser.php';
25 require_once
'Services/Mail/classes/class.ilMailbox.php';
26 require_once
'Services/Mail/classes/class.ilMail.php';
59 $this->umail =
new ilMail($ilUser->getId());
60 $this->mbox =
new ilMailBox($ilUser->getId());
64 $_GET[
'mobj_id'] = $_POST[
'mobj_id'];
67 if(!(
int)
$_GET[
'mobj_id'])
69 $_GET[
'mobj_id'] = $this->mbox->getInboxFolder();
71 $ilCtrl->saveParameter($this,
'mobj_id');
72 $ilCtrl->setParameter($this,
'mobj_id',
$_GET[
'mobj_id']);
80 $_GET[
"cmd"] =
'editFolder';
84 if (
$_GET[
"selected_cmd"] ==
"deleteMails" &&
$_GET[
"mail_id"])
86 $_GET[
"cmd"] =
"editFolder";
87 $_POST[
"selected_cmd"] =
"deleteMails";
91 $forward_class = $this->ctrl->getNextClass($this);
92 switch($forward_class)
94 case 'ilmailaddressbookgui':
95 include_once
'Services/Contact/classes/class.ilMailAddressbookGUI.php';
100 case 'ilmailoptionsgui':
101 include_once
'Services/Mail/classes/class.ilMailOptionsGUI.php';
106 case 'ilpublicuserprofilegui':
107 include_once(
"Services/User/classes/class.ilPublicUserProfileGUI.php");
109 $ret = $this->ctrl->forwardCommand($profile_gui);
113 if (!(
$cmd = $this->ctrl->getCmd()))
125 global
$lng, $ilUser;
127 if(
$_GET[
"mail_id"] !=
"")
129 if (is_array($mail_data = $this->umail->getMail(
$_GET[
"mail_id"])))
131 require_once
"Services/Contact/classes/class.ilAddressbook.php";
134 $tmp_user =
new ilObjUser($mail_data[
"sender_id"]);
135 if ($abook->checkEntryByLogin($tmp_user->getLogin()) > 0)
141 $abook->addEntry($tmp_user->getLogin(),
142 $tmp_user->getFirstname(),
143 $tmp_user->getLastname(),
144 $tmp_user->getEmail());
167 $this->umail->deleteMailsOfFolder(
$_GET[
"mobj_id"]);
180 if($this->umail->countMailsOfFolder((
int)
$_GET[
'mobj_id']))
183 $this->askForConfirmation =
true;
195 $this->ctrl->setParameter($this,
"mail_id",
$_GET[
"mail_id"]);
197 $this->tpl->setTitle($this->lng->txt(
"mail"));
198 $ilToolbar->addButton($this->lng->txt(
"back"), $this->ctrl->getLinkTarget($this,
"showMail"));
200 $this->tpl->setVariable(
"TBL_TITLE", $this->lng->txt(
"profile_of").
" ".
203 $this->tpl->setVariable(
"TBL_TITLE_IMG_ALT", $this->lng->txt(
"public_profile"));
205 include_once
'./Services/User/classes/class.ilPublicUserProfileGUI.php';
207 $this->tpl->setContent($ilCtrl->getHTML($profile_gui));
220 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.mail.html',
'Services/Mail');
221 $this->tpl->setVariable(
'HEADER', $this->lng->txt(
'mail'));
223 include_once
'Services/Mail/classes/class.ilMailFolderTableGUI.php';
225 $sentFolderId = $this->mbox->getSentFolder();
226 $draftsFolderId = $this->mbox->getDraftsFolder();
228 $isTrashFolder =
$_GET[
'mobj_id'] == $this->mbox->getTrashFolder();
229 $isSentFolder =
$_GET[
'mobj_id'] == $sentFolderId;
230 $isDraftFolder =
$_GET[
'mobj_id'] == $draftsFolderId;
233 if(
$_POST[
'selected_cmd'] ==
'deleteMails' &&
234 !$this->errorDelete &&
235 $_POST[
'selected_cmd'] !=
'confirm' &&
238 if(isset($_REQUEST[
'mail_id']) && !is_array($_REQUEST[
'mail_id'])) $_REQUEST[
'mail_id'] = array($_REQUEST[
'mail_id']);
239 foreach((array)$_REQUEST[
'mail_id'] as $id)
241 $this->tpl->setCurrentBlock(
'mail_ids');
242 $this->tpl->setVariable(
'MAIL_ID_VALUE', $id);
243 $this->tpl->parseCurrentBlock();
246 $this->tpl->setCurrentBlock(
'confirm_delete');
247 $this->tpl->setVariable(
'ACTION', $this->ctrl->getFormAction($this,
'confirmDeleteMails'));
248 $this->tpl->setVariable(
'BUTTON_CONFIRM',$this->lng->txt(
'confirm'));
249 $this->tpl->setVariable(
'BUTTON_CANCEL',$this->lng->txt(
'cancel'));
250 $this->tpl->parseCurrentBlock();
254 $mailtable->isSentFolder($isSentFolder)
255 ->isDraftFolder($isDraftFolder)
256 ->isTrashFolder($isTrashFolder)
257 ->setSelectedItems(
$_POST[
'mail_id'])
261 $folders = $this->mbox->getSubFolders();
262 $mtree =
new ilTree($ilUser->getId());
266 foreach($folders as $folder)
268 $this->tpl->setCurrentBLock(
'flat_select');
269 $folder_d = $mtree->getNodeData($folder[
'obj_id']);
270 if($folder[
'obj_id'] == $_GET[
'mobj_id'])
272 $this->tpl->setVariable(
'FLAT_SELECTED',
' selected="selected"');
274 $this->tpl->setVariable(
'FLAT_VALUE', $folder[
'obj_id']);
275 if($folder[
'type'] ==
'user_folder')
278 for ($i = 2; $i < $folder_d[
'depth'] - 1; $i++)
280 if ($folder_d[
'depth'] > 1)
282 $this->tpl->setVariable(
'FLAT_NAME', $pre.
' '.$folder[
'title']);
286 $this->tpl->setVariable(
'FLAT_NAME', $this->lng->txt(
'mail_'.$folder[
'title']));
288 $this->tpl->parseCurrentBlock();
291 $this->tpl->setCurrentBlock(
'show_folder');
292 $this->tpl->setVariable(
'TXT_FOLDERS', $this->lng->txt(
'mail_change_to_folder'));
294 $this->tpl->setVariable(
'FOLDER_VALUE', $this->lng->txt(
'change'));
295 $this->tpl->setVariable(
'ACTION_FLAT', $this->ctrl->getFormAction($this,
'showFolder'));
296 $this->tpl->parseCurrentBlock();
301 if($mailtable->isTrashFolder() &&
302 $mailtable->getNumerOfMails() > 0)
304 if($this->askForConfirmation ==
true)
306 $this->tpl->setCurrentBlock(
'CONFIRM_EMPTY_TRASH');
307 $this->tpl->setVariable(
'ACTION_EMPTY_TRASH_CONFIRMATION', $this->ctrl->getFormAction($this,
'performEmptyTrash'));
308 $this->tpl->setVariable(
'BUTTON_CONFIRM_EMPTY_TRASH', $this->lng->txt(
'confirm'));
309 $this->tpl->setVariable(
'BUTTON_CANCEL_EMPTY_TRASH', $this->lng->txt(
'cancel'));
310 $this->tpl->parseCurrentBlock();
315 $this->tpl->setVariable(
'MAIL_TABLE', $mailtable->getHtml());
323 ilUtil::redirect(
"ilias.php?baseClass=ilMailGUI&mobj_id=".
$_GET[
"mobj_id"].
"&type=confirmdelete_folderdata");
344 $new_parent = $this->mbox->getParentFolderId(
$_GET[
"mobj_id"]);
346 if ($this->mbox->deleteFolder(
$_GET[
"mobj_id"]))
356 ilUtil::redirect(
"ilias.php?baseClass=ilMailGUI&mobj_id=".
$_GET[
"mobj_id"].
"&type=confirmdelete_folderdata");
372 ilUtil::redirect(
"ilias.php?baseClass=ilMailGUI&mobj_id=".
$_GET[
"mobj_id"].
"&type=enter_folderdata");
385 ilUtil::redirect(
"ilias.php?baseClass=ilMailGUI&mobj_id=".
$_GET[
"mobj_id"].
"&target=ilmailfoldergui");
398 $tmp_data = $this->mbox->getFolderData(
$_GET[
"mobj_id"]);
399 if ($tmp_data[
"title"] !=
$_POST[
"folder_name_add"])
401 if (
$_POST[
"folder_name_add"] ==
"")
406 ilUtil::redirect(
"ilias.php?baseClass=ilMailGUI&mobj_id=".
$_GET[
"mobj_id"].
"&type=enter_folderdata");
427 ilUtil::redirect(
"ilias.php?baseClass=ilMailGUI&mobj_id=".
$_GET[
"mobj_id"].
"&type=enter_folderdata");
441 ilUtil::redirect(
"ilias.php?baseClass=ilMailGUI&mobj_id=".
$_GET[
"mobj_id"].
"&type=enter_folderdata");
456 if (empty(
$_POST[
'folder_name_add']))
472 $ilCtrl->saveParameter($this,
'mobj_id');
473 $ilCtrl->setParameter($this,
'mobj_id',
$_GET[
'mobj_id']);
516 $mtree =
new ilTree($ilUser->getId());
518 $folder_node = $mtree->getNodeData(
$_GET[mobj_id]);
520 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.mail_edit_user_folder.html",
'Services/Mail');
524 $this->tpl->setCurrentBlock(
"confirm_delete");
525 $this->ctrl->setParameter($this,
"cmd",
"post");
526 $this->tpl->setVariable(
"ACTION_DELETE", $this->ctrl->getFormAction($this));
528 $this->ctrl->clearParameters($this);
529 $this->tpl->setVariable(
"TXT_DELETE_CONFIRM",$this->lng->txt(
"confirm"));
530 $this->tpl->setVariable(
"TXT_DELETE_CANCEL",$this->lng->txt(
"cancel"));
531 $this->tpl->parseCurrentBlock();
534 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
536 $this->tpl->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this));
539 if (
$cmd ==
"saveFolderSettings")
541 $this->tpl->setVariable(
"TXT_HEADLINE", $this->lng->txt(
'mail_folder_edit'));
542 $this->tpl->setVariable(
"TXT_TITLE", $this->lng->txt(
'name'));
543 $this->tpl->setVariable(
"TXT_DELETE", $this->lng->txt(
'delete'));
551 $this->tpl->setVariable(
"TXT_HEADLINE", $this->lng->txt(
'mail_add_subfolder'));
552 $this->tpl->setVariable(
"TXT_TITLE", $this->lng->txt(
'name'));
560 $this->tpl->setVariable(
"CMD_SUBMIT",
$cmd);
561 $this->tpl->setVariable(
"TXT_SUBMIT", (
$cmd ==
"saveSubFolderSettings" ? $this->lng->txt(
'save') : $this->lng->txt(
'rename')));
562 $this->tpl->setVariable(
"TITLE_VALUE", $title_value);
563 $this->tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
'cancel'));
565 $this->tpl->setVariable(
"HEADER", $this->lng->txt(
"mail"));
573 switch (
$_POST[
"selected_cmd"])
576 if(!(
int)
$_GET[
"mail_id"] || !(
int)
$_POST[
"selected_cmd"])
582 if ($this->umail->moveMailsToFolder(array(
$_GET[
"mail_id"]), $_POST[
"selected_cmd"]))
585 $this->ctrl->redirectByClass(
"ilMailGUI");
601 switch (
$_POST[
"selected_cmd"])
603 case 'markMailsRead':
604 if(is_array(
$_POST[
"mail_id"]))
606 $this->umail->markRead(
$_POST[
"mail_id"]);
613 case 'markMailsUnread':
614 if(is_array(
$_POST[
"mail_id"]))
616 $this->umail->markUnread(
$_POST[
"mail_id"]);
626 if($this->mbox->getTrashFolder() ==
$_GET[
"mobj_id"])
628 if(!is_array(
$_POST[
"mail_id"]))
631 $this->errorDelete =
true;
641 if(!is_array(
$_POST[
"mail_id"]))
645 else if($this->umail->moveMailsToFolder(
$_POST[
"mail_id"], $this->mbox->getTrashFolder()))
658 $this->ctrl->setParameterByClass(
"ilmailoptionsgui",
"cmd",
"add");
659 $this->ctrl->redirectByClass(
"ilmailoptionsgui");
663 if(!is_array(
$_POST[
"mail_id"]))
667 else if($this->umail->moveMailsToFolder(
$_POST[
"mail_id"],
$_POST[
"selected_cmd"]))
684 if($this->mbox->getTrashFolder() ==
$_GET[
"mobj_id"])
686 if(!is_array(
$_POST[
"mail_id"]))
690 else if($this->umail->deleteMails(
$_POST[
"mail_id"]))
707 $this->ctrl->redirect($this);
720 $this->umail->markRead(array(
$_GET[
"mail_id"]));
722 $mailData = $this->umail->getMail(
$_GET[
"mail_id"]);
724 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.mail_read.html",
"Services/Mail");
725 $this->tpl->setVariable(
"HEADER",$this->lng->txt(
"mail_mails_of"));
729 include_once(
"./Services/Accessibility/classes/class.ilAccessKeyGUI.php");
733 include_once(
"./Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php");
735 if($mailData[
"sender_id"] &&
736 $mailData[
"sender_id"] != ANONYMOUS_USER_ID)
738 $this->ctrl->setParameterByClass(
"ilmailformgui",
"mail_id",
$_GET[
"mail_id"]);
739 $this->ctrl->setParameterByClass(
"ilmailformgui",
"type",
"reply");
740 $this->ctrl->clearParametersByClass(
"iliasmailformgui");
742 $toolbar->addButton($this->lng->txt(
"reply"), $this->ctrl->getLinkTargetByClass(
"ilmailformgui"),
747 $this->ctrl->setParameterByClass(
"ilmailformgui",
"mail_id",
$_GET[
"mail_id"]);
748 $this->ctrl->setParameterByClass(
"ilmailformgui",
"type",
"forward");
749 $this->ctrl->clearParametersByClass(
"iliasmailformgui");
750 $toolbar->addButton($this->lng->txt(
"forward"), $this->ctrl->getLinkTargetByClass(
"ilmailformgui"),
754 $this->ctrl->setParameter($this,
"mail_id",
$_GET[
"mail_id"]);
755 $this->ctrl->setParameter($this,
"cmd",
"printMail");
756 $toolbar->addButton($this->lng->txt(
"print"), $this->ctrl->getLinkTarget($this),
758 $this->ctrl->clearParameters($this);
761 $this->ctrl->setParameter($this,
"mail_id",
$_GET[
"mail_id"]);
762 $this->ctrl->setParameter($this,
"selected_cmd",
"deleteMails");
763 $toolbar->addButton($this->lng->txt(
"delete"), $this->ctrl->getLinkTarget($this),
765 $this->ctrl->clearParameters($this);
767 $this->tpl->setVariable(
"BUTTONS2",$toolbar->getHTML());
769 $this->ctrl->setParameter($this,
"mail_id",
$_GET[
"mail_id"]);
770 $this->tpl->setVariable(
"ACTION", $this->ctrl->getFormAction($this));
771 $this->ctrl->clearParameters($this);
773 if ($mailData[
"sender_id"] &&
774 $mailData[
"sender_id"] != $ilUser->getId() &&
775 $mailData[
"sender_id"] != ANONYMOUS_USER_ID)
777 require_once
"Services/Contact/classes/class.ilAddressbook.php";
779 $tmp_user =
new ilObjUser($mailData[
"sender_id"]);
780 if ($abook->checkEntryByLogin($tmp_user->getLogin()) == 0)
784 $tplbtn->setCurrentBlock(
"btn_cell");
785 $this->ctrl->setParameter($this,
"mail_id",
$_GET[
"mail_id"]);
786 $this->ctrl->setParameter($this,
"cmd",
"add");
787 $tplbtn->setVariable(
"BTN_LINK", $this->ctrl->getLinkTarget($this));
788 $this->ctrl->clearParameters($this);
789 $tplbtn->setVariable(
"BTN_TXT", $this->lng->txt(
"mail_add_to_addressbook"));
792 $this->tpl->setVariable(
"ADD_USER_BTN",
$tplbtn->get());
800 if($mailData[
"sender_id"] != ANONYMOUS_USER_ID)
802 $tmp_user =
new ilObjUser($mailData[
'sender_id']);
803 $this->ctrl->setParameter($this,
'mail_id',
$_GET[
'mail_id']);
804 $this->ctrl->setParameter($this,
'user', $tmp_user->getId());
807 $this->tpl->setVariable(
'PROFILE_LINK_FROM', $this->ctrl->getLinkTarget($this,
'showUser'));
808 $this->tpl->setVariable(
'FROM', $tmp_user->getFullname());
810 $this->tpl->setCurrentBlock(
"pers_image");
811 $this->tpl->setVariable(
"IMG_SENDER", $tmp_user->getPersonalPicturePath(
"xsmall"));
812 $this->tpl->setVariable(
"ALT_SENDER", $tmp_user->getFullname());
813 $this->tpl->parseCurrentBlock();
814 $this->tpl->setCurrentBlock(
"adm_content");
815 if(!(
$login = $tmp_user->getLogin()))
817 $login = $mailData[
"import_name"].
" (".$this->lng->txt(
"user_deleted").
")";
819 $this->tpl->setVariable(
"MAIL_LOGIN",
$login);
820 $this->tpl->setVariable(
"CSSROW_FROM", (++$counter) % 2 ?
'tblrow1' :
'tblrow2');
824 $tmp_user =
new ilObjUser(ANONYMOUS_USER_ID);
826 $this->tpl->setCurrentBlock(
'pers_image');
829 $this->tpl->parseCurrentBlock();
832 $this->tpl->setVariable(
'TXT_FROM', $this->lng->txt(
'from'));
835 $this->tpl->setVariable(
'TXT_TO', $this->lng->txt(
'mail_to'));
838 $this->tpl->setVariable(
'CSSROW_TO', (++$counter) % 2 ?
'tblrow1' :
'tblrow2');
841 if($mailData[
'rcp_cc'])
843 $this->tpl->setCurrentBlock(
'cc');
844 $this->tpl->setVariable(
'TXT_CC',$this->lng->txt(
'cc'));
847 $this->tpl->setVariable(
'CSSROW_CC', (++$counter) % 2 ?
'tblrow1' :
'tblrow2');
848 $this->tpl->parseCurrentBlock();
852 $this->tpl->setVariable(
'TXT_SUBJECT', $this->lng->txt(
'subject'));
855 $this->tpl->setVariable(
'CSSROW_SUBJ', (++$counter) % 2 ?
'tblrow1' :
'tblrow2');
858 $this->tpl->setVariable(
'TXT_DATE', $this->lng->txt(
'date'));
860 $this->tpl->setVariable(
'CSSROW_DATE', (++$counter) % 2 ?
'tblrow1' :
'tblrow2');
863 if($mailData[
'attachments'])
865 $this->tpl->setCurrentBlock(
'attachment');
866 $this->tpl->setCurrentBlock(
'a_row');
868 foreach($mailData[
'attachments'] as
$file)
870 $this->tpl->setVariable(
'A_CSSROW', (++$counter) % 2 ?
'tblrow1' :
'tblrow2');
871 $this->tpl->setVariable(
'FILE', md5($file));
872 $this->tpl->setVariable(
'FILE_NAME', $file);
873 $this->tpl->parseCurrentBlock();
875 $this->tpl->setVariable(
'TXT_ATTACHMENT', $this->lng->txt(
'attachments'));
876 $this->tpl->setVariable(
'TXT_DOWNLOAD', $this->lng->txt(
'download'));
877 $this->tpl->parseCurrentBlock();
881 $this->tpl->setVariable(
'TXT_MESSAGE', $this->lng->txt(
'message'));
886 $isTrashFolder =
false;
887 if ($this->mbox->getTrashFolder() ==
$_GET[
'mobj_id'])
889 $isTrashFolder =
true;
895 $selectOptions = array();
896 $actions = $this->mbox->getActions(
$_GET[
"mobj_id"]);
897 foreach($actions as
$key => $action)
899 if(
$key ==
'moveMails')
901 $folders = $this->mbox->getSubFolders();
902 foreach($folders as $folder)
904 if ($folder[
"type"] !=
'trash' ||
908 if($folder[
'type'] !=
'user_folder')
910 $optionText = $action.
' '.$this->lng->txt(
'mail_'.$folder[
'title']).($folder[
'type'] ==
'trash' ?
' ('.$this->lng->txt(
'delete').
')' :
'');
914 $optionText = $action.
' '.$folder[
'title'];
917 $selectOptions[$folder[
'obj_id']] = $optionText;
922 if(is_array($selectOptions) && count($selectOptions))
924 include_once
'Services/Form/classes/class.ilSelectInputGUI.php';
926 $oActionSelectBox->setOptions($selectOptions);
927 $oBottomToolbar->addInputItem($oActionSelectBox);
928 $oBottomToolbar->addFormButton($this->lng->txt(
'submit'),
'changeFolder');
932 $prevMail = $this->umail->getPreviousMail(
$_GET[
'mail_id']);
933 $nextMail = $this->umail->getNextMail(
$_GET[
'mail_id']);
934 if(is_array($prevMail) || is_array($nextMail))
936 $oBottomToolbar->addSeparator();
938 if($prevMail[
'mail_id'])
940 $this->ctrl->setParameter($this,
'mail_id', $prevMail[
'mail_id']);
941 $this->ctrl->setParameter($this,
'cmd',
'showMail');
942 $oBottomToolbar->addButton($this->lng->txt(
'previous'), $this->ctrl->getLinkTarget($this));
943 $this->ctrl->clearParameters($this);
946 if($nextMail[
'mail_id'])
948 $this->ctrl->setParameter($this,
'mail_id', $nextMail[
'mail_id']);
949 $this->ctrl->setParameter($this,
'cmd',
'showMail');
950 $oBottomToolbar->addButton($this->lng->txt(
'next'), $this->ctrl->getLinkTarget($this));
951 $this->ctrl->clearParameters($this);
955 $this->tpl->setVariable(
'MAIL_NAVIGATION', $oBottomToolbar->getHTML());
961 $tplprint =
new ilTemplate(
"Services/Mail/templates/default/tpl.mail_print.html",
true,
true,
true);
962 $tplprint->setVariable(
"JSPATH",
$tpl->tplPath);
965 $mailData = $this->umail->getMail(
$_GET[
"mail_id"]);
969 if($mailData[
"sender_id"] != ANONYMOUS_USER_ID)
971 $tmp_user =
new ilObjUser($mailData[
"sender_id"]);
972 if(!(
$login = $tmp_user->getFullname()))
974 $login = $mailData[
"import_name"].
" (".$this->lng->txt(
"user_deleted").
")";
976 $tplprint->setVariable(
"FROM",
$login);
983 $tplprint->setVariable(
'TXT_FROM', $this->lng->txt(
'from'));
986 $tplprint->setVariable(
"TXT_TO", $this->lng->txt(
"mail_to"));
987 $tplprint->setVariable(
"TO", $mailData[
"rcp_to"]);
990 if($mailData[
"rcp_cc"])
992 $tplprint->setCurrentBlock(
"cc");
993 $tplprint->setVariable(
"TXT_CC",$this->lng->txt(
"cc"));
994 $tplprint->setVariable(
"CC",$mailData[
"rcp_cc"]);
995 $tplprint->parseCurrentBlock();
998 $tplprint->setVariable(
"TXT_SUBJECT",$this->lng->txt(
"subject"));
999 $tplprint->setVariable(
"SUBJECT",htmlspecialchars($mailData[
"m_subject"]));
1002 $tplprint->setVariable(
"TXT_DATE", $this->lng->txt(
"date"));
1007 $tplprint->setVariable(
"TXT_MESSAGE", $this->lng->txt(
"message"));
1008 $tplprint->setVariable(
"MAIL_MESSAGE", nl2br(htmlspecialchars($mailData[
"m_message"])));
1026 :
$_GET[
"filename"]));
1031 require_once
"classes/class.ilFileDataMail.php";
1037 if(!is_array(
$file = $mfile->getAttachmentPathByMD5Filename(
$filename,
$_GET[
'mail_id'])))