ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilMailTemplateGUI Class Reference

Class ilMailTemplateGUI. More...

+ Collaboration diagram for ilMailTemplateGUI:

Public Member Functions

 __construct (ilObject $parentObject, ilGlobalPageTemplate $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,
ilGlobalPageTemplate  $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
ilGlobalPageTemplate | 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 67 of file class.ilMailTemplateGUI.php.

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

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

Member Function Documentation

◆ confirmDeleteTemplate()

ilMailTemplateGUI::confirmDeleteTemplate ( )
protected

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

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

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

◆ deleteTemplate()

ilMailTemplateGUI::deleteTemplate ( )
protected

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

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

403  : void
404  {
405  if (!$this->isEditingAllowed()) {
406  $this->error->raiseError($this->lng->txt('msg_no_perm_write'), $this->error->WARNING);
407  }
408 
409  $templateIds = $this->http->request()->getParsedBody()['tpl_id'] ?? array();
410  if (is_array($templateIds) && count($templateIds) > 0) {
411  $templateIds = array_filter(array_map('intval', $templateIds));
412  } else {
413  $templateId = $this->http->request()->getQueryParams()['tpl_id'] ?? '';
414  if (is_numeric($templateId) && $templateId > 0) {
415  $templateIds = array_filter(array((int) $templateId));
416  } else {
417  $templateIds = array();
418  }
419  }
420 
421  if (0 === count($templateIds)) {
422  ilUtil::sendFailure($this->lng->txt('select_one'));
423  $this->showTemplates();
424  return;
425  }
426 
427  $this->service->deleteTemplatesByIds($templateIds);
428 
429  if (1 === count($templateIds)) {
430  ilUtil::sendSuccess($this->lng->txt('mail_tpl_deleted_s'), true);
431  } else {
432  ilUtil::sendSuccess($this->lng->txt('mail_tpl_deleted_p'), true);
433  }
434  $this->ctrl->redirect($this, 'showTemplates');
435  }
static http()
Fetches the global http state from ILIAS.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

◆ executeCommand()

ilMailTemplateGUI::executeCommand ( )

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

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

◆ getAjaxPlaceholdersById()

ilMailTemplateGUI::getAjaxPlaceholdersById ( )
Exceptions
ilMailException

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

References $context, exit, ilMailTemplateContextService\getTemplateContextById(), ILIAS\FileDelivery\http(), and ilUtil\stripSlashes().

440  : void
441  {
442  $triggerValue = $this->http->request()->getQueryParams()['triggerValue'] ?? '';
443  $contextId = ilUtil::stripSlashes($triggerValue);
444 
445  $placeholders = new ilManualPlaceholderInputGUI('m_message');
446  $placeholders->setInstructionText($this->lng->txt('mail_nacc_use_placeholder'));
447  $placeholders->setAdviseText(sprintf($this->lng->txt('placeholders_advise'), '<br />'));
448 
450  foreach ($context->getPlaceholders() as $key => $value) {
451  $placeholders->addPlaceholder($value['placeholder'], $value['label']);
452  }
453 
454  $placeholders->render(true);
455  exit();
456  }
exit
Definition: login.php:29
$context
Definition: webdav.php:26
Class ilManualPlaceholderInputGUI.
static http()
Fetches the global http state from ILIAS.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
+ 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 463 of file class.ilMailTemplateGUI.php.

References $context, $form, $message, ilMailTemplateContextService\getTemplateContextById(), ilMailTemplateContextService\getTemplateContexts(), ilMailTemplate\getTplId(), isEditingAllowed(), ilUtil\sendFailure(), and ilRadioOption\setInfo().

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

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

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

194  : void
195  {
196  if (!$this->isEditingAllowed()) {
197  $this->error->raiseError($this->lng->txt('msg_no_perm_write'), $this->error->WARNING);
198  }
199 
200  $form = $this->getTemplateForm();
201 
202  if (!$form->checkInput()) {
203  $form->setValuesByPost();
205  return;
206  }
207 
208  $generic_context = new ilMailTemplateGenericContext();
209  if ($form->getInput('context') === $generic_context->getId()) {
210  $form->getItemByPostVar('context')->setAlert($this->lng->txt('mail_template_no_valid_context'));
211  $form->setValuesByPost();
213  return;
214  }
215 
216  try {
217  $this->service->createNewTemplate(
218  (string) ilMailTemplateContextService::getTemplateContextById($form->getInput('context'))->getId(),
219  (string) $form->getInput('title'),
220  (string) $form->getInput('m_subject'),
221  (string) $form->getInput('m_message'),
222  (string) $form->getInput('lang')
223  );
224 
225  ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
226  $this->ctrl->redirect($this, 'showTemplates');
227  } catch (Exception $e) {
228  $form->getItemByPostVar('context')->setAlert($this->lng->txt('mail_template_no_valid_context'));
229  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
230  }
231 
232  $form->setValuesByPost();
234  }
getTemplateForm(ilMailTemplate $template=null)
showInsertTemplateForm(ilPropertyFormGUI $form=null)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

◆ isEditingAllowed()

ilMailTemplateGUI::isEditingAllowed ( )
private
Returns
bool

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

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

140  : bool
141  {
142  return $this->rbacsystem->checkAccess('write', $this->parentObject->getRefId());
143  }
+ Here is the caller graph for this function:

◆ populateFormWithTemplate()

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

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

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

Referenced by showEditTemplateForm().

343  {
344  $form->setValuesByArray(array(
345  'tpl_id' => $template->getTplId(),
346  'title' => $template->getTitle(),
347  'context' => $template->getContext(),
348  'lang' => $template->getLang(),
349  'm_subject' => $template->getSubject(),
350  'm_message' => $template->getMessage(),
351  ));
352  }
setValuesByArray($a_values, $a_restrict_to_value_keys=false)
Set form values from an array.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAsContextDefault()

ilMailTemplateGUI::setAsContextDefault ( )

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

References Vendor\Package\$e, ILIAS\FileDelivery\http(), isEditingAllowed(), ilUtil\sendFailure(), and showTemplates().

602  {
603  if (!$this->isEditingAllowed()) {
604  $this->error->raiseError($this->lng->txt('msg_no_perm_write'), $this->error->WARNING);
605  }
606 
607  $templateId = $this->http->request()->getQueryParams()['tpl_id'] ?? 0;
608 
609  if (!is_numeric($templateId) || $templateId < 1) {
610  ilUtil::sendFailure($this->lng->txt('mail_template_missing_id'));
611  $this->showTemplates();
612  return;
613  }
614 
615  try {
616  $template = $this->service->loadTemplateForId((int) $templateId);
617  $this->service->setAsContextDefault($template);
618  } catch (Exception $e) {
619  ilUtil::sendFailure($this->lng->txt('mail_template_missing_id'));
620  $this->showTemplates();
621  return;
622  }
623 
624  ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
625  $this->ctrl->redirect($this, 'showTemplates');
626  }
static http()
Fetches the global http state from ILIAS.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

◆ showEditTemplateForm()

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

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

References Vendor\Package\$e, $form, getTemplateForm(), ILIAS\FileDelivery\http(), populateFormWithTemplate(), ilUtil\sendFailure(), and showTemplates().

Referenced by updateTemplate().

313  : void
314  {
315  if (!($form instanceof ilPropertyFormGUI)) {
316  $templateId = $this->http->request()->getQueryParams()['tpl_id'] ?? 0;
317 
318  if (!is_numeric($templateId) || $templateId < 1) {
319  ilUtil::sendFailure($this->lng->txt('mail_template_missing_id'));
320  $this->showTemplates();
321  return;
322  }
323 
324  try {
325  $template = $this->service->loadTemplateForId((int) $templateId);
326  $form = $this->getTemplateForm($template);
327  $this->populateFormWithTemplate($form, $template);
328  } catch (Exception $e) {
329  ilUtil::sendFailure($this->lng->txt('mail_template_missing_id'));
330  $this->showTemplates();
331  return;
332  }
333  }
334 
335  $this->tpl->setContent($form->getHTML());
336  }
This class represents a property form user interface.
getTemplateForm(ilMailTemplate $template=null)
static http()
Fetches the global http state from ILIAS.
populateFormWithTemplate(ilPropertyFormGUI $form, ilMailTemplate $template)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ 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 240 of file class.ilMailTemplateGUI.php.

References $form, and getTemplateForm().

Referenced by insertTemplate().

240  : void
241  {
242  if (!($form instanceof ilPropertyFormGUI)) {
243  $form = $this->getTemplateForm();
244  }
245 
246  $this->tpl->setContent($form->getHTML());
247  }
This class represents a property form user interface.
getTemplateForm(ilMailTemplate $template=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showTemplates()

ilMailTemplateGUI::showTemplates ( )
protected

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

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

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

167  : void
168  {
170  if (count($contexts) <= 1) {
171  ilUtil::sendFailure($this->lng->txt('mail_template_no_context_available'));
172  } elseif ($this->isEditingAllowed()) {
173  $create_tpl_button = ilLinkButton::getInstance();
174  $create_tpl_button->setCaption('mail_new_template');
175  $create_tpl_button->setUrl($this->ctrl->getLinkTarget($this, 'showInsertTemplateForm'));
176  $this->toolbar->addButtonInstance($create_tpl_button);
177  }
178 
179  $tbl = new ilMailTemplateTableGUI(
180  $this,
181  'showTemplates',
182  $this->uiFactory,
183  $this->uiRenderer,
184  !$this->isEditingAllowed()
185  );
186  $tbl->setData($this->service->listAllTemplatesAsArray());
187 
188  $this->tpl->setContent($tbl->getHTML());
189  }
Class ilMailTemplateTableGUI.
static getTemplateContexts($a_id=null)
Returns an array of mail template contexts, the key of each entry matches its id. ...
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unsetAsContextDefault()

ilMailTemplateGUI::unsetAsContextDefault ( )

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

References Vendor\Package\$e, ILIAS\FileDelivery\http(), isEditingAllowed(), ilUtil\sendFailure(), and showTemplates().

571  : void
572  {
573  if (!$this->isEditingAllowed()) {
574  $this->error->raiseError($this->lng->txt('msg_no_perm_write'), $this->error->WARNING);
575  }
576 
577  $templateId = $this->http->request()->getQueryParams()['tpl_id'] ?? 0;
578 
579  if (!is_numeric($templateId) || $templateId < 1) {
580  ilUtil::sendFailure($this->lng->txt('mail_template_missing_id'));
581  $this->showTemplates();
582  return;
583  }
584 
585  try {
586  $template = $this->service->loadTemplateForId((int) $templateId);
587  $this->service->unsetAsContextDefault($template);
588  } catch (Exception $e) {
589  ilUtil::sendFailure($this->lng->txt('mail_template_missing_id'));
590  $this->showTemplates();
591  return;
592  }
593 
594  ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
595  $this->ctrl->redirect($this, 'showTemplates');
596  }
static http()
Fetches the global http state from ILIAS.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

◆ updateTemplate()

ilMailTemplateGUI::updateTemplate ( )
protected

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

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

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

Field Documentation

◆ $ctrl

ilMailTemplateGUI::$ctrl
protected

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

Referenced by __construct().

◆ $error

ilMailTemplateGUI::$error
protected

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

Referenced by __construct().

◆ $form

ilMailTemplateGUI::$form
protected

◆ $http

ilMailTemplateGUI::$http
protected

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

Referenced by __construct().

◆ $lng

ilMailTemplateGUI::$lng
protected

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

Referenced by __construct().

◆ $parentObject

ilMailTemplateGUI::$parentObject
protected

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

Referenced by __construct().

◆ $rbacsystem

ilMailTemplateGUI::$rbacsystem
protected

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

Referenced by __construct().

◆ $service

ilMailTemplateGUI::$service
protected

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

◆ $toolbar

ilMailTemplateGUI::$toolbar
protected

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

Referenced by __construct().

◆ $tpl

ilMailTemplateGUI::$tpl
protected

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

Referenced by __construct().

◆ $uiFactory

ilMailTemplateGUI::$uiFactory
protected

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

Referenced by __construct().

◆ $uiRenderer

ilMailTemplateGUI::$uiRenderer
protected

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

Referenced by __construct().


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