ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilExtIdGUI.php
Go to the documentation of this file.
1 <?php
2 
19 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
20 
27 {
28  protected ilTabsGUI $tabs_gui;
30  protected ilCtrl $ctrl;
33  protected ilLanguage $lng;
38 
39  public function __construct(ilObjectGUI $parent_gui)
40  {
41  global $DIC;
42  $main_tpl = $DIC->ui()->mainTemplate();
43 
44  $this->tpl = $DIC->ui()->mainTemplate();
45  $this->ctrl = $DIC->ctrl();
46  $this->parent_gui = $parent_gui;
47  $this->parent_object = $parent_gui->getObject();
48  $this->tabs_gui = $DIC->tabs();
49  $this->toolbar = $DIC->toolbar();
50  $this->lng = $DIC->language();
51  $this->ilAccess = $DIC->access();
52  $this->lng->loadLanguageModule('user');
53  if (!$this->ilAccess->checkaccess("write", "", $this->parent_gui->getObject()->getRefId())) {
54  $main_tpl->setOnScreenMessage('failure', $this->lng->txt("permission_denied"), true);
55  }
56  }
57 
58  public function executeCommand(): bool
59  {
60  $cmd = $this->ctrl->getCmd();
61 
62  switch ($cmd) {
63  case 'edit':
64  $this->edit();
65  break;
66  case 'update':
67  $this->update();
68  break;
69  }
70 
71  return true;
72  }
73 
74  public function edit(): void
75  {
76  $form = $this->initForm();
77  $this->tpl->setContent($form->getHTML());
78  }
79 
80  public function initForm(): ilPropertyFormGUI
81  {
82  $form = new ilPropertyFormGUI();
83  $input = new ilTextInputGUI($this->lng->txt("ext_id"), "ext_id");
84  $input->setValue($this->parent_object->getImportId());
85  $form->addItem($input);
86  $form->setFormAction($this->ctrl->getFormAction($this));
87  $form->addCommandButton("update", $this->lng->txt("save"));
88 
89  return $form;
90  }
91 
92  public function update(): void
93  {
94  $form = $this->initForm();
95  $form->setValuesByPost();
96  if ($form->checkInput()) {
97  $this->parent_object->setImportId($form->getItemByPostVar("ext_id")->getValue());
98  $this->parent_object->update();
99  $this->tpl->setOnScreenMessage('success', $this->lng->txt("ext_id_updated"), true);
100  $this->ctrl->redirect($this, "edit");
101  } else {
102  $this->tpl->setContent($form->getHTML());
103  }
104  }
105 }
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
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.
global $DIC
Definition: shib_login.php:25
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...