ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilDclTableViewEditFormGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 {
24  protected ?ilDclTable $table = null;
26 
27  public function __construct(ilDclTableViewEditGUI $parent_gui, ilDclTableView $tableview, ?ilDclTable $table = null)
28  {
29  global $DIC;
30  $lng = $DIC['lng'];
31  $ilCtrl = $DIC['ilCtrl'];
33  $this->lng = $lng;
34  $this->ctrl = $ilCtrl;
35  $this->parent_gui = $parent_gui;
36  $this->tableview = $tableview;
37  $this->table = $table;
38  $this->ctrl->saveParameterByClass('ilDclTableViewGUI', 'tableview_id');
39  $this->initForm();
40  }
41 
42  protected function initForm(): void
43  {
44  global $DIC;
45  $rbacreview = $DIC['rbacreview'];
46 
47  $this->setTitle($this->tableview->getId() ? $this->lng->txt('dcl_view_settings') : $this->lng->txt('dcl_tableview_add'));
48 
49  //title
50  $item = new ilTextInputGUI($this->lng->txt('title'), 'title');
51  $item->setValue($this->tableview->getTitle());
52  $item->setRequired(true);
53  $this->addItem($item);
54 
55  //description
56  $item = new ilTextInputGUI($this->lng->txt('description'), 'description');
57  $item->setValue($this->tableview->getDescription());
58  $this->addItem($item);
59 
60  //roles
61  $checkbox_group_input_gui = new ilCheckboxGroupInputGUI($this->lng->txt('roles'), 'roles');
62 
63  $ref_id = $this->http->wrapper()->query()->retrieve('ref_id', $this->refinery->kindlyTo()->int());
64  foreach ($rbacreview->getParentRoleIds($ref_id) as $role_array) {
65  $option = new ilCheckboxOption(ilObjRole::_getTranslation($role_array['title']));
66  $option->setValue((string) $role_array['obj_id']);
67  $checkbox_group_input_gui->addOption($option);
68  }
69 
70  $checkbox_group_input_gui->setValue($this->tableview->getRoles());
71  $this->addItem($checkbox_group_input_gui);
72 
73  $this->setFormAction($this->ctrl->getFormAction($this->parent_gui));
74  if ($this->tableview->getId()) {
75  $this->addCommandButton('update', $this->lng->txt('save'));
76  } else {
77  $this->addCommandButton('create', $this->lng->txt('create'));
78  }
79  $this->addCommandButton('cancel', $this->lng->txt('cancel'));
80  }
81 
82  public function updateTableView(): void
83  {
84  $this->tableview->setTitle($this->getInput('title'));
85  $this->tableview->setDescription($this->getInput('description'));
86  $this->tableview->setRoles((array) $this->getInput('roles'));
87  $this->tableview->update();
88 
89  $this->global_tpl->setOnScreenMessage('success', $this->lng->txt('dcl_msg_tableview_updated'), true);
90  }
91 
92  public function createTableView(): void
93  {
94  $this->tableview->setTitle($this->getInput('title'));
95  $this->tableview->setDescription($this->getInput('description'));
96  $this->tableview->setRoles((array) $this->getInput('roles'));
97  $this->tableview->setTableId($this->table->getId());
98  $this->tableview->setOrder($this->table->getNewTableviewOrder());
99  $this->tableview->create();
100 
101  $this->ctrl->setParameterByClass('ilDclTableViewGUI', 'tableview_id', $this->tableview->getId());
102 
103  $this->global_tpl->setOnScreenMessage('success', $this->lng->txt('dcl_msg_tableview_created'), true);
104  }
105 }
ilDclTableViewEditGUI: ilDclDetailedViewDefinitionGUI ilDclTableViewEditGUI: ilDclCreateViewDefiniti...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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-...
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.
$ref_id
Definition: ltiauth.php:67
__construct(VocabulariesInterface $vocabularies)
setFormAction(string $a_formaction)
static _getTranslation(string $a_role_title)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
__construct(ilDclTableViewEditGUI $parent_gui, ilDclTableView $tableview, ?ilDclTable $table=null)