19 declare(strict_types=1);
41 public function __construct($a_data,
int $a_id,
bool $a_call_by_reference =
true,
bool $a_prepare_output =
true)
47 $this->
lng->loadLanguageModule($this->type);
49 $this->settings_storage =
new StorageImpl($DIC->settings());
54 if ($this->rbac_system->checkAccess(
'visible,read', $this->object->getRefId())) {
55 $this->tabs_gui->addTarget(
'settings', $this->
ctrl->getLinkTargetByClass(self::class, self::CMD_EDIT));
58 if ($this->rbac_system->checkAccess(
'edit_permission', $this->object->getRefId())) {
59 $this->tabs_gui->addTarget(
61 $this->
ctrl->getLinkTargetByClass(ilPermissionGUI::class,
'perm'),
63 ilPermissionGUI::class
70 if (!$this->rbac_system->checkAccess(
'visible,read', $this->object->getRefId())) {
71 $this->error->raiseError($this->
lng->txt(
'no_permission'), $this->error->WARNING);
74 $nextClass = $this->
ctrl->getNextClass($this) ??
'';
75 $cmd = $this->
ctrl->getCmd() ??
'';
78 switch (strtolower($nextClass)) {
79 case strtolower(ilPermissionGUI::class):
80 $this->tabs_gui->setTabActive(
'perm_settings');
82 $this->
ctrl->forwardCommand($perm_gui);
87 self::CMD_VIEW, self::CMD_EDIT => $this->
edit(),
88 self::CMD_SAVE => $this->
save(),
89 default =>
throw new RuntimeException(__METHOD__ .
' :: Unknown command ' . $cmd),
94 private function getForm(array $values = []): Form
96 $may_write = $this->rbac_system->checkAccess(
'write', $this->
object->getRefId());
98 $action = $this->
ctrl->getLinkTargetByClass(self::class, self::CMD_SAVE);
100 $action = $this->
ctrl->getLinkTargetByClass(self::class, self::CMD_VIEW);
103 $readingTimeStatus = $this->ui_factory
107 $this->
lng->txt(
'cpad_reading_time_status'),
108 $this->
lng->txt(
'cpad_reading_time_status_desc')
110 ->withDisabled(!$may_write);
112 if (isset($values[self::F_READING_TIME])) {
113 $readingTimeStatus = $readingTimeStatus->withValue($values[self::F_READING_TIME]);
116 $section = $this->ui_factory->input()->field()->section(
117 [self::F_READING_TIME => $readingTimeStatus],
118 $this->
lng->txt(
'settings')
119 )->withDisabled(!$may_write);
121 $form = $this->ui_factory
125 ->standard($action, [$section])
126 ->withAdditionalTransformation($this->
refinery->custom()->transformation(
static function ($values): array {
127 return array_merge(...$values);
131 $form = $form->withSubmitLabel($this->
lng->txt(
'refresh'));
142 $this->tpl->setContent(
143 $this->ui_renderer->render($components)
150 self::F_READING_TIME => $this->settings_storage->getSettings()->isReadingTimeEnabled(),
153 $form = $this->
getForm($values);
155 $this->
show([$form]);
160 if (!$this->rbac_system->checkAccess(
'write', $this->object->getRefId())) {
161 $this->error->raiseError($this->
lng->txt(
'no_permission'), $this->error->WARNING);
164 $form = $this->
getForm()->withRequest($this->
http->request());
165 $data = $form->getData();
167 if (
$data ===
null || $this->request->getMethod() !==
'POST') {
168 $this->
show([$form]);
172 $readingTime =
$data[self::F_READING_TIME];
175 ->withDisabledReadingTime();
179 $this->settings_storage->store(
$settings);
181 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
182 $this->
ctrl->redirect($this, self::CMD_EDIT);
__construct($a_data, int $a_id, bool $a_call_by_reference=true, bool $a_prepare_output=true)
getForm(array $values=[])
prepareOutput(bool $show_sub_objects=true)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static http()
Fetches the global http state from ILIAS.
readonly Storage $settings_storage
Class ilObjectGUI Basic methods of all Output classes.
const string F_READING_TIME
ilObjContentPageAdministrationGUI: ilPermissionGUI
__construct(Container $dic, ilPlugin $plugin)