ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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
38 protected ilTabsGUI $tabs;
41 protected ilCtrl $ctrl;
44 protected Factory $refinery;
46
51 public function __construct(int $id = 0, int $id_type = self::REPOSITORY_NODE_ID, int $parent_node_id = 0)
52 {
53 global $DIC;
54
56 parent::__construct($id, $id_type, $parent_node_id);
57
58 $this->tabs = $DIC['ilTabs'];
59 $this->lng = $DIC->language();
60 $this->lng->loadLanguageModule('adn');
61 $this->lng->loadLanguageModule('irss');
62 $this->ctrl = $DIC['ilCtrl'];
63 $this->tpl = $DIC['tpl'];
64 $this->tree = $DIC['tree'];
65 $this->settings = $DIC['ilSetting'];
66 $this->error_handling = $DIC["ilErr"];
67 $this->ref_id = $this->request_wrapper->retrieve('ref_id', $DIC->refinery()->kindlyTo()->int());
68 $this->refinery = $DIC->refinery();
69 $this->file_service_settings = $DIC->fileServiceSettings();
70 }
71
72 public function getType(): string
73 {
75 }
76
77 protected function checkPermissionOrFail(string $str): void
78 {
79 if (!$this->hasUserPermissionTo($str)) {
80 $this->error_handling->raiseError(
81 $this->lng->txt('no_permission'),
82 $this->error->MESSAGE
83 );
84 }
85 }
86
87 protected function hasUserPermissionTo(string $str): bool
88 {
89 return $this->access->checkAccess($str, '', $this->ref_id);
90 }
91
96 #[\Override]
97 public function executeCommand(): void
98 {
99 $this->lng->loadLanguageModule("fils");
100
101 $next_class = $this->ctrl->getNextClass($this);
102 $cmd = $this->ctrl->getCmd();
103
104 $this->prepareOutput();
105 $this->checkPermissionOrFail('read');
106
107 switch ($next_class) {
108 case strtolower(ilPermissionGUI::class):
109 $this->tabs_gui->activateTab(self::TAB_PERMISSIONS);
110 $perm_gui = new ilPermissionGUI($this);
111 $this->ctrl->forwardCommand($perm_gui);
112 break;
113 case strtolower(ilResourceOverviewGUI::class):
114 $this->tabs_gui->activateTab(self::TAB_OVERVIEW);
115 $overview = new ilResourceOverviewGUI();
116 $this->ctrl->forwardCommand($overview);
117 break;
118 case strtolower(ilUploadLimitsOverviewGUI::class):
119 $this->tabs_gui->activateTab(self::TAB_UPLOAD_LIMITS);
120 $limits_gui = new ilUploadLimitsOverviewGUI();
121 $this->ctrl->forwardCommand($limits_gui);
122 break;
123 default:
124 if (!$cmd || $cmd === 'view') {
126 }
127 $this->$cmd();
128 break;
129 }
130 }
131
135 #[\Override]
136 public function getAdminTabs(): void
137 {
138 // General Settings for File-Services
139 if ($this->rbac_system->checkAccess(
140 "visible,read",
141 $this->object->getRefId()
142 )
143 ) {
144 $this->tabs_gui->addTab(
145 self::TAB_SETTINGS,
146 $this->lng->txt(self::TAB_SETTINGS),
147 $this->ctrl->getLinkTarget($this, self::CMD_EDIT_SETTINGS)
148 );
149 }
150 // Resource-Overview
151 if ($this->rbac_system->checkAccess(
152 "visible,read",
153 $this->object->getRefId()
154 )
155 ) {
156 $this->tabs_gui->addTab(
157 self::TAB_OVERVIEW,
158 $this->lng->txt(self::TAB_OVERVIEW),
159 $this->ctrl->getLinkTargetByClass(ilResourceOverviewGUI::class),
160 );
161 }
162 // Upload-Limit
163 if ($this->rbac_system->checkAccess(
164 "visible,read",
165 $this->object->getRefId()
166 )
167 ) {
168 $this->tabs_gui->addTab(
169 self::TAB_UPLOAD_LIMITS,
170 $this->lng->txt(self::TAB_UPLOAD_LIMITS),
171 $this->ctrl->getLinkTargetByClass(ilUploadLimitsOverviewGUI::class),
172 );
173 }
174 // Permissions-tab
175 if ($this->rbac_system->checkAccess(
176 'edit_permission',
177 $this->object->getRefId()
178 )
179 ) {
180 $this->tabs_gui->addTab(
181 self::TAB_PERMISSIONS,
182 $this->lng->txt(self::TAB_PERMISSIONS),
183 $this->ctrl->getLinkTargetByClass(ilPermissionGUI::class, "perm")
184 );
185 }
186 }
187
188 #[\Override]
189 public function setTitleAndDescription(): void
190 {
191 parent::setTitleAndDescription();
192 $this->tpl->setDescription($this->object->getDescription());
193 }
194
196 {
197 $permission_to_write = $this->hasUserPermissionTo('write');
198
199 $form = new ilPropertyFormGUI();
200 $form->setFormAction($this->ctrl->getFormAction($this));
201 $form->setTitle($this->lng->txt(self::TAB_SETTINGS));
202
203 // default positive list
204 $ne = new ilNonEditableValueGUI($this->lng->txt("file_suffix_default_positive"), "");
205 $ne->setValue(implode(", ", $this->file_service_settings->getDefaultWhitelist()));
206 $ne->setInfo($this->lng->txt("file_suffix_default_positive_info"));
207 $form->addItem($ne);
208
209 // file suffix custom negative list
210 $ta = new ilTextAreaInputGUI(
211 $this->lng->txt(
212 "file_suffix_custom_negative"
213 ),
214 "suffix_repl_additional"
215 );
216 $ta->setInfo($this->lng->txt("file_suffix_custom_negative_info"));
217 $ta->setRows(5);
218 $ta->setDisabled(!$permission_to_write);
219 $form->addItem($ta);
220
221 // file suffix custom positive list
222 $ta = new ilTextAreaInputGUI(
223 $this->lng->txt(
224 "file_suffix_custom_positive"
225 ),
226 "suffix_custom_white_list"
227 );
228 $ta->setInfo($this->lng->txt("file_suffix_custom_positive_info"));
229 $ta->setRows(5);
230 $ta->setDisabled(!$permission_to_write);
231 $form->addItem($ta);
232
233 // resulting overall positive list
234 $ne = new ilNonEditableValueGUI($this->lng->txt("file_suffix_overall_positive"), "");
235 $ne->setValue(implode(", ", $this->file_service_settings->getWhiteListedSuffixes()));
236 $ne->setInfo($this->lng->txt("file_suffix_overall_positive_info"));
237 $form->addItem($ne);
238
239 // explicit negative list
240 $ta = new ilTextAreaInputGUI(
241 $this->lng->txt("file_suffix_custom_expl_negative"),
242 "suffix_custom_expl_black"
243 );
244 $ta->setInfo($this->lng->txt("file_suffix_custom_expl_negative_info"));
245 $ta->setRows(5);
246 $ta->setDisabled(!$permission_to_write);
247 $form->addItem($ta);
248
249 // command buttons
250 if ($permission_to_write) {
251 $form->addCommandButton('saveSettings', $this->lng->txt('save'));
252 $form->addCommandButton('view', $this->lng->txt('cancel'));
253 }
254
255 return $form;
256 }
257
258 protected function editSettings(): void
259 {
260 $this->tabs_gui->setTabActive(self::TAB_SETTINGS);
261
262 $this->checkPermissionOrFail("visible,read");
263
264 // get form
265 $form = $this->initSettingsForm();
266
267 // set current values
268 $val = [];
269 $val["suffix_repl_additional"] = implode(", ", $this->file_service_settings->getWhiteListNegative());
270 $val["suffix_custom_white_list"] = implode(", ", $this->file_service_settings->getWhiteListPositive());
271 $val["suffix_custom_expl_black"] = implode(", ", $this->file_service_settings->getProhibited());
272 $form->setValuesByArray($val);
273
274 // set content
275 $this->tpl->setContent($form->getHTML());
276 }
277
278 protected function saveSettings(): void
279 {
280 $this->checkPermissionOrFail("write");
281
282 // get form
283 $form = $this->initSettingsForm();
284 if ($form->checkInput()) {
285 $trafo = (fn(string $id): ?string => $this->post_wrapper->has($id)
286 ? $this->post_wrapper->retrieve($id, $this->refinery->to()->string())
287 : null);
288
289
290 $this->settings->set("suffix_repl_additional", $trafo("suffix_repl_additional"));
291 $this->settings->set("suffix_custom_white_list", $trafo("suffix_custom_white_list"));
292 $this->settings->set("suffix_custom_expl_black", $trafo("suffix_custom_expl_black"));
293
294 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
295 $this->ctrl->redirect($this, self::CMD_EDIT_SETTINGS);
296 } else {
297 $form->setValuesByPost();
298 $this->tpl->setContent($form->getHTML());
299 }
300 }
301}
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