19 declare(strict_types=1);
44 public function __construct($a_data,
int $a_id,
bool $a_call_by_reference =
true,
bool $a_prepare_output =
true)
50 $this->
lng->loadLanguageModule($this->type);
52 $this->uiFactory = $DIC->ui()->factory();
53 $this->uiRenderer = $DIC->ui()->renderer();
54 $this->
http = $DIC->http();
55 $this->settingsStorage =
new StorageImpl($DIC->settings());
60 if ($this->rbac_system->checkAccess(
'visible,read', $this->object->getRefId())) {
61 $this->tabs_gui->addTarget(
'settings', $this->
ctrl->getLinkTargetByClass(self::class, self::CMD_EDIT));
64 if ($this->rbac_system->checkAccess(
'edit_permission', $this->object->getRefId())) {
65 $this->tabs_gui->addTarget(
67 $this->
ctrl->getLinkTargetByClass(ilPermissionGUI::class,
'perm'),
69 ilPermissionGUI::class
76 if (!$this->rbac_system->checkAccess(
'visible,read', $this->object->getRefId())) {
77 $this->error->raiseError($this->
lng->txt(
'no_permission'), $this->error->WARNING);
80 $nextClass = $this->
ctrl->getNextClass($this);
81 $cmd = $this->
ctrl->getCmd();
84 switch (strtolower($nextClass)) {
85 case strtolower(ilPermissionGUI::class):
86 $this->tabs_gui->setTabActive(
'perm_settings');
88 $this->
ctrl->forwardCommand($perm_gui);
108 $action = $this->
ctrl->getLinkTargetByClass(self::class, self::CMD_SAVE);
110 $readingTimeStatus = $this->uiFactory
114 $this->
lng->txt(
'cpad_reading_time_status'),
115 $this->
lng->txt(
'cpad_reading_time_status_desc')
118 if (isset($values[self::F_READING_TIME])) {
119 $readingTimeStatus = $readingTimeStatus->withValue($values[self::F_READING_TIME]);
122 $section = $this->uiFactory->input()->field()->section(
123 [self::F_READING_TIME => $readingTimeStatus],
124 $this->
lng->txt(
'settings')
127 return $this->uiFactory
131 ->standard($action, [$section])
132 ->withAdditionalTransformation($this->
refinery->custom()->transformation(
static function ($values): array {
133 return array_merge(...$values);
140 protected function show(array $components): void
142 $this->tpl->setContent(
143 $this->uiRenderer->render($components)
147 protected function edit(): void
150 self::F_READING_TIME => $this->settingsStorage->getSettings()->isReadingTimeEnabled(),
153 $form = $this->
getForm($values);
155 $this->
show([$form]);
158 protected function save(): void
161 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
164 $form = $this->
getForm()->withRequest($this->
http->request());
165 $data = $form->getData();
167 $readingTime =
$data[self::F_READING_TIME];
168 $settings = $this->settingsStorage->getSettings()
169 ->withDisabledReadingTime();
173 $this->settingsStorage->store(
$settings);
177 [$this->uiFactory->messageBox()->success($this->
lng->txt(
'saved_successfully')), $form]
Interface GlobalHttpState.
An entity that renders components to a string output.
__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)
static http()
Fetches the global http state from ILIAS.
Class ilObjectGUI Basic methods of all Output classes.
ilObjContentPageAdministrationGUI: ilPermissionGUI
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
__construct(Container $dic, ilPlugin $plugin)
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.