ILIAS  trunk Revision v12.0_alpha-1338-g8f7e531aa3c
class.ilObjFileAccessSettingsGUI.php
Go to the documentation of this file.
1<?php
2
26
40{
41 public const CMD_EDIT_SETTINGS = 'editSettings';
42 public const CMD_SHOW_PREVIEW_RENDERERS = 'showPreviewRenderers';
43 public const SUBTAB_SUFFIX_SPECIFIC_ICONS = 'suffix_specific_icons';
44 public const CMD_SAVE_SETTINGS = 'saveSettings';
45 public const CMD_VIEW = 'view';
48 private \ILIAS\components\File\Settings\Form $file_object_settings;
49 private bool $write_access;
52
58 public function __construct($a_data, int $a_id, bool $a_call_by_reference)
59 {
60 global $DIC;
61 $this->type = "facs";
62 parent::__construct($a_data, $a_id, $a_call_by_reference, false);
63 $this->write_access = $this->access->checkAccess('write', '', $this->object->getRefId());
64 $this->preview_settings = new Form(
65 new Settings(),
66 $this->write_access
67 );
68 $this->file_object_settings = new \ILIAS\components\File\Settings\Form(
69 new General(),
70 $this->write_access
71 );
72 $this->ui_factory = $DIC->ui()->factory();
73 $this->ui_renderer = $DIC->ui()->renderer();
74 $this->language = $DIC->language();
75 }
76
77 protected function checkAccess(string $permission): void
78 {
79 if (!$this->access->checkAccess($permission, '', $this->object->getRefId())) {
80 $this->ilias->raiseError(
81 $this->lng->txt('no_permission'),
82 $this->ilias->error_obj->MESSAGE
83 );
84 }
85 }
86
87 private function buildForm(): Standard
88 {
89 return $this->ui_factory->input()->container()->form()->standard(
90 $this->ctrl->getLinkTarget($this, self::CMD_SAVE_SETTINGS),
91 [
92 $this->file_object_settings->asFormSection(),
93 $this->preview_settings->asFormSection(),
94 ]
95 );
96 }
97
98 #[\Override]
99 public function executeCommand(): void
100 {
101 $this->lng->loadLanguageModule("file");
102
103 $this->prepareOutput();
104
105 $this->checkAccess('read');
106
107 switch ($this->ctrl->getNextClass($this)) {
108 case 'ilpermissiongui':
109 $this->tabs_gui->setTabActive('perm_settings');
110 $perm_gui = new ilPermissionGUI($this);
111 $this->ctrl->forwardCommand($perm_gui);
112 break;
113 case strtolower(ilObjFileIconsOverviewGUI::class):
114 $this->tabs_gui->setTabActive('file_objects');
115 $this->addFileObjectsSubTabs();
116 $this->tabs_gui->setSubTabActive(self::SUBTAB_SUFFIX_SPECIFIC_ICONS);
117 $icon_overview = new ilObjFileIconsOverviewGUI();
118 $this->ctrl->forwardCommand($icon_overview);
119 break;
120 default:
121 $cmd = $this->ctrl->getCmd(self::CMD_EDIT_SETTINGS);
122 $this->tabs_gui->setTabActive('file_objects');
123 switch ($cmd) {
124 case self::CMD_VIEW:
126 $this->checkAccess('read');
127 $this->editSettings();
128 break;
130 $this->checkAccess('write');
131 $this->saveSettings();
132 break;
133 default:
134 throw new ilException("ilObjFileAccessSettingsGUI: Command not found: $cmd");
135 }
136 break;
137 }
138 }
139
140 #[\Override]
141 public function getAdminTabs(): void
142 {
143 if ($this->rbac_system->checkAccess("read", $this->object->getRefId())) {
144 $this->tabs_gui->addTarget(
145 'file_objects',
146 $this->ctrl->getLinkTarget($this, self::CMD_EDIT_SETTINGS),
147 [self::CMD_EDIT_SETTINGS, self::CMD_VIEW]
148 );
149 }
150 if ($this->rbac_system->checkAccess('edit_permission', $this->object->getRefId())) {
151 $this->tabs_gui->addTarget(
152 "perm_settings",
153 $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm"),
154 [],
155 'ilpermissiongui'
156 );
157 }
158 }
159
160 protected function addFileObjectsSubTabs(): void
161 {
162 $this->tabs_gui->addSubTabTarget(
163 "settings",
164 $this->ctrl->getLinkTarget($this, self::CMD_EDIT_SETTINGS),
165 [self::CMD_EDIT_SETTINGS, "view"]
166 );
167 $this->tabs_gui->addSubTabTarget(
168 self::SUBTAB_SUFFIX_SPECIFIC_ICONS,
169 $this->ctrl->getLinkTargetByClass(ilObjFileIconsOverviewGUI::class, ilObjFileIconsOverviewGUI::CMD_INDEX),
170 [ilObjFileIconsOverviewGUI::CMD_INDEX, "view"]
171 );
172 }
173
174
175 protected function editSettings(): void
176 {
177 $this->addFileObjectsSubTabs();
178 $this->tabs_gui->setSubTabActive("settings");
179 $this->tpl->setContent($this->ui_renderer->render($this->buildForm()));
180 }
181
182 protected function saveSettings(): void
183 {
184 $form = $this->buildForm();
185 $form = $form->withRequest($this->http->request());
186
187 if ($form->getData() === null) {
188 $this->tpl->setContent($this->ui_renderer->render($form));
189 return;
190 }
191
192 $this->tpl->setOnScreenMessage(
193 'success',
194 $this->language->txt('settings_saved'),
195 true
196 );
197 $this->ctrl->redirect($this, self::CMD_EDIT_SETTINGS);
198 }
199}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Base class for ILIAS Exception handling.
language handling
Class ilObjFileAccessSettingsGUI.
__construct($a_data, int $a_id, bool $a_call_by_reference)
Constructor.
ILIAS components File Settings Form $file_object_settings
getAdminTabs()
administration tabs show only permissions and trash folder
Class ilObjectGUI Basic methods of all Output classes.
prepareOutput(bool $show_sub_objects=true)
This describes a standard form.
Definition: Standard.php:30
This is how the factory for UI elements looks.
Definition: Factory.php:38
An entity that renders components to a string output.
Definition: Renderer.php:31
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Class ilObjForumAdministration.
global $DIC
Definition: shib_login.php:26