19 declare(strict_types=1);
39 public function __construct($a_data,
int $a_id,
bool $a_call_by_reference =
true,
bool $a_prepare_output =
true)
46 $this->cronManager = $DIC->cron()->manager();
47 $this->
ui = $DIC->ui();
51 $this->
lng->loadLanguageModule(
'forum');
52 $this->
lng->loadLanguageModule(
'form');
57 if (!$this->rbac_system->checkAccess(
'visible,read', $this->object->getRefId())) {
58 $this->error->raiseError($this->
lng->txt(
'no_permission'), $this->error->WARNING);
61 $next_class = $this->
ctrl->getNextClass($this);
62 $cmd = $this->
ctrl->getCmd();
66 switch ($next_class) {
67 case 'ilpermissiongui':
68 $this->tabs_gui->setTabActive(
'perm_settings');
73 if (!$cmd || $cmd ===
'view') {
74 $cmd =
'editSettings';
84 if ($this->rbac_system->checkAccess(
'visible,read', $this->object->getRefId())) {
85 $this->tabs_gui->addTarget(
87 $this->
ctrl->getLinkTarget($this,
'editSettings'),
88 [
'editSettings',
'view']
92 if ($this->rbac_system->checkAccess(
'edit_permission', $this->object->getRefId())) {
93 $this->tabs_gui->addTarget(
95 $this->
ctrl->getLinkTargetByClass(ilPermissionGUI::class,
'perm'),
104 $this->tabs_gui->activateTab(
'settings');
106 $this->tpl->setContent($this->
render([
114 return $this->
ui->renderer()->render($x);
119 if (!$this->rbac_system->checkAccess(
'write', $this->object->getRefId())) {
120 $this->error->raiseError($this->
lng->txt(
'no_permission'), $this->error->WARNING);
123 $form = $this->
settingsForm()->withRequest($this->request);
124 $data = $form->getData();
125 if (
$data === null || $this->request->getMethod() !==
'POST') {
130 $set_int = fn(
string $field,
string $section) => $this->
settings->set(
132 (
string) ((
int)
$data[$section][$field])
135 $data[self::PROP_SECTION_NOTIFICATIONS][
'forum_notification'] = (
140 'forum_default_view',
141 'forum_enable_print',
142 'enable_fora_statistics',
143 'enable_anonymous_fora',
144 'file_upload_allowed_fora',
145 'forum_notification',
146 'send_attachments_by_mail',
149 self::PROP_SECTION_DEFAULTS,
150 self::PROP_SECTION_FEATURES,
151 self::PROP_SECTION_FEATURES,
152 self::PROP_SECTION_FEATURES,
153 self::PROP_SECTION_FEATURES,
154 self::PROP_SECTION_NOTIFICATIONS,
155 self::PROP_SECTION_NOTIFICATIONS,
156 self::PROP_SECTION_DRAFTS
159 $drafts =
$data[self::PROP_SECTION_DRAFTS][
'autosave_drafts'] !== null;
160 $this->
settings->set(
'autosave_drafts', (
string) ((
int) $drafts));
163 'autosave_drafts_ival',
164 (
string) ((
int)
$data[self::PROP_SECTION_DRAFTS][
'autosave_drafts'][
'ival'])
168 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
169 $this->
ctrl->redirect($this,
'editSettings');
174 $may_write = $this->rbac_system->checkAccess(
'write', $this->
object->getRefId());
176 $field = $this->
ui->factory()->input()->field();
178 $section = fn(
string $label, array
$inputs): \ILIAS\UI\Component\Input\Field\Section => $field->section(
180 $this->
lng->txt($label)
182 $checkbox = fn(
string $label): \ILIAS\UI\Component\Input\Field\Checkbox => $field->checkbox(
183 $this->
lng->txt($label),
184 $this->
lng->txt($label .
'_desc')
186 $by_date_with_additional_info = fn(
string $label):
string => sprintf(
188 $this->
lng->txt(
'sort_by_date'),
189 $this->
lng->txt($label)
191 $to_string =
static fn($value):
string => (string) $value;
192 $radio_with_options =
static fn(
195 ): \ILIAS\UI\Component\Input\Field\Radio => array_reduce(
197 static fn($field, array $option) => $field->withOption(...array_map($to_string, $option)),
200 $checkbox_with_func =
function (
string $name, ?
string $label = null,
$f = null) use (
202 ): \ILIAS\UI\Component\Input\Field\Checkbox {
203 $f ??=
static fn($x) => $x;
206 $disable_if_no_permission = $may_write ?
static fn(
208 ): array => $fields :
static fn(
211 static fn($x) => $x->withDisabled(
true),
215 $action = $this->
ctrl->getFormAction($this,
'saveSettings');
217 $action = $this->
ctrl->getFormAction($this,
'editSettings');
220 $form = $this->
ui->factory()->input()->container()->form()->standard(
223 self::PROP_SECTION_DEFAULTS => $section(
'frm_adm_sec_default_settings', $disable_if_no_permission([
224 'forum_default_view' => $radio_with_options($field->radio($this->lng->txt(
'frm_default_view')), [
227 $this->
lng->txt(
'sort_by_posts'),
228 $this->
lng->txt(
'sort_by_posts_desc')
232 $by_date_with_additional_info(
'ascending_order'),
233 $this->
lng->txt(
'sort_by_date_desc')
237 $by_date_with_additional_info(
'descending_order'),
238 $this->
lng->txt(
'sort_by_date_desc')
242 self::PROP_SECTION_FEATURES => $section(
'frm_adm_sec_features', $disable_if_no_permission([
243 'forum_enable_print' => $checkbox_with_func(
'forum_enable_print',
'frm_enable_print_option'),
244 'enable_fora_statistics' => $checkbox_with_func(
'enable_fora_statistics'),
245 'enable_anonymous_fora' => $checkbox_with_func(
'enable_anonymous_fora'),
246 'file_upload_allowed_fora' => $radio_with_options(
247 $field->radio($this->lng->txt(
'file_upload_allowed_fora')),
251 $this->
lng->txt(
'file_upload_option_allow'),
252 $this->
lng->txt(
'file_upload_option_allow_info')
256 $this->
lng->txt(
'file_upload_option_disallow'),
257 $this->
lng->txt(
'file_upload_allowed_fora_desc')
262 'file_upload_allowed_fora',
267 self::PROP_SECTION_NOTIFICATIONS => $section(
'frm_adm_sec_notifications', $disable_if_no_permission([
268 'forum_notification' => $checkbox_with_func(
269 'forum_notification',
270 'forums_forum_notification',
278 'send_attachments_by_mail' => $checkbox_with_func(
279 'send_attachments_by_mail',
280 'enable_send_attachments' 283 self::PROP_SECTION_DRAFTS => $section(
'frm_adm_sec_drafts', $disable_if_no_permission([
284 'save_post_drafts' => $checkbox_with_func(
'save_post_drafts',
'adm_save_drafts'),
285 'autosave_drafts' => $field->optionalGroup([
287 ->numeric($this->lng->txt(
'adm_autosave_ival'))
289 ->withAdditionalTransformation(
291 $this->
refinery->int()->isGreaterThanOrEqual(30),
292 $this->
refinery->int()->isLessThanOrEqual(60 * 60)
295 ], $this->
lng->txt(
'adm_autosave_drafts'), $this->
lng->txt(
'adm_autosave_drafts_desc'))->
withValue(
296 $this->
settings->get(
'autosave_drafts') ? [
298 'autosave_drafts_ival',
308 $form = $form->withSubmitLabel($this->
lng->txt(
'refresh'));
318 'enable_fora_statistics' => [
319 (bool) $this->
settings->get(
'enable_fora_statistics',
'0'),
322 'enable_anonymous_fora' => [
323 (bool) $this->
settings->get(
'enable_anonymous_fora',
'0'),
327 return [[
'editSettings', $fields]];
339 $url = $this->
ctrl->getLinkTargetByClass(
340 [ilAdministrationGUI::class, ilObjSystemFolderGUI::class],
344 return $this->
ui->factory()->messageBox()->info($this->
lng->txt(key(
$data)) .
': ' . current(
$data))->withLinks(
346 $this->
ui->factory()->link()->standard($this->
lng->txt(
'adm_external_setting_edit'),
$url)
353 return $this->cronManager->isJobActive(
'frm_notification');
359 sprintf(
'%s<br/>%s', $component->getByLine(), $this->
lng->txt(
'cron_forum_notification_disabled')) :
360 $component->getByLine();
forumByLine(Component $component)
const PROP_SECTION_DRAFTS
const PROP_SECTION_DEFAULTS
prepareOutput(bool $show_sub_objects=true)
Interface Observer Contains several chained tasks and infos about them.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const FILE_UPLOAD_INDIVIDUAL
editSettings(Form $form=null)
Provides fluid interface to RBAC services.
const FILE_UPLOAD_GLOBALLY_ALLOWED
Class ilObjectGUI Basic methods of all Output classes.
const PROP_SECTION_FEATURES
ilObjForumAdministrationGUI: ilPermissionGUI ilObjForumAdministrationGUI: ilAdministrationGUI ...
__construct(Container $dic, ilPlugin $plugin)
const PROP_SECTION_NOTIFICATIONS
readonly ilCronManager $cronManager
addToExternalSettingsForm(int $a_form_id)