ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilObjFileAccessSettingsGUI.php
Go to the documentation of this file.
1 <?php
22 
36 {
37  public const CMD_EDIT_SETTINGS = 'editSettings';
38  public const CMD_SHOW_PREVIEW_RENDERERS = 'showPreviewRenderers';
39  public const SUBTAB_SUFFIX_SPECIFIC_ICONS = 'suffix_specific_icons';
40  public const CMD_SAVE_SETTINGS = 'saveSettings';
41  public const CMD_VIEW = 'view';
43  private \ILIAS\Modules\File\Preview\Form $preview_settings;
44  private \ILIAS\Modules\File\Settings\Form $file_object_settings;
45  protected \ILIAS\UI\Factory $ui_factory;
46  protected \ILIAS\UI\Renderer $ui_renderer;
47  protected Services $http;
48 
54  public function __construct($a_data, int $a_id, bool $a_call_by_reference)
55  {
56  global $DIC;
57  $this->type = "facs";
58  parent::__construct($a_data, $a_id, $a_call_by_reference, false);
59  $this->preview_settings = new ILIAS\Modules\File\Preview\Form(new Settings());
60  $this->file_object_settings = new \ILIAS\Modules\File\Settings\Form(new General());
61  $this->http = $DIC->http();
62  $this->ui_factory = $DIC->ui()->factory();
63  $this->ui_renderer = $DIC->ui()->renderer();
64  $this->language = $DIC->language();
65  }
66 
67  protected function checkAccess(string $permission): void
68  {
69  if (!$this->access->checkAccess($permission, '', $this->object->getRefId())) {
70  $this->ilias->raiseError(
71  $this->lng->txt('no_permission'),
72  $this->ilias->error_obj->MESSAGE
73  );
74  }
75  }
76 
77  private function buildForm(): \ILIAS\UI\Component\Input\Container\Form\Standard
78  {
79  return $this->ui_factory->input()->container()->form()->standard(
80  $this->ctrl->getLinkTarget($this, self::CMD_SAVE_SETTINGS),
81  [
82  $this->file_object_settings->asFormSection(),
83  $this->preview_settings->asFormSection(),
84  ]
85  );
86  }
87 
88  public function executeCommand(): void
89  {
90  $this->lng->loadLanguageModule("file");
91 
92  $this->prepareOutput();
93 
94  $this->checkAccess('read');
95 
96  switch ($this->ctrl->getNextClass($this)) {
97  case 'ilpermissiongui':
98  $this->tabs_gui->setTabActive('perm_settings');
99  $perm_gui = new ilPermissionGUI($this);
100  $this->ctrl->forwardCommand($perm_gui);
101  break;
102  case strtolower(ilObjFileIconsOverviewGUI::class):
103  $this->tabs_gui->setTabActive('file_objects');
104  $this->addFileObjectsSubTabs();
105  $this->tabs_gui->setSubTabActive(self::SUBTAB_SUFFIX_SPECIFIC_ICONS);
106  $icon_overview = new ilObjFileIconsOverviewGUI();
107  $this->ctrl->forwardCommand($icon_overview);
108  break;
109  default:
110  $cmd = $this->ctrl->getCmd(self::CMD_EDIT_SETTINGS);
111  $this->tabs_gui->setTabActive('file_objects');
112  switch ($cmd) {
113  case self::CMD_VIEW:
114  case self::CMD_EDIT_SETTINGS:
115  $this->checkAccess('read');
116  $this->editSettings();
117  break;
118  case self::CMD_SAVE_SETTINGS:
119  $this->checkAccess('write');
120  $this->saveSettings();
121  break;
122  default:
123  throw new ilException("ilObjFileAccessSettingsGUI: Command not found: $cmd");
124  }
125  break;
126  }
127  }
128 
129  public function getAdminTabs(): void
130  {
131  if ($this->rbac_system->checkAccess("visible,read", $this->object->getRefId())) {
132  $this->tabs_gui->addTarget(
133  'file_objects',
134  $this->ctrl->getLinkTarget($this, self::CMD_EDIT_SETTINGS),
135  [self::CMD_EDIT_SETTINGS, self::CMD_VIEW]
136  );
137  }
138  if ($this->rbac_system->checkAccess('edit_permission', $this->object->getRefId())) {
139  $this->tabs_gui->addTarget(
140  "perm_settings",
141  $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm"),
142  [],
143  'ilpermissiongui'
144  );
145  }
146  }
147 
148  protected function addFileObjectsSubTabs(): void
149  {
150  $this->tabs_gui->addSubTabTarget(
151  "settings",
152  $this->ctrl->getLinkTarget($this, self::CMD_EDIT_SETTINGS),
153  array(self::CMD_EDIT_SETTINGS, "view")
154  );
155  $this->tabs_gui->addSubTabTarget(
156  self::SUBTAB_SUFFIX_SPECIFIC_ICONS,
157  $this->ctrl->getLinkTargetByClass(ilObjFileIconsOverviewGUI::class, ilObjFileIconsOverviewGUI::CMD_INDEX),
158  array(ilObjFileIconsOverviewGUI::CMD_INDEX, "view")
159  );
160  }
161 
162 
163  protected function editSettings(): void
164  {
165  $this->addFileObjectsSubTabs();
166  $this->tabs_gui->setSubTabActive("settings");
167  $form = $this->buildForm();
168  $this->tpl->setContent($this->ui_renderer->render($this->buildForm()));
169  }
170 
171  protected function saveSettings(): void
172  {
173  $form = $this->buildForm();
174  $form = $form->withRequest($this->http->request());
175 
176  if ($form->getData() === null) {
177  $this->tpl->setContent($this->ui_renderer->render($form));
178  return;
179  }
180 
181  $this->tpl->setOnScreenMessage(
182  'success',
183  $this->language->txt('settings_saved'),
184  true
185  );
186  $this->ctrl->redirect($this, self::CMD_EDIT_SETTINGS);
187  }
188 }
prepareOutput(bool $show_sub_objects=true)
Class ChatMainBarProvider .
__construct($a_data, int $a_id, bool $a_call_by_reference)
Constructor.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS Modules File Preview Form $preview_settings
Class ilObjFileAccessSettingsGUI.
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.
__construct(VocabulariesInterface $vocabularies)
Class ilObjectGUI Basic methods of all Output classes.
ILIAS Modules File Settings Form $file_object_settings
header include for all ilias files.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.