ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilMailFormGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
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';
9 
18 {
19  private $tpl = null;
20  private $ctrl = null;
21  private $lng = null;
22 
23  private $umail = null;
24  private $mbox = null;
25  private $mfile = null;
26 
27  public function __construct()
28  {
29  global $tpl, $ilCtrl, $lng, $ilUser;
30 
31  $this->tpl = $tpl;
32  $this->ctrl = $ilCtrl;
33  $this->lng = $lng;
34 
35  $this->umail = new ilFormatMail($ilUser->getId());
36  $this->mfile = new ilFileDataMail($ilUser->getId());
37  $this->mbox = new ilMailBox($ilUser->getId());
38 
39  if(isset($_POST['mobj_id']) && (int)$_POST['mobj_id'])
40  {
41  $_GET['mobj_id'] = $_POST['mobj_id'];
42  }
43  // IF THERE IS NO OBJ_ID GIVEN GET THE ID OF MAIL ROOT NODE
44  if(!(int)$_GET['mobj_id'])
45  {
46  $_GET['mobj_id'] = $this->mbox->getInboxFolder();
47  }
48  $_GET['mobj_id'] = (int)$_GET['mobj_id'];
49  $this->ctrl->saveParameter($this, 'mobj_id');
50  }
51 
52  public function executeCommand()
53  {
54  $forward_class = $this->ctrl->getNextClass($this);
55  switch($forward_class)
56  {
57  case 'ilmailfoldergui':
58  include_once 'Services/Mail/classes/class.ilMailFolderGUI.php';
59 
60  $this->ctrl->forwardCommand(new ilMailFolderGUI());
61  break;
62 
63  case 'ilmailattachmentgui':
64  include_once 'Services/Mail/classes/class.ilMailAttachmentGUI.php';
65 
66  $this->ctrl->setReturn($this, "returnFromAttachments");
67  $this->ctrl->forwardCommand(new ilMailAttachmentGUI());
68  break;
69 
70  case 'ilmailsearchgui':
71  include_once 'Services/Contact/classes/class.ilMailSearchGUI.php';
72 
73  $this->ctrl->setReturn($this, "searchResults");
74  $this->ctrl->forwardCommand(new ilMailSearchGUI());
75  break;
76 
77  case 'ilmailsearchcoursesgui':
78  include_once 'Services/Contact/classes/class.ilMailSearchCoursesGUI.php';
79 
80  $this->ctrl->setReturn($this, "searchResults");
81  $this->ctrl->forwardCommand(new ilMailSearchCoursesGUI());
82  break;
83 
84  case 'ilmailinglistsgui':
85  include_once 'Services/Contact/classes/class.ilMailingListsGUI.php';
86 
87  $this->ctrl->setReturn($this, 'searchResults');
88  $this->ctrl->forwardCommand(new ilMailingListsGUI());
89  break;
90 
91  case 'ilmailsearchgroupsgui':
92  include_once 'Services/Contact/classes/class.ilMailSearchGroupsGUI.php';
93 
94  $this->ctrl->setReturn($this, "searchResults");
95  $this->ctrl->forwardCommand(new ilMailSearchGroupsGUI());
96  break;
97 
98  default:
99  if (!($cmd = $this->ctrl->getCmd()))
100  {
101  $cmd = "showForm";
102  }
103 
104  $this->$cmd();
105  break;
106  }
107  return true;
108  }
109 
110  public function sendMessage()
111  {
112  global $ilUser;
113 
114  // decode post values
115  $files = array();
116  if(is_array($_POST['attachments']))
117  {
118  foreach($_POST['attachments'] as $value)
119  {
120  if(is_file($this->mfile->getMailPath() . '/' . $ilUser->getId() . "_" . urldecode($value)))
121  {
122  $files[] = urldecode($value);
123  }
124  }
125  }
126 
127  // Remove \r
128  $f_message = str_replace("\r", '', ilUtil::securePlainString($_POST['m_message']));
129 
130  // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
131  $f_message = $this->umail->formatLinebreakMessage($f_message);
132 
133  $this->umail->setSaveInSentbox(true);
134 
135  $m_type = isset($_POST["m_type"]) ? $_POST["m_type"] : array("normal");
136 
137  // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
138  if($errorMessage = $this->umail->sendMail(
141  ilUtil::securePlainString($_POST['rcp_bcc']),
142  ilUtil::securePlainString($_POST['m_subject']), $f_message,
143  $files,
144 // $_POST['m_type'],
145  $m_type,
146  ilUtil::securePlainString($_POST['use_placeholders'])
147  )
148  )
149  {
150  if(is_array($_POST['attachments']))
151  {
152  foreach($_POST['attachments'] as $key => $value)
153  {
154  if(is_file($this->mfile->getMailPath() . '/' . $ilUser->getId() . "_" . urldecode($value)))
155  {
156  $_POST['attachments'][$key] = urldecode($value);
157  }
158  else
159  {
160  unset($_POST['attachments'][$key]);
161  }
162  }
163  }
164  ilUtil::sendInfo($errorMessage);
165  }
166  else
167  {
168  $this->umail->savePostData($ilUser->getId(), array(), "", "", "", "", "", "", "", "");
169 
170  $this->ctrl->setParameterByClass('ilmailgui', 'type', 'message_sent');
171 
173  {
174  ilUtil::sendInfo($this->lng->txt('mail_message_send'), true);
176  }
177  else
178  $this->ctrl->redirectByClass('ilmailgui');
179  }
180 
181  $this->showForm();
182  }
183 
184  public function saveDraft()
185  {
186  if(!$_POST['m_subject'])
187  {
188  $_POST['m_subject'] = 'No title';
189  }
190 
191  $draftsId = $this->mbox->getDraftsFolder();
192 
193  // decode post values
194  $files = array();
195  if(is_array($_POST['attachments']))
196  {
197  foreach($_POST['attachments'] as $value)
198  {
199  $files[] = urldecode($value);
200  }
201  }
202 
203  if(isset($_SESSION["draft"]))
204  {
205  // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
206  $this->umail->updateDraft($draftsId, $files,
209  ilUtil::securePlainString($_POST["rcp_bcc"]),
210  $_POST["m_type"],
211  ilUtil::securePlainString($_POST["m_email"]),
212  ilUtil::securePlainString($_POST["m_subject"]),
213  ilUtil::securePlainString($_POST["m_message"]),
214  (int)$_SESSION["draft"],
215  (int)ilUtil::securePlainString($_POST['use_placeholders'])
216  );
217  #session_unregister("draft");
218  #ilUtil::sendInfo($this->lng->txt("mail_saved"),true);
219  #ilUtil::redirect("ilias.php?baseClass=ilMailGUI&mobj_id=".$mbox->getInboxFolder());
220 
221  unset($_SESSION["draft"]);
222  ilUtil::sendInfo($this->lng->txt("mail_saved"), true);
223 
226  else
227  $this->ctrl->redirectByClass("ilmailfoldergui");
228  }
229  else
230  {
231  if ($this->umail->sendInternalMail($draftsId,$_SESSION["AccountId"],$files,
232  // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
235  ilUtil::securePlainString($_POST["rcp_bcc"]),
236  'read',
237  $_POST["m_type"],
238  ilUtil::securePlainString($_POST["m_email"]),
239  ilUtil::securePlainString($_POST["m_subject"]),
240  ilUtil::securePlainString($_POST["m_message"]),
241  $_SESSION["AccountId"],
242  ilUtil::securePlainString($_POST['use_placeholders'])
243  )
244  )
245  {
246  ilUtil::sendInfo($this->lng->txt("mail_saved"),true);
247  #$this->ctrl->setParameterByClass("ilmailfoldergui", "mobj_id", $this->mbox->getDraftsFolder());
248 
251  else
252  $this->ctrl->redirectByClass("ilmailfoldergui");
253  }
254  else
255  {
256  ilUtil::sendInfo($this->lng->txt("mail_send_error"));
257  }
258  }
259 
260  $this->showForm();
261  }
262 
263  public function searchUsers($save = true)
264  {
265  global $ilUser, $ilCtrl;
266 
267  $this->tpl->setTitle($this->lng->txt("mail"));
268 
269  if ($save)
270  {
271  // decode post values
272  $files = array();
273  if(is_array($_POST['attachments']))
274  {
275  foreach($_POST['attachments'] as $value)
276  {
277  $files[] = urldecode($value);
278  }
279  }
280 
281  // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
282  $this->umail->savePostData($ilUser->getId(),
283  $files,
286  ilUtil::securePlainString($_POST["rcp_bcc"]),
287  $_POST["m_type"],
288  ilUtil::securePlainString($_POST["m_email"]),
289  ilUtil::securePlainString($_POST["m_subject"]),
290  ilUtil::securePlainString($_POST["m_message"]),
291  ilUtil::securePlainString($_POST['use_placeholders'])
292  );
293  }
294  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
295  $form = new ilPropertyFormGUI();
296  $form->setId('search_rcp');
297  $form->setTitle($this->lng->txt('search_recipients'));
298  $form->setFormAction($ilCtrl->getFormAction($this, 'search'));
299 
300  $inp = new ilTextInputGUI($this->lng->txt("search_for"), 'search');
301  $inp->setSize(30);
302  $dsDataLink = $ilCtrl->getLinkTarget($this, 'lookupRecipientAsync', '', true);
303  $inp->setDataSource($dsDataLink);
304 
305  if (strlen(trim($_SESSION["mail_search_search"])) > 0)
306  {
307  $inp->setValue(ilUtil::prepareFormOutput(trim($_SESSION["mail_search_search"]), true));
308  }
309  $form->addItem($inp);
310 
311  $form->addCommandButton('search', $this->lng->txt("search"));
312  $form->addCommandButton('cancelSearch', $this->lng->txt("cancel"));
313 
314  $this->tpl->setContent($form->getHtml());
315  $this->tpl->show();
316  }
317 
321  public function searchCoursesTo()
322  {
323  $this->saveMailBeforeSearch();
324 
325  if($_SESSION['search_crs'])
326  {
327  $this->ctrl->setParameterByClass('ilmailsearchcoursesgui', 'cmd', 'showMembers');
328  }
329 
330  $this->ctrl->setParameterByClass('ilmailsearchcoursesgui', 'ref', 'mail');
331  $this->ctrl->redirectByClass('ilmailsearchcoursesgui');
332  }
333 
337  public function searchGroupsTo()
338  {
339  $this->saveMailBeforeSearch();
340 
341  $this->ctrl->setParameterByClass('ilmailsearchgroupsgui', 'ref', 'mail');
342  $this->ctrl->redirectByClass('ilmailsearchgroupsgui');
343  }
344 
345  public function search()
346  {
347  $_SESSION["mail_search_search"] = $_POST["search"];
348  if(strlen(trim($_SESSION["mail_search_search"])) == 0)
349  {
350  ilUtil::sendInfo($this->lng->txt("mail_insert_query"));
351  $this->searchUsers(false);
352  }
353  else
354  {
355  if(strlen(trim($_SESSION["mail_search_search"])) < 3)
356  {
357  $this->lng->loadLanguageModule('search');
358  ilUtil::sendInfo($this->lng->txt('search_minimum_three'));
359  $this->searchUsers(false);
360  }
361  else
362  {
363  $this->ctrl->setParameterByClass("ilmailsearchgui", "search", urlencode($_SESSION["mail_search_search"]));
364  $this->ctrl->redirectByClass("ilmailsearchgui");
365  }
366  }
367  }
368 
369  public function cancelSearch()
370  {
371  unset($_SESSION["mail_search"]);
372  $this->searchResults();
373  }
374 
375  public function editAttachments()
376  {
377  // decode post values
378  $files = array();
379  if(is_array($_POST['attachments']))
380  {
381  foreach($_POST['attachments'] as $value)
382  {
383  $files[] = urldecode($value);
384  }
385  }
386 
387  // Note: For security reasons, ILIAS only allows Plain text messages.
388  $this->umail->savePostData($_SESSION["AccountId"],
389  $files,
392  ilUtil::securePlainString($_POST["rcp_bcc"]),
393  $_POST["m_type"],
394  ilUtil::securePlainString($_POST["m_email"]),
395  ilUtil::securePlainString($_POST["m_subject"]),
396  ilUtil::securePlainString($_POST["m_message"]),
397  ilUtil::securePlainString($_POST['use_placeholders'])
398  );
399 
400  $this->ctrl->redirectByClass("ilmailattachmentgui");
401  }
402 
403  public function returnFromAttachments()
404  {
405  $_GET["type"] = "attach";
406  $this->showForm();
407  }
408 
409  public function searchResults()
410  {
411  $_GET["type"] = "search_res";
412  $this->showForm();
413  }
414 
415  public function mailUser()
416  {
417  $_GET["type"] = "new";
418  $this->showForm();
419  }
420 
421  public function mailRole()
422  {
423  $_GET["type"] = "role";
424  $this->showForm();
425  }
426 
427  public function replyMail()
428  {
429  $_GET["type"] = "reply";
430  $this->showForm();
431  }
432 
433  public function mailAttachment()
434  {
435  $_GET["type"] = "attach";
436  $this->showForm();
437  }
438 
439  public function showForm()
440  {
441  global $rbacsystem, $ilUser, $ilCtrl, $lng, $ilTabs;
442 
443  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.mail_new.html", "Services/Mail");
444  $this->tpl->setTitle($this->lng->txt("mail"));
445 
446  $this->lng->loadLanguageModule("crs");
447 
449  $ilTabs->setBackTarget($lng->txt('back'), $ilCtrl->getLinkTarget($this, 'cancelMail'));
450 
451  switch($_GET["type"])
452  {
453  case 'reply':
454  if($_SESSION['mail_id'])
455  {
456  $_GET['mail_id'] = $_SESSION['mail_id'];
457  }
458  $mailData = $this->umail->getMail($_GET["mail_id"]);
459  $mailData["m_subject"] = $this->umail->formatReplySubject();
460  $mailData["m_message"] = $this->umail->formatReplyMessage();
461  $mailData["m_message"] = $this->umail->prependSignature();
462  // NO ATTACHMENTS FOR REPLIES
463  $mailData["attachments"] = array();
464  //$mailData["rcp_cc"] = $this->umail->formatReplyRecipientsForCC();
465  $mailData["rcp_cc"] = '';
466  $mailData["rcp_to"] = $this->umail->formatReplyRecipient();
467  $_SESSION["mail_id"] = "";
468  break;
469 
470  case 'search_res':
471  $mailData = $this->umail->getSavedData();
472 
473  /*if($_SESSION["mail_search_results"])
474  {
475  $mailData = $this->umail->appendSearchResult($_SESSION["mail_search_results"],$_SESSION["mail_search"]);
476  }
477  unset($_SESSION["mail_search"]);
478  unset($_SESSION["mail_search_results"]);*/
479 
480  if($_SESSION["mail_search_results_to"])
481  {
482  $mailData = $this->umail->appendSearchResult($_SESSION["mail_search_results_to"], 'to');
483  }
484  if($_SESSION["mail_search_results_cc"])
485  {
486  $mailData = $this->umail->appendSearchResult($_SESSION["mail_search_results_cc"], 'cc');
487  }
488  if($_SESSION["mail_search_results_bcc"])
489  {
490  $mailData = $this->umail->appendSearchResult($_SESSION["mail_search_results_bcc"], 'bc');
491  }
492 
493  unset($_SESSION["mail_search_results_to"]);
494  unset($_SESSION["mail_search_results_cc"]);
495  unset($_SESSION["mail_search_results_bcc"]);
496 
497  break;
498 
499  case 'attach':
500  $mailData = $this->umail->getSavedData();
501  break;
502 
503  case 'draft':
504  $_SESSION["draft"] = $_GET["mail_id"];
505  $mailData = $this->umail->getMail($_GET["mail_id"]);
506  break;
507 
508  case 'forward':
509  $mailData = $this->umail->getMail($_GET["mail_id"]);
510  $mailData["rcp_to"] = $mailData["rcp_cc"] = $mailData["rcp_bcc"] = '';
511  $mailData["m_subject"] = $this->umail->formatForwardSubject();
512  $mailData["m_message"] = $this->umail->prependSignature();
513  if(count($mailData["attachments"]))
514  {
515  if($error = $this->mfile->adoptAttachments($mailData["attachments"],$_GET["mail_id"]))
516  {
517  ilUtil::sendInfo($error);
518  }
519  }
520  break;
521 
522  case 'new':
523  if($_GET['rcp_to'])
524  {
525  // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
526  $mailData["rcp_to"] = ilUtil::securePlainString($_GET['rcp_to']);
527  }
528  else if($_SESSION['rcp_to'])
529  {
530  $mailData["rcp_to"] = $_SESSION['rcp_to'];
531  }
532  if($_GET['rcp_cc'])
533  {
534  // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
535  $mailData["rcp_cc"] = ilUtil::securePlainString($_GET['rcp_cc']);
536  }
537  else if($_SESSION['rcp_cc'])
538  {
539  $mailData["rcp_cc"] = $_SESSION['rcp_cc'];
540  }
541  if($_GET['rcp_bcc'])
542  {
543  // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
544  $mailData["rcp_bcc"] = ilUtil::securePlainString($_GET['rcp_bcc']);
545  }
546  else if($_SESSION['rcp_bcc'])
547  {
548  $mailData["rcp_bcc"] = $_SESSION['rcp_bcc'];
549  }
550  $mailData['m_message'] = '';
551  if(strlen($sig = ilMailFormCall::getSignature()))
552  {
553  $mailData['m_message'] = $sig;
554  $mailData['m_message'] .= chr(13).chr(10).chr(13).chr(10);
555  }
556  $mailData['m_message'] .= $this->umail->appendSignature();
557 
558  $_SESSION['rcp_to'] = '';
559  $_SESSION['rcp_cc'] = '';
560  $_SESSION['rcp_bcc'] = '';
561  break;
562 
563  case 'role':
564 
565  if(is_array($_POST['roles']))
566  {
567  // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
568  $mailData['rcp_to'] = ilUtil::securePlainString(implode(',',$_POST['roles']));
569  }
570  elseif(is_array($_SESSION['mail_roles']))
571  {
572  $mailData['rcp_to'] = ilUtil::securePlainString(implode(',', $_SESSION['mail_roles']));
573  }
574 
575  $mailData['m_message'] = '';
576  if(strlen($sig = ilMailFormCall::getSignature()))
577  {
578  $mailData['m_message'] = $sig;
579  $mailData['m_message'] .= chr(13).chr(10).chr(13).chr(10);
580  }
581 
582  $mailData['m_message'] .= $_POST["additional_message_text"].chr(13).chr(10).$this->umail->appendSignature();
583  $_POST["additional_message_text"] = "";
584  $_SESSION['mail_roles'] = "";
585  break;
586 
587  case 'address':
588  $mailData["rcp_to"] = urldecode($_GET["rcp"]);
589  break;
590 
591  default:
592  // GET DATA FROM POST
593  $mailData = $_POST;
594 
595  // strip slashes
596  foreach ($mailData as $key => $value)
597  {
598  if (is_string($value))
599  {
600  // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
601  $mailData[$key] = ilUtil::securePlainString($value);
602  }
603  }
604  break;
605  }
606 
607  include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
608 
609  $form_gui = new ilPropertyFormGUI();
610  $form_gui->setTitle($this->lng->txt('compose'));
611  $form_gui->setOpenTag(false);
612  $this->tpl->setVariable('FORM_ACTION', $this->ctrl->getFormAction($this, 'sendMessage'));
613 
614  $this->tpl->setVariable('BUTTON_TO', $lng->txt("search_recipients"));
615  $this->tpl->setVariable('BUTTON_COURSES_TO', $lng->txt("mail_my_courses"));
616  $this->tpl->setVariable('BUTTON_GROUPS_TO', $lng->txt("mail_my_groups"));
617  $this->tpl->setVariable('BUTTON_MAILING_LISTS_TO', $lng->txt("mail_my_mailing_lists"));
618 
619  $dsDataLink = $ilCtrl->getLinkTarget($this, 'lookupRecipientAsync', '', true);
620 
621  // RECIPIENT
622  $inp = new ilTextInputGUI($this->lng->txt('mail_to'), 'rcp_to');
623  $inp->setRequired(true);
624  $inp->setSize(50);
625  $inp->setValue($mailData["rcp_to"]);
626  $inp->setDataSource($dsDataLink, ",");
627  $inp->setMaxLength(null);
628  $form_gui->addItem($inp);
629 
630  // CC
631  $inp = new ilTextInputGUI($this->lng->txt('cc'), 'rcp_cc');
632  $inp->setSize(50);
633  $inp->setValue($mailData["rcp_cc"]);
634  $inp->setDataSource($dsDataLink, ",");
635  $inp->setMaxLength(null);
636  $form_gui->addItem($inp);
637 
638  // BCC
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  // SUBJECT
647  $inp = new ilTextInputGUI($this->lng->txt('subject'), 'm_subject');
648  $inp->setSize(50);
649  $inp->setRequired(true);
650  $inp->setValue($mailData["m_subject"]);
651  $form_gui->addItem($inp);
652 
653  // Attachments
654  include_once 'Services/Mail/classes/class.ilMailFormAttachmentFormPropertyGUI.php';
655  $att = new ilMailFormAttachmentPropertyGUI($this->lng->txt( ($mailData["attachments"]) ? 'edit' : 'add' ));
656 
657 
658  if (is_array($mailData["attachments"]) && count($mailData["attachments"]))
659  {
660  foreach($mailData["attachments"] as $data)
661  {
662  if(is_file($this->mfile->getMailPath() . '/' . $ilUser->getId() . "_" . $data))
663  {
664  $hidden = new ilHiddenInputGUI('attachments[]');
665  $form_gui->addItem($hidden);
666  $size = filesize($this->mfile->getMailPath() . '/' . $ilUser->getId() . "_" . $data);
667  $label = $data . " [" . ilFormat::formatSize($size) . "]";
668  $att->addItem($label);
669  $hidden->setValue(urlencode($data));
670  }
671  }
672  }
673  $form_gui->addItem($att);
674 
675  // ONLY IF SYSTEM MAILS ARE ALLOWED
676  if($rbacsystem->checkAccess("system_message",$this->umail->getMailObjectReferenceId()))
677  {
678  $chb = new ilCheckboxInputGUI($this->lng->txt('type'), 'm_type[]');
679  $chb->setOptionTitle($this->lng->txt('system_message'));
680  $chb->setValue('system');
681  $chb->setChecked(false);
682  if(is_array($mailData["m_type"]) and in_array('system',$mailData["m_type"]))
683  {
684  $chb->setChecked(true);
685  }
686  $form_gui->addItem($chb);
687  }
688 
689 
690  // MESSAGE
691  $inp = new ilTextAreaInputGUI($this->lng->txt('message_content'), 'm_message');
692  //$inp->setValue(htmlspecialchars($mailData["m_message"], false));
693  $inp->setValue($mailData["m_message"]);
694  $inp->setRequired(false);
695  $inp->setCols(60);
696  $inp->setRows(10);
697 
698  // PLACEHOLDERS
699  $chb = new ilCheckboxInputGUI($this->lng->txt('activate_serial_letter_placeholders'), 'use_placeholders');
700  $chb->setOptionTitle($this->lng->txt('activate_serial_letter_placeholders'));
701  $chb->setValue(1);
702  $chb->setChecked(false);
703  $form_gui->addItem($inp);
704 
705  include_once 'Services/Mail/classes/class.ilMailFormPlaceholdersPropertyGUI.php';
706  $prop = new ilMailFormPlaceholdersPropertyGUI();
707 
708  $chb->addSubItem($prop);
709 
710  if ($mailData['use_placeholders'])
711  {
712  $chb->setChecked(true);
713  }
714 
715  $form_gui->addItem($chb);
716 
717  $form_gui->addCommandButton('sendMessage', $this->lng->txt('send_mail'));
718  $form_gui->addCommandButton('saveDraft', $this->lng->txt('save_message'));
720  $form_gui->addCommandButton('cancelMail', $this->lng->txt('cancel'));
721 
722  $this->tpl->parseCurrentBlock();
723 
724  $this->tpl->setVariable('FORM', $form_gui->getHTML());
725 
726  $this->tpl->addJavaScript('Services/Mail/js/ilMailComposeFunctions.js');
727  $this->tpl->show();
728  }
729 
730  public function lookupRecipientAsync()
731  {
732  include_once 'Services/JSON/classes/class.ilJsonUtil.php';
733  include_once 'Services/Mail/classes/class.ilMailForm.php';
734 
735  $search = $_REQUEST["term"];
736  $result = array();
737  if (!$search)
738  {
740  exit;
741  }
742 
743  // #14768
744  $quoted = $search;
745  $quoted = str_replace('%', '\%', $quoted);
746  $quoted = str_replace('_', '\_', $quoted);
747 
748  $mailFormObj = new ilMailForm;
749  $result = $mailFormObj->getRecipientAsync("%" .$quoted. "%", $search);
750 
752  exit;
753  }
754 
755  public function cancelMail()
756  {
759  else
760  return $this->showForm();
761  }
762 
766  protected function saveMailBeforeSearch()
767  {
771  global $ilUser;
772 
773  // decode post values
774  $files = array();
775  if(is_array($_POST['attachments']))
776  {
777  foreach($_POST['attachments'] as $value)
778  {
779  $files[] = urldecode($value);
780  }
781  }
782 
783  $this->umail->savePostData($ilUser->getId(),
784  $files,
787  ilUtil::securePlainString($_POST['rcp_bcc']),
788  $_POST['m_type'],
789  ilUtil::securePlainString($_POST['m_email']),
790  ilUtil::securePlainString($_POST['m_subject']),
791  ilUtil::securePlainString($_POST['m_message']),
792  ilUtil::securePlainString($_POST['use_placeholders'])
793  );
794  }
795 
799  public function searchMailingListsTo()
800  {
801  $this->saveMailBeforeSearch();
802 
803  $this->ctrl->setParameterByClass('ilmailinglistsgui', 'ref', 'mail');
804  $this->ctrl->redirectByClass('ilmailinglistsgui');
805  }
806 }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
$size
Definition: RandomTest.php:79
exit
Definition: login.php:54
$_POST['username']
Definition: cron.php:12
static securePlainString($a_str)
Remove unsecure characters from a plain text string.
$result
This class represents a property form user interface.
$_GET["client_id"]
This class handles all operations on files (attachments) in directory ilias_data/mail.
$cmd
Definition: sahs_server.php:35
setValue($a_value)
Set Value.
This class represents a checkbox property in a property form.
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
This class represents a hidden form property in a property form.
Class UserMail this class handles user mails.
static encode($mixed, $suppress_native=false)
setSize($a_size)
Set Size.
searchUsers($save=true)
This class represents a text property in a property form.
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
global $ilUser
Definition: imgupload.php:15
static formatSize($size, $a_mode='short', $a_lng=null)
Returns the specified file size value in a human friendly form.
This class represents a text area property in a property form.
static getSignature()
Get preset signature.
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
setOptionTitle($a_optiontitle)
Set Option Title (optional).
static redirect($a_script)
http redirect to other script
setRequired($a_required)
Set Required.