ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilMailFormGUI Class Reference
+ Collaboration diagram for ilMailFormGUI:

Public Member Functions

 __construct (ilMailTemplateService $templateService=null, ilMailBodyPurifier $bodyPurifier=null)
 ilMailFormGUI constructor. More...
 
 executeCommand ()
 
 sendMessage ()
 
 saveDraft ()
 
 searchUsers ($save=true)
 
 searchCoursesTo ()
 
 searchGroupsTo ()
 
 search ()
 
 cancelSearch ()
 
 editAttachments ()
 
 returnFromAttachments ()
 
 searchResults ()
 
 mailUser ()
 
 mailRole ()
 
 replyMail ()
 
 mailAttachment ()
 
 showForm ()
 
 lookupRecipientAsync ()
 
 cancelMail ()
 
 searchMailingListsTo ()
 

Protected Member Functions

 decodeAttachmentFiles (array $files)
 
 getTemplateDataById ()
 Called asynchronously when changing the template. More...
 
 saveMailBeforeSearch ()
 
 showSubmissionErrors (array $errors)
 

Protected Attributes

 $templateService
 

Private Attributes

 $tpl
 
 $ctrl
 
 $lng
 
 $user
 
 $tabs
 
 $toolbar
 
 $rbacsystem
 
 $umail
 
 $mbox
 
 $mfile
 
 $purifier
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilMailFormGUI::__construct ( ilMailTemplateService  $templateService = null,
ilMailBodyPurifier  $bodyPurifier = null 
)

ilMailFormGUI constructor.

Parameters
ilMailTemplateService | null$templateService
ilMailBodyPurifier | null$bodyPurifier

Definition at line 54 of file class.ilMailFormGUI.php.

57 {
58 global $DIC;
59
60 if (null === $templateService) {
61 $templateService = $DIC['mail.texttemplates.service'];
62 }
63 $this->templateService = $templateService;
64
65 $this->tpl = $DIC->ui()->mainTemplate();
66 $this->ctrl = $DIC->ctrl();
67 $this->lng = $DIC->language();
68 $this->user = $DIC->user();
69 $this->tabs = $DIC->tabs();
70 $this->toolbar = $DIC->toolbar();
71 $this->rbacsystem = $DIC->rbac()->system();
72
73 $this->umail = new ilFormatMail($this->user->getId());
74 $this->mfile = new ilFileDataMail($this->user->getId());
75 $this->mbox = new ilMailbox($this->user->getId());
76
77 if (null === $bodyPurifier) {
78 $bodyPurifier = new ilMailBodyPurifier();
79 }
80 $this->purifier = $bodyPurifier;
81
82 if (isset($_POST['mobj_id']) && (int) $_POST['mobj_id']) {
83 $_GET['mobj_id'] = $_POST['mobj_id'];
84 }
85
86 if (!(int) $_GET['mobj_id']) {
87 $_GET['mobj_id'] = $this->mbox->getInboxFolder();
88 }
89 $_GET['mobj_id'] = (int) $_GET['mobj_id'];
90
91 $this->ctrl->saveParameter($this, 'mobj_id');
92 }
user()
Definition: user.php:4
$_GET["client_id"]
$_POST["username"]
Class ilFileDataMail.
Class UserMail this class handles user mails.
Mail Box class Base class for creating and handling mail boxes.
$DIC
Definition: xapitoken.php:46

References $_GET, $_POST, $DIC, $templateService, and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ cancelMail()

ilMailFormGUI::cancelMail ( )

Definition at line 785 of file class.ilMailFormGUI.php.

786 {
789 }
790
791 $this->showForm();
792 }
static redirect($a_script)

References ilMailFormCall\getRefererRedirectUrl(), ilMailFormCall\isRefererStored(), ilUtil\redirect(), and showForm().

+ Here is the call graph for this function:

◆ cancelSearch()

ilMailFormGUI::cancelSearch ( )

Definition at line 346 of file class.ilMailFormGUI.php.

347 {
348 unset($_SESSION["mail_search"]);
349 $this->searchResults();
350 }
$_SESSION["AccountId"]

References $_SESSION, and searchResults().

+ Here is the call graph for this function:

◆ decodeAttachmentFiles()

ilMailFormGUI::decodeAttachmentFiles ( array  $files)
protected
Parameters
array$files
Returns
array

Definition at line 141 of file class.ilMailFormGUI.php.

142 {
143 $decodedFiles = array();
144
145 foreach ($files as $value) {
146 if (is_file($this->mfile->getMailPath() . '/' . $this->user->getId() . '_' . urldecode($value))) {
147 $decodedFiles[] = urldecode($value);
148 }
149 }
150
151 return $decodedFiles;
152 }

Referenced by saveDraft(), and sendMessage().

+ Here is the caller graph for this function:

◆ editAttachments()

ilMailFormGUI::editAttachments ( )

Definition at line 352 of file class.ilMailFormGUI.php.

353 {
354 // decode post values
355 $files = array();
356 if (is_array($_POST['attachments'])) {
357 foreach ($_POST['attachments'] as $value) {
358 $files[] = urldecode($value);
359 }
360 }
361
362 // Note: For security reasons, ILIAS only allows Plain text messages.
363 $this->umail->savePostData(
364 $this->user->getId(),
365 $files,
370 ilUtil::securePlainString($_POST["m_subject"]),
371 ilUtil::securePlainString($_POST["m_message"]),
372 ilUtil::securePlainString($_POST['use_placeholders']),
375 );
376
377 $this->ctrl->redirectByClass("ilmailattachmentgui");
378 }
static securePlainString($a_str)
Remove unsecure characters from a plain text string.

References $_POST, ilMailFormCall\getContextId(), ilMailFormCall\getContextParameters(), ilUtil\securePlainString(), and user().

+ Here is the call graph for this function:

◆ executeCommand()

ilMailFormGUI::executeCommand ( )

Definition at line 94 of file class.ilMailFormGUI.php.

95 {
96 $forward_class = $this->ctrl->getNextClass($this);
97 switch ($forward_class) {
98 case 'ilmailfoldergui':
99 $this->ctrl->forwardCommand(new ilMailFolderGUI());
100 break;
101
102 case 'ilmailattachmentgui':
103 $this->ctrl->setReturn($this, "returnFromAttachments");
104 $this->ctrl->forwardCommand(new ilMailAttachmentGUI());
105 break;
106
107 case 'ilmailsearchgui':
108 $this->ctrl->setReturn($this, "searchResults");
109 $this->ctrl->forwardCommand(new ilMailSearchGUI());
110 break;
111
112 case 'ilmailsearchcoursesgui':
113 $this->ctrl->setReturn($this, "searchResults");
114 $this->ctrl->forwardCommand(new ilMailSearchCoursesGUI());
115 break;
116
117 case 'ilmailinglistsgui':
118 $this->ctrl->setReturn($this, 'searchResults');
119 $this->ctrl->forwardCommand(new ilMailingListsGUI());
120 break;
121
122 case 'ilmailsearchgroupsgui':
123 $this->ctrl->setReturn($this, "searchResults");
124 $this->ctrl->forwardCommand(new ilMailSearchGroupsGUI());
125 break;
126
127 default:
128 if (!($cmd = $this->ctrl->getCmd())) {
129 $cmd = "showForm";
130 }
131
132 $this->$cmd();
133 break;
134 }
135 }

◆ getTemplateDataById()

ilMailFormGUI::getTemplateDataById ( )
protected

Called asynchronously when changing the template.

Definition at line 419 of file class.ilMailFormGUI.php.

420 {
421 if (!isset($_GET['template_id'])) {
422 exit();
423 }
424
425 try {
426 $template = $this->templateService->loadTemplateForId((int) $_GET['template_id']);
427 $context = ilMailTemplateContextService::getTemplateContextById((string) $template->getContext());
428
429 echo json_encode([
430 'm_subject' => $template->getSubject(),
431 'm_message' => $template->getMessage(),
432 ]);
433 } catch (Exception $e) {
434 }
435 exit();
436 }
exit
Definition: login.php:29
$context
Definition: webdav.php:26

References $_GET, $context, Vendor\Package\$e, exit, and ilMailTemplateContextService\getTemplateContextById().

+ Here is the call graph for this function:

◆ lookupRecipientAsync()

ilMailFormGUI::lookupRecipientAsync ( )

Definition at line 753 of file class.ilMailFormGUI.php.

754 {
755 $search = '';
756 if (isset($_GET["term"]) && is_string($_GET["term"])) {
757 $search = $_GET["term"];
758 }
759 if (isset($_POST["term"]) && is_string($_POST["term"])) {
760 $search = $_POST["term"];
761 }
762
763 $search = trim($search);
764
765 $result = array();
766
767 require_once 'Services/Utilities/classes/class.ilStr.php';
768 if (ilStr::strLen($search) < 3) {
769 echo json_encode($result);
770 exit;
771 }
772
773 // #14768
774 $quoted = ilUtil::stripSlashes($search);
775 $quoted = str_replace('%', '\%', $quoted);
776 $quoted = str_replace('_', '\_', $quoted);
777
778 $mailFormObj = new ilMailForm;
779 $result = $mailFormObj->getRecipientAsync("%" . $quoted . "%", ilUtil::stripSlashes($search));
780
781 echo json_encode($result);
782 exit;
783 }
$result
static strLen($a_string)
Definition: class.ilStr.php:78
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled

References $_GET, $_POST, $result, exit, ilUtil\stripSlashes(), and ilStr\strLen().

+ Here is the call graph for this function:

◆ mailAttachment()

ilMailFormGUI::mailAttachment ( )

Definition at line 410 of file class.ilMailFormGUI.php.

411 {
412 $_GET["type"] = "attach";
413 $this->showForm();
414 }

References $_GET, and showForm().

+ Here is the call graph for this function:

◆ mailRole()

ilMailFormGUI::mailRole ( )

Definition at line 398 of file class.ilMailFormGUI.php.

399 {
400 $_GET["type"] = "role";
401 $this->showForm();
402 }

References $_GET, and showForm().

+ Here is the call graph for this function:

◆ mailUser()

ilMailFormGUI::mailUser ( )

Definition at line 392 of file class.ilMailFormGUI.php.

393 {
394 $_GET["type"] = "new";
395 $this->showForm();
396 }

References $_GET, and showForm().

+ Here is the call graph for this function:

◆ replyMail()

ilMailFormGUI::replyMail ( )

Definition at line 404 of file class.ilMailFormGUI.php.

405 {
406 $_GET["type"] = "reply";
407 $this->showForm();
408 }

References $_GET, and showForm().

+ Here is the call graph for this function:

◆ returnFromAttachments()

ilMailFormGUI::returnFromAttachments ( )

Definition at line 380 of file class.ilMailFormGUI.php.

381 {
382 $_GET["type"] = "attach";
383 $this->showForm();
384 }

References $_GET, and showForm().

+ Here is the call graph for this function:

◆ saveDraft()

ilMailFormGUI::saveDraft ( )

Definition at line 198 of file class.ilMailFormGUI.php.

199 {
200 if (!$_POST['m_subject']) {
201 $_POST['m_subject'] = 'No title';
202 }
203
204 $draftFolderId = $this->mbox->getDraftsFolder();
205 $files = $this->decodeAttachmentFiles(isset($_POST['attachments']) ? (array) $_POST['attachments'] : array());
206
207 if ($errors = $this->umail->validateRecipients(
208 (string) ilUtil::securePlainString($_POST['rcp_to']),
209 (string) ilUtil::securePlainString($_POST['rcp_cc']),
210 (string) ilUtil::securePlainString($_POST['rcp_bcc'])
211 )) {
212 $_POST['attachments'] = $files;
214 $this->showForm();
215 return;
216 }
217
218 if (isset($_SESSION["draft"])) {
219 $draftId = (int) $_SESSION['draft'];
220 unset($_SESSION['draft']);
221 } else {
222 $draftId = $this->umail->getNewDraftId($this->user->getId(), $draftFolderId);
223 }
224
225 $this->umail->updateDraft(
226 $draftFolderId,
227 $files,
232 ilUtil::securePlainString($_POST['m_subject']),
233 ilUtil::securePlainString($_POST['m_message']),
234 $draftId,
235 (int) $_POST['use_placeholders'],
238 );
239
240 ilUtil::sendInfo($this->lng->txt('mail_saved'), true);
241
244 } else {
245 $this->ctrl->redirectByClass(['ilmailgui', 'ilmailfoldergui']);
246 }
247
248 $this->showForm();
249 }
showSubmissionErrors(array $errors)
decodeAttachmentFiles(array $files)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$errors

References $_POST, $_SESSION, $errors, decodeAttachmentFiles(), ilMailFormCall\getContextId(), ilMailFormCall\getContextParameters(), ilMailFormCall\getRefererRedirectUrl(), ilMailFormCall\isRefererStored(), ilUtil\redirect(), ilUtil\securePlainString(), ilUtil\sendInfo(), showForm(), showSubmissionErrors(), and user().

+ Here is the call graph for this function:

◆ saveMailBeforeSearch()

ilMailFormGUI::saveMailBeforeSearch ( )
protected

Definition at line 797 of file class.ilMailFormGUI.php.

798 {
799 $files = array();
800 if (is_array($_POST['attachments'])) {
801 foreach ($_POST['attachments'] as $value) {
802 $files[] = urldecode($value);
803 }
804 }
805
806 $this->umail->savePostData(
807 $this->user->getId(),
808 $files,
813 ilUtil::securePlainString($_POST['m_subject']),
814 ilUtil::securePlainString($_POST['m_message']),
815 ilUtil::securePlainString($_POST['use_placeholders']),
818 );
819 }

References $_POST, ilMailFormCall\getContextId(), ilMailFormCall\getContextParameters(), ilUtil\securePlainString(), and user().

Referenced by searchCoursesTo(), searchGroupsTo(), and searchMailingListsTo().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ search()

ilMailFormGUI::search ( )

Definition at line 328 of file class.ilMailFormGUI.php.

329 {
330 $_SESSION["mail_search_search"] = $_POST["search"];
331 if (strlen(trim($_SESSION["mail_search_search"])) == 0) {
332 ilUtil::sendInfo($this->lng->txt("mail_insert_query"));
333 $this->searchUsers(false);
334 } else {
335 if (strlen(trim($_SESSION["mail_search_search"])) < 3) {
336 $this->lng->loadLanguageModule('search');
337 ilUtil::sendInfo($this->lng->txt('search_minimum_three'));
338 $this->searchUsers(false);
339 } else {
340 $this->ctrl->setParameterByClass("ilmailsearchgui", "search", urlencode($_SESSION["mail_search_search"]));
341 $this->ctrl->redirectByClass("ilmailsearchgui");
342 }
343 }
344 }
searchUsers($save=true)

References $_POST, $_SESSION, searchUsers(), and ilUtil\sendInfo().

+ Here is the call graph for this function:

◆ searchCoursesTo()

ilMailFormGUI::searchCoursesTo ( )

Definition at line 305 of file class.ilMailFormGUI.php.

306 {
307 $this->saveMailBeforeSearch();
308
309 if ($_SESSION['search_crs']) {
310 $this->ctrl->setParameterByClass('ilmailsearchcoursesgui', 'cmd', 'showMembers');
311 }
312
313 $this->ctrl->setParameterByClass('ilmailsearchcoursesgui', 'ref', 'mail');
314 $this->ctrl->redirectByClass('ilmailsearchcoursesgui');
315 }

References $_SESSION, and saveMailBeforeSearch().

+ Here is the call graph for this function:

◆ searchGroupsTo()

ilMailFormGUI::searchGroupsTo ( )

Definition at line 320 of file class.ilMailFormGUI.php.

321 {
322 $this->saveMailBeforeSearch();
323
324 $this->ctrl->setParameterByClass('ilmailsearchgroupsgui', 'ref', 'mail');
325 $this->ctrl->redirectByClass('ilmailsearchgroupsgui');
326 }

References saveMailBeforeSearch().

+ Here is the call graph for this function:

◆ searchMailingListsTo()

ilMailFormGUI::searchMailingListsTo ( )

Definition at line 824 of file class.ilMailFormGUI.php.

825 {
826 $this->saveMailBeforeSearch();
827
828 $this->ctrl->setParameterByClass('ilmailinglistsgui', 'ref', 'mail');
829 $this->ctrl->redirectByClass('ilmailinglistsgui');
830 }

References saveMailBeforeSearch().

+ Here is the call graph for this function:

◆ searchResults()

ilMailFormGUI::searchResults ( )

Definition at line 386 of file class.ilMailFormGUI.php.

387 {
388 $_GET["type"] = "search_res";
389 $this->showForm();
390 }

References $_GET, and showForm().

Referenced by cancelSearch().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ searchUsers()

ilMailFormGUI::searchUsers (   $save = true)

Definition at line 251 of file class.ilMailFormGUI.php.

252 {
253 $this->tpl->setTitle($this->lng->txt("mail"));
254
255 if ($save) {
256 // decode post values
257 $files = array();
258 if (is_array($_POST['attachments'])) {
259 foreach ($_POST['attachments'] as $value) {
260 $files[] = urldecode($value);
261 }
262 }
263
264 // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
265 $this->umail->savePostData(
266 $this->user->getId(),
267 $files,
272 ilUtil::securePlainString($_POST["m_subject"]),
273 ilUtil::securePlainString($_POST["m_message"]),
274 ilUtil::securePlainString($_POST['use_placeholders']),
277 );
278 }
279
280 $form = new ilPropertyFormGUI();
281 $form->setId('search_rcp');
282 $form->setTitle($this->lng->txt('search_recipients'));
283 $form->setFormAction($this->ctrl->getFormAction($this, 'search'));
284
285 $inp = new ilTextInputGUI($this->lng->txt("search_for"), 'search');
286 $inp->setSize(30);
287 $dsDataLink = $this->ctrl->getLinkTarget($this, 'lookupRecipientAsync', '', true, false);
288 $inp->setDataSource($dsDataLink);
289
290 if (strlen(trim($_SESSION["mail_search_search"])) > 0) {
291 $inp->setValue(ilUtil::prepareFormOutput(trim($_SESSION["mail_search_search"]), true));
292 }
293 $form->addItem($inp);
294
295 $form->addCommandButton('search', $this->lng->txt("search"));
296 $form->addCommandButton('cancelSearch', $this->lng->txt("cancel"));
297
298 $this->tpl->setContent($form->getHtml());
299 $this->tpl->printToStdout();
300 }
This class represents a property form user interface.
This class represents a text property in a property form.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public

References $_POST, $_SESSION, ilMailFormCall\getContextId(), ilMailFormCall\getContextParameters(), ilUtil\prepareFormOutput(), ilUtil\securePlainString(), and user().

Referenced by search().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendMessage()

ilMailFormGUI::sendMessage ( )

Definition at line 154 of file class.ilMailFormGUI.php.

155 {
156 $message = (string) $_POST['m_message'];
157
158 $mailBody = new ilMailBody($message, $this->purifier);
159
160 $sanitizedMessage = $mailBody->getContent();
161
162 $files = $this->decodeAttachmentFiles(isset($_POST['attachments']) ? (array) $_POST['attachments'] : array());
163
164 $mailer = $this->umail
165 ->withContextId(ilMailFormCall::getContextId() ?: '')
166 ->withContextParameters(is_array(ilMailFormCall::getContextParameters()) ? ilMailFormCall::getContextParameters() : []);
167
168 $mailer->setSaveInSentbox(true);
169
170 if ($errors = $mailer->enqueue(
174 ilUtil::securePlainString($_POST['m_subject']),
175 $sanitizedMessage,
176 $files,
177 (int) $_POST['use_placeholders']
178 )
179 ) {
180 $_POST['attachments'] = $files;
182 } else {
183 $mailer->savePostData($this->user->getId(), array(), "", "", "", "", "", "", "", "");
184
185 $this->ctrl->setParameterByClass('ilmailgui', 'type', 'message_sent');
186
188 ilUtil::sendSuccess($this->lng->txt('mail_message_send'), true);
189 $this->ctrl->redirectToURL(ilMailFormCall::getRefererRedirectUrl());
190 } else {
191 $this->ctrl->redirectByClass('ilmailgui');
192 }
193 }
194
195 $this->showForm();
196 }
$message
Definition: xapiexit.php:14

References $_POST, $errors, $message, decodeAttachmentFiles(), ilMailFormCall\getContextId(), ilMailFormCall\getContextParameters(), ilMailFormCall\getRefererRedirectUrl(), ilMailFormCall\isRefererStored(), ilUtil\securePlainString(), showForm(), showSubmissionErrors(), and user().

+ Here is the call graph for this function:

◆ showForm()

ilMailFormGUI::showForm ( )

Definition at line 438 of file class.ilMailFormGUI.php.

439 {
440 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.mail_new.html", "Services/Mail");
441 $this->tpl->setTitle($this->lng->txt("mail"));
442
443 $this->lng->loadLanguageModule("crs");
444
446 $this->tabs->setBackTarget($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'cancelMail'));
447 }
448
449 switch ($_GET["type"]) {
450 case 'reply':
451 if ($_SESSION['mail_id']) {
452 $_GET['mail_id'] = $_SESSION['mail_id'];
453 }
454 $mailData = $this->umail->getMail($_GET["mail_id"]);
455 $mailData["m_subject"] = $this->umail->formatReplySubject();
456 $mailData["m_message"] = $this->umail->formatReplyMessage();
457 $mailData["m_message"] = $this->umail->prependSignature();
458 // NO ATTACHMENTS FOR REPLIES
459 $mailData["attachments"] = array();
460 //$mailData["rcp_cc"] = $this->umail->formatReplyRecipientsForCC();
461 $mailData["rcp_cc"] = '';
462 $mailData["rcp_to"] = $this->umail->formatReplyRecipient();
463 $_SESSION["mail_id"] = "";
464 break;
465
466 case 'search_res':
467 $mailData = $this->umail->getSavedData();
468
469 /*if($_SESSION["mail_search_results"])
470 {
471 $mailData = $this->umail->appendSearchResult($_SESSION["mail_search_results"],$_SESSION["mail_search"]);
472 }
473 unset($_SESSION["mail_search"]);
474 unset($_SESSION["mail_search_results"]);*/
475
476 if ($_SESSION["mail_search_results_to"]) {
477 $mailData = $this->umail->appendSearchResult($_SESSION["mail_search_results_to"], 'to');
478 }
479 if ($_SESSION["mail_search_results_cc"]) {
480 $mailData = $this->umail->appendSearchResult($_SESSION["mail_search_results_cc"], 'cc');
481 }
482 if ($_SESSION["mail_search_results_bcc"]) {
483 $mailData = $this->umail->appendSearchResult($_SESSION["mail_search_results_bcc"], 'bc');
484 }
485
486 unset($_SESSION["mail_search_results_to"]);
487 unset($_SESSION["mail_search_results_cc"]);
488 unset($_SESSION["mail_search_results_bcc"]);
489
490 break;
491
492 case 'attach':
493 $mailData = $this->umail->getSavedData();
494 break;
495
496 case 'draft':
497 $_SESSION["draft"] = $_GET["mail_id"];
498 $mailData = $this->umail->getMail($_GET["mail_id"]);
499 ilMailFormCall::setContextId($mailData['tpl_ctx_id']);
500 ilMailFormCall::setContextParameters($mailData['tpl_ctx_params']);
501 break;
502
503 case 'forward':
504 $mailData = $this->umail->getMail($_GET["mail_id"]);
505 $mailData["rcp_to"] = $mailData["rcp_cc"] = $mailData["rcp_bcc"] = '';
506 $mailData["m_subject"] = $this->umail->formatForwardSubject();
507 $mailData["m_message"] = $this->umail->prependSignature();
508 if (is_array($mailData["attachments"]) && count($mailData["attachments"])) {
509 if ($error = $this->mfile->adoptAttachments($mailData["attachments"], $_GET["mail_id"])) {
510 ilUtil::sendInfo($error);
511 }
512 }
513 break;
514
515 case 'new':
516 if ($_GET['rcp_to']) {
517 // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
518 $mailData["rcp_to"] = ilUtil::securePlainString($_GET['rcp_to']);
519 } elseif ($_SESSION['rcp_to']) {
520 $mailData["rcp_to"] = $_SESSION['rcp_to'];
521 }
522 if ($_GET['rcp_cc']) {
523 // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
524 $mailData["rcp_cc"] = ilUtil::securePlainString($_GET['rcp_cc']);
525 } elseif ($_SESSION['rcp_cc']) {
526 $mailData["rcp_cc"] = $_SESSION['rcp_cc'];
527 }
528 if ($_GET['rcp_bcc']) {
529 // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
530 $mailData["rcp_bcc"] = ilUtil::securePlainString($_GET['rcp_bcc']);
531 } elseif ($_SESSION['rcp_bcc']) {
532 $mailData["rcp_bcc"] = $_SESSION['rcp_bcc'];
533 }
534 $mailData['m_message'] = '';
535 if (strlen($sig = ilMailFormCall::getSignature())) {
536 $mailData['m_message'] = $sig;
537 $mailData['m_message'] .= chr(13) . chr(10) . chr(13) . chr(10);
538 }
539 $mailData['m_message'] .= $this->umail->appendSignature();
540
541 $_SESSION['rcp_to'] = '';
542 $_SESSION['rcp_cc'] = '';
543 $_SESSION['rcp_bcc'] = '';
544 break;
545
546 case 'role':
547
548 if (is_array($_POST['roles'])) {
549 // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
550 $mailData['rcp_to'] = ilUtil::securePlainString(implode(',', $_POST['roles']));
551 } elseif (is_array($_SESSION['mail_roles'])) {
552 $mailData['rcp_to'] = ilUtil::securePlainString(implode(',', $_SESSION['mail_roles']));
553 }
554
555 $mailData['m_message'] = '';
556 if (strlen($sig = ilMailFormCall::getSignature())) {
557 $mailData['m_message'] = $sig;
558 $mailData['m_message'] .= chr(13) . chr(10) . chr(13) . chr(10);
559 }
560
561 $mailData['m_message'] .= $_POST["additional_message_text"] . chr(13) . chr(10) . $this->umail->appendSignature();
562 $_POST["additional_message_text"] = "";
563 $_SESSION['mail_roles'] = [];
564 break;
565
566 case 'address':
567 $mailData["rcp_to"] = urldecode($_GET["rcp"]);
568 break;
569
570 default:
571 // GET DATA FROM POST
572 $mailData = $_POST;
573
574 // strip slashes
575 foreach ($mailData as $key => $value) {
576 if (is_string($value)) {
577 // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
578 $mailData[$key] = ilUtil::securePlainString($value);
579 }
580 }
581 break;
582 }
583
584 $form_gui = new ilPropertyFormGUI();
585 $form_gui->setTitle($this->lng->txt('compose'));
586 $form_gui->setId('mail_compose_form');
587 $form_gui->setName('mail_compose_form');
588 $form_gui->setFormAction($this->ctrl->getFormAction($this, 'sendMessage'));
589
590 $this->tpl->setVariable('FORM_ID', $form_gui->getId());
591
592 $btn = ilButton::getInstance();
593 $btn->setButtonType(ilButton::BUTTON_TYPE_SUBMIT);
594 $btn->setForm('form_' . $form_gui->getName())
595 ->setName('searchUsers')
596 ->setCaption('search_recipients');
597 $this->toolbar->addStickyItem($btn);
598
599 $btn = ilButton::getInstance();
600 $btn->setButtonType(ilButton::BUTTON_TYPE_SUBMIT)
601 ->setName('searchCoursesTo')
602 ->setForm('form_' . $form_gui->getName())
603 ->setCaption('mail_my_courses');
604 $this->toolbar->addButtonInstance($btn);
605
606 $btn = ilButton::getInstance();
607 $btn->setButtonType(ilButton::BUTTON_TYPE_SUBMIT)
608 ->setName('searchGroupsTo')
609 ->setForm('form_' . $form_gui->getName())
610 ->setCaption('mail_my_groups');
611 $this->toolbar->addButtonInstance($btn);
612
613 if (count(ilBuddyList::getInstanceByGlobalUser()->getLinkedRelations()) > 0) {
614 $btn = ilButton::getInstance();
615 $btn->setButtonType(ilButton::BUTTON_TYPE_SUBMIT)
616 ->setName('searchMailingListsTo')
617 ->setForm('form_' . $form_gui->getName())
618 ->setCaption('mail_my_mailing_lists');
619 $this->toolbar->addButtonInstance($btn);
620 }
621
622 $dsDataLink = $this->ctrl->getLinkTarget($this, 'lookupRecipientAsync', '', true);
623
624 $inp = new ilTextInputGUI($this->lng->txt('mail_to'), 'rcp_to');
625 $inp->setRequired(true);
626 $inp->setSize(50);
627 $inp->setValue($mailData["rcp_to"]);
628 $inp->setDataSource($dsDataLink, ",");
629 $inp->setMaxLength(null);
630 $form_gui->addItem($inp);
631
632 $inp = new ilTextInputGUI($this->lng->txt('cc'), 'rcp_cc');
633 $inp->setSize(50);
634 $inp->setValue($mailData["rcp_cc"]);
635 $inp->setDataSource($dsDataLink, ",");
636 $inp->setMaxLength(null);
637 $form_gui->addItem($inp);
638
639 $inp = new ilTextInputGUI($this->lng->txt('bc'), 'rcp_bcc');
640 $inp->setSize(50);
641 $inp->setValue($mailData["rcp_bcc"]);
642 $inp->setDataSource($dsDataLink, ",");
643 $inp->setMaxLength(null);
644 $form_gui->addItem($inp);
645
646 $inp = new ilTextInputGUI($this->lng->txt('subject'), 'm_subject');
647 $inp->setSize(50);
648 $inp->setRequired(true);
649 $inp->setValue($mailData["m_subject"]);
650 $form_gui->addItem($inp);
651
652 $att = new ilMailFormAttachmentPropertyGUI($this->lng->txt(($mailData["attachments"]) ? 'edit' : 'add'));
653
654 if (is_array($mailData["attachments"]) && count($mailData["attachments"])) {
655 foreach ($mailData["attachments"] as $data) {
656 if (is_file($this->mfile->getMailPath() . '/' . $this->user->getId() . "_" . $data)) {
657 $hidden = new ilHiddenInputGUI('attachments[]');
658 $form_gui->addItem($hidden);
659 $size = filesize($this->mfile->getMailPath() . '/' . $this->user->getId() . "_" . $data);
660 $label = $data . " [" . ilUtil::formatSize($size) . "]";
661 $att->addItem($label);
662 $hidden->setValue(urlencode($data));
663 }
664 }
665 }
666 $form_gui->addItem($att);
667
669 $context_id = ilMailFormCall::getContextId();
670
671 $mailData['use_placeholders'] = true;
672
673 try {
675
676 $templates = $this->templateService->loadTemplatesForContextId($context->getId());
677 if (count($templates) > 0) {
678 $options = array();
679
680 $template_chb = new ilMailTemplateSelectInputGUI(
681 $this->lng->txt('mail_template_client'),
682 'template_id',
683 $this->ctrl->getLinkTarget($this, 'getTemplateDataById', '', true, false),
684 array('m_subject' => false, 'm_message' => true)
685 );
686
687 foreach ($templates as $template) {
688 $options[$template->getTplId()] = $template->getTitle();
689
690 if (!isset($mailData['template_id']) && $template->isDefault()) {
691 $template_chb->setValue($template->getTplId());
692 $form_gui->getItemByPostVar('m_subject')->setValue($template->getSubject());
693 $mailData["m_message"] = $template->getMessage();
694 }
695 }
696 if (isset($mailData['template_id'])) {
697 $template_chb->setValue((int) $mailData['template_id']);
698 }
699 asort($options);
700
701 $template_chb->setInfo($this->lng->txt('mail_template_client_info'));
702 $template_chb->setOptions(array('' => $this->lng->txt('please_choose')) + $options);
703 $form_gui->addItem($template_chb);
704 }
705 } catch (Exception $e) {
706 ilLoggerFactory::getLogger('mail')->error(sprintf(
707 '%s has been called with invalid context id: %s.',
708 __METHOD__,
709 $context_id
710 ));
711 }
712 } else {
714 }
715
716 $inp = new ilTextAreaInputGUI($this->lng->txt('message_content'), 'm_message');
717 //$inp->setValue(htmlspecialchars($mailData["m_message"], false));
718 $inp->setValue($mailData["m_message"]);
719 $inp->setRequired(false);
720 $inp->setCols(60);
721 $inp->setRows(10);
722 $form_gui->addItem($inp);
723
724 $chb = new ilCheckboxInputGUI($this->lng->txt('mail_serial_letter_placeholders'), 'use_placeholders');
725 $chb->setValue('1');
726 if (isset($mailData['use_placeholders']) && $mailData['use_placeholders']) {
727 $chb->setChecked(true);
728 }
729
730 $placeholders = new ilManualPlaceholderInputGUI('m_message');
731 $placeholders->setInstructionText($this->lng->txt('mail_nacc_use_placeholder'));
732 $placeholders->setAdviseText(sprintf($this->lng->txt('placeholders_advise'), '<br />'));
733 foreach ($context->getPlaceholders() as $key => $value) {
734 $placeholders->addPlaceholder($value['placeholder'], $value['label']);
735 }
736 $chb->addSubItem($placeholders);
737 $form_gui->addItem($chb);
738
739 $form_gui->addCommandButton('sendMessage', $this->lng->txt('send_mail'));
740 $form_gui->addCommandButton('saveDraft', $this->lng->txt('save_message'));
742 $form_gui->addCommandButton('cancelMail', $this->lng->txt('cancel'));
743 }
744
745 $this->tpl->parseCurrentBlock();
746
747 $this->tpl->setVariable('FORM', $form_gui->getHTML());
748
749 $this->tpl->addJavaScript('Services/Mail/js/ilMailComposeFunctions.js');
750 $this->tpl->printToStdout();
751 }
$size
Definition: RandomTest.php:84
static getInstanceByGlobalUser()
const BUTTON_TYPE_SUBMIT
static getInstance()
This class represents a checkbox property in a property form.
This class represents a hidden form property in a property form.
static getLogger($a_component_id)
Get component logger.
static getSignature()
Get preset signature.
static setContextParameters(array $parameters)
Class ilMailTemplateSelectInputGUI.
Class ilManualPlaceholderInputGUI.
This class represents a text area property in a property form.
static formatSize($size, $a_mode='short', $a_lng=null)
Returns the specified file size value in a human friendly form.
$data
Definition: storeScorm.php:23

References $_GET, $_POST, $_SESSION, $context, $data, Vendor\Package\$e, $size, ilButton\BUTTON_TYPE_SUBMIT, ilUtil\formatSize(), ilMailFormCall\getContextId(), ilButton\getInstance(), ilBuddyList\getInstanceByGlobalUser(), ilLoggerFactory\getLogger(), ilMailFormCall\getSignature(), ilMailTemplateContextService\getTemplateContextById(), ilMailFormCall\isRefererStored(), ilUtil\securePlainString(), ilUtil\sendInfo(), ilMailFormCall\setContextId(), and ilMailFormCall\setContextParameters().

Referenced by cancelMail(), mailAttachment(), mailRole(), mailUser(), replyMail(), returnFromAttachments(), saveDraft(), searchResults(), and sendMessage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showSubmissionErrors()

ilMailFormGUI::showSubmissionErrors ( array  $errors)
protected
Parameters
$errorsilMailError[]

Definition at line 835 of file class.ilMailFormGUI.php.

836 {
837 $formatter = new ilMailErrorFormatter($this->lng);
838 $formattedErrors = $formatter->format($errors);
839
840 if (strlen($formattedErrors) > 0) {
841 ilUtil::sendFailure($formattedErrors);
842 }
843 }
Class ilMailErrorFormatter.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.

References $errors, and ilUtil\sendFailure().

Referenced by saveDraft(), and sendMessage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilMailFormGUI::$ctrl
private

Definition at line 17 of file class.ilMailFormGUI.php.

◆ $lng

ilMailFormGUI::$lng
private

Definition at line 20 of file class.ilMailFormGUI.php.

◆ $mbox

ilMailFormGUI::$mbox
private

Definition at line 38 of file class.ilMailFormGUI.php.

◆ $mfile

ilMailFormGUI::$mfile
private

Definition at line 41 of file class.ilMailFormGUI.php.

◆ $purifier

ilMailFormGUI::$purifier
private

Definition at line 47 of file class.ilMailFormGUI.php.

◆ $rbacsystem

ilMailFormGUI::$rbacsystem
private

Definition at line 32 of file class.ilMailFormGUI.php.

◆ $tabs

ilMailFormGUI::$tabs
private

Definition at line 26 of file class.ilMailFormGUI.php.

◆ $templateService

ilMailFormGUI::$templateService
protected

Definition at line 44 of file class.ilMailFormGUI.php.

Referenced by __construct().

◆ $toolbar

ilMailFormGUI::$toolbar
private

Definition at line 29 of file class.ilMailFormGUI.php.

◆ $tpl

ilMailFormGUI::$tpl
private

Definition at line 14 of file class.ilMailFormGUI.php.

◆ $umail

ilMailFormGUI::$umail
private

Definition at line 35 of file class.ilMailFormGUI.php.

◆ $user

ilMailFormGUI::$user
private

Definition at line 23 of file class.ilMailFormGUI.php.


The documentation for this class was generated from the following file: