ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjFileServicesGUI.php
Go to the documentation of this file.
1<?php
2
10{
11 const CMD_EDIT_SETTINGS = 'editSettings';
12
16 protected $rbacsystem;
20 protected $tabs;
24 public $lng;
32 protected $ctrl;
36 protected $settings;
40 public $tpl;
41
46 public function __construct($a_data, $a_id, $a_call_by_reference)
47 {
48 global $DIC;
49
50 $this->type = "fils";
51 parent::__construct($a_data, $a_id, $a_call_by_reference, false);
52
53 $this->tabs = $DIC['ilTabs'];
54 $this->lng = $DIC->language();
55 $this->lng->loadLanguageModule('adn');
56 $this->ctrl = $DIC['ilCtrl'];
57 $this->tpl = $DIC['tpl'];
58 $this->tree = $DIC['tree'];
59 $this->settings = $DIC['ilSetting'];
60 $this->rbacsystem = $DIC['rbacsystem'];
61 $this->error_handling = $DIC["ilErr"];
62 }
63
67 protected function checkPermissionOrFail(string $str) : void
68 {
69 if (!$this->hasUserPermissionTo($str)) {
70 $this->error_handling->raiseError(
71 $this->lng->txt('no_permission'),
72 $this->error_handling->error_obj->MESSAGE
73 );
74 }
75 }
76
77 protected function hasUserPermissionTo($str) : bool
78 {
79 return $this->access->checkAccess($str, '', $this->object->getRefId());
80 }
81
86 public function executeCommand()
87 {
88 $this->lng->loadLanguageModule("fils");
89
90 $next_class = $this->ctrl->getNextClass($this);
91 $cmd = $this->ctrl->getCmd();
92
93 $this->prepareOutput();
94 $this->checkPermissionOrFail('read');
95
96 switch ($next_class) {
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 default:
103 if (!$cmd || $cmd === 'view') {
105 }
106 $this->$cmd();
107 break;
108 }
109
110 return true;
111 }
112
116 public function getAdminTabs()
117 {
118 global $DIC;
119 $rbacsystem = $DIC['rbacsystem'];
120
121 if ($rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
122 $this->tabs_gui->addTarget(
123 'settings',
124 $this->ctrl->getLinkTarget($this, self::CMD_EDIT_SETTINGS),
125 array(self::CMD_EDIT_SETTINGS, "view")
126 );
127 }
128 if ($rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
129 $this->tabs_gui->addTarget(
130 "perm_settings",
131 $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm"),
132 array(),
133 'ilpermissiongui'
134 );
135 }
136 }
137
141 public function setTitleAndDescription() : void
142 {
143 parent::setTitleAndDescription();
144 $this->tpl->setDescription($this->object->getDescription());
145 }
146
151 {
152 $permission_to_write = $this->hasUserPermissionTo('write');
153
154 $form = new ilPropertyFormGUI();
155 $form->setFormAction($this->ctrl->getFormAction($this));
156 $form->setTitle($this->lng->txt("settings"));
157
158 // default positive list
159 $ne = new ilNonEditableValueGUI($this->lng->txt("file_suffix_default_positive"), "");
160 $ne->setValue(implode(", ", ilFileUtils::getDefaultValidExtensionWhiteList()));
161 $ne->setInfo($this->lng->txt("file_suffix_default_positive_info"));
162 $form->addItem($ne);
163
164 // file suffix custom negative list
165 $ta = new ilTextAreaInputGUI($this->lng->txt(
166 "file_suffix_custom_negative"),
167 "suffix_repl_additional"
168 );
169 $ta->setInfo($this->lng->txt("file_suffix_custom_negative_info"));
170 $ta->setRows(5);
171 $ta->setDisabled(!$permission_to_write);
172 $form->addItem($ta);
173
174 // file suffix custom positive list
175 $ta = new ilTextAreaInputGUI($this->lng->txt(
176 "file_suffix_custom_positive"),
177 "suffix_custom_white_list"
178 );
179 $ta->setInfo($this->lng->txt("file_suffix_custom_positive_info"));
180 $ta->setRows(5);
181 $ta->setDisabled(!$permission_to_write);
182 $form->addItem($ta);
183
184 // resulting overall positive list
185 $ne = new ilNonEditableValueGUI($this->lng->txt("file_suffix_overall_positive"), "");
186 $ne->setValue(implode(", ", ilFileUtils::getValidExtensions()));
187 $ne->setInfo($this->lng->txt("file_suffix_overall_positive_info"));
188 $form->addItem($ne);
189
190 // explicit negative list
191 $ta = new ilTextAreaInputGUI(
192 $this->lng->txt("file_suffix_custom_expl_negative"),
193 "suffix_custom_expl_black"
194 );
195 $ta->setInfo($this->lng->txt("file_suffix_custom_expl_negative_info"));
196 $ta->setRows(5);
197 $ta->setDisabled(!$permission_to_write);
198 $form->addItem($ta);
199
200 // command buttons
201 if ($permission_to_write) {
202 $form->addCommandButton('saveSettings', $this->lng->txt('save'));
203 $form->addCommandButton('view', $this->lng->txt('cancel'));
204 }
205
206 return $form;
207 }
208
212 protected function editSettings() : void
213 {
214 $this->tabs_gui->setTabActive('settings');
215
216 $this->checkPermissionOrFail("visible,read");
217
218 // get form
219 $form = $this->initSettingsForm();
220
221 // set current values
222 $val = array();
223 $val["suffix_repl_additional"] = $this->settings->get("suffix_repl_additional");
224 $val["suffix_custom_white_list"] = $this->settings->get("suffix_custom_white_list");
225 $val["suffix_custom_expl_black"] = $this->settings->get("suffix_custom_expl_black");
226 $form->setValuesByArray($val);
227
228 // set content
229 $this->tpl->setContent($form->getHTML());
230 }
231
235 protected function saveSettings():void
236 {
237 $this->checkPermissionOrFail("write");
238
239 // get form
240 $form = $this->initSettingsForm();
241 if ($form->checkInput()) {
242 $this->settings->set("suffix_repl_additional", $_POST["suffix_repl_additional"]);
243 $this->settings->set("suffix_custom_white_list", $_POST["suffix_custom_white_list"]);
244 $this->settings->set("suffix_custom_expl_black", $_POST["suffix_custom_expl_black"]);
245
246 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
247 $this->ctrl->redirect($this, self::CMD_EDIT_SETTINGS);
248 } else {
249 $form->setValuesByPost();
250 $this->tpl->setContent($form->getHTML());
251 }
252 }
253}
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
static getDefaultValidExtensionWhiteList()
Valid extensions.
static getValidExtensions()
Valid extensions.
This class represents a non editable value in a property form.
Class ilObjFileServicesGUI.
__construct($a_data, $a_id, $a_call_by_reference)
Constructor @access public.
initSettingsForm()
Initializes the settings form.
setTitleAndDescription()
called by prepare output
executeCommand()
Execute command @access public.
Class ilObjectGUI Basic methods of all Output classes.
prepareOutput($a_show_subobjects=true)
prepare output
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
This class represents a text area property in a property form.
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
settings()
Definition: settings.php:2