ILIAS  release_7 Revision v7.30-3-g800a261c036
ilMailFormGUI Class Reference
+ Collaboration diagram for ilMailFormGUI:

Public Member Functions

 __construct (ilMailTemplateService $templateService=null, ilMailBodyPurifier $bodyPurifier=null)
 ilMailFormGUI constructor. More...
 
 executeCommand ()
 
 sendMessage ()
 
 saveDraft ()
 
 searchUsers (bool $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.
global $DIC
Definition: goto.php:24

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

+ Here is the call graph for this function:

Member Function Documentation

◆ cancelMail()

ilMailFormGUI::cancelMail ( )

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

804 {
807 }
808
809 $this->showForm();
810 }
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 350 of file class.ilMailFormGUI.php.

351 {
352 unset($_SESSION["mail_search"]);
353 $this->searchResults();
354 }
$_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 356 of file class.ilMailFormGUI.php.

356 : void
357 {
358 // decode post values
359 $files = [];
360 if (isset($_POST['attachments']) && is_array($_POST['attachments'])) {
361 foreach ($_POST['attachments'] as $value) {
362 $files[] = urldecode($value);
363 }
364 }
365
366 // Note: For security reasons, ILIAS only allows Plain text messages.
367 $this->umail->savePostData(
368 $this->user->getId(),
369 $files,
373 (bool) ($_POST["m_email"] ?? false),
374 ilUtil::securePlainString($_POST["m_subject"]),
375 ilUtil::securePlainString($_POST["m_message"]),
376 (bool) ($_POST["use_placeholders"] ?? false),
379 );
380
381 $this->ctrl->redirectByClass("ilmailattachmentgui");
382 }
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 423 of file class.ilMailFormGUI.php.

424 {
425 if (!isset($_GET['template_id'])) {
426 exit();
427 }
428
429 try {
430 $template = $this->templateService->loadTemplateForId((int) $_GET['template_id']);
431 $context = ilMailTemplateContextService::getTemplateContextById((string) $template->getContext());
432
433 echo json_encode([
434 'm_subject' => $template->getSubject(),
435 'm_message' => $template->getMessage() . $this->umail->appendSignature(),
436 ]);
437 } catch (Exception $e) {
438 }
439 exit();
440 }
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 771 of file class.ilMailFormGUI.php.

772 {
773 $search = '';
774 if (isset($_GET["term"]) && is_string($_GET["term"])) {
775 $search = $_GET["term"];
776 }
777 if (isset($_POST["term"]) && is_string($_POST["term"])) {
778 $search = $_POST["term"];
779 }
780
781 $search = trim($search);
782
783 $result = array();
784
785 require_once 'Services/Utilities/classes/class.ilStr.php';
786 if (ilStr::strLen($search) < 3) {
787 echo json_encode($result);
788 exit;
789 }
790
791 // #14768
792 $quoted = ilUtil::stripSlashes($search);
793 $quoted = str_replace('%', '\%', $quoted);
794 $quoted = str_replace('_', '\_', $quoted);
795
796 $mailFormObj = new ilMailForm;
797 $result = $mailFormObj->getRecipientAsync("%" . $quoted . "%", ilUtil::stripSlashes($search));
798
799 echo json_encode($result);
800 exit;
801 }
$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 414 of file class.ilMailFormGUI.php.

415 {
416 $_GET["type"] = "attach";
417 $this->showForm();
418 }

References $_GET, and showForm().

+ Here is the call graph for this function:

◆ mailRole()

ilMailFormGUI::mailRole ( )

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

403 {
404 $_GET["type"] = "role";
405 $this->showForm();
406 }

References $_GET, and showForm().

+ Here is the call graph for this function:

◆ mailUser()

ilMailFormGUI::mailUser ( )

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

397 {
398 $_GET["type"] = "new";
399 $this->showForm();
400 }

References $_GET, and showForm().

+ Here is the call graph for this function:

◆ replyMail()

ilMailFormGUI::replyMail ( )

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

409 {
410 $_GET["type"] = "reply";
411 $this->showForm();
412 }

References $_GET, and showForm().

+ Here is the call graph for this function:

◆ returnFromAttachments()

ilMailFormGUI::returnFromAttachments ( )

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

385 {
386 $_GET["type"] = "attach";
387 $this->showForm();
388 }

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'] = $this->lng->txt('mail_no_subject');
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
Definition: imgupload.php:49

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 815 of file class.ilMailFormGUI.php.

816 {
817 $files = array();
818 if (is_array($_POST['attachments'])) {
819 foreach ($_POST['attachments'] as $value) {
820 $files[] = urldecode($value);
821 }
822 }
823
824 $this->umail->savePostData(
825 $this->user->getId(),
826 $files,
831 ilUtil::securePlainString($_POST['m_subject']),
832 ilUtil::securePlainString($_POST['m_message']),
833 ilUtil::securePlainString($_POST['use_placeholders']),
836 );
837 }

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(
341 "ilmailsearchgui",
342 "search",
343 urlencode($_SESSION["mail_search_search"])
344 );
345 $this->ctrl->redirectByClass("ilmailsearchgui");
346 }
347 }
348 }
searchUsers(bool $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 842 of file class.ilMailFormGUI.php.

843 {
844 $this->saveMailBeforeSearch();
845
846 $this->ctrl->setParameterByClass('ilmailinglistsgui', 'ref', 'mail');
847 $this->ctrl->redirectByClass('ilmailinglistsgui');
848 }

References saveMailBeforeSearch().

+ Here is the call graph for this function:

◆ searchResults()

ilMailFormGUI::searchResults ( )

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

391 {
392 $_GET["type"] = "search_res";
393 $this->showForm();
394 }

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 ( bool  $save = true)

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

251 : void
252 {
253 $this->tpl->setTitle($this->lng->txt("mail"));
254
255 if ($save) {
256 $files = [];
257 if (isset($_POST['attachments']) && is_array($_POST['attachments'])) {
258 foreach ($_POST['attachments'] as $value) {
259 $files[] = urldecode($value);
260 }
261 }
262
263 // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
264 $this->umail->savePostData(
265 $this->user->getId(),
266 $files,
267 ilUtil::securePlainString($_POST["rcp_to"] ?? ''),
268 ilUtil::securePlainString($_POST["rcp_cc"] ?? ''),
269 ilUtil::securePlainString($_POST["rcp_bcc"] ?? ''),
270 ilUtil::securePlainString($_POST["m_email"] ?? ''),
271 ilUtil::securePlainString($_POST["m_subject"] ?? ''),
272 ilUtil::securePlainString($_POST["m_message"] ?? ''),
273 (bool) ($_POST['use_placeholders'] ?? false),
276 );
277 }
278
279 $form = new ilPropertyFormGUI();
280 $form->setId('search_rcp');
281 $form->setTitle($this->lng->txt('search_recipients'));
282 $form->setFormAction($this->ctrl->getFormAction($this, 'search'));
283
284 $inp = new ilTextInputGUI($this->lng->txt("search_for"), 'search');
285 $inp->setSize(30);
286 $dsDataLink = $this->ctrl->getLinkTarget($this, 'lookupRecipientAsync', '', true);
287 $inp->setDataSource($dsDataLink);
288
289 $searchQuery = trim((string) ilSession::get('mail_search_search'));
290 if ($searchQuery !== '') {
291 $inp->setValue(ilUtil::prepareFormOutput($searchQuery), 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.
static get($a_var)
Get a value.
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, ilSession\get(), 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 442 of file class.ilMailFormGUI.php.

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

854 {
855 $formatter = new ilMailErrorFormatter($this->lng);
856 $formattedErrors = $formatter->format($errors);
857
858 if (strlen($formattedErrors) > 0) {
859 ilUtil::sendFailure($formattedErrors);
860 }
861 }
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: