4 require_once
'Services/User/classes/class.ilObjUser.php';
5 require_once
'Services/Mail/classes/class.ilMailbox.php';
6 require_once
'Services/Mail/classes/class.ilFormatMail.php';
7 require_once
'./Services/Mail/classes/class.ilFileDataMail.php';
8 require_once
'Services/Mail/classes/class.ilMailFormCall.php';
37 $this->mbox =
new ilMailBox($ilUser->getId());
41 $_GET[
'mobj_id'] = $_POST[
'mobj_id'];
44 if(!(
int)
$_GET[
'mobj_id'])
46 $_GET[
'mobj_id'] = $this->mbox->getInboxFolder();
49 $this->ctrl->saveParameter($this,
'mobj_id');
54 $forward_class = $this->ctrl->getNextClass($this);
55 switch($forward_class)
57 case 'ilmailfoldergui':
58 include_once
'Services/Mail/classes/class.ilMailFolderGUI.php';
63 case 'ilmailattachmentgui':
64 include_once
'Services/Mail/classes/class.ilMailAttachmentGUI.php';
66 $this->ctrl->setReturn($this,
"returnFromAttachments");
70 case 'ilmailsearchgui':
71 include_once
'Services/Contact/classes/class.ilMailSearchGUI.php';
73 $this->ctrl->setReturn($this,
"searchResults");
77 case 'ilmailsearchcoursesgui':
78 include_once
'Services/Contact/classes/class.ilMailSearchCoursesGUI.php';
80 $this->ctrl->setReturn($this,
"searchResults");
84 case 'ilmailinglistsgui':
85 include_once
'Services/Contact/classes/class.ilMailingListsGUI.php';
87 $this->ctrl->setReturn($this,
'searchResults');
91 case 'ilmailsearchgroupsgui':
92 include_once
'Services/Contact/classes/class.ilMailSearchGroupsGUI.php';
94 $this->ctrl->setReturn($this,
"searchResults");
99 if (!(
$cmd = $this->ctrl->getCmd()))
116 $decodedFiles = array();
118 foreach($files as $value)
120 if(is_file($this->mfile->getMailPath() .
'/' .
$GLOBALS[
'ilUser']->getId() .
'_' . urldecode($value)))
122 $decodedFiles[] = urldecode($value);
126 return $decodedFiles;
139 $f_message = $this->umail->formatLinebreakMessage($f_message);
141 $this->umail->setSaveInSentbox(
true);
143 $m_type = isset(
$_POST[
"m_type"]) ?
$_POST[
"m_type"] : array(
"normal");
146 if($errorMessage = $this->umail->sendMail(
158 $_POST[
'attachments'] = $files;
163 $this->umail->savePostData($ilUser->getId(), array(),
"",
"",
"",
"",
"",
"",
"",
"");
165 $this->ctrl->setParameterByClass(
'ilmailgui',
'type',
'message_sent');
173 $this->ctrl->redirectByClass(
'ilmailgui');
183 $_POST[
'm_subject'] =
'No title';
186 $draftsId = $this->mbox->getDraftsFolder();
190 if($errorMessage = $this->umail->validateRecipients(
196 $_POST[
'attachments'] = $files;
205 $this->umail->updateDraft($draftsId, $files,
216 #session_unregister("draft"); 217 #ilUtil::sendInfo($this->lng->txt("mail_saved"),true); 218 #ilUtil::redirect("ilias.php?baseClass=ilMailGUI&mobj_id=".$mbox->getInboxFolder()); 220 unset($_SESSION[
"draft"]);
226 $this->ctrl->redirectByClass(
"ilmailfoldergui");
230 if ($this->umail->sendInternalMail($draftsId,
$_SESSION[
"AccountId"],$files,
246 #$this->ctrl->setParameterByClass("ilmailfoldergui", "mobj_id", $this->mbox->getDraftsFolder()); 251 $this->ctrl->redirectByClass(
"ilmailfoldergui");
266 $this->tpl->setTitle($this->lng->txt(
"mail"));
272 if(is_array(
$_POST[
'attachments']))
274 foreach(
$_POST[
'attachments'] as $value)
276 $files[] = urldecode($value);
281 $this->umail->savePostData($ilUser->getId(),
293 include_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
295 $form->setId(
'search_rcp');
296 $form->setTitle($this->lng->txt(
'search_recipients'));
297 $form->setFormAction($ilCtrl->getFormAction($this,
'search'));
299 $inp =
new ilTextInputGUI($this->lng->txt(
"search_for"),
'search');
301 $dsDataLink = $ilCtrl->getLinkTarget($this,
'lookupRecipientAsync',
'',
true,
false);
302 $inp->setDataSource($dsDataLink);
304 if (strlen(trim(
$_SESSION[
"mail_search_search"])) > 0)
308 $form->addItem($inp);
310 $form->addCommandButton(
'search', $this->lng->txt(
"search"));
311 $form->addCommandButton(
'cancelSearch', $this->lng->txt(
"cancel"));
313 $this->tpl->setContent($form->getHtml());
322 $this->saveMailBeforeSearch();
326 $this->ctrl->setParameterByClass(
'ilmailsearchcoursesgui',
'cmd',
'showMembers');
329 $this->ctrl->setParameterByClass(
'ilmailsearchcoursesgui',
'ref',
'mail');
330 $this->ctrl->redirectByClass(
'ilmailsearchcoursesgui');
338 $this->saveMailBeforeSearch();
340 $this->ctrl->setParameterByClass(
'ilmailsearchgroupsgui',
'ref',
'mail');
341 $this->ctrl->redirectByClass(
'ilmailsearchgroupsgui');
347 if(strlen(trim(
$_SESSION[
"mail_search_search"])) == 0)
354 if(strlen(trim(
$_SESSION[
"mail_search_search"])) < 3)
356 $this->lng->loadLanguageModule(
'search');
362 $this->ctrl->setParameterByClass(
"ilmailsearchgui",
"search", urlencode(
$_SESSION[
"mail_search_search"]));
363 $this->ctrl->redirectByClass(
"ilmailsearchgui");
378 if(is_array(
$_POST[
'attachments']))
380 foreach(
$_POST[
'attachments'] as $value)
382 $files[] = urldecode($value);
387 $this->umail->savePostData(
$_SESSION[
"AccountId"],
399 $this->ctrl->redirectByClass(
"ilmailattachmentgui");
404 $_GET[
"type"] =
"attach";
410 $_GET[
"type"] =
"search_res";
416 $_GET[
"type"] =
"new";
422 $_GET[
"type"] =
"role";
428 $_GET[
"type"] =
"reply";
434 $_GET[
"type"] =
"attach";
442 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.mail_new.html",
"Services/Mail");
443 $this->tpl->setTitle($this->lng->txt(
"mail"));
445 $this->lng->loadLanguageModule(
"crs");
448 $ilTabs->setBackTarget($lng->txt(
'back'), $ilCtrl->getLinkTarget($this,
'cancelMail'));
450 switch(
$_GET[
"type"])
457 $mailData = $this->umail->getMail(
$_GET[
"mail_id"]);
458 $mailData[
"m_subject"] = $this->umail->formatReplySubject();
459 $mailData[
"m_message"] = $this->umail->formatReplyMessage();
460 $mailData[
"m_message"] = $this->umail->prependSignature();
462 $mailData[
"attachments"] = array();
464 $mailData[
"rcp_cc"] =
'';
465 $mailData[
"rcp_to"] = $this->umail->formatReplyRecipient();
470 $mailData = $this->umail->getSavedData();
481 $mailData = $this->umail->appendSearchResult(
$_SESSION[
"mail_search_results_to"],
'to');
485 $mailData = $this->umail->appendSearchResult(
$_SESSION[
"mail_search_results_cc"],
'cc');
489 $mailData = $this->umail->appendSearchResult(
$_SESSION[
"mail_search_results_bcc"],
'bc');
492 unset(
$_SESSION[
"mail_search_results_to"]);
493 unset(
$_SESSION[
"mail_search_results_cc"]);
494 unset(
$_SESSION[
"mail_search_results_bcc"]);
499 $mailData = $this->umail->getSavedData();
504 $mailData = $this->umail->getMail(
$_GET[
"mail_id"]);
508 $mailData = $this->umail->getMail(
$_GET[
"mail_id"]);
509 $mailData[
"rcp_to"] = $mailData[
"rcp_cc"] = $mailData[
"rcp_bcc"] =
'';
510 $mailData[
"m_subject"] = $this->umail->formatForwardSubject();
511 $mailData[
"m_message"] = $this->umail->prependSignature();
512 if(count($mailData[
"attachments"]))
514 if($error = $this->mfile->adoptAttachments($mailData[
"attachments"],
$_GET[
"mail_id"]))
529 $mailData[
"rcp_to"] =
$_SESSION[
'rcp_to'];
538 $mailData[
"rcp_cc"] =
$_SESSION[
'rcp_cc'];
547 $mailData[
"rcp_bcc"] =
$_SESSION[
'rcp_bcc'];
549 $mailData[
'm_message'] =
'';
552 $mailData[
'm_message'] = $sig;
553 $mailData[
'm_message'] .= chr(13).chr(10).chr(13).chr(10);
555 $mailData[
'm_message'] .= $this->umail->appendSignature();
564 if(is_array(
$_POST[
'roles']))
569 elseif(is_array(
$_SESSION[
'mail_roles']))
574 $mailData[
'm_message'] =
'';
577 $mailData[
'm_message'] = $sig;
578 $mailData[
'm_message'] .= chr(13).chr(10).chr(13).chr(10);
581 $mailData[
'm_message'] .=
$_POST[
"additional_message_text"].chr(13).chr(10).$this->umail->appendSignature();
582 $_POST[
"additional_message_text"] =
"";
587 $mailData[
"rcp_to"] = urldecode(
$_GET[
"rcp"]);
595 foreach ($mailData as $key => $value)
597 if (is_string($value))
606 include_once(
'./Services/Form/classes/class.ilPropertyFormGUI.php');
609 $form_gui->setTitle($this->lng->txt(
'compose'));
610 $form_gui->setOpenTag(
false);
611 $this->tpl->setVariable(
'FORM_ACTION', $this->ctrl->getFormAction($this,
'sendMessage'));
613 $this->tpl->setVariable(
'BUTTON_TO', $lng->txt(
"search_recipients"));
614 $this->tpl->setVariable(
'BUTTON_COURSES_TO', $lng->txt(
"mail_my_courses"));
615 $this->tpl->setVariable(
'BUTTON_GROUPS_TO', $lng->txt(
"mail_my_groups"));
616 $this->tpl->setVariable(
'BUTTON_MAILING_LISTS_TO', $lng->txt(
"mail_my_mailing_lists"));
618 $dsDataLink = $ilCtrl->getLinkTarget($this,
'lookupRecipientAsync',
'',
true);
624 $inp->setValue($mailData[
"rcp_to"]);
625 $inp->setDataSource($dsDataLink,
",");
626 $inp->setMaxLength(null);
627 $form_gui->addItem($inp);
632 $inp->setValue($mailData[
"rcp_cc"]);
633 $inp->setDataSource($dsDataLink,
",");
634 $inp->setMaxLength(null);
635 $form_gui->addItem($inp);
640 $inp->setValue($mailData[
"rcp_bcc"]);
641 $inp->setDataSource($dsDataLink,
",");
642 $inp->setMaxLength(null);
643 $form_gui->addItem($inp);
646 $inp =
new ilTextInputGUI($this->lng->txt(
'subject'),
'm_subject');
648 $inp->setRequired(
true);
649 $inp->setValue($mailData[
"m_subject"]);
650 $form_gui->addItem($inp);
653 include_once
'Services/Mail/classes/class.ilMailFormAttachmentFormPropertyGUI.php';
657 if (is_array($mailData[
"attachments"]) && count($mailData[
"attachments"]))
659 foreach($mailData[
"attachments"] as
$data)
661 if(is_file($this->mfile->getMailPath() .
'/' . $ilUser->getId() .
"_" .
$data))
664 $form_gui->addItem($hidden);
665 $size = filesize($this->mfile->getMailPath() .
'/' . $ilUser->getId() .
"_" .
$data);
667 $att->addItem($label);
668 $hidden->setValue(urlencode($data));
672 $form_gui->addItem($att);
675 if($rbacsystem->checkAccess(
"system_message",$this->umail->getMailObjectReferenceId()))
679 $chb->setValue(
'system');
680 $chb->setChecked(
false);
681 if(is_array($mailData[
"m_type"]) and in_array(
'system',$mailData[
"m_type"]))
683 $chb->setChecked(
true);
685 $form_gui->addItem($chb);
692 $inp->
setValue($mailData[
"m_message"]);
693 $inp->setRequired(
false);
698 $chb =
new ilCheckboxInputGUI($this->lng->txt(
'activate_serial_letter_placeholders'),
'use_placeholders');
699 $chb->
setOptionTitle($this->lng->txt(
'activate_serial_letter_placeholders'));
701 $chb->setChecked(
false);
702 $form_gui->addItem($inp);
704 include_once
'Services/Mail/classes/class.ilMailFormPlaceholdersPropertyGUI.php';
707 $chb->addSubItem($prop);
709 if ($mailData[
'use_placeholders'])
711 $chb->setChecked(
true);
714 $form_gui->addItem($chb);
716 $form_gui->addCommandButton(
'sendMessage', $this->lng->txt(
'send_mail'));
717 $form_gui->addCommandButton(
'saveDraft', $this->lng->txt(
'save_message'));
719 $form_gui->addCommandButton(
'cancelMail', $this->lng->txt(
'cancel'));
721 $this->tpl->parseCurrentBlock();
723 $this->tpl->setVariable(
'FORM', $form_gui->getHTML());
725 $this->tpl->addJavaScript(
'Services/Mail/js/ilMailComposeFunctions.js');
731 include_once
'Services/JSON/classes/class.ilJsonUtil.php';
732 include_once
'Services/Mail/classes/class.ilMailForm.php';
744 $quoted = str_replace(
'%',
'\%', $quoted);
745 $quoted = str_replace(
'_',
'\_', $quoted);
765 protected function saveMailBeforeSearch()
774 if(is_array(
$_POST[
'attachments']))
776 foreach(
$_POST[
'attachments'] as $value)
778 $files[] = urldecode($value);
782 $this->umail->savePostData($ilUser->getId(),
800 $this->saveMailBeforeSearch();
802 $this->ctrl->setParameterByClass(
'ilmailinglistsgui',
'ref',
'mail');
803 $this->ctrl->redirectByClass(
'ilmailinglistsgui');
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
static securePlainString($a_str)
Remove unsecure characters from a plain text string.
This class handles all operations on files (attachments) in directory ilias_data/mail.
setValue($a_value)
Set Value.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static encode($mixed, $suppress_native=false)
setSize($a_size)
Set Size.
This class represents a text property in a property form.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
This class represents a text area property in a property form.
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
static redirect($a_script)
http redirect to other script