ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilMailTemplateGUI Class Reference

Class ilMailTemplateGUI. More...

+ Collaboration diagram for ilMailTemplateGUI:

Public Member Functions

 __construct (\ilObject $parentObject, \ilTemplate $tpl=null, \ilCtrl $ctrl=null, \ilLanguage $lng=null, \ilToolbarGUI $toolbar=null, \ilRbacSystem $rbacsystem=null, \ilErrorHandling $error=null, HTTPServices $http=null, Factory $uiFactory=null, Renderer $uiRenderer=null, \ilMailTemplateService $templateService=null)
 ilMailTemplateGUI constructor. More...
 
 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

 $form
 
 $tpl
 
 $ctrl
 
 $lng
 
 $toolbar
 
 $rbacsystem
 
 $parentObject
 
 $error
 
 $service
 
 $http
 
 $uiFactory
 
 $uiRenderer
 

Private Member Functions

 isEditingAllowed ()
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

ilMailTemplateGUI constructor.

Parameters
\ilObject$parentObject
ilTemplate | null$tpl
ilCtrl | null$ctrl
ilLanguage | null$lng
ilToolbarGUI | null$toolbar
ilRbacSystem | null$rbacsystem
ilErrorHandling | null$error
HTTPServices | null$http
Factory | null$uiFactory
Renderer | null$uiRenderer
ilMailTemplateService | null$templateService

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

78 {
79 global $DIC;
80
81 $this->parentObject = $parentObject;
82
83 if ($tpl === null) {
84 $tpl = $DIC->ui()->mainTemplate();
85 }
86 $this->tpl = $tpl;
87
88 if ($ctrl === null) {
89 $ctrl = $DIC->ctrl();
90 }
91 $this->ctrl = $ctrl;
92
93 if ($lng === null) {
94 $lng = $DIC->language();
95 }
96 $this->lng = $lng;
97
98 if ($toolbar === null) {
99 $toolbar = $DIC->toolbar();
100 }
101 $this->toolbar = $toolbar;
102
103 if ($rbacsystem === null) {
104 $rbacsystem = $DIC->rbac()->system();
105 }
106 $this->rbacsystem = $rbacsystem;
107
108 if ($error === null) {
109 $error = $DIC['ilErr'];
110 }
111 $this->error = $error;
112
113 if ($http === null) {
114 $http = $DIC->http();
115 }
116 $this->http = $http;
117
118 if ($uiFactory === null) {
119 $uiFactory = $DIC->ui()->factory();
120 }
121 $this->uiFactory = $uiFactory;
122
123 if ($uiRenderer === null) {
124 $uiRenderer = $DIC->ui()->renderer();
125 }
126 $this->uiRenderer = $uiRenderer;
127
128 if (null === $templateService) {
129 $templateService = $DIC['mail.texttemplates.service'];
130 }
131 $this->service = $templateService;
132
133 $this->lng->loadLanguageModule('meta');
134 }
error($a_errmsg)
set error message @access public
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: saml.php:7

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

+ Here is the call graph for this function:

Member Function Documentation

◆ confirmDeleteTemplate()

ilMailTemplateGUI::confirmDeleteTemplate ( )
protected

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

357 {
358 if (!$this->isEditingAllowed()) {
359 $this->error->raiseError($this->lng->txt('msg_no_perm_write'), $this->error->WARNING);
360 }
361
362 $templateIds = $this->http->request()->getParsedBody()['tpl_id'] ?? array();
363 if (is_array($templateIds) && count($templateIds) > 0) {
364 $templateIds = array_filter(array_map('intval', $templateIds));
365 } else {
366 $templateId = $this->http->request()->getQueryParams()['tpl_id'] ?? '';
367 if (is_numeric($templateId) && $templateId > 0) {
368 $templateIds = array_filter(array((int) $templateId));
369 } else {
370 $templateIds = array();
371 }
372 }
373
374 if (0 === count($templateIds)) {
375 ilUtil::sendFailure($this->lng->txt('select_one'));
376 $this->showTemplates();
377 return;
378 }
379
380 $confirm = new \ilConfirmationGUI();
381 $confirm->setFormAction($this->ctrl->getFormAction($this, 'deleteTemplate'));
382
383 $confirm->setHeaderText($this->lng->txt('mail_tpl_sure_delete_entry'));
384 if (1 === count($templateIds)) {
385 $confirm->setHeaderText($this->lng->txt('mail_tpl_sure_delete_entries'));
386 }
387
388 $confirm->setConfirm($this->lng->txt('confirm'), 'deleteTemplate');
389 $confirm->setCancel($this->lng->txt('cancel'), 'showTemplates');
390
391 foreach ($templateIds as $templateId) {
392 $template = $this->service->loadTemplateForId((int) $templateId);
393 $confirm->addItem('tpl_id[]', $templateId, $template->getTitle());
394 }
395
396 $this->tpl->setContent($confirm->getHTML());
397 }
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$template

References $template, error(), ILIAS\FileDelivery\http(), isEditingAllowed(), ilUtil\sendFailure(), and showTemplates().

+ Here is the call graph for this function:

◆ deleteTemplate()

ilMailTemplateGUI::deleteTemplate ( )
protected

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

403 {
404 if (!$this->isEditingAllowed()) {
405 $this->error->raiseError($this->lng->txt('msg_no_perm_write'), $this->error->WARNING);
406 }
407
408 $templateIds = $this->http->request()->getParsedBody()['tpl_id'] ?? array();
409 if (is_array($templateIds) && count($templateIds) > 0) {
410 $templateIds = array_filter(array_map('intval', $templateIds));
411 } else {
412 $templateId = $this->http->request()->getQueryParams()['tpl_id'] ?? '';
413 if (is_numeric($templateId) && $templateId > 0) {
414 $templateIds = array_filter(array((int) $templateId));
415 } else {
416 $templateIds = array();
417 }
418 }
419
420 if (0 === count($templateIds)) {
421 \ilUtil::sendFailure($this->lng->txt('select_one'));
422 $this->showTemplates();
423 return;
424 }
425
426 $this->service->deleteTemplatesByIds($templateIds);
427
428 if (1 === count($templateIds)) {
429 \ilUtil::sendSuccess($this->lng->txt('mail_tpl_deleted_s'), true);
430 } else {
431 \ilUtil::sendSuccess($this->lng->txt('mail_tpl_deleted_p'), true);
432 }
433 $this->ctrl->redirect($this, 'showTemplates');
434 }

References error(), ILIAS\FileDelivery\http(), isEditingAllowed(), ilUtil\sendFailure(), and showTemplates().

+ Here is the call graph for this function:

◆ executeCommand()

ilMailTemplateGUI::executeCommand ( )

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

148 {
149 $next_class = $this->ctrl->getNextClass($this);
150 $cmd = $this->ctrl->getCmd();
151
152 switch ($next_class) {
153 default:
154 if (!$cmd || !method_exists($this, $cmd)) {
155 $cmd = 'showTemplates';
156 }
157
158 $this->$cmd();
159 break;
160 }
161 }

◆ getAjaxPlaceholdersById()

ilMailTemplateGUI::getAjaxPlaceholdersById ( )
Exceptions

ilMailException

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

440 {
441 $triggerValue = $this->http->request()->getQueryParams()['triggerValue'] ?? '';
442 $contextId = \ilUtil::stripSlashes($triggerValue);
443
444 $placeholders = new \ilManualPlaceholderInputGUI('m_message');
445 $placeholders->setInstructionText($this->lng->txt('mail_nacc_use_placeholder'));
446 $placeholders->setAdviseText(sprintf($this->lng->txt('placeholders_advise'), '<br />'));
447
449 foreach ($context->getPlaceholders() as $key => $value) {
450 $placeholders->addPlaceholder($value['placeholder'], $value['label']);
451 }
452
453 $placeholders->render(true);
454 exit();
455 }
exit
Definition: backend.php:16
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$key
Definition: croninfo.php:18
$context
Definition: webdav.php:25

References $context, $key, exit, ilMailTemplateContextService\getTemplateContextById(), ILIAS\FileDelivery\http(), 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 462 of file class.ilMailTemplateGUI.php.

463 {
464 $form = new \ilPropertyFormGUI();
465
466 $title = new \ilTextInputGUI($this->lng->txt('mail_template_title'), 'title');
467 $title->setRequired(true);
468 $title->setDisabled(!$this->isEditingAllowed());
469 $form->addItem($title);
470
471 $context = new \ilRadioGroupInputGUI($this->lng->txt('mail_template_context'), 'context');
472 $context->setDisabled(!$this->isEditingAllowed());
474
475 if (count($contexts) <= 1) {
476 ilUtil::sendFailure($this->lng->txt('mail_template_no_context_available'), true);
477 $this->ctrl->redirect($this, 'showTemplates');
478 }
479
480 $context_sort = array();
481 $context_options = array();
482 $generic_context = new \ilMailTemplateGenericContext();
483 foreach ($contexts as $ctx) {
484 if ($ctx->getId() != $generic_context->getId()) {
485 $context_options[$ctx->getId()] = $ctx;
486 $context_sort[$ctx->getId()] = $ctx->getTitle();
487 }
488 }
489 asort($context_sort);
490 $first = null;
491 foreach ($context_sort as $id => $title) {
492 $ctx = $context_options[$id];
493 $option = new \ilRadioOption($ctx->getTitle(), $ctx->getId());
494 $option->setInfo($ctx->getDescription());
495 $context->addOption($option);
496
497 if (!$first) {
498 $first = $id;
499 }
500 }
501 $context->setValue($first);
502 $context->setRequired(true);
503 $form->addItem($context);
504
505 $hidden = new \ilHiddenInputGUI('lang');
506 $hidden->setValue($this->lng->getLangKey());
507 $form->addItem($hidden);
508
509 $subject = new \ilTextInputGUI($this->lng->txt('subject'), 'm_subject');
510 $subject->setDisabled(!$this->isEditingAllowed());
511 $subject->setSize(50);
512 $form->addItem($subject);
513
514 $message = new \ilTextAreaInputGUI($this->lng->txt('message'), 'm_message');
515 $message->setDisabled(!$this->isEditingAllowed());
516 $message->setRequired(true);
517 $message->setCols(60);
518 $message->setRows(10);
519 $form->addItem($message);
520
521 $placeholders = new \ilManualPlaceholderInputGUI('m_message');
522 $placeholders->setDisabled(!$this->isEditingAllowed());
523 $placeholders->setInstructionText($this->lng->txt('mail_nacc_use_placeholder'));
524 $placeholders->setAdviseText(sprintf($this->lng->txt('placeholders_advise'), '<br />'));
525 $placeholders->supportsRerenderSignal(
526 'context',
527 $this->ctrl->getLinkTarget($this, 'getAjaxPlaceholdersById', '', true, false)
528 );
529 if ($template === null) {
530 $context_id = $generic_context->getId();
531 } else {
532 $context_id = $template->getContext();
533 }
535 foreach ($context->getPlaceholders() as $key => $value) {
536 $placeholders->addPlaceholder($value['placeholder'], $value['label']);
537 }
538 $form->addItem($placeholders);
539 if ($template instanceof \ilMailTemplate && $template->getTplId() > 0) {
540 $id = new \ilHiddenInputGUI('tpl_id');
541 $form->addItem($id);
542
543 $form->setTitle($this->lng->txt('mail_edit_tpl'));
544 $form->setFormAction($this->ctrl->getFormaction($this, 'updateTemplate'));
545
546 if ($this->isEditingAllowed()) {
547 $form->addCommandButton('updateTemplate', $this->lng->txt('save'));
548 }
549 } else {
550 $form->setTitle($this->lng->txt('mail_create_tpl'));
551 $form->setFormAction($this->ctrl->getFormaction($this, 'insertTemplate'));
552
553 if ($this->isEditingAllowed()) {
554 $form->addCommandButton('insertTemplate', $this->lng->txt('save'));
555 }
556 }
557
558 if ($this->isEditingAllowed()) {
559 $form->addCommandButton('showTemplates', $this->lng->txt('cancel'));
560 } else {
561 $form->addCommandButton('showTemplates', $this->lng->txt('back'));
562 }
563
564 return $form;
565 }
static getTemplateContexts($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.
if(!array_key_exists('StateId', $_REQUEST)) $id
catch(Exception $e) $message

References $context, $form, $id, $key, $message, $template, $title, ilMailTemplateContextService\getTemplateContextById(), ilMailTemplateContextService\getTemplateContexts(), isEditingAllowed(), and ilUtil\sendFailure().

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 193 of file class.ilMailTemplateGUI.php.

194 {
195 if (!$this->isEditingAllowed()) {
196 $this->error->raiseError($this->lng->txt('msg_no_perm_write'), $this->error->WARNING);
197 }
198
199 $form = $this->getTemplateForm();
200
201 if (!$form->checkInput()) {
202 $form->setValuesByPost();
204 return;
205 }
206
207 $generic_context = new \ilMailTemplateGenericContext();
208 if ($form->getInput('context') === $generic_context->getId()) {
209 $form->getItemByPostVar('context')->setAlert($this->lng->txt('mail_template_no_valid_context'));
210 $form->setValuesByPost();
212 return;
213 }
214
215 try {
216 $this->service->createNewTemplate(
217 (string) \ilMailTemplateContextService::getTemplateContextById($form->getInput('context'))->getId(),
218 (string) $form->getInput('title'),
219 (string) $form->getInput('m_subject'),
220 (string) $form->getInput('m_message'),
221 (string) $form->getInput('lang')
222 );
223
224 \ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
225 $this->ctrl->redirect($this, 'showTemplates');
226 } catch (\Exception $e) {
227 $form->getItemByPostVar('context')->setAlert($this->lng->txt('mail_template_no_valid_context'));
228 \ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
229 }
230
231 $form->setValuesByPost();
233 }
getTemplateForm(\ilMailTemplate $template=null)
showInsertTemplateForm(\ilPropertyFormGUI $form=null)

References $form, error(), ilMailTemplateContextService\getTemplateContextById(), getTemplateForm(), isEditingAllowed(), ilUtil\sendFailure(), and showInsertTemplateForm().

+ Here is the call graph for this function:

◆ isEditingAllowed()

ilMailTemplateGUI::isEditingAllowed ( )
private
Returns
bool

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

139 : bool
140 {
141 return $this->rbacsystem->checkAccess('write', $this->parentObject->getRefId());
142 }

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
Parameters
\ilPropertyFormGUI$form
\ilMailTemplate$template

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

342 {
343 $form->setValuesByArray(array(
344 'tpl_id' => $template->getTplId(),
345 'title' => $template->getTitle(),
346 'context' => $template->getContext(),
347 'lang' => $template->getLang(),
348 'm_subject' => $template->getSubject(),
349 'm_message' => $template->getMessage(),
350 ));
351 }

References $form, and $template.

Referenced by showEditTemplateForm().

+ Here is the caller graph for this function:

◆ setAsContextDefault()

ilMailTemplateGUI::setAsContextDefault ( )

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

601 {
602 if (!$this->isEditingAllowed()) {
603 $this->error->raiseError($this->lng->txt('msg_no_perm_write'), $this->error->WARNING);
604 }
605
606 $templateId = $this->http->request()->getQueryParams()['tpl_id'] ?? 0;
607
608 if (!is_numeric($templateId) || $templateId < 1) {
609 \ilUtil::sendFailure($this->lng->txt('mail_template_missing_id'));
610 $this->showTemplates();
611 return;
612 }
613
614 try {
615 $template = $this->service->loadTemplateForId((int) $templateId);
616 $this->service->setAsContextDefault($template);
617 } catch (\Exception $e) {
618 \ilUtil::sendFailure($this->lng->txt('mail_template_missing_id'));
619 $this->showTemplates();
620 return;
621 }
622
623 \ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
624 $this->ctrl->redirect($this, 'showTemplates');
625 }

References $template, error(), ILIAS\FileDelivery\http(), isEditingAllowed(), ilUtil\sendFailure(), and showTemplates().

+ Here is the call graph for this function:

◆ showEditTemplateForm()

ilMailTemplateGUI::showEditTemplateForm ( \ilPropertyFormGUI  $form = null)
protected
Parameters
\ilPropertyFormGUI | null$form

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

313 {
314 if (!($form instanceof \ilPropertyFormGUI)) {
315 $templateId = $this->http->request()->getQueryParams()['tpl_id'] ?? 0;
316
317 if (!is_numeric($templateId) || $templateId < 1) {
318 ilUtil::sendFailure($this->lng->txt('mail_template_missing_id'));
319 $this->showTemplates();
320 return;
321 }
322
323 try {
324 $template = $this->service->loadTemplateForId((int) $templateId);
327 } catch (\Exception $e) {
328 \ilUtil::sendFailure($this->lng->txt('mail_template_missing_id'));
329 $this->showTemplates();
330 return;
331 }
332 }
333
334 $this->tpl->setContent($form->getHTML());
335 }
populateFormWithTemplate(\ilPropertyFormGUI $form, \ilMailTemplate $template)

References $form, $template, getTemplateForm(), ILIAS\FileDelivery\http(), populateFormWithTemplate(), ilUtil\sendFailure(), 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 239 of file class.ilMailTemplateGUI.php.

240 {
241 if (!($form instanceof \ilPropertyFormGUI)) {
242 $form = $this->getTemplateForm();
243 }
244
245 $this->tpl->setContent($form->getHTML());
246 }

References $form, 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 166 of file class.ilMailTemplateGUI.php.

167 {
169 if (count($contexts) <= 1) {
170 \ilUtil::sendFailure($this->lng->txt('mail_template_no_context_available'));
171 } elseif ($this->isEditingAllowed()) {
172 $create_tpl_button = \ilLinkButton::getInstance();
173 $create_tpl_button->setCaption('mail_new_template');
174 $create_tpl_button->setUrl($this->ctrl->getLinkTarget($this, 'showInsertTemplateForm'));
175 $this->toolbar->addButtonInstance($create_tpl_button);
176 }
177
178 $tbl = new \ilMailTemplateTableGUI(
179 $this,
180 'showTemplates',
181 $this->uiFactory,
182 $this->uiRenderer,
183 !$this->isEditingAllowed()
184 );
185 $tbl->setData($this->service->listAllTemplatesAsArray());
186
187 $this->tpl->setContent($tbl->getHTML());
188 }
static getInstance()
Factory.
$tbl
Definition: example_048.php:81

References $tbl, ilLinkButton\getInstance(), ilMailTemplateContextService\getTemplateContexts(), isEditingAllowed(), and ilUtil\sendFailure().

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 570 of file class.ilMailTemplateGUI.php.

571 {
572 if (!$this->isEditingAllowed()) {
573 $this->error->raiseError($this->lng->txt('msg_no_perm_write'), $this->error->WARNING);
574 }
575
576 $templateId = $this->http->request()->getQueryParams()['tpl_id'] ?? 0;
577
578 if (!is_numeric($templateId) || $templateId < 1) {
579 \ilUtil::sendFailure($this->lng->txt('mail_template_missing_id'));
580 $this->showTemplates();
581 return;
582 }
583
584 try {
585 $template = $this->service->loadTemplateForId((int) $templateId);
586 $this->service->unsetAsContextDefault($template);
587 } catch (\Exception $e) {
588 \ilUtil::sendFailure($this->lng->txt('mail_template_missing_id'));
589 $this->showTemplates();
590 return;
591 }
592
593 \ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
594 $this->ctrl->redirect($this, 'showTemplates');
595 }

References $template, error(), ILIAS\FileDelivery\http(), isEditingAllowed(), ilUtil\sendFailure(), and showTemplates().

+ Here is the call graph for this function:

◆ updateTemplate()

ilMailTemplateGUI::updateTemplate ( )
protected

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

252 {
253 if (!$this->isEditingAllowed()) {
254 $this->error->raiseError($this->lng->txt('msg_no_perm_write'), $this->error->WARNING);
255 }
256
257 $templateId = $this->http->request()->getParsedBody()['tpl_id'] ?? 0;
258
259 if (!is_numeric($templateId) || $templateId < 1) {
260 \ilUtil::sendFailure($this->lng->txt('mail_template_missing_id'));
261 $this->showTemplates();
262 return;
263 }
264
265 try {
266 $form = $this->getTemplateForm();
267 if (!$form->checkInput()) {
268 $form->setValuesByPost();
270 return;
271 }
272
273 $genericContext = new \ilMailTemplateGenericContext();
274 if ($form->getInput('context') === $genericContext->getId()) {
275 $form->getItemByPostVar('context')->setAlert($this->lng->txt('mail_template_no_valid_context'));
276 $form->setValuesByPost();
278 return;
279 }
280
281 try {
282 $this->service->modifyExistingTemplate(
283 (int) $templateId,
284 (string) \ilMailTemplateContextService::getTemplateContextById($form->getInput('context'))->getId(),
285 (string) $form->getInput('title'),
286 (string) $form->getInput('m_subject'),
287 (string) $form->getInput('m_message'),
288 (string) $form->getInput('lang')
289 );
290
291 \ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
292 $this->ctrl->redirect($this, 'showTemplates');
293 } catch (\OutOfBoundsException $e) {
294 \ilUtil::sendFailure($this->lng->txt('mail_template_missing_id'));
295 } catch (\Exception $e) {
296 $form->getItemByPostVar('context')->setAlert($this->lng->txt('mail_template_no_valid_context'));
297 \ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
298 }
299
300 $form->setValuesByPost();
302 } catch (\Exception $e) {
303 \ilUtil::sendFailure($this->lng->txt('mail_template_missing_id'));
304 $this->showTemplates();
305 return;
306 }
307 }
showEditTemplateForm(\ilPropertyFormGUI $form=null)

References $form, error(), ilMailTemplateContextService\getTemplateContextById(), getTemplateForm(), ILIAS\FileDelivery\http(), isEditingAllowed(), ilUtil\sendFailure(), showEditTemplateForm(), and showTemplates().

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilMailTemplateGUI::$ctrl
protected

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

Referenced by __construct().

◆ $error

ilMailTemplateGUI::$error
protected

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

Referenced by __construct().

◆ $form

◆ $http

ilMailTemplateGUI::$http
protected

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

Referenced by __construct().

◆ $lng

ilMailTemplateGUI::$lng
protected

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

Referenced by __construct().

◆ $parentObject

ilMailTemplateGUI::$parentObject
protected

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

Referenced by __construct().

◆ $rbacsystem

ilMailTemplateGUI::$rbacsystem
protected

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

Referenced by __construct().

◆ $service

ilMailTemplateGUI::$service
protected

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

◆ $toolbar

ilMailTemplateGUI::$toolbar
protected

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

Referenced by __construct().

◆ $tpl

ilMailTemplateGUI::$tpl
protected

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

Referenced by __construct().

◆ $uiFactory

ilMailTemplateGUI::$uiFactory
protected

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

Referenced by __construct().

◆ $uiRenderer

ilMailTemplateGUI::$uiRenderer
protected

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

Referenced by __construct().


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