ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilObjFileServicesGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
23
31{
32 public const CMD_EDIT_SETTINGS = 'editSettings';
33 protected const TAB_PERMISSIONS = 'perm_settings';
34 protected const TAB_SETTINGS = 'settings';
35 protected const TAB_OVERVIEW = 'resource_overview';
36 protected const TAB_UPLOAD_LIMITS = 'upload_limits';
37 protected const TAB_WOPI = 'wopi_settings';
38
39 protected ilTabsGUI $tabs;
42 protected ilCtrl $ctrl;
45 protected Factory $refinery;
47
52 public function __construct(int $id = 0, int $id_type = self::REPOSITORY_NODE_ID, int $parent_node_id = 0)
53 {
54 global $DIC;
55
57 parent::__construct($id, $id_type, $parent_node_id);
58
59 $this->tabs = $DIC['ilTabs'];
60 $this->lng = $DIC->language();
61 $this->lng->loadLanguageModule('adn');
62 $this->lng->loadLanguageModule('irss');
63 $this->lng->loadLanguageModule('wopi');
64 $this->ctrl = $DIC['ilCtrl'];
65 $this->tpl = $DIC['tpl'];
66 $this->tree = $DIC['tree'];
67 $this->settings = $DIC['ilSetting'];
68 $this->error_handling = $DIC["ilErr"];
69 $this->ref_id = $this->request_wrapper->retrieve('ref_id', $DIC->refinery()->kindlyTo()->int());
70 $this->refinery = $DIC->refinery();
71 $this->file_service_settings = $DIC->fileServiceSettings();
72 }
73
74 public function getType(): string
75 {
77 }
78
79 protected function checkPermissionOrFail(string $str): void
80 {
81 if (!$this->hasUserPermissionTo($str)) {
82 $this->error_handling->raiseError(
83 $this->lng->txt('no_permission'),
84 $this->error->MESSAGE
85 );
86 }
87 }
88
89 protected function hasUserPermissionTo(string $str): bool
90 {
91 return $this->access->checkAccess($str, '', $this->ref_id);
92 }
93
98 #[\Override]
99 public function executeCommand(): void
100 {
101 $this->lng->loadLanguageModule("fils");
102
103 $next_class = $this->ctrl->getNextClass($this);
104 $cmd = $this->ctrl->getCmd();
105
106 $this->prepareOutput();
107 $this->checkPermissionOrFail('read');
108
109 switch ($next_class) {
110 case strtolower(ilPermissionGUI::class):
111 $this->tabs_gui->activateTab(self::TAB_PERMISSIONS);
112 $perm_gui = new ilPermissionGUI($this);
113 $this->ctrl->forwardCommand($perm_gui);
114 break;
115 case strtolower(ilResourceOverviewGUI::class):
116 $this->tabs_gui->activateTab(self::TAB_OVERVIEW);
117 $overview = new ilResourceOverviewGUI();
118 $this->ctrl->forwardCommand($overview);
119 break;
120 case strtolower(ilUploadLimitsOverviewGUI::class):
121 $this->tabs_gui->activateTab(self::TAB_UPLOAD_LIMITS);
122 $limits_gui = new ilUploadLimitsOverviewGUI();
123 $this->ctrl->forwardCommand($limits_gui);
124 break;
125 case strtolower(ilWOPIAdministrationGUI::class):
126 $this->tabs_gui->activateTab(self::TAB_WOPI);
127 $wopi_gui = new ilWOPIAdministrationGUI();
128 $this->ctrl->forwardCommand($wopi_gui);
129 break;
130 default:
131 if (!$cmd || $cmd === 'view') {
133 }
134 $this->$cmd();
135 break;
136 }
137 }
138
142 #[\Override]
143 public function getAdminTabs(): void
144 {
145 // General Settings for File-Services
146 if ($this->rbac_system->checkAccess(
147 "read",
148 $this->object->getRefId()
149 )
150 ) {
151 $this->tabs_gui->addTab(
152 self::TAB_SETTINGS,
153 $this->lng->txt(self::TAB_SETTINGS),
154 $this->ctrl->getLinkTarget($this, self::CMD_EDIT_SETTINGS)
155 );
156 }
157 // Resource-Overview
158 if ($this->rbac_system->checkAccess(
159 "read",
160 $this->object->getRefId()
161 )
162 ) {
163 $this->tabs_gui->addTab(
164 self::TAB_OVERVIEW,
165 $this->lng->txt(self::TAB_OVERVIEW),
166 $this->ctrl->getLinkTargetByClass(ilResourceOverviewGUI::class),
167 );
168 }
169 // Upload-Limit
170 if ($this->rbac_system->checkAccess(
171 "read",
172 $this->object->getRefId()
173 )
174 ) {
175 $this->tabs_gui->addTab(
176 self::TAB_UPLOAD_LIMITS,
177 $this->lng->txt(self::TAB_UPLOAD_LIMITS),
178 $this->ctrl->getLinkTargetByClass(ilUploadLimitsOverviewGUI::class),
179 );
180 }
181 // WOPI
182 if ($this->rbac_system->checkAccess(
183 "read",
184 $this->object->getRefId()
185 )
186 ) {
187 $this->tabs_gui->addTab(
188 self::TAB_WOPI,
189 $this->lng->txt(self::TAB_WOPI),
190 $this->ctrl->getLinkTargetByClass(ilWOPIAdministrationGUI::class),
191 );
192 }
193
194 // Permissions-tab
195 if ($this->rbac_system->checkAccess(
196 'edit_permission',
197 $this->object->getRefId()
198 )
199 ) {
200 $this->tabs_gui->addTab(
201 self::TAB_PERMISSIONS,
202 $this->lng->txt(self::TAB_PERMISSIONS),
203 $this->ctrl->getLinkTargetByClass(ilPermissionGUI::class, "perm")
204 );
205 }
206 }
207
208 #[\Override]
209 public function setTitleAndDescription(): void
210 {
211 parent::setTitleAndDescription();
212 $this->tpl->setDescription($this->object->getDescription());
213 }
214
216 {
217 $permission_to_write = $this->hasUserPermissionTo('write');
218
219 $form = new ilPropertyFormGUI();
220 $form->setFormAction($this->ctrl->getFormAction($this));
221 $form->setTitle($this->lng->txt(self::TAB_SETTINGS));
222
223 // default positive list
224 $ne = new ilNonEditableValueGUI($this->lng->txt("file_suffix_default_positive"), "");
225 $ne->setValue(implode(", ", $this->file_service_settings->getDefaultWhitelist()));
226 $ne->setInfo($this->lng->txt("file_suffix_default_positive_info"));
227 $form->addItem($ne);
228
229 // file suffix custom negative list
230 $ta = new ilTextAreaInputGUI(
231 $this->lng->txt(
232 "file_suffix_custom_negative"
233 ),
234 "suffix_repl_additional"
235 );
236 $ta->setInfo($this->lng->txt("file_suffix_custom_negative_info"));
237 $ta->setRows(5);
238 $ta->setDisabled(!$permission_to_write);
239 $form->addItem($ta);
240
241 // file suffix custom positive list
242 $ta = new ilTextAreaInputGUI(
243 $this->lng->txt(
244 "file_suffix_custom_positive"
245 ),
246 "suffix_custom_white_list"
247 );
248 $ta->setInfo($this->lng->txt("file_suffix_custom_positive_info"));
249 $ta->setRows(5);
250 $ta->setDisabled(!$permission_to_write);
251 $form->addItem($ta);
252
253 // resulting overall positive list
254 $ne = new ilNonEditableValueGUI($this->lng->txt("file_suffix_overall_positive"), "");
255 $ne->setValue(implode(", ", $this->file_service_settings->getWhiteListedSuffixes()));
256 $ne->setInfo($this->lng->txt("file_suffix_overall_positive_info"));
257 $form->addItem($ne);
258
259 // explicit negative list
260 $ta = new ilTextAreaInputGUI(
261 $this->lng->txt("file_suffix_custom_expl_negative"),
262 "suffix_custom_expl_black"
263 );
264 $ta->setInfo($this->lng->txt("file_suffix_custom_expl_negative_info"));
265 $ta->setRows(5);
266 $ta->setDisabled(!$permission_to_write);
267 $form->addItem($ta);
268
269 // command buttons
270 if ($permission_to_write) {
271 $form->addCommandButton('saveSettings', $this->lng->txt('save'));
272 $form->addCommandButton('view', $this->lng->txt('cancel'));
273 }
274
275 return $form;
276 }
277
278 protected function editSettings(): void
279 {
280 $this->tabs_gui->setTabActive(self::TAB_SETTINGS);
281
282 $this->checkPermissionOrFail("read");
283
284 // get form
285 $form = $this->initSettingsForm();
286
287 // set current values
288 $val = [];
289 $val["suffix_repl_additional"] = implode(", ", $this->file_service_settings->getWhiteListNegative());
290 $val["suffix_custom_white_list"] = implode(", ", $this->file_service_settings->getWhiteListPositive());
291 $val["suffix_custom_expl_black"] = implode(", ", $this->file_service_settings->getProhibited());
292 $form->setValuesByArray($val);
293
294 // set content
295 $this->tpl->setContent($form->getHTML());
296 }
297
298 protected function saveSettings(): void
299 {
300 $this->checkPermissionOrFail("write");
301
302 // get form
303 $form = $this->initSettingsForm();
304 if ($form->checkInput()) {
305 $trafo = (fn(string $id): ?string => $this->post_wrapper->has($id)
306 ? $this->post_wrapper->retrieve($id, $this->refinery->to()->string())
307 : null);
308
309
310 $this->settings->set("suffix_repl_additional", $trafo("suffix_repl_additional"));
311 $this->settings->set("suffix_custom_white_list", $trafo("suffix_custom_white_list"));
312 $this->settings->set("suffix_custom_expl_black", $trafo("suffix_custom_expl_black"));
313
314 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
315 $this->ctrl->redirect($this, self::CMD_EDIT_SETTINGS);
316 } else {
317 $form->setValuesByPost();
318 $this->tpl->setContent($form->getHTML());
319 }
320 }
321}
Builds data types.
Definition: Factory.php:36
Class ilCtrl provides processing control methods.
Error Handling & global info handling.
language handling
This class represents a non editable value in a property form.
Class ilObjFileServicesGUI.
executeCommand()
Execute command @access public.
ilGlobalTemplateInterface $tpl
ilFileServicesSettings $file_service_settings
__construct(int $id=0, int $id_type=self::REPOSITORY_NODE_ID, int $parent_node_id=0)
Constructor @access public.
getType()
Functions that must be overwritten.
New implementation of ilObjectGUI.
prepareOutput(bool $show_sub_objects=true)
This class represents a property form user interface.
ILIAS Setting Class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text area property in a property form.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26