19declare(strict_types=1);
 
   95        $cmd = $this->
ctrl->getCmd();
 
   97        if (!$this->rbacsystem->checkAccess(
'read', $this->tos->getRefId())) {
 
   98            $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  101        if ($cmd === 
null || $cmd === 
'' || !method_exists($this, $cmd)) {
 
  102            $cmd = 
'showDocuments';
 
  109        if (!$this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  110            $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  114        $confirmation->setFormAction($this->
ctrl->getFormAction($this, 
'confirmReset'));
 
  115        $confirmation->setConfirm($this->
lng->txt(
'confirm'), 
'reset');
 
  116        $confirmation->setCancel($this->
lng->txt(
'cancel'), 
'showDocuments');
 
  117        $confirmation->setHeaderText($this->
lng->txt(
'tos_sure_reset_tos'));
 
  119        $this->tpl->setContent($confirmation->getHTML());
 
  124        if (!$this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  125            $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  128        $this->tos->resetAll();
 
  130        $this->log->info(
'Terms of service reset by ' . $this->
user->getId() . 
' [' . $this->user->getLogin() . 
']');
 
  131        $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'tos_reset_successful'));
 
  138        if ($this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  140            $addDocumentBtn->setPrimary(
true);
 
  141            $addDocumentBtn->setUrl($this->
ctrl->getLinkTarget($this, 
'showAddDocumentForm'));
 
  142            $addDocumentBtn->setCaption(
'tos_add_document_btn_label');
 
  143            $this->
toolbar->addStickyItem($addDocumentBtn);
 
  149            $this->criterionTypeFactory,
 
  152            $this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())
 
  155        $documentTableGui->populate();
 
  157        $this->tpl->setCurrentBlock(
'mess');
 
  159        $this->tpl->parseCurrentBlock(
'mess');
 
  160        $this->tpl->setContent($documentTableGui->getHTML());
 
  165        if (((
int) $this->tos->getLastResetDate()->get(
IL_CAL_UNIX)) !== 0) {
 
  168            $resetText = sprintf(
 
  169                $this->
lng->txt(
'tos_last_reset_date'),
 
  174            $resetText = $this->
lng->txt(
'tos_never_reset');
 
  178        if ($this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  183                        $this->
lng->txt(
'tos_reset_tos_for_all_users'),
 
  184                        $this->ctrl->getLinkTarget($this, 
'confirmReset')
 
  189        return $this->uiRenderer->render(
 
  190            $this->uiFactory->messageBox()
 
  192                            ->withButtons($buttons)
 
  198        if ($document->getId() > 0) {
 
  199            $this->
ctrl->setParameter($this, 
'tos_id', $document->getId());
 
  202        $formAction = $this->
ctrl->getFormAction($this, 
'saveAddDocumentForm');
 
  203        $saveCommand = 
'saveAddDocumentForm';
 
  205        if ($document->getId() > 0) {
 
  206            $formAction = $this->
ctrl->getFormAction($this, 
'saveEditDocumentForm');
 
  207            $saveCommand = 
'saveEditDocumentForm';
 
  212            $this->documentPurifier,
 
  214            $this->fileSystems->temp(),
 
  219            $this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())
 
  227        if (!$this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  228            $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  232        if ($form->saveObject()) {
 
  233            $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'), 
true);
 
  234            if ($form->hasTranslatedInfo()) {
 
  235                $this->tpl->setOnScreenMessage(
'info', $form->getTranslatedInfo(), 
true);
 
  237            $this->
ctrl->redirect($this, 
'showDocuments');
 
  238        } elseif ($form->hasTranslatedError()) {
 
  239            $this->tpl->setOnScreenMessage(
'failure', $form->getTranslatedError());
 
  242        $this->tpl->setContent($form->getHTML());
 
  247        if (!$this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  248            $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  252        $this->tpl->setContent($form->getHTML());
 
  257        if (!$this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  258            $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  264        $this->tpl->setContent($form->getHTML());
 
  269        if (!$this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  270            $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  276        if ($form->saveObject()) {
 
  277            $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'), 
true);
 
  278            if ($form->hasTranslatedInfo()) {
 
  279                $this->tpl->setOnScreenMessage(
'info', $form->getTranslatedInfo(), 
true);
 
  281            $this->
ctrl->redirect($this, 
'showDocuments');
 
  282        } elseif ($form->hasTranslatedError()) {
 
  283            $this->tpl->setOnScreenMessage(
'failure', $form->getTranslatedError());
 
  286        $this->tpl->setContent($form->getHTML());
 
  296        if ($this->httpState->wrapper()->post()->has(
'tos_id')) {
 
  297            $documentIds = $this->httpState->wrapper()->post()->retrieve(
 
  299                $this->
refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
 
  303        if ($documentIds === [] && $this->httpState->wrapper()->query()->has(
'tos_id')) {
 
  304            $documentIds = [$this->httpState->wrapper()->query()->retrieve(
 
  310        if ($documentIds === []) {
 
  315            [
'id' => array_filter(array_map(
'intval', $documentIds))],
 
  324        if (1 !== count($documents)) {
 
  325            throw new UnexpectedValueException(
'Expected exactly one document in list');
 
  329        $document = $document->buildFromArray(current($documents));
 
  334    protected function deleteDocuments(): void
 
  336        if (!$this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  337            $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  341        if (0 === count($documents)) {
 
  348            $document = $document->buildFromArray(
$data);
 
  353        $isDeletionRequest = (bool) ($this->httpState->request()->getQueryParams()[
'delete'] ?? 
false);
 
  354        if ($isDeletionRequest) {
 
  355            $this->processDocumentDeletion($documents);
 
  357            $this->
ctrl->redirect($this);
 
  359            $this->
ctrl->setParameter($this, 
'delete', 1);
 
  361            $confirmation->setFormAction($this->
ctrl->getFormAction($this, 
'deleteDocuments'));
 
  362            $confirmation->setConfirm($this->
lng->txt(
'confirm'), 
'deleteDocuments');
 
  363            $confirmation->setCancel($this->
lng->txt(
'cancel'), 
'showDocuments');
 
  365            $confirmation->setHeaderText($this->
lng->txt(
'tos_sure_delete_documents_p'));
 
  366            if (1 === count($documents)) {
 
  367                $confirmation->setHeaderText($this->
lng->txt(
'tos_sure_delete_documents_s'));
 
  370            foreach ($documents as $document) {
 
  372                $confirmation->addItem(
'tos_id[]', (
string) $document->getId(), implode(
' | ', [
 
  373                    $document->getTitle()
 
  377            $this->tpl->setContent($confirmation->getHTML());
 
  384    protected function processDocumentDeletion(array $documents): void
 
  386        foreach ($documents as $document) {
 
  392            $this->tos->saveStatus(
false);
 
  393            $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'tos_disabled_no_docs_left'), 
true);
 
  396        $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'tos_deleted_documents_p'), 
true);
 
  397        if (1 === count($documents)) {
 
  398            $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'tos_deleted_documents_s'), 
true);
 
  404        if (!$this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  405            $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  410        $this->processDocumentDeletion([$document]);
 
  412        $this->
ctrl->redirect($this);
 
  417        if (!$this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  418            $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  421        $sorting = $this->httpState->request()->getParsedBody()[
'sorting'] ?? [];
 
  422        if (!is_array($sorting) || 0 === count($sorting)) {
 
  427        asort($sorting, SORT_NUMERIC);
 
  430        foreach ($sorting as $documentId => $ignoredSortValue) {
 
  431            if (!is_numeric($documentId)) {
 
  437                $document->setSorting(++$position);
 
  444        $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'tos_saved_sorting'), 
true);
 
  445        $this->
ctrl->redirect($this);
 
  452        $this->
ctrl->setParameter($this, 
'tos_id', $document->
getId());
 
  454        if ($criterionAssignment->getId() > 0) {
 
  455            $this->
ctrl->setParameter($this, 
'crit_id', $criterionAssignment->getId());
 
  458        $formAction = $this->
ctrl->getFormAction($this, 
'saveAttachCriterionForm');
 
  459        $saveCommand = 
'saveAttachCriterionForm';
 
  461        if ($criterionAssignment->getId() > 0) {
 
  462            $formAction = $this->
ctrl->getFormAction($this, 
'saveChangeCriterionForm');
 
  463            $saveCommand = 
'saveChangeCriterionForm';
 
  468            $criterionAssignment,
 
  469            $this->criterionTypeFactory,
 
  481        if (!$this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  482            $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  485        $document = $this->getFirstDocumentFromList($this->getDocumentsByServerRequest());
 
  488        if ($form->saveObject()) {
 
  489            $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'tos_doc_crit_attached'), 
true);
 
  490            $this->
ctrl->redirect($this, 
'showDocuments');
 
  491        } elseif ($form->hasTranslatedError()) {
 
  492            $this->tpl->setOnScreenMessage(
'failure', $form->getTranslatedError());
 
  495        $this->tpl->setContent($form->getHTML());
 
  500        if (!$this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  501            $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  504        $document = $this->getFirstDocumentFromList($this->getDocumentsByServerRequest());
 
  507        $this->tpl->setContent($form->getHTML());
 
  512        if (!$this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  513            $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  516        $document = $this->getFirstDocumentFromList($this->getDocumentsByServerRequest());
 
  518        $criterionId = $this->httpState->request()->getQueryParams()[
'crit_id'] ?? 0;
 
  519        if (!is_numeric($criterionId) || $criterionId < 1) {
 
  520            $this->showDocuments();
 
  524        $criterionAssignment = array_values(array_filter(
 
  529                return $criterionAssignment->getId() == $criterionId;
 
  533        $form = $this->getCriterionForm($document, $criterionAssignment);
 
  534        $this->tpl->setContent($form->getHTML());
 
  539        if (!$this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  540            $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  543        $document = $this->getFirstDocumentFromList($this->getDocumentsByServerRequest());
 
  545        $criterionId = $this->httpState->request()->getQueryParams()[
'crit_id'] ?? 0;
 
  546        if (!is_numeric($criterionId) || $criterionId < 1) {
 
  547            $this->showDocuments();
 
  551        $criterionAssignment = array_values(array_filter(
 
  556                return $criterionAssignment->getId() == $criterionId;
 
  560        $form = $this->getCriterionForm($document, $criterionAssignment);
 
  561        if ($form->saveObject()) {
 
  562            $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'tos_doc_crit_changed'), 
true);
 
  563            $this->
ctrl->redirect($this, 
'showDocuments');
 
  564        } elseif ($form->hasTranslatedError()) {
 
  565            $this->tpl->setOnScreenMessage(
'failure', $form->getTranslatedError());
 
  568        $this->tpl->setContent($form->getHTML());
 
  573        if (!$this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  574            $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  577        $document = $this->getFirstDocumentFromList($this->getDocumentsByServerRequest());
 
  579        $criterionId = $this->httpState->request()->getQueryParams()[
'crit_id'] ?? 0;
 
  580        if (!is_numeric($criterionId) || $criterionId < 1) {
 
  581            $this->showDocuments();
 
  585        $criterionAssignment = array_values(array_filter(
 
  590                return $criterionAssignment->getId() == $criterionId;
 
  597        $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'tos_doc_crit_detached'), 
true);
 
  598        $this->
ctrl->redirect($this, 
'showDocuments');
 
static return function(ContainerConfigurator $containerConfigurator)
 
static where($where, $operator=null)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static useRelativeDates()
 
static setUseRelativeDates(bool $a_status)
set use relative dates
 
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
 
Error Handling & global info handling uses PEAR error class.
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
Component logger with individual log levels by component id.
 
Class ilObjTermsOfService.
 
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
 
Class ilTermsOfServiceDocumentCriterionAssignment.
 
Class ilTermsOfServiceDocumentGUI.
 
ilGlobalTemplateInterface $tpl
 
saveAttachCriterionForm()
 
getFirstDocumentFromList(array $documents)
 
ilTermsOfServiceCriterionTypeFactoryInterface $criterionTypeFactory
 
getCriterionForm(ilTermsOfServiceDocument $document, ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment)
 
saveChangeCriterionForm()
 
detachCriterionAssignment()
 
ilTermsOfServiceTableDataProviderFactory $tableDataProviderFactory
 
ILIAS HTTP GlobalHttpState $httpState
 
getDocumentForm(ilTermsOfServiceDocument $document)
 
getDocumentsByServerRequest()
 
__construct(ilObjTermsOfService $tos, ilTermsOfServiceCriterionTypeFactoryInterface $criterionTypeFactory, ilGlobalTemplateInterface $tpl, ilObjUser $user, ilCtrlInterface $ctrl, ilLanguage $lng, ilRbacSystem $rbacsystem, ilErrorHandling $error, ilLogger $log, ilToolbarGUI $toolbar, GlobalHttpState $httpState, Factory $uiFactory, Renderer $uiRenderer, Filesystems $fileSystems, FileUpload $fileUpload, ilTermsOfServiceTableDataProviderFactory $tableDataProviderFactory, ilHtmlPurifierInterface $documentPurifier, Refinery $refinery)
 
executeCommand()
The implemented class should be ilCtrlInterface enabled and execute or forward the given command.
 
ilHtmlPurifierInterface $documentPurifier
 
showChangeCriterionForm()
 
showAttachCriterionForm()
 
Class ilTermsOfServiceDocumentTableGUI.
 
Class ilTermsOfServiceDocument.
 
detachCriterion(ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment)
 
Class ilTermsOfServiceTableDataProviderFactory.
 
Interface GlobalHttpState.
 
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.
 
Interface ilTermsOfServiceControllerEnabled.
 
Interface ilTermsOfServiceCriterionTypeFactoryInterface.