19declare(strict_types=1);
40 public function __construct($a_data,
int $a_id,
bool $a_call_by_reference =
true,
bool $a_prepare_output =
true)
47 $this->cronManager =
$DIC->cron()->manager();
48 $this->
ui = $DIC->ui();
52 $this->
lng->loadLanguageModule(
'forum');
53 $this->
lng->loadLanguageModule(
'form');
58 if (!$this->rbac_system->checkAccess(
'visible,read', $this->object->getRefId())) {
59 $this->
error->raiseError($this->
lng->txt(
'no_permission'), $this->error->WARNING);
62 $next_class = $this->
ctrl->getNextClass($this);
63 $cmd = $this->
ctrl->getCmd();
67 switch ($next_class) {
68 case 'ilpermissiongui':
69 $this->tabs_gui->setTabActive(
'perm_settings');
74 if (!$cmd || $cmd ===
'view') {
75 $cmd =
'editSettings';
85 if ($this->rbac_system->checkAccess(
'visible,read', $this->object->getRefId())) {
86 $this->tabs_gui->addTarget(
88 $this->
ctrl->getLinkTarget($this,
'editSettings'),
89 [
'editSettings',
'view']
93 if ($this->rbac_system->checkAccess(
'edit_permission', $this->object->getRefId())) {
94 $this->tabs_gui->addTarget(
96 $this->
ctrl->getLinkTargetByClass(ilPermissionGUI::class,
'perm'),
105 $this->tabs_gui->activateTab(
'settings');
107 $this->tpl->setContent($this->
render([
115 return $this->
ui->renderer()->render($x);
120 if (!$this->rbac_system->checkAccess(
'write', $this->object->getRefId())) {
121 $this->
error->raiseError($this->
lng->txt(
'no_permission'), $this->error->WARNING);
124 $form = $this->
settingsForm()->withRequest($this->request);
125 $data = $form->getData();
126 if (
$data ===
null || $this->request->getMethod() !==
'POST') {
131 $set_int = fn(
string $field,
string $section) => $this->
settings->set(
133 (
string) ((
int)
$data[$section][$field])
140 array_map($set_int, [
141 'forum_default_view',
142 'forum_enable_print',
143 'enable_fora_statistics',
144 'enable_anonymous_fora',
145 'file_upload_allowed_fora',
146 'forum_notification',
147 'send_attachments_by_mail',
150 self::PROP_SECTION_DEFAULTS,
151 self::PROP_SECTION_FEATURES,
152 self::PROP_SECTION_FEATURES,
153 self::PROP_SECTION_FEATURES,
154 self::PROP_SECTION_FEATURES,
155 self::PROP_SECTION_NOTIFICATIONS,
156 self::PROP_SECTION_NOTIFICATIONS,
157 self::PROP_SECTION_DRAFTS
161 $this->
settings->set(
'autosave_drafts', (
string) ((
int) $drafts));
164 'autosave_drafts_ival',
165 (
string) ((
int)
$data[self::PROP_SECTION_DRAFTS][
'autosave_drafts'][
'ival'])
169 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
170 $this->
ctrl->redirect($this,
'editSettings');
175 $may_write = $this->rbac_system->checkAccess(
'write', $this->
object->getRefId());
177 $field = $this->
ui->factory()->input()->field();
181 $this->
lng->txt($label)
184 $this->
lng->txt($label),
185 $this->lng->txt($label .
'_desc')
187 $by_date_with_additional_info = fn(
string $label):
string => sprintf(
189 $this->
lng->txt(
'sort_by_date'),
190 $this->lng->txt($label)
192 $to_string =
static fn($value):
string => (string) $value;
193 $radio_with_options =
static fn(
198 static fn($field, array $option) => $field->withOption(...array_map($to_string, $option)),
201 $checkbox_with_func =
function (
string $name, ?
string $label =
null,
$f =
null) use (
204 $f ??=
static fn($x) => $x;
207 $disable_if_no_permission = $may_write ?
static fn(
209 ): array => $fields :
static fn(
211 ): array => array_map(
212 static fn($x) => $x->withDisabled(
true),
216 $action = $this->
ctrl->getFormAction($this,
'saveSettings');
218 $action = $this->
ctrl->getFormAction($this,
'editSettings');
221 $form = $this->
ui->factory()->input()->container()->form()->standard(
224 self::PROP_SECTION_DEFAULTS => $section(
'frm_adm_sec_default_settings', $disable_if_no_permission([
225 'forum_default_view' => $radio_with_options($field->radio($this->lng->txt(
'frm_default_view')), [
228 $this->lng->txt(
'sort_by_posts'),
229 $this->lng->txt(
'sort_by_posts_desc')
233 $by_date_with_additional_info(
'ascending_order'),
234 $this->
lng->txt(
'sort_by_date_desc')
238 $by_date_with_additional_info(
'descending_order'),
239 $this->
lng->txt(
'sort_by_date_desc')
243 self::PROP_SECTION_FEATURES => $section(
'frm_adm_sec_features', $disable_if_no_permission([
244 'forum_enable_print' => $checkbox_with_func(
'forum_enable_print',
'frm_enable_print_option'),
245 'enable_fora_statistics' => $checkbox_with_func(
'enable_fora_statistics'),
246 'enable_anonymous_fora' => $checkbox_with_func(
'enable_anonymous_fora'),
247 'file_upload_allowed_fora' => $radio_with_options(
248 $field->radio($this->lng->txt(
'file_upload_allowed_fora')),
252 $this->lng->txt(
'file_upload_option_allow'),
253 $this->lng->txt(
'file_upload_option_allow_info')
257 $this->lng->txt(
'file_upload_option_disallow'),
258 $this->lng->txt(
'file_upload_allowed_fora_desc')
262 $this->settings->get(
263 'file_upload_allowed_fora',
268 self::PROP_SECTION_NOTIFICATIONS => $section(
'frm_adm_sec_notifications', $disable_if_no_permission([
269 'forum_notification' => $checkbox_with_func(
270 'forum_notification',
271 'forums_forum_notification',
275 ->
withValue($field->getValue() || $this->forumJobActive())
276 ->withByLine($this->forumByLine($field))
279 'send_attachments_by_mail' => $checkbox_with_func(
280 'send_attachments_by_mail',
281 'enable_send_attachments'
284 self::PROP_SECTION_DRAFTS => $section(
'frm_adm_sec_drafts', $disable_if_no_permission([
285 'save_post_drafts' => $checkbox_with_func(
'save_post_drafts',
'adm_save_drafts'),
286 'autosave_drafts' => $field->optionalGroup([
288 ->numeric($this->lng->txt(
'adm_autosave_ival'))
290 ->withAdditionalTransformation(
291 $this->refinery->in()->series([
292 $this->refinery->int()->isGreaterThanOrEqual(30),
293 $this->refinery->int()->isLessThanOrEqual(60 * 60)
296 ], $this->lng->txt(
'adm_autosave_drafts'), $this->lng->txt(
'adm_autosave_drafts_desc'))->withValue(
297 $this->settings->get(
'autosave_drafts') ? [
298 'ival' => $this->settings->get(
299 'autosave_drafts_ival',
309 $form = $form->withSubmitLabel($this->
lng->txt(
'refresh'));
319 'enable_fora_statistics' => [
320 (bool) $this->
settings->get(
'enable_fora_statistics',
'0'),
323 'enable_anonymous_fora' => [
324 (bool) $this->
settings->get(
'enable_anonymous_fora',
'0'),
328 return [[
'editSettings', $fields]];
340 $url = $this->
ctrl->getLinkTargetByClass(
341 [ilAdministrationGUI::class, ilObjSystemFolderGUI::class],
345 return $this->
ui->factory()->messageBox()->info($this->
lng->txt(key(
$data)) .
': ' . current(
$data))->withLinks(
347 $this->
ui->factory()->link()->standard($this->lng->txt(
'adm_external_setting_edit'),
$url)
354 return $this->cronManager->isJobActive(
'frm_notification');
360 sprintf(
'%s<br/>%s', $component->getByLine(), $this->lng->txt(
'cron_forum_notification_disabled')) :
361 $component->getByLine();
Provides fluid interface to RBAC services.
@ilCtrl_Calls ilCronManagerGUI: ilPropertyFormGUI @ilCtrl_isCalledBy ilCronManagerGUI: ilAdministrati...
const FILE_UPLOAD_INDIVIDUAL
const FILE_UPLOAD_GLOBALLY_ALLOWED
@ilCtrl_Calls ilObjForumAdministrationGUI: ilPermissionGUI @ilCtrl_IsCalledBy ilObjForumAdministratio...
addToExternalSettingsForm(int $a_form_id)
const string PROP_SECTION_DRAFTS
getAdminTabs()
administration tabs show only permissions and trash folder
editSettings(?Form $form=null)
forumByLine(Component $component)
const string PROP_SECTION_DEFAULTS
const string PROP_SECTION_NOTIFICATIONS
readonly JobManager $cronManager
const string PROP_SECTION_FEATURES
Class ilObjectGUI Basic methods of all Output classes.
prepareOutput(bool $show_sub_objects=true)
A component is the most general form of an entity in the UI.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.