130        $nextClass = $this->ctrl->getNextClass($this);
 
  131        $cmd = $this->ctrl->getCmd();
 
  133        if (!$this->rbacsystem->checkAccess(
'read', $this->tos->getRefId())) {
 
  134            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  137        switch (strtolower($nextClass)) {
 
  139                if ($cmd == 
'' || !method_exists($this, $cmd)) {
 
  140                    $cmd = 
'showDocuments';
 
  152        if (!$this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  153            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  156        $confirmation = new \ilConfirmationGUI();
 
  157        $confirmation->setFormAction($this->ctrl->getFormAction($this, 
'confirmReset'));
 
  158        $confirmation->setConfirm($this->lng->txt(
'confirm'), 
'reset');
 
  159        $confirmation->setCancel($this->lng->txt(
'cancel'), 
'showDocuments');
 
  160        $confirmation->setHeaderText($this->lng->txt(
'tos_sure_reset_tos'));
 
  162        $this->tpl->setContent($confirmation->getHTML());
 
  170        if (!$this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  171            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  174        $this->tos->resetAll();
 
  176        $this->log->info(
'Terms of service reset by ' . $this->
user->getId() . 
' [' . $this->user->getLogin() . 
']');
 
  177        \ilUtil::sendSuccess($this->lng->txt(
'tos_reset_successful'));
 
  187        if ($this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  189            $addDocumentBtn->setPrimary(
true);
 
  190            $addDocumentBtn->setUrl($this->ctrl->getLinkTarget($this, 
'showAddDocumentForm'));
 
  191            $addDocumentBtn->setCaption(
'tos_add_document_btn_label');
 
  192            $this->toolbar->addStickyItem($addDocumentBtn);
 
  195        $documentTableGui = new \ilTermsOfServiceDocumentTableGUI(
 
  198            $this->criterionTypeFactory,
 
  201            $this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())
 
  204        $documentTableGui->populate();
 
  206        $this->tpl->setCurrentBlock(
'mess');
 
  208        $this->tpl->parseCurrentBlock(
'mess');
 
  209        $this->tpl->setContent($documentTableGui->getHTML());
 
  217        if ($this->tos->getLastResetDate() && $this->tos->getLastResetDate()->get(
IL_CAL_UNIX) != 0) {
 
  220            $resetText = sprintf(
 
  221                $this->lng->txt(
'tos_last_reset_date'),
 
  226            $resetText = $this->lng->txt(
'tos_never_reset');
 
  230        if ($this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  234                    ->standard($this->lng->txt(
'tos_reset_tos_for_all_users'), $this->ctrl->getLinkTarget($this, 
'confirmReset'))
 
  238        return $this->uiRenderer->render(
 
  239            $this->uiFactory->messageBox()
 
  241                ->withButtons($buttons)
 
  251        if ($document->getId() > 0) {
 
  252            $this->ctrl->setParameter($this, 
'tos_id', $document->getId());
 
  255        $formAction = $this->ctrl->
getFormAction($this, 
'saveAddDocumentForm');
 
  256        $saveCommand = 
'saveAddDocumentForm';
 
  258        if ($document->getId() > 0) {
 
  259            $formAction = $this->ctrl->getFormAction($this, 
'saveEditDocumentForm');
 
  260            $saveCommand = 
'saveEditDocumentForm';
 
  263        $form = new \ilTermsOfServiceDocumentFormGUI(
 
  265            $this->documentPurifier,
 
  267            $this->fileSystems->temp(),
 
  272            $this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())
 
  283        if (!$this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  284            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  288        if (
$form->saveObject()) {
 
  289            \ilUtil::sendSuccess($this->lng->txt(
'saved_successfully'), 
true);
 
  290            if (
$form->hasTranslatedInfo()) {
 
  293            $this->ctrl->redirect($this, 
'showDocuments');
 
  294        } elseif (
$form->hasTranslatedError()) {
 
  298        $this->tpl->setContent(
$form->getHTML());
 
  306        if (!$this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  307            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  311        $this->tpl->setContent(
$form->getHTML());
 
  319        if (!$this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  320            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  326        $this->tpl->setContent(
$form->getHTML());
 
  334        if (!$this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  335            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  341        if (
$form->saveObject()) {
 
  342            \ilUtil::sendSuccess($this->lng->txt(
'saved_successfully'), 
true);
 
  343            if (
$form->hasTranslatedInfo()) {
 
  346            $this->ctrl->redirect($this, 
'showDocuments');
 
  347        } elseif (
$form->hasTranslatedError()) {
 
  351        $this->tpl->setContent(
$form->getHTML());
 
  361        $documentIds = $this->httpState->request()->getParsedBody()[
'tos_id'] ?? [];
 
  362        if (!is_array($documentIds) || 0 === count($documentIds)) {
 
  363            $documentIds = $this->httpState->request()->getQueryParams()[
'tos_id'] ? [$this->httpState->request()->getQueryParams()[
'tos_id']] : [];
 
  366        if (0 === count($documentIds)) {
 
  371            [
'id' => array_filter(array_map(
'intval', $documentIds))],
 
  385        if (1 !== count($documents)) {
 
  386            throw new \UnexpectedValueException(
'Expected exactly one document in list');
 
  389        $document = new \ilTermsOfServiceDocument(0);
 
  390        $document = $document->buildFromArray(current($documents));
 
  398    protected function deleteDocuments()
 
  400        if (!$this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  401            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  405        if (0 === count($documents)) {
 
  409            $documents = array_map(
function (array 
$data) {
 
  410                $document = new \ilTermsOfServiceDocument(0);
 
  411                $document = $document->buildFromArray(
$data);
 
  417        $isDeletionRequest = (bool) ($this->httpState->request()->getQueryParams()[
'delete'] ?? 
false);
 
  418        if ($isDeletionRequest) {
 
  419            $this->processDocumentDeletion($documents);
 
  421            $this->ctrl->redirect($this);
 
  423            $this->ctrl->setParameter($this, 
'delete', 1);
 
  424            $confirmation = new \ilConfirmationGUI();
 
  425            $confirmation->setFormAction($this->ctrl->getFormAction($this, 
'deleteDocuments'));
 
  426            $confirmation->setConfirm($this->lng->txt(
'confirm'), 
'deleteDocuments');
 
  427            $confirmation->setCancel($this->lng->txt(
'cancel'), 
'showDocuments');
 
  429            $confirmation->setHeaderText($this->lng->txt(
'tos_sure_delete_documents_p'));
 
  430            if (1 === count($documents)) {
 
  431                $confirmation->setHeaderText($this->lng->txt(
'tos_sure_delete_documents_s'));
 
  434            foreach ($documents as $document) {
 
  436                $confirmation->addItem(
'tos_id[]', $document->getId(), implode(
' | ', [
 
  437                    $document->getTitle()
 
  441            $this->tpl->setContent($confirmation->getHTML());
 
  448    protected function processDocumentDeletion(array $documents)
 
  450        foreach ($documents as $document) {
 
  456            $this->tos->saveStatus(
false);
 
  460        \ilUtil::sendSuccess($this->lng->txt(
'tos_deleted_documents_p'), 
true);
 
  461        if (1 === count($documents)) {
 
  462            \ilUtil::sendSuccess($this->lng->txt(
'tos_deleted_documents_s'), 
true);
 
  471        if (!$this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  472            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  477        $this->processDocumentDeletion([$document]);
 
  479        $this->ctrl->redirect($this);
 
  487        if (!$this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  488            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  491        $sorting = $this->httpState->request()->getParsedBody()[
'sorting'] ?? [];
 
  492        if (!is_array($sorting) || 0 === count($sorting)) {
 
  497        asort($sorting, SORT_NUMERIC);
 
  500        foreach ($sorting as $documentId => $ignoredSortValue) {
 
  501            if (!is_numeric($documentId)) {
 
  506                $document = new \ilTermsOfServiceDocument((
int) $documentId);
 
  507                $document->setSorting(++$position);
 
  514        \ilUtil::sendSuccess($this->lng->txt(
'tos_saved_sorting'), 
true);
 
  515        $this->ctrl->redirect($this);
 
  527        $this->ctrl->setParameter($this, 
'tos_id', $document->getId());
 
  529        if ($criterionAssignment->getId() > 0) {
 
  530            $this->ctrl->setParameter($this, 
'crit_id', $criterionAssignment->getId());
 
  533        $formAction = $this->ctrl->
getFormAction($this, 
'saveAttachCriterionForm');
 
  534        $saveCommand = 
'saveAttachCriterionForm';
 
  536        if ($criterionAssignment->getId() > 0) {
 
  537            $formAction = $this->ctrl->getFormAction($this, 
'saveChangeCriterionForm');
 
  538            $saveCommand = 
'saveChangeCriterionForm';
 
  541        $form = new \ilTermsOfServiceCriterionFormGUI(
 
  543            $criterionAssignment,
 
  544            $this->criterionTypeFactory,
 
  559        if (!$this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  560            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  563        $document = $this->getFirstDocumentFromList($this->getDocumentsByServerRequest());
 
  566        if (
$form->saveObject()) {
 
  567            \ilUtil::sendSuccess($this->lng->txt(
'tos_doc_crit_attached'), 
true);
 
  568            $this->ctrl->redirect($this, 
'showDocuments');
 
  569        } elseif (
$form->hasTranslatedError()) {
 
  573        $this->tpl->setContent(
$form->getHTML());
 
  581        if (!$this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  582            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  585        $document = $this->getFirstDocumentFromList($this->getDocumentsByServerRequest());
 
  588        $this->tpl->setContent(
$form->getHTML());
 
  596        if (!$this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  597            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  600        $document = $this->getFirstDocumentFromList($this->getDocumentsByServerRequest());
 
  602        $criterionId = $this->httpState->request()->getQueryParams()[
'crit_id'] ?? 0;
 
  603        if (!is_numeric($criterionId) || $criterionId < 1) {
 
  604            $this->showDocuments();
 
  608        $criterionAssignment = array_values(array_filter(
 
  611                return $criterionAssignment->getId() == $criterionId;
 
  615        $form = $this->getCriterionForm($document, $criterionAssignment);
 
  616        $this->tpl->setContent(
$form->getHTML());
 
  624        if (!$this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  625            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  628        $document = $this->getFirstDocumentFromList($this->getDocumentsByServerRequest());
 
  630        $criterionId = $this->httpState->request()->getQueryParams()[
'crit_id'] ?? 0;
 
  631        if (!is_numeric($criterionId) || $criterionId < 1) {
 
  632            $this->showDocuments();
 
  636        $criterionAssignment = array_values(array_filter(
 
  639                return $criterionAssignment->getId() == $criterionId;
 
  643        $form = $this->getCriterionForm($document, $criterionAssignment);
 
  644        if (
$form->saveObject()) {
 
  645            \ilUtil::sendSuccess($this->lng->txt(
'tos_doc_crit_changed'), 
true);
 
  646            $this->ctrl->redirect($this, 
'showDocuments');
 
  647        } elseif (
$form->hasTranslatedError()) {
 
  651        $this->tpl->setContent(
$form->getHTML());
 
  659        if (!$this->rbacsystem->checkAccess(
'write', $this->tos->getRefId())) {
 
  660            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  663        $document = $this->getFirstDocumentFromList($this->getDocumentsByServerRequest());
 
  665        $criterionId = $this->httpState->request()->getQueryParams()[
'crit_id'] ?? 0;
 
  666        if (!is_numeric($criterionId) || $criterionId < 1) {
 
  667            $this->showDocuments();
 
  671        $criterionAssignment = array_values(array_filter(
 
  674                return $criterionAssignment->getId() == $criterionId;
 
  681        \ilUtil::sendSuccess($this->lng->txt(
'tos_doc_crit_detached'), 
true);
 
  682        $this->ctrl->redirect($this, 
'showDocuments');
 
static where($where, $operator=null)
An exception for terminatinating execution or to throw for unit testing.
error($a_errmsg)
set error message @access public
This class provides processing control methods.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
static setUseRelativeDates($a_status)
set use relative dates
static useRelativeDates()
check if relative dates are used
Base class for ILIAS Exception handling.
Component logger with individual log levels by component id.
Class ilObjTermsOfService.
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
special template class to simplify handling of ITX/PEAR
Class ilTermsOfServiceDocumentCriterionAssignment.
Class ilTermsOfServiceDocumentGUI.
saveAttachCriterionForm()
getFirstDocumentFromList(array $documents)
saveChangeCriterionForm()
getCriterionForm(\ilTermsOfServiceDocument $document, \ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment)
$tableDataProviderFactory
detachCriterionAssignment()
getDocumentForm(ilTermsOfServiceDocument $document)
getDocumentsByServerRequest()
executeCommand()
The implemented class should be \ilCtrl enabled and execute or forward the given command.
__construct(\ilObjTermsOfService $tos, \ilTermsOfServiceCriterionTypeFactoryInterface $criterionTypeFactory, \ilTemplate $tpl, \ilObjUser $user, \ilCtrl $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)
ilTermsOfServiceDocumentGUI constructor.
showChangeCriterionForm()
showAttachCriterionForm()
Class ilTermsOfServiceDocument.
criteria()
\ilTermsOfServiceEvaluableCriterion[]
detachCriterion(\ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment)
Class ilTermsOfServiceTableDataProviderFactory.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
Interface GlobalHttpState.
This is how the factory for UI elements looks.
An entity that renders components to a string output.
Interface for html sanitizing functionality.
Interface ilTermsOfServiceControllerEnabled.
Interface ilTermsOfServiceCriterionTypeFactoryInterface.
if(isset($_POST['submit'])) $form