ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilMailFormGUI Class Reference
+ Collaboration diagram for ilMailFormGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 
 sendMessage ()
 
 saveDraft ()
 
 searchUsers ($save=true)
 
 searchCoursesTo ()
 
 searchGroupsTo ()
 
 search ()
 
 cancelSearch ()
 
 editAttachments ()
 
 returnFromAttachments ()
 
 searchResults ()
 
 mailUser ()
 
 mailRole ()
 
 replyMail ()
 
 mailAttachment ()
 
 lookupRecipientAsync ()
 
 cancelMail ()
 
 searchMailingListsTo ()
 
 getAjaxPlaceholdersById ()
 

Protected Member Functions

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

Private Attributes

 $tpl = null
 
 $ctrl = null
 
 $lng = null
 
 $umail = null
 
 $mbox = null
 
 $mfile = null
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilMailFormGUI::__construct ( )

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

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 }
$_GET["client_id"]
This class handles all operations on files (attachments) in directory ilias_data/mail.
Class UserMail this class handles user mails.
$_POST['username']
Definition: cron.php:12
global $ilCtrl
Definition: ilias.php:18
global $ilUser
Definition: imgupload.php:15

References $_GET, $_POST, $ilCtrl, $ilUser, $lng, and $tpl.

Member Function Documentation

◆ cancelMail()

ilMailFormGUI::cancelMail ( )

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

839 {
842 else
843 return $this->showForm();
844 }
static redirect($a_script)
http redirect to other script

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

+ Here is the call graph for this function:

◆ cancelSearch()

ilMailFormGUI::cancelSearch ( )

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

342 {
343 unset($_SESSION["mail_search"]);
344 $this->searchResults();
345 }
$_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 114 of file class.ilMailFormGUI.php.

115 {
116 $decodedFiles = array();
117
118 foreach($files as $value)
119 {
120 if(is_file($this->mfile->getMailPath() . '/' . $GLOBALS['ilUser']->getId() . '_' . urldecode($value)))
121 {
122 $decodedFiles[] = urldecode($value);
123 }
124 }
125
126 return $decodedFiles;
127 }
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276

References $GLOBALS.

Referenced by saveDraft(), and sendMessage().

+ Here is the caller graph for this function:

◆ editAttachments()

ilMailFormGUI::editAttachments ( )

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

348 {
349 // decode post values
350 $files = array();
351 if(is_array($_POST['attachments']))
352 {
353 foreach($_POST['attachments'] as $value)
354 {
355 $files[] = urldecode($value);
356 }
357 }
358
359 // Note: For security reasons, ILIAS only allows Plain text messages.
360 $this->umail->savePostData($_SESSION["AccountId"],
361 $files,
365 $_POST["m_type"],
367 ilUtil::securePlainString($_POST["m_subject"]),
368 ilUtil::securePlainString($_POST["m_message"]),
369 ilUtil::securePlainString($_POST['use_placeholders']),
372 );
373
374 $this->ctrl->redirectByClass("ilmailattachmentgui");
375 }
static securePlainString($a_str)
Remove unsecure characters from a plain text string.

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

+ Here is the call graph for this function:

◆ executeCommand()

ilMailFormGUI::executeCommand ( )

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

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 }
$cmd
Definition: sahs_server.php:35

References $cmd.

◆ getAjaxPlaceholdersById()

ilMailFormGUI::getAjaxPlaceholdersById ( )

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

893 {
894 $context_id = ilUtil::stripSlashes($_GET['context_id']);
895 require_once 'Services/Mail/classes/class.ilMailTemplateService.php';
896 require_once 'Services/Mail/classes/Form/class.ilManualPlaceholderInputGUI.php';
897 $placeholders = new ilManualPlaceholderInputGUI($this->ctrl->getLinkTarget($this, 'getAjaxPlaceholdersById', '', true, false));
898 $context = ilMailTemplateService::getTemplateContextById($context_id);
899 foreach($context->getPlaceholders() as $key => $value)
900 {
901 $placeholders->addPlaceholder($value['placeholder'], $value['label'] );
902 }
903 $placeholders->render(true);
904 exit();
905 }
Class ilManualPlaceholderInputGUI.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
exit
Definition: login.php:54

References $_GET, exit, ilMailTemplateService\getTemplateContextById(), and ilUtil\stripSlashes().

+ Here is the call graph for this function:

◆ getTemplateDataById()

ilMailFormGUI::getTemplateDataById ( )
protected

Called asynchronously when changing the template.

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

417 {
418 require_once 'Services/JSON/classes/class.ilJsonUtil.php';
419
420 if(!isset($_GET['template_id']))
421 {
422 exit();
423 }
424
425 try
426 {
427 require_once 'Services/Mail/classes/class.ilMailTemplateService.php';
428 require_once 'Services/Mail/classes/class.ilMailTemplateDataProvider.php';
429 $template_id = (int)$_GET['template_id'];
430 $template_provider = new ilMailTemplateDataProvider();
431 $template = $template_provider->getTemplateById($template_id);
432 $context = ilMailTemplateService::getTemplateContextById($template->getContext());
433 echo ilJsonUtil::encode(array(
434 'm_subject' => $template->getSubject(),
435 'm_message' => $template->getMessage()
436 ));
437 }
438 catch(Exception $e)
439 {
440 }
441 exit();
442 }
static encode($mixed, $suppress_native=false)
Class ilMailTemplateDataProvider.
$template_id
Definition: example_062.php:89

References $_GET, $template_id, ilJsonUtil\encode(), exit, and ilMailTemplateService\getTemplateContextById().

+ Here is the call graph for this function:

◆ lookupRecipientAsync()

ilMailFormGUI::lookupRecipientAsync ( )

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

814 {
815 include_once 'Services/JSON/classes/class.ilJsonUtil.php';
816 include_once 'Services/Mail/classes/class.ilMailForm.php';
817
818 $search = $_REQUEST["term"];
819 $result = array();
820 if (!$search)
821 {
823 exit;
824 }
825
826 // #14768
827 $quoted = ilUtil::stripSlashes($search);
828 $quoted = str_replace('%', '\%', $quoted);
829 $quoted = str_replace('_', '\_', $quoted);
830
831 $mailFormObj = new ilMailForm;
832 $result = $mailFormObj->getRecipientAsync("%" . $quoted . "%", ilUtil::stripSlashes($search));
833
835 exit;
836 }
$result
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7

References $_REQUEST, $result, ilJsonUtil\encode(), exit, and ilUtil\stripSlashes().

+ Here is the call graph for this function:

◆ mailAttachment()

ilMailFormGUI::mailAttachment ( )

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

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

References $_GET.

◆ mailRole()

ilMailFormGUI::mailRole ( )

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

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

References $_GET.

◆ mailUser()

ilMailFormGUI::mailUser ( )

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

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

References $_GET.

◆ replyMail()

ilMailFormGUI::replyMail ( )

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

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

References $_GET.

◆ returnFromAttachments()

ilMailFormGUI::returnFromAttachments ( )

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

378 {
379 $_GET["type"] = "attach";
380 $this->showForm();
381 }

References $_GET.

◆ saveDraft()

ilMailFormGUI::saveDraft ( )

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

178 {
179 if(!$_POST['m_subject'])
180 {
181 $_POST['m_subject'] = 'No title';
182 }
183
184 $draftFolderId = $this->mbox->getDraftsFolder();
185 $files = $this->decodeAttachmentFiles(isset($_POST['attachments']) ? (array)$_POST['attachments'] : array());
186
187 if($errorMessage = $this->umail->validateRecipients(
191 ))
192 {
193 $_POST['attachments'] = $files;
194 ilUtil::sendInfo($errorMessage);
195 $this->showForm();
196 return;
197 }
198
199 if(isset($_SESSION["draft"]))
200 {
201 $draftId = (int)$_SESSION['draft'];
202 unset($_SESSION['draft']);
203 }
204 else
205 {
206 $draftId = $this->umail->getNewDraftId($GLOBALS['ilUser']->getId(), $draftFolderId);
207 }
208
209 $this->umail->updateDraft($draftFolderId, $files,
213 $_POST['m_type'],
215 ilUtil::securePlainString($_POST['m_subject']),
216 ilUtil::securePlainString($_POST['m_message']),
217 $draftId,
218 (int)$_POST['use_placeholders'],
221 );
222
223 ilUtil::sendInfo($this->lng->txt('mail_saved'), true);
224
227 else
228 $this->ctrl->redirectByClass("ilmailfoldergui");
229
230 $this->showForm();
231 }
decodeAttachmentFiles(array $files)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.

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

+ Here is the call graph for this function:

◆ search()

ilMailFormGUI::search ( )

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

318 {
319 $_SESSION["mail_search_search"] = $_POST["search"];
320 if(strlen(trim($_SESSION["mail_search_search"])) == 0)
321 {
322 ilUtil::sendInfo($this->lng->txt("mail_insert_query"));
323 $this->searchUsers(false);
324 }
325 else
326 {
327 if(strlen(trim($_SESSION["mail_search_search"])) < 3)
328 {
329 $this->lng->loadLanguageModule('search');
330 ilUtil::sendInfo($this->lng->txt('search_minimum_three'));
331 $this->searchUsers(false);
332 }
333 else
334 {
335 $this->ctrl->setParameterByClass("ilmailsearchgui", "search", urlencode($_SESSION["mail_search_search"]));
336 $this->ctrl->redirectByClass("ilmailsearchgui");
337 }
338 }
339 }
searchUsers($save=true)

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

+ Here is the call graph for this function:

◆ searchCoursesTo()

ilMailFormGUI::searchCoursesTo ( )

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

294 {
295 $this->saveMailBeforeSearch();
296
297 if($_SESSION['search_crs'])
298 {
299 $this->ctrl->setParameterByClass('ilmailsearchcoursesgui', 'cmd', 'showMembers');
300 }
301
302 $this->ctrl->setParameterByClass('ilmailsearchcoursesgui', 'ref', 'mail');
303 $this->ctrl->redirectByClass('ilmailsearchcoursesgui');
304 }

References $_SESSION.

◆ searchGroupsTo()

ilMailFormGUI::searchGroupsTo ( )

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

310 {
311 $this->saveMailBeforeSearch();
312
313 $this->ctrl->setParameterByClass('ilmailsearchgroupsgui', 'ref', 'mail');
314 $this->ctrl->redirectByClass('ilmailsearchgroupsgui');
315 }

◆ searchMailingListsTo()

ilMailFormGUI::searchMailingListsTo ( )

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

885 {
886 $this->saveMailBeforeSearch();
887
888 $this->ctrl->setParameterByClass('ilmailinglistsgui', 'ref', 'mail');
889 $this->ctrl->redirectByClass('ilmailinglistsgui');
890 }

◆ searchResults()

ilMailFormGUI::searchResults ( )

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

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

References $_GET.

Referenced by cancelSearch().

+ Here is the caller graph for this function:

◆ searchUsers()

ilMailFormGUI::searchUsers (   $save = true)

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

234 {
235 global $ilUser, $ilCtrl;
236
237 $this->tpl->setTitle($this->lng->txt("mail"));
238
239 if ($save)
240 {
241 // decode post values
242 $files = array();
243 if(is_array($_POST['attachments']))
244 {
245 foreach($_POST['attachments'] as $value)
246 {
247 $files[] = urldecode($value);
248 }
249 }
250
251 // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
252 $this->umail->savePostData($ilUser->getId(),
253 $files,
257 $_POST["m_type"],
259 ilUtil::securePlainString($_POST["m_subject"]),
260 ilUtil::securePlainString($_POST["m_message"]),
261 ilUtil::securePlainString($_POST['use_placeholders']),
264 );
265 }
266 include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
267 $form = new ilPropertyFormGUI();
268 $form->setId('search_rcp');
269 $form->setTitle($this->lng->txt('search_recipients'));
270 $form->setFormAction($ilCtrl->getFormAction($this, 'search'));
271
272 $inp = new ilTextInputGUI($this->lng->txt("search_for"), 'search');
273 $inp->setSize(30);
274 $dsDataLink = $ilCtrl->getLinkTarget($this, 'lookupRecipientAsync', '', true, false);
275 $inp->setDataSource($dsDataLink);
276
277 if (strlen(trim($_SESSION["mail_search_search"])) > 0)
278 {
279 $inp->setValue(ilUtil::prepareFormOutput(trim($_SESSION["mail_search_search"]), true));
280 }
281 $form->addItem($inp);
282
283 $form->addCommandButton('search', $this->lng->txt("search"));
284 $form->addCommandButton('cancelSearch', $this->lng->txt("cancel"));
285
286 $this->tpl->setContent($form->getHtml());
287 $this->tpl->show();
288 }
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, $ilCtrl, $ilUser, ilMailFormCall\getContextId(), ilMailFormCall\getContextParameters(), ilUtil\prepareFormOutput(), and ilUtil\securePlainString().

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

130 {
131 global $ilUser;
132
133 $files = $this->decodeAttachmentFiles(isset($_POST['attachments']) ? (array)$_POST['attachments'] : array());
134
135 $message = strip_tags(ilUtil::stripSlashes($_POST['m_message'], false));
136 $message = str_replace("\r", '', $message);
137 // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
138 $message = $this->umail->formatLinebreakMessage($message);
139
140 $this->umail->setSaveInSentbox(true);
141
142 $m_type = isset($_POST["m_type"]) ? $_POST["m_type"] : array("normal");
143
144 // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
145 if($errorMessage = $this->umail->sendMail(
149 ilUtil::securePlainString($_POST['m_subject']), $message,
150 $files,
151 $m_type,
152 (int)$_POST['use_placeholders']
153 )
154 )
155 {
156 $_POST['attachments'] = $files;
157 ilUtil::sendInfo($errorMessage);
158 }
159 else
160 {
161 $this->umail->savePostData($ilUser->getId(), array(), "", "", "", "", "", "", "", "");
162
163 $this->ctrl->setParameterByClass('ilmailgui', 'type', 'message_sent');
164
166 {
167 ilUtil::sendInfo($this->lng->txt('mail_message_send'), true);
169 }
170 else
171 $this->ctrl->redirectByClass('ilmailgui');
172 }
173
174 $this->showForm();
175 }

References $_POST, $ilUser, decodeAttachmentFiles(), ilMailFormCall\getRefererRedirectUrl(), ilMailFormCall\isRefererStored(), ilUtil\redirect(), ilUtil\securePlainString(), ilUtil\sendInfo(), and ilUtil\stripSlashes().

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilMailFormGUI::$ctrl = null
private

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

◆ $lng

ilMailFormGUI::$lng = null
private

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

Referenced by __construct().

◆ $mbox

ilMailFormGUI::$mbox = null
private

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

◆ $mfile

ilMailFormGUI::$mfile = null
private

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

◆ $tpl

ilMailFormGUI::$tpl = null
private

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

Referenced by __construct().

◆ $umail

ilMailFormGUI::$umail = null
private

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


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