88 $cmd = $this->
ctrl->getCmd();
90 if (!$this->rbacsystem->checkAccess(
'read', $this->accs->getRefId())) {
91 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
94 if ($cmd ==
'' || !method_exists($this, $cmd)) {
95 $cmd =
'showDocuments';
107 if ($this->rbacsystem->checkAccess(
'write', $this->accs->getRefId())) {
108 $addDocumentBtn = $this->uiFactory->button()->primary(
109 $this->
lng->txt(
'acc_add_document_btn_label'),
110 $this->ctrl->getLinkTarget($this,
'showAddDocumentForm')
112 $this->
toolbar->addStickyItem($addDocumentBtn);
118 $this->criterionTypeFactory,
121 $this->rbacsystem->checkAccess(
'write', $this->accs->getRefId())
124 $documentTableGui->populate();
126 $this->tpl->setContent($documentTableGui->getHTML());
134 if ($document->getId() > 0) {
135 $this->
ctrl->setParameter($this,
'acc_id', $document->getId());
138 $formAction = $this->
ctrl->getFormAction($this,
'saveAddDocumentForm');
139 $saveCommand =
'saveAddDocumentForm';
141 if ($document->getId() > 0) {
142 $formAction = $this->
ctrl->getFormAction($this,
'saveEditDocumentForm');
143 $saveCommand =
'saveEditDocumentForm';
148 $this->documentPurifier,
150 $this->fileSystems->temp(),
155 $this->rbacsystem->checkAccess(
'write', $this->accs->getRefId())
163 if (!$this->rbacsystem->checkAccess(
'write', $this->accs->getRefId())) {
164 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
168 if ($form->saveObject()) {
169 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'),
true);
170 if ($form->hasTranslatedInfo()) {
171 $this->tpl->setOnScreenMessage(
'info', $form->getTranslatedInfo(),
true);
173 $this->
ctrl->redirect($this,
'showDocuments');
174 } elseif ($form->hasTranslatedError()) {
175 $this->tpl->setOnScreenMessage(
'failure', $form->getTranslatedError());
178 $this->tpl->setContent($form->getHTML());
183 if (!$this->rbacsystem->checkAccess(
'write', $this->accs->getRefId())) {
184 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
188 $this->tpl->setContent($form->getHTML());
193 if (!$this->rbacsystem->checkAccess(
'write', $this->accs->getRefId())) {
194 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
200 $this->tpl->setContent($form->getHTML());
205 if (!$this->rbacsystem->checkAccess(
'write', $this->accs->getRefId())) {
206 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
212 if ($form->saveObject()) {
213 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'),
true);
214 if ($form->hasTranslatedInfo()) {
215 $this->tpl->setOnScreenMessage(
'info', $form->getTranslatedInfo(),
true);
217 $this->
ctrl->redirect($this,
'showDocuments');
218 } elseif ($form->hasTranslatedError()) {
219 $this->tpl->setOnScreenMessage(
'failure', $form->getTranslatedError());
222 $this->tpl->setContent($form->getHTML());
232 $documentIds = $this->httpState->request()->getParsedBody()[
'acc_id'] ?? [];
233 if (!is_array($documentIds) || 0 === count($documentIds)) {
234 $documentIds = $this->httpState->request()->getQueryParams()[
'acc_id'] ? [$this->httpState->request()->getQueryParams()[
'acc_id']] : [];
237 if (0 === count($documentIds)) {
242 [
'id' => array_filter(array_map(
'intval', $documentIds))],
256 if (1 !== count($documents)) {
257 throw new UnexpectedValueException(
'Expected exactly one document in list');
262 $document = $document->buildFromArray(current($documents));
267 protected function deleteDocuments(): void
269 if (!$this->rbacsystem->checkAccess(
'write', $this->accs->getRefId())) {
270 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
274 if (0 === count($documents)) {
278 $documents = array_map(
function (array
$data) {
280 $document = $document->buildFromArray(
$data);
286 $isDeletionRequest = (bool) ($this->httpState->request()->getQueryParams()[
'delete'] ??
false);
287 if ($isDeletionRequest) {
288 $this->processDocumentDeletion($documents);
290 $this->
ctrl->redirect($this);
292 $this->
ctrl->setParameter($this,
'delete', 1);
294 $confirmation->setFormAction($this->
ctrl->getFormAction($this,
'deleteDocuments'));
295 $confirmation->setConfirm($this->
lng->txt(
'confirm'),
'deleteDocuments');
296 $confirmation->setCancel($this->
lng->txt(
'cancel'),
'showDocuments');
298 $confirmation->setHeaderText($this->
lng->txt(
'acc_sure_delete_documents_p'));
299 if (1 === count($documents)) {
300 $confirmation->setHeaderText($this->
lng->txt(
'acc_sure_delete_documents_s'));
303 foreach ($documents as $document) {
305 $confirmation->addItem(
'acc_id[]', $document->getId(), implode(
' | ', [
306 $document->getTitle()
310 $this->tpl->setContent($confirmation->getHTML());
314 protected function processDocumentDeletion(array $documents): void
316 foreach ($documents as $document) {
321 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'acc_deleted_documents_p'),
true);
322 if (1 === count($documents)) {
323 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'acc_deleted_documents_s'),
true);
329 if (!$this->rbacsystem->checkAccess(
'write', $this->accs->getRefId())) {
330 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
335 $this->processDocumentDeletion([$document]);
337 $this->
ctrl->redirect($this);
342 if (!$this->rbacsystem->checkAccess(
'write', $this->accs->getRefId())) {
343 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
346 $sorting = $this->httpState->request()->getParsedBody()[
'sorting'] ?? [];
347 if (!is_array($sorting) || 0 === count($sorting)) {
352 asort($sorting, SORT_NUMERIC);
355 foreach ($sorting as $documentId => $ignoredSortValue) {
356 if (!is_numeric($documentId)) {
362 $document->setSorting(++$position);
369 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'acc_saved_sorting'),
true);
370 $this->
ctrl->redirect($this);
380 $this->
ctrl->setParameter($this,
'acc_id', $document->
getId());
382 if ($criterionAssignment->getId() > 0) {
383 $this->
ctrl->setParameter($this,
'crit_id', $criterionAssignment->getId());
386 $formAction = $this->
ctrl->getFormAction($this,
'saveAttachCriterionForm');
387 $saveCommand =
'saveAttachCriterionForm';
389 if ($criterionAssignment->getId() > 0) {
390 $formAction = $this->
ctrl->getFormAction($this,
'saveChangeCriterionForm');
391 $saveCommand =
'saveChangeCriterionForm';
396 $criterionAssignment,
397 $this->criterionTypeFactory,
409 if (!$this->rbacsystem->checkAccess(
'write', $this->accs->getRefId())) {
410 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
413 $document = $this->getFirstDocumentFromList($this->getDocumentsByServerRequest());
416 if ($form->saveObject()) {
417 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'acc_doc_crit_attached'),
true);
418 $this->
ctrl->redirect($this,
'showDocuments');
419 } elseif ($form->hasTranslatedError()) {
420 $this->tpl->setOnScreenMessage(
'failure', $form->getTranslatedError());
423 $this->tpl->setContent($form->getHTML());
428 if (!$this->rbacsystem->checkAccess(
'write', $this->accs->getRefId())) {
429 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
432 $document = $this->getFirstDocumentFromList($this->getDocumentsByServerRequest());
435 $this->tpl->setContent($form->getHTML());
440 if (!$this->rbacsystem->checkAccess(
'write', $this->accs->getRefId())) {
441 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
444 $document = $this->getFirstDocumentFromList($this->getDocumentsByServerRequest());
446 $criterionId = $this->httpState->request()->getQueryParams()[
'crit_id'] ?? 0;
447 if (!is_numeric($criterionId) || $criterionId < 1) {
448 $this->showDocuments();
452 $criterionAssignment = array_values(array_filter(
455 return $criterionAssignment->getId() == $criterionId;
459 $form = $this->getCriterionForm($document, $criterionAssignment);
460 $this->tpl->setContent($form->getHTML());
465 if (!$this->rbacsystem->checkAccess(
'write', $this->accs->getRefId())) {
466 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
469 $document = $this->getFirstDocumentFromList($this->getDocumentsByServerRequest());
471 $criterionId = $this->httpState->request()->getQueryParams()[
'crit_id'] ?? 0;
472 if (!is_numeric($criterionId) || $criterionId < 1) {
473 $this->showDocuments();
477 $criterionAssignment = array_values(array_filter(
480 return $criterionAssignment->getId() == $criterionId;
484 $form = $this->getCriterionForm($document, $criterionAssignment);
485 if ($form->saveObject()) {
486 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'acc_doc_crit_changed'),
true);
487 $this->
ctrl->redirect($this,
'showDocuments');
488 } elseif ($form->hasTranslatedError()) {
489 $this->tpl->setOnScreenMessage(
'failure', $form->getTranslatedError());
492 $this->tpl->setContent($form->getHTML());
497 if (!$this->rbacsystem->checkAccess(
'write', $this->accs->getRefId())) {
498 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
501 $document = $this->getFirstDocumentFromList($this->getDocumentsByServerRequest());
503 $criterionId = $this->httpState->request()->getQueryParams()[
'crit_id'] ?? 0;
504 if (!is_numeric($criterionId) || $criterionId < 1) {
505 $this->showDocuments();
509 $criterionAssignment = array_values(array_filter(
512 return $criterionAssignment->getId() == $criterionId;
519 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'acc_doc_crit_detached'),
true);
520 $this->
ctrl->redirect($this,
'showDocuments');
static where($where, $operator=null)
Builds a Color from either hex- or rgb values.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilAccessibilityDocumentGUI.
showChangeCriterionForm()
ILIAS HTTP Services $httpState
saveAttachCriterionForm()
ilGlobalTemplateInterface $tpl
showAttachCriterionForm()
getCriterionForm(ilAccessibilityDocument $document, ilAccessibilityDocumentCriterionAssignment $criterionAssignment)
ilObjAccessibilitySettings $accs
executeCommand()
The implemented class should be ilCtrl enabled and execute or forward the given command.
ilHtmlPurifierInterface $documentPurifier
detachCriterionAssignment()
saveChangeCriterionForm()
__construct(ilObjAccessibilitySettings $accs, ilAccessibilityCriterionTypeFactoryInterface $criterionTypeFactory, ilGlobalTemplateInterface $tpl, ilObjUser $user, ilCtrl $ctrl, ilLanguage $lng, ilRbacSystem $rbacsystem, ilErrorHandling $error, ilLogger $log, ilToolbarGUI $toolbar, Services $httpState, Factory $uiFactory, Renderer $uiRenderer, Filesystems $fileSystems, FileUpload $fileUpload, ilAccessibilityTableDataProviderFactory $tableDataProviderFactory, ilHtmlPurifierInterface $documentPurifier)
getDocumentForm(ilAccessibilityDocument $document)
getDocumentsByServerRequest()
ilAccessibilityTableDataProviderFactory $tableDataProviderFactory
ilAccessibilityCriterionTypeFactoryInterface $criterionTypeFactory
Class ilAccessibilityDocumentTableGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
detachCriterion(ilAccessibilityDocumentCriterionAssignment $criterionAssignment)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrl provides processing control methods.
Error Handling & global info handling.
Base class for ILIAS Exception handling.
Component logger with individual log levels by component id.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
The Filesystems interface defines the access methods which can be used to fetch the different filesys...
This is how the factory for UI elements looks.
An entity that renders components to a string output.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface for html sanitizing functionality.