19 declare(strict_types=1);
47 public function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
52 $this->
lng = $DIC->language();
53 $this->error = $DIC[
'ilErr'];
57 $this->
lng->loadLanguageModule(
'tos');
58 $this->
lng->loadLanguageModule(
'meta');
59 $config =
new Config($this->dic[
'legalDocuments']->provide(Consumer::ID));
60 if ($this->rbac_system->checkAccess(
'write', $this->object->getRefId())) {
61 $config = $config->allowEditing();
65 $this->
ui =
new UI(Consumer::ID, $this->dic->ui(), $this->dic->language());
76 if (!$this->rbac_system->checkAccess(
'read', $this->object->getRefId())) {
77 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
80 $next_class = $this->
ctrl->getNextClass($this);
81 $cmd = $this->
ctrl->getCmd();
83 switch (strtolower($next_class)) {
84 case strtolower(ilLegalDocumentsAdministrationGUI::class):
88 default: $this->
ctrl->forwardCommand($this->legal_documents);
91 case strtolower(ilPermissionGUI::class):
92 $this->tabs_gui->activateTab(
'permissions');
102 $this->
ctrl->redirectByClass([self::class, get_class($this->legal_documents)],
'documents');
112 $can_edit_permissions = $this->rbac_system->checkAccess(
'edit_permission', $this->
object->getRefId());
115 $this->legal_documents->tabs([
116 'documents' => fn() => $this->tabs_gui->addTab(
'settings', $this->lng->txt(
'settings'), $this->
ctrl->getLinkTarget($this,
'settings')),
119 if ($can_edit_permissions) {
120 $this->tabs_gui->addTab(
122 $this->
lng->txt(
'perm_settings'),
123 $this->
ctrl->getLinkTargetByClass([self::class, ilPermissionGUI::class],
'perm')
130 $read_only = !$this->rbac_system->checkAccess(
'write', $this->
object->getRefId());
132 $enabled = $this->dic->ui()->factory()->input()->field()->optionalGroup(
134 'reeval_on_login' => $this->dic->ui()->factory()->input()->field()->checkbox(
135 $this->
ui->txt(
'reevaluate_on_login'),
136 $this->
ui->txt(
'reevaluate_on_login_desc')
139 $this->
lng->txt(
'tos_status_enable'),
140 $this->
lng->txt(
'tos_status_desc')
142 $enabled =
$enabled->withValue($this->tos_settings->enabled()->value() ? [
'reeval_on_login' => $this->tos_settings->validateOnLogin()->value()] : null);
145 $form = $this->dic->ui()->factory()->input()->container()->form()->standard(
146 $this->
ctrl->getFormAction($this,
'saveSettings'),
151 $form = $form->withSubmitLabel($this->
lng->txt(
'refresh'));
152 return $this->legal_documents->admin()->withFormData($form,
function () {
153 $this->
ctrl->redirect($this,
'settings');
157 return $this->legal_documents->admin()->withFormData($form,
function (array
$data):
void {
158 $no_documents = $this->config->legalDocuments()->document()->repository()->countAll() === 0;
159 if ($no_documents && $data[
'enabled']) {
160 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'tos_no_documents_exist_cant_save'),
true);
161 $this->
ctrl->redirect($this,
'settings');
163 $this->tos_settings->enabled()->update(isset($data[
'enabled']));
164 $this->tos_settings->validateOnLogin()->update($data[
'enabled'][
'reeval_on_login'] ??
false);
165 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
166 $this->
ctrl->redirect($this,
'settings');
172 if ($this->config->legalDocuments()->document()->repository()->countAll() === 0) {
173 $this->tos_settings->enabled()->update(
false);
179 if (!$this->rbac_system->checkAccess(
'read', $this->object->getRefId())) {
180 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
183 $this->tabs_gui->activateTab(
'settings');
187 if ($this->tos_settings->enabled()->value() && $this->config->legalDocuments()->document()->repository()->countAll() === 0) {
188 $components[] = $this->
ui->create()->messageBox()->info(
189 $this->
ui->txt(
'no_documents_exist')
193 $components[] = $this->legal_documents->admin()->externalSettingsMessage($this->tos_settings->deleteUserOnWithdrawal()->value());
195 $components[] = $this->
form();
196 $this->tpl->setContent($this->dic->ui()->renderer()->render($components));
201 $buttons = $this->config->editable() ?
202 [$this->legal_documents->admin()->resetButton($this->dic->ctrl()->getLinkTarget($this,
'confirmReset'))] :
205 $reset_date =
new DateTimeImmutable(
'@' . $this->dic->settings()->get(
'tos_last_reset',
'0'));
207 $this->tpl->setCurrentBlock(
'mess');
208 $this->legal_documents->admin()->setVariable(
'MESSAGE', $this->legal_documents->admin()->resetBox($reset_date, $buttons));
209 $this->tpl->parseCurrentBlock(
'mess');
214 $this->legal_documents->admin()->requireEditable();
215 $this->legal_documents->admin()->setContent((
new Confirmation($this->dic->language()))->render(
216 $this->dic->ctrl()->getFormAction($this,
'resetNow'),
219 $this->dic->language()->txt(
'tos_sure_reset_tos')
225 $this->legal_documents->admin()->requireEditable();
227 $this->dic->database()->manipulate(
"UPDATE usr_data SET agree_date = NULL WHERE $in");
228 $this->tos_settings->lastResetDate()->update((
new DataFactory())->clock()->system()->now());
229 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
230 $this->dic->ctrl()->redirectByClass([self::class, get_class($this->legal_documents)],
'documents');
235 $blocks =
new Blocks($this->config->legalDocuments()->id(),
$this->dic, $this->config->legalDocuments());
236 return new Settings($blocks->selectSettingsFrom($blocks->globalStore()));
New implementation of ilObjectGUI.
Class ChatMainBarProvider .
const SYSTEM_USER_ID
This file contains constants for PHPStan analyis, see: https://phpstan.org/config-reference#constants...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct($a_id=0, $a_id_type=self::REPOSITORY_NODE_ID, $a_parent_node_id=0)
prepareOutput(bool $show_sub_objects=true)
readonly ilLegalDocumentsAdministrationGUI $legal_documents
Error Handling & global info handling.
readonly Settings $tos_settings
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.