ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilExtIdGUI.php
Go to the documentation of this file.
1 <?php
18 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
19 
26 {
27  protected ilTabsGUI $tabs_gui;
29  protected ilCtrl $ctrl;
32  protected ilLanguage $lng;
37 
38  public function __construct(ilObjectGUI $parent_gui)
39  {
40  global $DIC;
41  $main_tpl = $DIC->ui()->mainTemplate();
42 
43  $this->tpl = $DIC->ui()->mainTemplate();
44  $this->ctrl = $DIC->ctrl();
45  $this->parent_gui = $parent_gui;
46  $this->parent_object = $parent_gui->getObject();
47  $this->tabs_gui = $DIC->tabs();
48  $this->toolbar = $DIC->toolbar();
49  $this->lng = $DIC->language();
50  $this->ilAccess = $DIC->access();
51  $this->lng->loadLanguageModule('user');
52  if (!$this->ilAccess->checkaccess("write", "", $this->parent_gui->getObject()->getRefId())) {
53  $main_tpl->setOnScreenMessage('failure', $this->lng->txt("permission_denied"), true);
54  }
55  }
56 
57  public function executeCommand(): bool
58  {
59  $cmd = $this->ctrl->getCmd();
60 
61  switch ($cmd) {
62  case 'edit':
63  $this->edit();
64  break;
65  case 'update':
66  $this->update();
67  break;
68  }
69 
70  return true;
71  }
72 
73  public function edit(): void
74  {
75  $form = $this->initForm();
76  $this->tpl->setContent($form->getHTML());
77  }
78 
79  public function initForm(): ilPropertyFormGUI
80  {
81  $form = new ilPropertyFormGUI();
82  $input = new ilTextInputGUI($this->lng->txt("ext_id"), "ext_id");
83  $input->setValue($this->parent_object->getImportId());
84  $form->addItem($input);
85  $form->setFormAction($this->ctrl->getFormAction($this));
86  $form->addCommandButton("update", $this->lng->txt("save"));
87 
88  return $form;
89  }
90 
91  public function update(): void
92  {
93  $form = $this->initForm();
94  $form->setValuesByPost();
95  if ($form->checkInput()) {
96  $this->parent_object->setImportId($form->getItemByPostVar("ext_id")->getValue());
97  $this->parent_object->update();
98  $this->tpl->setOnScreenMessage('success', $this->lng->txt("ext_id_updated"), true);
99  $this->ctrl->redirect($this, "edit");
100  } else {
101  $this->tpl->setContent($form->getHTML());
102  }
103  }
104 }
ilAccessHandler $ilAccess
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getItemByPostVar(string $a_post_var)
ilToolbarGUI $toolbar
ilObjCategory $object
ilObjectGUI $parent_gui
ilPropertyFormGUI $form
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(ilObjectGUI $parent_gui)
ilTabsGUI $tabs_gui
ilGlobalTemplateInterface $tpl
ilObject $parent_object
setFormAction(string $a_formaction)
Class ilObjectGUI Basic methods of all Output classes.
ilLanguage $lng
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...