19 declare(strict_types=1);
47 public function __construct(
int $a_id = 0,
int $a_id_type = self::REPOSITORY_NODE_ID,
int $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');
98 $this->
ctrl->redirectByClass([self::class, ilLegalDocumentsAdministrationGUI::class],
'documents');
105 $this->
ctrl->redirectByClass([self::class, get_class($this->legal_documents)],
'documents');
115 $can_edit_permissions = $this->rbac_system->checkAccess(
'edit_permission', $this->
object->getRefId());
118 $this->legal_documents->tabs([
119 'documents' => fn() => $this->tabs_gui->addTab(
'settings', $this->lng->txt(
'settings'), $this->
ctrl->getLinkTarget($this,
'settings')),
122 if ($can_edit_permissions) {
123 $this->tabs_gui->addTab(
125 $this->
lng->txt(
'perm_settings'),
126 $this->
ctrl->getLinkTargetByClass([self::class, ilPermissionGUI::class],
'perm')
133 $read_only = !$this->rbac_system->checkAccess(
'write', $this->
object->getRefId());
135 $no_documents = $this->config->legalDocuments()->document()->repository()->countAll() === 0;
137 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'tos_no_documents_exist'));
140 $enabled = $this->dic->ui()->factory()->input()->field()->optionalGroup(
142 'reeval_on_login' => $this->dic->ui()->factory()->input()->field()->checkbox(
143 $this->
ui->txt(
'reevaluate_on_login'),
144 $this->
ui->txt(
'reevaluate_on_login_desc')
147 $this->
lng->txt(
'tos_status_enable'),
148 $this->
lng->txt(
'tos_status_desc')
150 $enabled = $enabled->withValue($this->tos_settings->enabled()->value() ? [
'reeval_on_login' => $this->tos_settings->validateOnLogin()->value()] :
null);
151 $enabled = $enabled->withDisabled($read_only);
153 $form = $this->dic->ui()->factory()->input()->container()->form()->standard(
154 $this->
ctrl->getFormAction($this,
'saveSettings'),
155 [
'enabled' => $enabled]
159 $form = $form->withSubmitLabel($this->
lng->txt(
'refresh'));
160 return $this->legal_documents->admin()->withFormData($form,
function () {
161 $this->
ctrl->redirect($this,
'settings');
165 return $this->legal_documents->admin()->withFormData($form,
function (array
$data) use ($no_documents):
void {
166 if ($no_documents && $data[
'enabled']) {
167 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'tos_no_documents_exist_cant_save'),
true);
168 $this->
ctrl->redirect($this,
'settings');
170 $this->tos_settings->enabled()->update(isset($data[
'enabled']));
171 $this->tos_settings->validateOnLogin()->update($data[
'enabled'][
'reeval_on_login'] ??
false);
172 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
173 $this->
ctrl->redirect($this,
'settings');
179 if ($this->config->legalDocuments()->document()->repository()->countAll() === 0) {
180 $this->tos_settings->enabled()->update(
false);
186 if (!$this->rbac_system->checkAccess(
'read', $this->object->getRefId())) {
187 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
190 $this->tabs_gui->activateTab(
'settings');
194 if ($this->tos_settings->enabled()->value() && $this->config->legalDocuments()->document()->repository()->countAll() === 0) {
196 $this->
ui->txt(
'no_documents_exist')
200 $components[] = $this->legal_documents->admin()->externalSettingsMessage($this->tos_settings->deleteUserOnWithdrawal()->value());
203 $this->tpl->setContent($this->dic->ui()->renderer()->render(
$components));
208 $buttons = $this->config->editable() ?
209 [$this->legal_documents->admin()->resetButton($this->dic->ctrl()->getLinkTarget($this,
'confirmReset'))] :
212 $reset_date =
new DateTimeImmutable(
'@' . $this->dic->settings()->get(
'tos_last_reset',
'0'));
214 $this->tpl->setCurrentBlock(
'mess');
215 $this->legal_documents->admin()->setVariable(
'MESSAGE', $this->legal_documents->admin()->resetBox($reset_date, $buttons));
216 $this->tpl->parseCurrentBlock(
'mess');
221 $this->legal_documents->admin()->requireEditable();
222 $this->legal_documents->admin()->setContent((
new Confirmation($this->dic->language()))->render(
223 $this->dic->ctrl()->getFormAction($this,
'resetNow'),
226 $this->dic->language()->txt(
'tos_sure_reset_tos')
232 $this->legal_documents->admin()->requireEditable();
234 $this->dic->database()->manipulate(
"UPDATE usr_data SET agree_date = NULL WHERE $in");
235 $this->tos_settings->lastResetDate()->update((
new DataFactory())->clock()->system()->now());
236 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
237 $this->dic->ctrl()->redirectByClass([self::class, $this->legal_documents::class],
'documents');
242 $blocks =
new Blocks($this->config->legalDocuments()->id(),
$this->dic, $this->config->legalDocuments());
243 return new Settings($blocks->selectSettingsFrom($blocks->globalStore()));
New implementation of ilObjectGUI.
const SYSTEM_USER_ID
This file contains constants for PHPStan analyis, see: https://phpstan.org/config-reference#constants...
prepareOutput(bool $show_sub_objects=true)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
readonly ilLegalDocumentsAdministrationGUI $legal_documents
__construct(int $a_id=0, int $a_id_type=self::REPOSITORY_NODE_ID, int $a_parent_node_id=0)
readonly Settings $tos_settings
__construct(Container $dic, ilPlugin $plugin)