19 declare(strict_types=1);
40 private \ILIAS\DI\RBACServices
$rbac;
44 public function __construct($a_data,
int $a_id,
bool $a_call_by_reference =
true,
bool $a_prepare_output =
true)
51 $this->
rbac = $DIC->rbac();
52 $this->cronManager = $DIC->cron()->manager();
53 $this->
ui = $DIC->ui();
57 $this->
lng->loadLanguageModule(
'forum');
58 $this->
lng->loadLanguageModule(
'form');
63 if (!$this->
rbac->system()->checkAccess(
'visible,read', $this->
object->getRefId())) {
64 $this->error->raiseError($this->
lng->txt(
'no_permission'), $this->error->WARNING);
67 $next_class = $this->
ctrl->getNextClass($this);
68 $cmd = $this->
ctrl->getCmd();
72 switch ($next_class) {
73 case 'ilpermissiongui':
74 $this->tabs_gui->setTabActive(
'perm_settings');
79 if (!$cmd || $cmd ===
'view') {
80 $cmd =
'editSettings';
90 if ($this->
rbac->system()->checkAccess(
'visible,read', $this->
object->getRefId())) {
91 $this->tabs_gui->addTarget(
93 $this->
ctrl->getLinkTarget($this,
'editSettings'),
94 [
'editSettings',
'view']
98 if ($this->
rbac->system()->checkAccess(
'edit_permission', $this->
object->getRefId())) {
99 $this->tabs_gui->addTarget(
101 $this->
ctrl->getLinkTargetByClass(ilPermissionGUI::class,
'perm'),
110 $this->tabs_gui->activateTab(
'settings');
112 $this->tpl->setContent($this->
render([
120 return $this->
ui->renderer()->render($x);
127 $form = $this->
settingsForm()->withRequest($this->request);
128 $data = $form->getData();
129 if (
$data === null || $this->request->getMethod() !==
'POST') {
134 $set_int = fn(
string $field,
string $section) => $this->
settings->set(
136 (
string) ((
int)
$data[$section][$field])
139 $data[self::PROP_SECTION_NOTIFICATIONS][
'forum_notification'] = (
143 array_map($set_int, [
144 'forum_default_view',
145 'forum_enable_print',
146 'enable_fora_statistics',
147 'enable_anonymous_fora',
148 'file_upload_allowed_fora',
149 'forum_notification',
150 'send_attachments_by_mail',
153 self::PROP_SECTION_DEFAULTS,
154 self::PROP_SECTION_FEATURES,
155 self::PROP_SECTION_FEATURES,
156 self::PROP_SECTION_FEATURES,
157 self::PROP_SECTION_FEATURES,
158 self::PROP_SECTION_NOTIFICATIONS,
159 self::PROP_SECTION_NOTIFICATIONS,
160 self::PROP_SECTION_DRAFTS
163 $drafts =
$data[self::PROP_SECTION_DRAFTS][
'autosave_drafts'] !== null;
164 $this->
settings->set(
'autosave_drafts', (
string) ((
int) $drafts));
167 'autosave_drafts_ival',
168 (
string) ((
int)
$data[self::PROP_SECTION_DRAFTS][
'autosave_drafts'][
'ival'])
172 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'));
178 $field = $this->
ui->factory()->input()->field();
182 $this->
lng->txt($label)
185 $this->
lng->txt($label),
186 $this->
lng->txt($label .
'_desc')
188 $by_date_with_additional_info = fn(
string $label):
string => sprintf(
190 $this->
lng->txt(
'sort_by_date'),
191 $this->
lng->txt($label)
193 $to_string =
static fn($value):
string => (string) $value;
194 $radio_with_options =
static fn(
199 static fn($field, array $option) => $field->withOption(...array_map($to_string, $option)),
202 $checkbox_with_func =
function (
string $name, ?
string $label = null,
$f = null) use (
205 $f = $f ??
static fn($x) => $x;
210 ): array => $fields :
static fn(
212 ): array => array_map(
213 static fn($x) => $x->withDisabled(
true),
217 return $this->
ui->factory()->input()->container()->form()->standard(
218 $this->
ctrl->getFormAction($this,
'saveSettings'),
220 self::PROP_SECTION_DEFAULTS => $section(
'frm_adm_sec_default_settings', $disable_if_no_permission([
221 'forum_default_view' => $radio_with_options($field->radio($this->lng->txt(
'frm_default_view')), [
224 $this->
lng->txt(
'sort_by_posts'),
225 $this->
lng->txt(
'sort_by_posts_desc')
229 $by_date_with_additional_info(
'ascending_order'),
230 $this->
lng->txt(
'sort_by_date_desc')
234 $by_date_with_additional_info(
'descending_order'),
235 $this->
lng->txt(
'sort_by_date_desc')
239 self::PROP_SECTION_FEATURES => $section(
'frm_adm_sec_features', $disable_if_no_permission([
240 'forum_enable_print' => $checkbox_with_func(
'forum_enable_print',
'frm_enable_print_option'),
241 'enable_fora_statistics' => $checkbox_with_func(
'enable_fora_statistics'),
242 'enable_anonymous_fora' => $checkbox_with_func(
'enable_anonymous_fora'),
243 'file_upload_allowed_fora' => $radio_with_options(
244 $field->radio($this->lng->txt(
'file_upload_allowed_fora')),
248 $this->
lng->txt(
'file_upload_option_allow'),
249 $this->
lng->txt(
'file_upload_option_allow_info')
253 $this->
lng->txt(
'file_upload_option_disallow'),
254 $this->
lng->txt(
'file_upload_allowed_fora_desc')
259 'file_upload_allowed_fora',
264 self::PROP_SECTION_NOTIFICATIONS => $section(
'frm_adm_sec_notifications', $disable_if_no_permission([
265 'forum_notification' => $checkbox_with_func(
266 'forum_notification',
267 'forums_forum_notification',
275 'send_attachments_by_mail' => $checkbox_with_func(
'send_attachments_by_mail',
'enable_send_attachments')
277 self::PROP_SECTION_DRAFTS => $section(
'frm_adm_sec_drafts', $disable_if_no_permission([
278 'save_post_drafts' => $checkbox_with_func(
'save_post_drafts',
'adm_save_drafts'),
279 'autosave_drafts' => $field->optionalGroup([
281 ->numeric($this->lng->txt(
'adm_autosave_ival'))
283 ->withAdditionalTransformation(
285 $this->
refinery->int()->isGreaterThanOrEqual(30),
286 $this->
refinery->int()->isLessThanOrEqual(60 * 60)
289 ], $this->
lng->txt(
'adm_autosave_drafts'), $this->
lng->txt(
'adm_autosave_drafts_desc'))->
withValue(
290 $this->
settings->get(
'autosave_drafts') ? [
292 'autosave_drafts_ival',
306 'enable_fora_statistics' => [
307 (bool) $this->
settings->get(
'enable_fora_statistics',
'0'),
310 'enable_anonymous_fora' => [
311 (bool) $this->
settings->get(
'enable_anonymous_fora',
'0'),
315 return [[
'editSettings', $fields]];
327 $url = $this->
ctrl->getLinkTargetByClass(
328 [ilAdministrationGUI::class, ilObjSystemFolderGUI::class],
332 return $this->
ui->factory()->messageBox()->info($this->
lng->txt(key(
$data)) .
': ' . current(
$data))->withLinks(
334 $this->
ui->factory()->link()->standard($this->
lng->txt(
'adm_external_setting_edit'),
$url)
341 return $this->cronManager->isJobActive(
'frm_notification');
347 sprintf(
'%s<br/>%s', $component->getByLine(), $this->
lng->txt(
'cron_forum_notification_disabled')) :
348 $component->getByLine();
forumByLine(Component $component)
const PROP_SECTION_DRAFTS
const PROP_SECTION_DEFAULTS
__construct($data, int $id=0, bool $call_by_reference=true, bool $prepare_output=true)
prepareOutput(bool $show_sub_objects=true)
Class ChatMainBarProvider .
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilCronManager $cronManager
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
ILIAS DI RBACServices $rbac
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
Forum Administration Settings.
const PROP_SECTION_NOTIFICATIONS
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
addToExternalSettingsForm(int $a_form_id)