ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjFileAccessSettingsGUI.php
Go to the documentation of this file.
1<?php
2
27
41{
42 public const CMD_EDIT_SETTINGS = 'editSettings';
43 public const CMD_SHOW_PREVIEW_RENDERERS = 'showPreviewRenderers';
44 public const SUBTAB_SUFFIX_SPECIFIC_ICONS = 'suffix_specific_icons';
45 public const CMD_SAVE_SETTINGS = 'saveSettings';
46 public const CMD_VIEW = 'view';
49 private \ILIAS\components\File\Settings\Form $file_object_settings;
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->preview_settings = new Form(new Settings());
64 $this->file_object_settings = new \ILIAS\components\File\Settings\Form(new General());
65 $this->ui_factory = $DIC->ui()->factory();
66 $this->ui_renderer = $DIC->ui()->renderer();
67 $this->language = $DIC->language();
68 }
69
70 protected function checkAccess(string $permission): void
71 {
72 if (!$this->access->checkAccess($permission, '', $this->object->getRefId())) {
73 $this->ilias->raiseError(
74 $this->lng->txt('no_permission'),
75 $this->ilias->error_obj->MESSAGE
76 );
77 }
78 }
79
80 private function buildForm(): Standard
81 {
82 return $this->ui_factory->input()->container()->form()->standard(
83 $this->ctrl->getLinkTarget($this, self::CMD_SAVE_SETTINGS),
84 [
85 $this->file_object_settings->asFormSection(),
86 $this->preview_settings->asFormSection(),
87 ]
88 );
89 }
90
91 #[\Override]
92 public function executeCommand(): void
93 {
94 $this->lng->loadLanguageModule("file");
95
96 $this->prepareOutput();
97
98 $this->checkAccess('read');
99
100 switch ($this->ctrl->getNextClass($this)) {
101 case 'ilpermissiongui':
102 $this->tabs_gui->setTabActive('perm_settings');
103 $perm_gui = new ilPermissionGUI($this);
104 $this->ctrl->forwardCommand($perm_gui);
105 break;
106 case strtolower(ilObjFileIconsOverviewGUI::class):
107 $this->tabs_gui->setTabActive('file_objects');
108 $this->addFileObjectsSubTabs();
109 $this->tabs_gui->setSubTabActive(self::SUBTAB_SUFFIX_SPECIFIC_ICONS);
110 $icon_overview = new ilObjFileIconsOverviewGUI();
111 $this->ctrl->forwardCommand($icon_overview);
112 break;
113 default:
114 $cmd = $this->ctrl->getCmd(self::CMD_EDIT_SETTINGS);
115 $this->tabs_gui->setTabActive('file_objects');
116 switch ($cmd) {
117 case self::CMD_VIEW:
119 $this->checkAccess('read');
120 $this->editSettings();
121 break;
123 $this->checkAccess('write');
124 $this->saveSettings();
125 break;
126 default:
127 throw new ilException("ilObjFileAccessSettingsGUI: Command not found: $cmd");
128 }
129 break;
130 }
131 }
132
133 #[\Override]
134 public function getAdminTabs(): void
135 {
136 if ($this->rbac_system->checkAccess("visible,read", $this->object->getRefId())) {
137 $this->tabs_gui->addTarget(
138 'file_objects',
139 $this->ctrl->getLinkTarget($this, self::CMD_EDIT_SETTINGS),
140 [self::CMD_EDIT_SETTINGS, self::CMD_VIEW]
141 );
142 }
143 if ($this->rbac_system->checkAccess('edit_permission', $this->object->getRefId())) {
144 $this->tabs_gui->addTarget(
145 "perm_settings",
146 $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm"),
147 [],
148 'ilpermissiongui'
149 );
150 }
151 }
152
153 protected function addFileObjectsSubTabs(): void
154 {
155 $this->tabs_gui->addSubTabTarget(
156 "settings",
157 $this->ctrl->getLinkTarget($this, self::CMD_EDIT_SETTINGS),
158 [self::CMD_EDIT_SETTINGS, "view"]
159 );
160 $this->tabs_gui->addSubTabTarget(
161 self::SUBTAB_SUFFIX_SPECIFIC_ICONS,
162 $this->ctrl->getLinkTargetByClass(ilObjFileIconsOverviewGUI::class, ilObjFileIconsOverviewGUI::CMD_INDEX),
163 [ilObjFileIconsOverviewGUI::CMD_INDEX, "view"]
164 );
165 }
166
167
168 protected function editSettings(): void
169 {
170 $this->addFileObjectsSubTabs();
171 $this->tabs_gui->setSubTabActive("settings");
172 $form = $this->buildForm();
173 $this->tpl->setContent($this->ui_renderer->render($this->buildForm()));
174 }
175
176 protected function saveSettings(): void
177 {
178 $form = $this->buildForm();
179 $form = $form->withRequest($this->http->request());
180
181 if ($form->getData() === null) {
182 $this->tpl->setContent($this->ui_renderer->render($form));
183 return;
184 }
185
186 $this->tpl->setOnScreenMessage(
187 'success',
188 $this->language->txt('settings_saved'),
189 true
190 );
191 $this->ctrl->redirect($this, self::CMD_EDIT_SETTINGS);
192 }
193}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Class Services.
Definition: Services.php:38
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:29
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