19 declare(strict_types=1);
36 private readonly \ILIAS\HTTP\GlobalHttpState
$http;
40 private readonly \ILIAS\DI\Container
$dic;
50 $this->
ctrl = $DIC->ctrl();
51 $this->tpl = $DIC->ui()->mainTemplate();
52 $this->
lng = $DIC->language();
54 $this->
tabs = $DIC->tabs();
55 $this->
access = $DIC->access();
56 $this->obj_service = $this->dic->object();
57 $this->
http = $DIC->http();
58 $this->ui_factory = $DIC->ui()->factory();
59 $this->error = $DIC[
'ilErr'];
61 $this->
lng->loadLanguageModule(
'style');
62 $this->
lng->loadLanguageModule(
'cont');
67 return $this->forum->getRefId();
78 $cmd = $this->
ctrl->getCmd();
81 case method_exists($this, $cmd):
87 $this->
ctrl->redirect($this->parent_obj);
94 $section->setTitle($this->
lng->txt(
'rep_activation_availability'));
98 $online->setInfo($this->
lng->txt(
'frm_activation_online_info'));
105 $this->
tabs->activateSubTab(self::UI_SUB_TAB_ID_BASIC_SETTINGS);
106 $a_form->
setTitle($this->
lng->txt(
'frm_settings_form_header'));
111 $presentationHeader->setTitle($this->
lng->txt(
'settings_presentation_header'));
112 $a_form->
addItem($presentationHeader);
114 $this->obj_service->commonSettings()->legacyForm($a_form, $this->parent_obj->getObject())->addTileImage();
118 $option_view_by_posts->
setInfo($this->
lng->txt(
'sort_by_posts_desc'));
119 $rg_pro->addOption($option_view_by_posts);
121 $option_view_by_date->setInfo($this->
lng->txt(
'sort_by_date_desc'));
126 $option_view_by_date->addSubItem($sub_group);
127 $rg_pro->addOption($option_view_by_date);
131 $userFunctionsHeader->setTitle($this->
lng->txt(
'frm_settings_user_functions_header'));
132 $a_form->
addItem($userFunctionsHeader);
136 $frm_subject->addOption(
new ilRadioOption($this->
lng->txt(
'add_re_to_subject'),
'add_re_to_subject'));
137 $frm_subject->addOption(
new ilRadioOption($this->
lng->txt(
'empty_subject'),
'empty_subject'));
138 $a_form->
addItem($frm_subject);
141 $cb_prop->setValue(
'1');
142 $cb_prop->setInfo($this->
lng->txt(
'enable_thread_ratings_info'));
147 $frm_upload->setValue(
'1');
148 $frm_upload->setInfo($this->
lng->txt(
'allow_file_upload_desc'));
153 $moderatorFunctionsHeader->setTitle($this->
lng->txt(
'frm_settings_mod_functions_header'));
154 $a_form->
addItem($moderatorFunctionsHeader);
157 $cb_prop->setValue(
'1');
158 $cb_prop->setInfo($this->
lng->txt(
'post_activation_desc'));
162 $cb_prop->setValue(
'1');
163 $cb_prop->setInfo($this->
lng->txt(
'mark_moderator_posts_desc'));
166 if ($this->
settings->get(
'enable_anonymous_fora') || $this->
settings->get(
'enable_fora_statistics')) {
168 $privacyHeader->setTitle($this->
lng->txt(
'frm_settings_privacy_header'));
169 $a_form->
addItem($privacyHeader);
172 if ($this->
settings->get(
'enable_fora_statistics')) {
174 $cb_prop->setValue(
'1');
175 $cb_prop->setInfo($this->
lng->txt(
'frm_statistics_enabled_desc'));
179 if ($this->
settings->get(
'enable_anonymous_fora') || $this->parent_obj->objProperties->isAnonymized()) {
181 $cb_prop->setValue(
'1');
182 $cb_prop->setInfo($this->
lng->txt(
'frm_anonymous_posting_desc'));
189 $this->
tabs->addSubTabTarget(
190 self::UI_SUB_TAB_ID_BASIC_SETTINGS,
191 $this->
ctrl->getLinkTarget($this->parent_obj,
'edit'),
193 [strtolower(ilObjForumGUI::class)]
196 if ($this->
settings->get(
'forum_notification') > 0 &&
197 $this->forum->isParentMembershipEnabledContainer() &&
198 $this->
access->checkAccess(
'write',
'', $this->parent_obj->getRefId())) {
199 $cmd = $this->dic->http()->wrapper()->query()->retrieve(
201 $this->dic->refinery()->byTrying([
202 $this->dic->refinery()->kindlyTo()->string(),
203 $this->dic->refinery()->always(
'showMembers')
206 $this->
tabs->addSubTabTarget(
207 self::UI_SUB_TAB_ID_NOTIFICATIONS,
208 $this->
ctrl->getLinkTarget($this,
'showMembers'),
210 [strtolower(self::class)],
212 in_array($cmd, [
'showMembers',
'forums_notification_settings'],
true)
216 $this->
tabs->addSubTabTarget(
217 self::UI_SUB_TAB_ID_NEWS,
218 $this->
ctrl->getLinkTargetByClass(ilContainerNewsSettingsGUI::class),
220 [strtolower(ilContainerNewsSettingsGUI::class)]
223 $this->
tabs->addSubTabTarget(
224 self::UI_SUB_TAB_ID_STYLE,
225 $this->
ctrl->getLinkTargetByClass(strtolower(ilObjectContentStyleSettingsGUI::class),
""),
227 [strtolower(ilObjectContentStyleSettingsGUI::class)]
230 $this->
tabs->activateTab(self::UI_TAB_ID_SETTINGS);
237 $a_values[
'anonymized'] = $this->parent_obj->objProperties->isAnonymized();
238 $a_values[
'statistics_enabled'] = $this->parent_obj->objProperties->isStatisticEnabled();
239 $a_values[
'post_activation'] = $this->parent_obj->objProperties->isPostActivationEnabled();
240 $a_values[
'subject_setting'] = $this->parent_obj->objProperties->getSubjectSetting();
241 $a_values[
'mark_mod_posts'] = $this->parent_obj->objProperties->getMarkModeratorPosts();
242 $a_values[
'thread_rating'] = $this->parent_obj->objProperties->isIsThreadRatingEnabled();
244 $default_view_value = $this->parent_obj->objProperties->getDefaultView();
245 if (in_array($default_view_value, [
251 if (in_array($default_view_value, [
255 $default_view_by_date = $default_view_value;
258 $default_view = $default_view_value;
264 $a_values[
'default_view'] = $default_view;
265 if (isset($default_view_by_date)) {
266 $a_values[
'default_view_by_date'] = $default_view_by_date;
268 $a_values[
'file_upload_allowed'] = $this->parent_obj->objProperties->getFileUploadAllowed();
270 $object = $this->parent_obj->getObject();
271 $a_values[
'activation_online'] = !$object->getOfflineStatus();
276 $default_view_input_value = (
int) $a_form->
getInput(
'default_view');
277 if (in_array($default_view_input_value, [
284 $default_view_order_by_date_value = (
int) $a_form->
getInput(
'default_view_by_date');
285 if (in_array($default_view_order_by_date_value, [
289 $default_view_input_value = $default_view_order_by_date_value;
292 $default_view = $default_view_input_value;
296 $this->parent_obj->objProperties->setDefaultView($default_view);
300 $view_mode =
'viewmode_' . $this->forum->getId();
305 if ($this->
settings->get(
'enable_anonymous_fora') || $this->parent_obj->objProperties->isAnonymized()) {
306 $this->parent_obj->objProperties->setAnonymisation((
bool) $a_form->
getInput(
'anonymized'));
308 if ($this->
settings->get(
'enable_fora_statistics')) {
309 $this->parent_obj->objProperties->setStatisticsStatus((
bool) $a_form->
getInput(
'statistics_enabled'));
311 $this->parent_obj->objProperties->setPostActivation((
bool) $a_form->
getInput(
'post_activation'));
312 $this->parent_obj->objProperties->setSubjectSetting($a_form->
getInput(
'subject_setting'));
313 $this->parent_obj->objProperties->setMarkModeratorPosts((
bool) $a_form->
getInput(
'mark_mod_posts'));
314 $this->parent_obj->objProperties->setIsThreadRatingEnabled((
bool) $a_form->
getInput(
'thread_rating'));
316 $this->parent_obj->objProperties->setFileUploadAllowed((
bool) $a_form->
getInput(
'file_upload_allowed'));
318 $this->parent_obj->objProperties->update();
319 $this->obj_service->commonSettings()->legacyForm($a_form, $this->parent_obj->getObject())->saveTileImage();
321 $object = $this->parent_obj->getObject();
322 $object->setOfflineStatus(!(
bool) $a_form->
getInput(
'activation_online'));
328 if (!$this->
access->checkAccess(
'write',
'', $this->parent_obj->getRefId())) {
329 $this->error->raiseError(
330 $this->
lng->txt(
'msg_no_perm_read'),
331 $this->error->MESSAGE
335 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.forums_members_list.html',
'components/ILIAS/Forum');
340 $interested_events = $this->parent_obj->objProperties->getInterestedEvents();
363 $this->notificationSettingsForm->setValuesByArray([
364 'notification_type' => $this->parent_obj->objProperties->getNotificationType()->value,
365 'adm_force' => $this->parent_obj->objProperties->isAdminForceNoti(),
366 'usr_toggle' => $this->parent_obj->objProperties->isUserToggleNoti(),
367 'notification_events' => $form_events
371 $this->tpl->setVariable(
'NOTIFICATIONS_SETTINGS_FORM', $this->notificationSettingsForm->getHTML());
375 $participants = $this->forum->parentParticipants();
376 $admin_ids = $participants->getAdmins();
377 $member_ids = $participants->getMembers();
378 $tutor_ids = $participants->getTutors();
382 $forum_noti->
setAdminForce($this->parent_obj->objProperties->isAdminForceNoti());
383 $forum_noti->setUserToggle($this->parent_obj->objProperties->isUserToggleNoti());
384 $forum_noti->setForumId($this->parent_obj->objProperties->getObjId());
385 $forum_noti->setInterestedEvents($this->parent_obj->objProperties->getInterestedEvents());
386 $forum_noti->update();
387 } elseif ($this->parent_obj->objProperties->getNotificationType() === NotificationType::PER_USER) {
408 $forced_events = $this->forumNotificationObj->getForcedEventsObjectByUserId($user_id);
413 $users[$counter][
'firstname'] = $name[
'firstname'];
414 $users[$counter][
'lastname'] = $name[
'lastname'];
415 $users[$counter][
'user_toggle_noti'] = $forced_events->getUserToggle();
416 $users[$counter][
'notification_id'] = $forced_events->getNotificationId();
417 $users[$counter][
'interested_events'] = $forced_events->getInterestedEvents();
418 $users[$counter][
'usr_id_events'] =
$user_id;
419 $users[$counter][
'forum_id'] = $forced_events->getForumId();
426 private function showMembersTable(array $moderators, array $admins, array $members, array $tutors): void
428 foreach (array_filter([
429 'moderators' => $moderators,
430 'administrator' => $admins,
432 'members' => $members
433 ]) as $type =>
$data) {
435 $tbl->setData(
$data);
437 $this->tpl->setCurrentBlock(strtolower($type) .
'_table');
438 $this->tpl->setVariable(strtoupper($type), $tbl->getHTML());
444 if (!$this->
access->checkAccess(
'write',
'', $this->parent_obj->getRefId())) {
445 $this->error->raiseError(
446 $this->
lng->txt(
'msg_no_perm_read'),
447 $this->error->MESSAGE
452 $this->
ctrl->getFormAction($this,
'saveEventsForUser'),
458 if ($this->
http->request()->getMethod() ===
'POST') {
459 $form = $events_form_builder->
build()->withRequest($this->
http->request());
460 $formData = $form->getData();
464 foreach ($events_form_builder->getValidEvents() as $event) {
465 $interested_events += isset($formData[$event]) && $formData[$event] ? $events_form_builder->getValueForEvent(
470 if (isset($formData[
'hidden_value']) && $formData[
'hidden_value']) {
471 $hidden_value = json_decode($formData[
'hidden_value'],
false, 512, JSON_THROW_ON_ERROR);
472 $valid_usr_ids = $this->forum->getAllForumParticipants();
474 if (in_array($hidden_value->usr_id, $valid_usr_ids)) {
476 $frm_noti->
setUserId($hidden_value->usr_id);
477 $frm_noti->setForumId($this->forum->getId());
478 $frm_noti->setInterestedEvents($interested_events);
479 $frm_noti->updateInterestedEvents();
484 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'),
true);
491 if (!$this->
access->checkAccess(
'write',
'', $this->parent_obj->getRefId())) {
492 $this->error->raiseError(
493 $this->
lng->txt(
'msg_no_perm_read'),
494 $this->error->MESSAGE
499 if ($this->dic->http()->wrapper()->post()->has(
'user_id')) {
500 $user_ids = $this->dic->http()->wrapper()->post()->retrieve(
502 $this->dic->refinery()->kindlyTo()->listOf($this->dic->refinery()->kindlyTo()->int())
506 if (count($user_ids) === 0) {
507 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'time_limit_no_users_selected'),
true);
513 $frm_noti->setUserToggle(
false);
514 $is_enabled = $frm_noti->isAdminForceNotification();
517 $frm_noti->setAdminForce(
true);
518 $frm_noti->insertAdminForce();
522 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'));
530 if (!$this->
access->checkAccess(
'write',
'', $this->parent_obj->getRefId())) {
531 $this->error->raiseError(
532 $this->
lng->txt(
'msg_no_perm_read'),
533 $this->error->MESSAGE
538 if ($this->dic->http()->wrapper()->post()->has(
'user_id')) {
539 $user_ids = $this->dic->http()->wrapper()->post()->retrieve(
541 $this->dic->refinery()->kindlyTo()->listOf($this->dic->refinery()->kindlyTo()->int())
545 if (count($user_ids) === 0) {
546 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'time_limit_no_users_selected'));
552 $is_enabled = $frm_noti->isAdminForceNotification();
555 $frm_noti->deleteAdminForce();
559 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'));
567 if (!$this->
access->checkAccess(
'write',
'', $this->parent_obj->getRefId())) {
568 $this->error->raiseError(
569 $this->
lng->txt(
'msg_no_perm_read'),
570 $this->error->MESSAGE
575 if ($this->dic->http()->wrapper()->post()->has(
'user_id')) {
576 $user_ids = $this->dic->http()->wrapper()->post()->retrieve(
578 $this->dic->refinery()->kindlyTo()->listOf($this->dic->refinery()->kindlyTo()->int())
582 if (count($user_ids) === 0) {
583 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'time_limit_no_users_selected'));
589 $frm_noti->setUserToggle(
true);
590 $is_enabled = $frm_noti->isAdminForceNotification();
593 $frm_noti->updateUserToggle();
595 $frm_noti->setAdminForce(
true);
596 $frm_noti->insertAdminForce();
600 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'));
608 if (!$this->
access->checkAccess(
'write',
'', $this->parent_obj->getRefId())) {
609 $this->error->raiseError(
610 $this->
lng->txt(
'msg_no_perm_read'),
611 $this->error->MESSAGE
616 if ($this->dic->http()->wrapper()->post()->has(
'user_id')) {
617 $user_ids = $this->dic->http()->wrapper()->post()->retrieve(
619 $this->dic->refinery()->kindlyTo()->listOf($this->dic->refinery()->kindlyTo()->int())
623 if (count($user_ids) === 0) {
624 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'time_limit_no_users_selected'));
630 $frm_noti->setUserToggle(
false);
631 $is_enabled = $frm_noti->isAdminForceNotification();
633 $frm_noti->updateUserToggle();
635 $frm_noti->setAdminForce(
true);
636 $frm_noti->insertAdminForce();
640 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'));
648 if ($this->notificationSettingsForm === null) {
650 $form->setFormAction($this->
ctrl->getFormAction($this,
'updateNotificationSettings'));
651 $form->setTitle($this->
lng->txt(
'forums_notification_settings'));
654 $radio_grp->setValue(
'default');
657 $this->
lng->txt(
'user_decides_notification'),
660 $opt_0 =
new ilRadioOption($this->
lng->txt(
'settings_for_all_members'), NotificationType::ALL_USERS->value);
661 $opt_1 =
new ilRadioOption($this->
lng->txt(
'settings_per_users'), NotificationType::PER_USER->value);
663 $radio_grp->addOption($opt_default);
664 $radio_grp->addOption($opt_0);
665 $radio_grp->addOption($opt_1);
668 $chb_2->setValue(
'1');
675 $cb_grp->addOption($notify_modified);
678 $cb_grp->addOption($notify_censored);
681 $cb_grp->addOption($notify_uncensored);
684 $cb_grp->addOption($notify_post_deleted);
687 $cb_grp->addOption($notify_thread_deleted);
690 $form->addItem($radio_grp);
692 $form->addCommandButton(
'updateNotificationSettings', $this->
lng->txt(
'save'));
694 $this->notificationSettingsForm = $form;
704 if (!$this->
access->checkAccess(
'write',
'', $this->parent_obj->getRefId())) {
705 $this->error->raiseError(
706 $this->
lng->txt(
'msg_no_perm_read'),
707 $this->error->MESSAGE
714 if ($this->notificationSettingsForm->checkInput()) {
715 $notification_type = NotificationType::tryFrom($this->dic->http()->wrapper()->post()->retrieve(
717 $this->dic->refinery()->byTrying([
718 $this->dic->refinery()->kindlyTo()->string(),
723 if ($notification_type === NotificationType::ALL_USERS) {
724 $notification_events = $this->notificationSettingsForm->getInput(
'notification_events');
725 $interested_events = 0;
727 if (is_array($notification_events)) {
728 foreach ($notification_events as $activated_event) {
729 $interested_events += (
int) $activated_event;
733 $this->parent_obj->objProperties->setAdminForceNoti(
true);
734 $this->parent_obj->objProperties->setUserToggleNoti(
735 (
bool) $this->notificationSettingsForm->getInput(
'usr_toggle')
737 $this->parent_obj->objProperties->setNotificationType(NotificationType::ALL_USERS);
738 $this->parent_obj->objProperties->setInterestedEvents($interested_events);
739 } elseif ($notification_type === NotificationType::PER_USER) {
740 $this->parent_obj->objProperties->setNotificationType(NotificationType::PER_USER);
741 $this->parent_obj->objProperties->setAdminForceNoti(
true);
742 $this->parent_obj->objProperties->setUserToggleNoti(
false);
745 $this->parent_obj->objProperties->setAdminForceNoti(
false);
746 $this->parent_obj->objProperties->setUserToggleNoti(
false);
747 $frm_noti->deleteNotificationAllUsers();
750 $frm_noti->updateUserNotifications($this->forum->getAllForumParticipants(), $properties);
752 $this->parent_obj->objProperties->update();
754 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'));
756 $this->notificationSettingsForm->setValuesByPost();
static get(string $a_var)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
readonly ILIAS HTTP GlobalHttpState $http
disableHideUserToggleNoti()
initNotificationSettingsForm()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setUserId(?int $a_user_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
readonly ILIAS UI Factory $ui_factory
showMembersTable(array $moderators, array $admins, array $members, array $tutors)
readonly ilObjectService $obj_service
ilPropertyFormGUI $notificationSettingsForm
ilForumNotification $forumNotificationObj
readonly ilGlobalTemplateInterface $tpl
static _lookupName(int $a_user_id)
lookup user name
Class ilForumSettingsGUI.
Class ilForumNotification.
addAvailabilitySection(ilPropertyFormGUI $form)
static getInstance(int $a_obj_id=0)
static http()
Fetches the global http state from ILIAS.
setAdminForce(bool $a_admin_force)
updateNotificationSettings()
readonly ilSetting $settings
readonly ilCtrlInterface $ctrl
enableHideUserToggleNoti()
__construct(private readonly ilObjForumGUI $parent_obj, private readonly ilObjForum $forum)
updateCustomValues(ilPropertyFormGUI $a_form)
getCustomValues(array &$a_values)
getCustomForm(ilPropertyFormGUI $a_form)
readonly ilAccessHandler $access
static isFileUploadGloballyAllowed()
static _getModerators(int $a_ref_id)
Class ilForumNotificationTableGUI.
getUserNotificationTableData(array $user_ids)
initForcedForumNotification()
readonly ilErrorHandling $error
readonly ILIAS DI Container $dic
static set(string $a_var, $a_val)
Set a value.
static _lookupLogin(int $a_user_id)