ILIAS  release_8 Revision v8.24
ilMailTemplateGUI Class Reference

Class ilMailTemplateGUI. More...

+ Collaboration diagram for ilMailTemplateGUI:

Public Member Functions

 __construct (ilObject $parentObject, ilGlobalTemplateInterface $tpl=null, ilCtrlInterface $ctrl=null, ilLanguage $lng=null, ilToolbarGUI $toolbar=null, ilRbacSystem $rbacsystem=null, ilErrorHandling $error=null, GlobalHttpState $http=null, Factory $uiFactory=null, Renderer $uiRenderer=null, ilMailTemplateService $templateService=null)
 
 executeCommand ()
 
 getAjaxPlaceholdersById ()
 
 unsetAsContextDefault ()
 
 setAsContextDefault ()
 

Protected Member Functions

 showTemplates ()
 
 insertTemplate ()
 
 showInsertTemplateForm (ilPropertyFormGUI $form=null)
 
 updateTemplate ()
 
 showEditTemplateForm (ilPropertyFormGUI $form=null)
 
 populateFormWithTemplate (ilPropertyFormGUI $form, ilMailTemplate $template)
 
 confirmDeleteTemplate ()
 
 deleteTemplate ()
 
 getTemplateForm (ilMailTemplate $template=null)
 

Protected Attributes

ilPropertyFormGUI $form
 
ilGlobalTemplateInterface $tpl
 
ilCtrlInterface $ctrl
 
ilLanguage $lng
 
ilToolbarGUI $toolbar
 
ilRbacSystem $rbacsystem
 
ilObject $parentObject
 
ilErrorHandling $error
 
ilMailTemplateService $service
 
GlobalHttpState $http
 
Refinery $refinery
 
Factory $uiFactory
 
Renderer $uiRenderer
 

Private Member Functions

 isEditingAllowed ()
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilMailTemplateGUI::__construct ( ilObject  $parentObject,
ilGlobalTemplateInterface  $tpl = null,
ilCtrlInterface  $ctrl = null,
ilLanguage  $lng = null,
ilToolbarGUI  $toolbar = null,
ilRbacSystem  $rbacsystem = null,
ilErrorHandling  $error = null,
GlobalHttpState  $http = null,
Factory  $uiFactory = null,
Renderer  $uiRenderer = null,
ilMailTemplateService  $templateService = null 
)

Definition at line 48 of file class.ilMailTemplateGUI.php.

60 {
61 global $DIC;
62 $this->parentObject = $parentObject;
63 $this->tpl = $tpl ?? $DIC->ui()->mainTemplate();
64 $this->ctrl = $ctrl ?? $DIC->ctrl();
65 $this->lng = $lng ?? $DIC->language();
66 $this->toolbar = $toolbar ?? $DIC->toolbar();
67 $this->rbacsystem = $rbacsystem ?? $DIC->rbac()->system();
68 $this->error = $error ?? $DIC['ilErr'];
69 $this->http = $http ?? $DIC->http();
70 $this->refinery = $DIC->refinery();
71 $this->uiFactory = $uiFactory ?? $DIC->ui()->factory();
72 $this->uiRenderer = $uiRenderer ?? $DIC->ui()->renderer();
73 $this->service = $templateService ?? $DIC['mail.texttemplates.service'];
74
75 $this->lng->loadLanguageModule('meta');
76 }
error(string $a_errmsg)
ilGlobalTemplateInterface $tpl
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.

References $DIC, $parentObject, $rbacsystem, $tpl, $uiFactory, $uiRenderer, ILIAS\Repository\ctrl(), error(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ILIAS\Repository\toolbar().

+ Here is the call graph for this function:

Member Function Documentation

◆ confirmDeleteTemplate()

ilMailTemplateGUI::confirmDeleteTemplate ( )
protected

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

293 : void
294 {
295 if (!$this->isEditingAllowed()) {
296 $this->error->raiseError($this->lng->txt('msg_no_perm_write'), $this->error->WARNING);
297 }
298
299 $templateIds = [];
300 if ($this->http->wrapper()->post()->has('tpl_id')) {
301 $templateIds = $this->http->wrapper()->post()->retrieve(
302 'tpl_id',
303 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
304 );
305 }
306 if (count($templateIds) === 0 && $this->http->wrapper()->query()->has('tpl_id')) {
307 $templateIds = [$this->http->wrapper()->query()->retrieve(
308 'tpl_id',
309 $this->refinery->kindlyTo()->int()
310 )];
311 }
312
313 if (0 === count($templateIds)) {
314 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
315 $this->showTemplates();
316 return;
317 }
318
319 $confirm = new ilConfirmationGUI();
320 $confirm->setFormAction($this->ctrl->getFormAction($this, 'deleteTemplate'));
321
322 $confirm->setHeaderText($this->lng->txt('mail_tpl_sure_delete_entries'));
323 if (1 === count($templateIds)) {
324 $confirm->setHeaderText($this->lng->txt('mail_tpl_sure_delete_entry'));
325 }
326
327 $confirm->setConfirm($this->lng->txt('confirm'), 'deleteTemplate');
328 $confirm->setCancel($this->lng->txt('cancel'), 'showTemplates');
329
330 foreach ($templateIds as $templateId) {
331 $template = $this->service->loadTemplateForId($templateId);
332 $confirm->addItem('tpl_id[]', (string) $templateId, $template->getTitle());
333 }
334
335 $this->tpl->setContent($confirm->getHTML());
336 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ILIAS\Repository\ctrl(), error(), ILIAS\FileDelivery\http(), isEditingAllowed(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and showTemplates().

+ Here is the call graph for this function:

◆ deleteTemplate()

ilMailTemplateGUI::deleteTemplate ( )
protected

Definition at line 338 of file class.ilMailTemplateGUI.php.

338 : void
339 {
340 if (!$this->isEditingAllowed()) {
341 $this->error->raiseError($this->lng->txt('msg_no_perm_write'), $this->error->WARNING);
342 }
343
344 $templateIds = [];
345 if ($this->http->wrapper()->post()->has('tpl_id')) {
346 $templateIds = $this->http->wrapper()->post()->retrieve(
347 'tpl_id',
348 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
349 );
350 }
351 if (count($templateIds) === 0) {
352 $templateId = 0;
353 if ($this->http->wrapper()->query()->has('tpl_id')) {
354 $templateId = $this->http->wrapper()->query()->retrieve('tpl_id', $this->refinery->kindlyTo()->int());
355 }
356 $templateIds = [$templateId];
357 }
358
359 if (0 === count($templateIds)) {
360 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
361 $this->showTemplates();
362 return;
363 }
364
365 $this->service->deleteTemplatesByIds($templateIds);
366
367 if (1 === count($templateIds)) {
368 $this->tpl->setOnScreenMessage('success', $this->lng->txt('mail_tpl_deleted_s'), true);
369 } else {
370 $this->tpl->setOnScreenMessage('success', $this->lng->txt('mail_tpl_deleted_p'), true);
371 }
372 $this->ctrl->redirect($this, 'showTemplates');
373 }

References ILIAS\Repository\ctrl(), error(), ILIAS\FileDelivery\http(), isEditingAllowed(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and showTemplates().

+ Here is the call graph for this function:

◆ executeCommand()

ilMailTemplateGUI::executeCommand ( )

Definition at line 83 of file class.ilMailTemplateGUI.php.

83 : void
84 {
85 $next_class = $this->ctrl->getNextClass($this);
86 $cmd = $this->ctrl->getCmd();
87
88 switch ($next_class) {
89 default:
90 if (!$cmd || !method_exists($this, $cmd)) {
91 $cmd = 'showTemplates';
92 }
93
94 $this->$cmd();
95 break;
96 }
97 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ getAjaxPlaceholdersById()

ilMailTemplateGUI::getAjaxPlaceholdersById ( )
Exceptions
ilMailException

Definition at line 378 of file class.ilMailTemplateGUI.php.

378 : void
379 {
380 $triggerValue = '';
381 if ($this->http->wrapper()->query()->has('triggerValue')) {
382 $triggerValue = $this->http->wrapper()->query()->retrieve(
383 'triggerValue',
384 $this->refinery->kindlyTo()->string()
385 );
386 }
387 $contextId = ilUtil::stripSlashes($triggerValue);
388
389 $placeholders = new ilManualPlaceholderInputGUI(
390 $this->lng->txt('mail_form_placeholders_label'),
391 'm_message'
392 );
393 $placeholders->setInstructionText($this->lng->txt('mail_nacc_use_placeholder'));
394 try {
395 $placeholders->setAdviseText(sprintf($this->lng->txt('placeholders_advise'), '<br />'));
396 } catch (Throwable $e) {
397 $placeholders->setAdviseText($this->lng->txt('placeholders_advise'));
398 }
399
401 foreach ($context->getPlaceholders() as $value) {
402 $placeholders->addPlaceholder($value['placeholder'], $value['label']);
403 }
404
405 $placeholders->render(true);
406 }
Class ilManualPlaceholderInputGUI.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
$context
Definition: webdav.php:29

References $context, Vendor\Package\$e, ilMailTemplateContextService\getTemplateContextById(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ilUtil\stripSlashes().

+ Here is the call graph for this function:

◆ getTemplateForm()

ilMailTemplateGUI::getTemplateForm ( ilMailTemplate  $template = null)
protected
Parameters
ilMailTemplate | null$template
Returns
ilPropertyFormGUI
Exceptions
ilMailException

Definition at line 413 of file class.ilMailTemplateGUI.php.

414 {
415 $form = new ilPropertyFormGUI();
416
417 $title = new ilTextInputGUI($this->lng->txt('mail_template_title'), 'title');
418 $title->setRequired(true);
419 $title->setDisabled(!$this->isEditingAllowed());
420 $form->addItem($title);
421
422 $context = new ilRadioGroupInputGUI($this->lng->txt('mail_template_context'), 'context');
423 $context->setDisabled(!$this->isEditingAllowed());
425
426 if (count($contexts) <= 1) {
427 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('mail_template_no_context_available'), true);
428 $this->ctrl->redirect($this, 'showTemplates');
429 }
430
431 $context_sort = [];
432 $context_options = [];
433 $generic_context = new ilMailTemplateGenericContext();
434 foreach ($contexts as $ctx) {
435 if ($ctx->getId() !== $generic_context->getId()) {
436 $context_options[$ctx->getId()] = $ctx;
437 $context_sort[$ctx->getId()] = $ctx->getTitle();
438 }
439 }
440 asort($context_sort);
441 $first = null;
442 foreach ($context_sort as $id => $title) {
443 $ctx = $context_options[$id];
444 $option = new ilRadioOption($ctx->getTitle(), $ctx->getId());
445 $option->setInfo($ctx->getDescription());
446 $context->addOption($option);
447
448 if (!$first) {
449 $first = $id;
450 }
451 }
452 $context->setValue($first);
453 $context->setRequired(true);
455
456 $hidden = new ilHiddenInputGUI('lang');
457 $hidden->setValue($this->lng->getLangKey());
458 $form->addItem($hidden);
459
460 $subject = new ilTextInputGUI($this->lng->txt('subject'), 'm_subject');
461 $subject->setDisabled(!$this->isEditingAllowed());
462 $subject->setSize(50);
463 $form->addItem($subject);
464
465 $message = new ilTextAreaInputGUI($this->lng->txt('message'), 'm_message');
466 $message->setDisabled(!$this->isEditingAllowed());
467 $message->setRequired(true);
468 $message->setCols(60);
469 $message->setRows(10);
471
472 $placeholders = new ilManualPlaceholderInputGUI(
473 $this->lng->txt('mail_form_placeholders_label'),
474 'm_message'
475 );
476 $placeholders->setDisabled(!$this->isEditingAllowed());
477 $placeholders->setInstructionText($this->lng->txt('mail_nacc_use_placeholder'));
478 try {
479 $placeholders->setAdviseText(sprintf($this->lng->txt('placeholders_advise'), '<br />'));
480 } catch (Throwable $e) {
481 $placeholders->setAdviseText($this->lng->txt('placeholders_advise'));
482 }
483 $placeholders->supportsRerenderSignal(
484 'context',
485 $this->ctrl->getLinkTarget($this, 'getAjaxPlaceholdersById', '', true)
486 );
487 if ($template === null) {
488 $context_id = $generic_context->getId();
489 } else {
490 $context_id = $template->getContext();
491 }
493 foreach ($context->getPlaceholders() as $key => $value) {
494 $placeholders->addPlaceholder($value['placeholder'], $value['label']);
495 }
496 $form->addItem($placeholders);
497 if ($template instanceof ilMailTemplate && $template->getTplId() > 0) {
498 $id = new ilHiddenInputGUI('tpl_id');
499 $form->addItem($id);
500
501 $form->setTitle($this->lng->txt('mail_edit_tpl'));
502 $form->setFormAction($this->ctrl->getFormAction($this, 'updateTemplate'));
503
504 if ($this->isEditingAllowed()) {
505 $form->addCommandButton('updateTemplate', $this->lng->txt('save'));
506 }
507 } else {
508 $form->setTitle($this->lng->txt('mail_create_tpl'));
509 $form->setFormAction($this->ctrl->getFormAction($this, 'insertTemplate'));
510
511 if ($this->isEditingAllowed()) {
512 $form->addCommandButton('insertTemplate', $this->lng->txt('save'));
513 }
514 }
515
516 if ($this->isEditingAllowed()) {
517 $form->addCommandButton('showTemplates', $this->lng->txt('cancel'));
518 } else {
519 $form->addCommandButton('showTemplates', $this->lng->txt('back'));
520 }
521
522 return $form;
523 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
setFormAction(string $a_formaction)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getTemplateContexts(?array $a_id=null)
Returns an array of mail template contexts, the key of each entry matches its id.
Class ilMailTemplate.
This class represents a property form user interface.
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
This class represents a property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text area property in a property form.
This class represents a text property in a property form.
string $key
Consumer key/client ID value.
Definition: System.php:193
$message
Definition: xapiexit.php:32

References $context, Vendor\Package\$e, $form, $id, ILIAS\LTI\ToolProvider\$key, $message, ilPropertyFormGUI\addCommandButton(), ilPropertyFormGUI\addItem(), ILIAS\Repository\ctrl(), ilMailTemplateContextService\getTemplateContextById(), ilMailTemplateContextService\getTemplateContexts(), ilMailTemplate\getTplId(), isEditingAllowed(), ILIAS\Repository\lng(), ilFormGUI\setFormAction(), and ilPropertyFormGUI\setTitle().

Referenced by insertTemplate(), showEditTemplateForm(), showInsertTemplateForm(), and updateTemplate().

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

◆ insertTemplate()

ilMailTemplateGUI::insertTemplate ( )
protected
Exceptions
ilMailException

Definition at line 126 of file class.ilMailTemplateGUI.php.

126 : void
127 {
128 if (!$this->isEditingAllowed()) {
129 $this->error->raiseError($this->lng->txt('msg_no_perm_write'), $this->error->WARNING);
130 }
131
132 $form = $this->getTemplateForm();
133
134 if (!$form->checkInput()) {
137 return;
138 }
139
140 $generic_context = new ilMailTemplateGenericContext();
141 if ($form->getInput('context') === $generic_context->getId()) {
142 $form->getItemByPostVar('context')->setAlert(
143 $this->lng->txt('mail_template_no_valid_context')
144 );
147 return;
148 }
149
150 try {
151 $this->service->createNewTemplate(
153 $form->getInput('title'),
154 $form->getInput('m_subject'),
155 $form->getInput('m_message'),
156 $form->getInput('lang')
157 );
158
159 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'), true);
160 $this->ctrl->redirect($this, 'showTemplates');
161 } catch (Exception $e) {
162 $form->getItemByPostVar('context')->setAlert(
163 $this->lng->txt('mail_template_no_valid_context')
164 );
165 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('form_input_not_valid'));
166 }
167
170 }
getTemplateForm(ilMailTemplate $template=null)
showInsertTemplateForm(ilPropertyFormGUI $form=null)
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
getItemByPostVar(string $a_post_var)

References Vendor\Package\$e, $form, ilPropertyFormGUI\checkInput(), ILIAS\Repository\ctrl(), error(), ilPropertyFormGUI\getInput(), ilPropertyFormGUI\getItemByPostVar(), ilMailTemplateContextService\getTemplateContextById(), getTemplateForm(), isEditingAllowed(), ILIAS\Repository\lng(), ilPropertyFormGUI\setValuesByPost(), and showInsertTemplateForm().

+ Here is the call graph for this function:

◆ isEditingAllowed()

ilMailTemplateGUI::isEditingAllowed ( )
private

Definition at line 78 of file class.ilMailTemplateGUI.php.

78 : bool
79 {
80 return $this->rbacsystem->checkAccess('write', $this->parentObject->getRefId());
81 }

Referenced by confirmDeleteTemplate(), deleteTemplate(), getTemplateForm(), insertTemplate(), setAsContextDefault(), showTemplates(), unsetAsContextDefault(), and updateTemplate().

+ Here is the caller graph for this function:

◆ populateFormWithTemplate()

ilMailTemplateGUI::populateFormWithTemplate ( ilPropertyFormGUI  $form,
ilMailTemplate  $template 
)
protected

Definition at line 281 of file class.ilMailTemplateGUI.php.

281 : void
282 {
284 'tpl_id' => $template->getTplId(),
285 'title' => $template->getTitle(),
286 'context' => $template->getContext(),
287 'lang' => $template->getLang(),
288 'm_subject' => $template->getSubject(),
289 'm_message' => $template->getMessage(),
290 ]);
291 }
setValuesByArray(array $a_values, bool $a_restrict_to_value_keys=false)

References $form, ilMailTemplate\getContext(), ilMailTemplate\getLang(), ilMailTemplate\getMessage(), ilMailTemplate\getSubject(), ilMailTemplate\getTitle(), ilMailTemplate\getTplId(), and ilPropertyFormGUI\setValuesByArray().

Referenced by showEditTemplateForm().

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

◆ setAsContextDefault()

ilMailTemplateGUI::setAsContextDefault ( )

Definition at line 555 of file class.ilMailTemplateGUI.php.

555 : void
556 {
557 if (!$this->isEditingAllowed()) {
558 $this->error->raiseError($this->lng->txt('msg_no_perm_write'), $this->error->WARNING);
559 }
560
561 $templateId = 0;
562 if ($this->http->wrapper()->query()->has('tpl_id')) {
563 $templateId = $this->http->wrapper()->query()->retrieve('tpl_id', $this->refinery->kindlyTo()->int());
564 }
565
566 if (!is_numeric($templateId) || $templateId < 1) {
567 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('mail_template_missing_id'));
568 $this->showTemplates();
569 return;
570 }
571
572 try {
573 $template = $this->service->loadTemplateForId((int) $templateId);
574 $this->service->setAsContextDefault($template);
575 } catch (Exception $e) {
576 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('mail_template_missing_id'));
577 $this->showTemplates();
578 return;
579 }
580
581 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'), true);
582 $this->ctrl->redirect($this, 'showTemplates');
583 }

References Vendor\Package\$e, ILIAS\Repository\ctrl(), error(), ILIAS\FileDelivery\http(), isEditingAllowed(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and showTemplates().

+ Here is the call graph for this function:

◆ showEditTemplateForm()

ilMailTemplateGUI::showEditTemplateForm ( ilPropertyFormGUI  $form = null)
protected

Definition at line 250 of file class.ilMailTemplateGUI.php.

250 : void
251 {
252 if (!($form instanceof ilPropertyFormGUI)) {
253 $templateId = 0;
254 if ($this->http->wrapper()->query()->has('tpl_id')) {
255 $templateId = $this->http->wrapper()->query()->retrieve(
256 'tpl_id',
257 $this->refinery->kindlyTo()->int()
258 );
259 }
260
261 if (!is_numeric($templateId) || $templateId < 1) {
262 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('mail_template_missing_id'));
263 $this->showTemplates();
264 return;
265 }
266
267 try {
268 $template = $this->service->loadTemplateForId((int) $templateId);
269 $form = $this->getTemplateForm($template);
270 $this->populateFormWithTemplate($form, $template);
271 } catch (Exception $e) {
272 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('mail_template_missing_id'));
273 $this->showTemplates();
274 return;
275 }
276 }
277
278 $this->tpl->setContent($form->getHTML());
279 }
populateFormWithTemplate(ilPropertyFormGUI $form, ilMailTemplate $template)

References Vendor\Package\$e, $form, ilPropertyFormGUI\getHTML(), getTemplateForm(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), populateFormWithTemplate(), ILIAS\Repository\refinery(), and showTemplates().

Referenced by updateTemplate().

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

◆ showInsertTemplateForm()

ilMailTemplateGUI::showInsertTemplateForm ( ilPropertyFormGUI  $form = null)
protected
Parameters
ilPropertyFormGUI | null$form
Exceptions
ilMailException

Definition at line 176 of file class.ilMailTemplateGUI.php.

176 : void
177 {
178 if (!($form instanceof ilPropertyFormGUI)) {
179 $form = $this->getTemplateForm();
180 }
181
182 $this->tpl->setContent($form->getHTML());
183 }

References $form, ilPropertyFormGUI\getHTML(), and getTemplateForm().

Referenced by insertTemplate().

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

◆ showTemplates()

ilMailTemplateGUI::showTemplates ( )
protected

Definition at line 99 of file class.ilMailTemplateGUI.php.

99 : void
100 {
102 if (count($contexts) <= 1) {
103 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('mail_template_no_context_available'));
104 } elseif ($this->isEditingAllowed()) {
105 $create_tpl_button = ilLinkButton::getInstance();
106 $create_tpl_button->setCaption('mail_new_template');
107 $create_tpl_button->setUrl($this->ctrl->getLinkTarget($this, 'showInsertTemplateForm'));
108 $this->toolbar->addButtonInstance($create_tpl_button);
109 }
110
111 $tbl = new ilMailTemplateTableGUI(
112 $this,
113 'showTemplates',
114 $this->uiFactory,
115 $this->uiRenderer,
116 !$this->isEditingAllowed()
117 );
118 $tbl->setData($this->service->listAllTemplatesAsArray());
119
120 $this->tpl->setContent($tbl->getHTML());
121 }
Class ilMailTemplateTableGUI.

References ILIAS\Repository\ctrl(), ilLinkButton\getInstance(), ilMailTemplateContextService\getTemplateContexts(), isEditingAllowed(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

Referenced by confirmDeleteTemplate(), deleteTemplate(), setAsContextDefault(), showEditTemplateForm(), unsetAsContextDefault(), and updateTemplate().

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

◆ unsetAsContextDefault()

ilMailTemplateGUI::unsetAsContextDefault ( )

Definition at line 525 of file class.ilMailTemplateGUI.php.

525 : void
526 {
527 if (!$this->isEditingAllowed()) {
528 $this->error->raiseError($this->lng->txt('msg_no_perm_write'), $this->error->WARNING);
529 }
530
531 $templateId = 0;
532 if ($this->http->wrapper()->query()->has('tpl_id')) {
533 $templateId = $this->http->wrapper()->query()->retrieve('tpl_id', $this->refinery->kindlyTo()->int());
534 }
535
536 if (!is_numeric($templateId) || $templateId < 1) {
537 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('mail_template_missing_id'));
538 $this->showTemplates();
539 return;
540 }
541
542 try {
543 $template = $this->service->loadTemplateForId((int) $templateId);
544 $this->service->unsetAsContextDefault($template);
545 } catch (Exception $e) {
546 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('mail_template_missing_id'));
547 $this->showTemplates();
548 return;
549 }
550
551 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'), true);
552 $this->ctrl->redirect($this, 'showTemplates');
553 }

References Vendor\Package\$e, ILIAS\Repository\ctrl(), error(), ILIAS\FileDelivery\http(), isEditingAllowed(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and showTemplates().

+ Here is the call graph for this function:

◆ updateTemplate()

ilMailTemplateGUI::updateTemplate ( )
protected

Definition at line 185 of file class.ilMailTemplateGUI.php.

185 : void
186 {
187 if (!$this->isEditingAllowed()) {
188 $this->error->raiseError($this->lng->txt('msg_no_perm_write'), $this->error->WARNING);
189 }
190
191 $templateId = 0;
192 if ($this->http->wrapper()->post()->has('tpl_id')) {
193 $templateId = $this->http->wrapper()->post()->retrieve('tpl_id', $this->refinery->kindlyTo()->int());
194 }
195
196 if (!is_numeric($templateId) || $templateId < 1) {
197 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('mail_template_missing_id'));
198 $this->showTemplates();
199 return;
200 }
201
202 try {
203 $form = $this->getTemplateForm();
204 if (!$form->checkInput()) {
207 return;
208 }
209
210 $genericContext = new ilMailTemplateGenericContext();
211 if ($form->getInput('context') === $genericContext->getId()) {
212 $form->getItemByPostVar('context')->setAlert(
213 $this->lng->txt('mail_template_no_valid_context')
214 );
217 return;
218 }
219
220 try {
221 $this->service->modifyExistingTemplate(
222 (int) $templateId,
224 $form->getInput('title'),
225 $form->getInput('m_subject'),
226 $form->getInput('m_message'),
227 $form->getInput('lang')
228 );
229
230 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'), true);
231 $this->ctrl->redirect($this, 'showTemplates');
232 } catch (OutOfBoundsException $e) {
233 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('mail_template_missing_id'));
234 } catch (Exception $e) {
235 $form->getItemByPostVar('context')->setAlert(
236 $this->lng->txt('mail_template_no_valid_context')
237 );
238 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('form_input_not_valid'));
239 }
240
243 } catch (Exception $e) {
244 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('mail_template_missing_id'));
245 $this->showTemplates();
246 return;
247 }
248 }
showEditTemplateForm(ilPropertyFormGUI $form=null)

References Vendor\Package\$e, $form, ilPropertyFormGUI\checkInput(), ILIAS\Repository\ctrl(), error(), ilPropertyFormGUI\getInput(), ilPropertyFormGUI\getItemByPostVar(), ilMailTemplateContextService\getTemplateContextById(), getTemplateForm(), ILIAS\FileDelivery\http(), isEditingAllowed(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), ilPropertyFormGUI\setValuesByPost(), showEditTemplateForm(), and showTemplates().

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilCtrlInterface ilMailTemplateGUI::$ctrl
protected

Definition at line 36 of file class.ilMailTemplateGUI.php.

◆ $error

ilErrorHandling ilMailTemplateGUI::$error
protected

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

◆ $form

◆ $http

GlobalHttpState ilMailTemplateGUI::$http
protected

Definition at line 43 of file class.ilMailTemplateGUI.php.

◆ $lng

ilLanguage ilMailTemplateGUI::$lng
protected

Definition at line 37 of file class.ilMailTemplateGUI.php.

◆ $parentObject

ilObject ilMailTemplateGUI::$parentObject
protected

Definition at line 40 of file class.ilMailTemplateGUI.php.

Referenced by __construct().

◆ $rbacsystem

ilRbacSystem ilMailTemplateGUI::$rbacsystem
protected

Definition at line 39 of file class.ilMailTemplateGUI.php.

Referenced by __construct().

◆ $refinery

Refinery ilMailTemplateGUI::$refinery
protected

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

◆ $service

ilMailTemplateService ilMailTemplateGUI::$service
protected

Definition at line 42 of file class.ilMailTemplateGUI.php.

◆ $toolbar

ilToolbarGUI ilMailTemplateGUI::$toolbar
protected

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

◆ $tpl

ilGlobalTemplateInterface ilMailTemplateGUI::$tpl
protected

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

Referenced by __construct().

◆ $uiFactory

Factory ilMailTemplateGUI::$uiFactory
protected

Definition at line 45 of file class.ilMailTemplateGUI.php.

Referenced by __construct().

◆ $uiRenderer

Renderer ilMailTemplateGUI::$uiRenderer
protected

Definition at line 46 of file class.ilMailTemplateGUI.php.

Referenced by __construct().


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