ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjTestFolderGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25use ILIAS\Data\Factory as DataFactory;
28
34{
35 private const SHOW_LOGS_CMD = 'logs';
36
39
40 private DataFactory $data_factory;
41
42 public function __construct(
43 $a_data,
44 int $a_id = 0,
45 bool $a_call_by_reference = true,
46 bool $a_prepare_output = true
47 ) {
48 global $DIC;
49 $rbacsystem = $DIC['rbacsystem'];
50 $this->data_factory = new DataFactory();
51
52 $local_dic = TestDIC::dic();
53 $this->testrequest = $local_dic['request_data_collector'];
54 $this->log_viewer = $local_dic['logging.viewer'];
55
56 $this->type = 'assf';
57
58 parent::__construct($a_data, $a_id, $a_call_by_reference, false);
59
60 if (!$rbacsystem->checkAccess('read', $this->object->getRefId())) {
61 $this->ilias->raiseError($this->lng->txt("msg_no_perm_read_assf"), $this->ilias->error_obj->WARNING);
62 }
63
64 $this->lng->loadLanguageModule('assessment');
65 }
66
67 private function getTestFolder(): ilObjTestFolder
68 {
70 return $this->object;
71 }
72
73 public function executeCommand(): void
74 {
75 $next_class = $this->ctrl->getNextClass($this);
76 $cmd = $this->ctrl->getCmd();
77 $this->prepareOutput();
78
79 switch ($next_class) {
80 case 'ilpermissiongui':
81 $this->tabs_gui->activateTab('perm_settings');
82 $perm_gui = new \ilPermissionGUI($this);
83 $this->ctrl->forwardCommand($perm_gui);
84 break;
85 case 'ilglobalunitconfigurationgui':
86 if (!$this->rbac_system->checkAccess('visible,read', $this->getTestFolder()->getRefId())) {
87 $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->WARNING);
88 }
89
90 $this->tabs_gui->setTabActive('units');
91
92 $gui = new \ilGlobalUnitConfigurationGUI(
94 );
95 $this->ctrl->forwardCommand($gui);
96 break;
97
98 default:
99 if ($cmd === null || $cmd === '' || $cmd === 'view') {
100 $cmd = 'showGlobalSettings';
101 }
102 $cmd .= 'Object';
103 $this->$cmd();
104
105 break;
106 }
107 }
108
109 public function showGlobalSettingsObject(?Form $form = null): void
110 {
111 $this->tabs_gui->setTabActive('settings');
112
113 if ($form === null) {
114 $form = $this->buildGlobalSettingsForm();
115 }
116
117 $this->tpl->setContent($this->ui_renderer->render($form));
118 }
119
120 private function buildGlobalSettingsForm(): Form
121 {
122 $inputs = $this->getTestFolder()->getGlobalSettingsRepository()->getGlobalSettings()->toForm(
123 $this->ui_factory,
124 $this->refinery,
125 $this->lng
126 );
127
128 return $this->ui_factory->input()->container()->form()->standard(
129 $this->ctrl->getFormActionByClass(self::class, 'SaveGlobalSettings'),
130 $inputs
131 );
132 }
133
137 public function saveGlobalSettingsObject(): void
138 {
139 if (!$this->access->checkAccess('write', '', $this->getTestFolder()->getRefId())) {
140 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_permission'));
142 return;
143 }
144
145 $form = $this->buildGlobalSettingsForm()->withRequest($this->request);
146 $data = $form->getData();
147 if ($data === null) {
148 $this->showGlobalSettingsObject($form);
149 return;
150 }
151
152 $this->getTestFolder()->getGlobalSettingsRepository()
153 ->storeGlobalSettings($data['global_settings']);
154
155 $this->showGlobalSettingsObject($form);
156 }
157
158 public function exportLegacyLogsObject(): void
159 {
160 $csv_output = $this->getTestFolder()->getTestLogViewer()->getLegacyLogExportForObjId();
161
163 $csv_output,
164 'legacy_logs.csv'
165 );
166 }
167
168 protected function showLogSettingsObject(?Form $form = null): void
169 {
170 $this->tabs_gui->activateTab('logs');
171
172 if ($form === null) {
173 $form = $this->buildLogSettingsForm();
174 }
175
176 $this->tpl->setContent($this->ui_renderer->render($form));
177 }
178
179 protected function saveLogSettingsObject(): void
180 {
181 if (!$this->access->checkAccess('write', '', $this->getTestFolder()->getRefId())) {
182 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_permission'));
183 $this->showLogSettingsObject();
184 return;
185 }
186
187 $form = $this->buildLogSettingsForm()->withRequest($this->request);
188 $data = $form->getData();
189 if ($data === null) {
190 $this->showLogSettingsObject($form);
191 return;
192 }
193
194 $this->getTestFolder()->getGlobalSettingsRepository()
195 ->storeLoggingSettings($data['logging']);
196
197 $this->showLogSettingsObject($form);
198 }
199
200 protected function buildLogSettingsForm(): Form
201 {
202 $inputs = $this->getTestFolder()->getGlobalSettingsRepository()->getLoggingSettings()->toForm(
203 $this->ui_factory,
204 $this->refinery,
205 $this->lng
206 );
207
208 return $this->ui_factory->input()->container()->form()->standard(
209 $this->ctrl->getFormActionByClass(self::class, 'saveLogSettings'),
210 $inputs
211 );
212 }
213
214 public function logsObject(): void
215 {
216 $this->tabs_gui->activateTab('logs');
217 $this->toolbar->addComponent(
218 $this->ui_factory->button()->standard(
219 $this->lng->txt('export_legacy_logs'),
220 $this->ctrl->getLinkTargetByClass(self::class, 'exportLegacyLogs')
221 )
222 );
223 $here_uri = $this->data_factory->uri(ILIAS_HTTP_PATH
224 . '/' . $this->ctrl->getLinkTargetByClass(self::class, self::SHOW_LOGS_CMD));
225 list($url_builder, $action_parameter_token, $row_id_token) = (new URLBuilder($here_uri))->acquireParameters(
226 LogTable::QUERY_PARAMETER_NAME_SPACE,
227 LogTable::ACTION_TOKEN_STRING,
228 LogTable::ENTRY_TOKEN_STRING
229 );
230
231 if ($this->request_wrapper->has($action_parameter_token->getName())) {
232 $this->object->getTestLogViewer()->executeLogTableAction(
233 $url_builder,
234 $action_parameter_token,
235 $row_id_token
236 );
237 }
238
239 $table_gui = $this->log_viewer->getLogTable(
240 $url_builder,
241 $action_parameter_token,
242 $row_id_token
243 );
244 $this->tpl->setVariable('ADM_CONTENT', $this->ui_renderer->render($table_gui));
245 }
246
247 public function getAdminTabs(): void
248 {
249 $this->getTabs();
250 }
251
252 public function getLogdataSubtabs(): void
253 {
254 $this->tabs_gui->addSubTabTarget(
255 'settings',
256 $this->ctrl->getLinkTarget($this, 'showLogSettings'),
257 ['saveLogSettings', 'showLogSettings'],
258 ''
259 );
260
261 // log output
262 $this->tabs_gui->addSubTabTarget(
263 'logs_output',
264 $this->ctrl->getLinkTargetByClass(self::class, self::SHOW_LOGS_CMD),
265 [self::SHOW_LOGS_CMD],
266 ''
267 );
268 }
269
270 protected function getTabs(): void
271 {
272 if (in_array($this->ctrl->getCmd(), ['saveLogSettings', 'showLogSettings', self::SHOW_LOGS_CMD])) {
273 $this->getLogdataSubtabs();
274 }
275
276 if ($this->rbac_system->checkAccess('visible,read', $this->getTestFolder()->getRefId())) {
277 $this->tabs_gui->addTarget(
278 'settings',
279 $this->ctrl->getLinkTarget($this, 'showGlobalSettings'),
280 ['showGlobalSettings', 'settings', '', 'view'],
281 '',
282 ''
283 );
284
285 $this->tabs_gui->addTarget(
286 'logs',
287 $this->ctrl->getLinkTarget($this, "showLogSettings"),
288 ['saveLogSettings', 'showLogSettings', self::SHOW_LOGS_CMD, 'showLog', 'exportLog', 'logAdmin', 'deleteLog'],
289 '',
290 ''
291 );
292
293 $this->tabs_gui->addTarget(
294 'units',
295 $this->ctrl->getLinkTargetByClass('ilGlobalUnitConfigurationGUI', ''),
296 '',
297 'ilglobalunitconfigurationgui'
298 );
299 }
300
301 if ($this->rbac_system->checkAccess('edit_permission', $this->getTestFolder()->getRefId())) {
302 $this->tabs_gui->addTarget(
303 "perm_settings",
304 $this->ctrl->getLinkTargetByClass([get_class($this), 'ilpermissiongui'], "perm"),
305 ["perm", "info", "owner"],
306 'ilpermissiongui'
307 );
308 }
309 }
310}
Builds data types.
Definition: Factory.php:36
showGlobalSettingsObject(?Form $form=null)
saveGlobalSettingsObject()
Save Assessment settings.
showLogSettingsObject(?Form $form=null)
RequestDataCollector $testrequest
getAdminTabs()
administration tabs show only permissions and trash folder
getTabs()
@abstract overwrite in derived GUI class of your object type
__construct( $a_data, int $a_id=0, bool $a_call_by_reference=true, bool $a_prepare_output=true)
Class ilObjTestFolder.
Class ilObjectGUI Basic methods of all Output classes.
prepareOutput(bool $show_sub_objects=true)
Class ilUnitConfigurationRepository.
static deliverData(string $a_data, string $a_filename, string $mime="application/octet-stream")
This describes commonalities between all forms.
Definition: Form.php:33
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Class ilObjForumAdministration.
global $DIC
Definition: shib_login.php:26