19declare(strict_types=1);
39 private readonly \ILIAS\HTTP\GlobalHttpState
$http;
43 private readonly \ILIAS\DI\Container
$dic;
55 $this->
ctrl = $DIC->ctrl();
56 $this->tpl =
$DIC->ui()->mainTemplate();
57 $this->
lng = $DIC->language();
59 $this->
tabs = $DIC->tabs();
60 $this->
access = $DIC->access();
61 $this->obj_service = $this->dic->object();
62 $this->
http = $DIC->http();
63 $this->ui_factory =
$DIC->ui()->factory();
64 $this->ui_renderer =
$DIC->ui()->renderer();
65 $this->ui_service =
$DIC->uiService();
66 $this->
error = $DIC[
'ilErr'];
68 $this->
lng->loadLanguageModule(
'style');
69 $this->
lng->loadLanguageModule(
'cont');
74 return $this->forum->getRefId();
80 $this->forumNotificationObj->readAllForcedEvents();
85 $cmd = $this->
ctrl->getCmd() ??
'';
87 case method_exists($this, $cmd .
'Command'):
89 $this->{$cmd .
'Command'}();
93 $this->
ctrl->redirect($this->parent_obj);
100 $section->setTitle($this->
lng->txt(
'rep_activation_availability'));
104 $online->setInfo($this->
lng->txt(
'frm_activation_online_info'));
111 $this->
tabs->activateSubTab(self::UI_SUB_TAB_ID_BASIC_SETTINGS);
112 $a_form->
setTitle($this->
lng->txt(
'frm_settings_form_header'));
117 $presentationHeader->setTitle($this->
lng->txt(
'settings_presentation_header'));
118 $a_form->
addItem($presentationHeader);
120 $this->obj_service->commonSettings()->legacyForm($a_form, $this->parent_obj->getObject())->addTileImage();
124 $option_view_by_posts->setInfo($this->
lng->txt(
'sort_by_posts_desc'));
125 $rg_pro->addOption($option_view_by_posts);
127 $option_view_by_date->setInfo($this->
lng->txt(
'sort_by_date_desc'));
132 $option_view_by_date->addSubItem($sub_group);
133 $rg_pro->addOption($option_view_by_date);
137 $userFunctionsHeader->setTitle($this->
lng->txt(
'frm_settings_user_functions_header'));
138 $a_form->
addItem($userFunctionsHeader);
141 $frm_subject->addOption(
new ilRadioOption($this->
lng->txt(
'preset_subject'),
'preset_subject'));
142 $frm_subject->addOption(
new ilRadioOption($this->
lng->txt(
'add_re_to_subject'),
'add_re_to_subject'));
143 $frm_subject->addOption(
new ilRadioOption($this->
lng->txt(
'empty_subject'),
'empty_subject'));
144 $a_form->
addItem($frm_subject);
147 $cb_prop->setValue(
'1');
148 $cb_prop->setInfo($this->
lng->txt(
'enable_thread_ratings_info'));
153 $frm_upload->setValue(
'1');
154 $frm_upload->setInfo($this->
lng->txt(
'allow_file_upload_desc'));
159 $moderatorFunctionsHeader->setTitle($this->
lng->txt(
'frm_settings_mod_functions_header'));
160 $a_form->
addItem($moderatorFunctionsHeader);
163 $cb_prop->setValue(
'1');
164 $cb_prop->setInfo($this->
lng->txt(
'post_activation_desc'));
168 $cb_prop->setValue(
'1');
169 $cb_prop->setInfo($this->
lng->txt(
'mark_moderator_posts_desc'));
172 if ($this->
settings->get(
'enable_anonymous_fora') || $this->settings->get(
'enable_fora_statistics')) {
174 $privacyHeader->setTitle($this->
lng->txt(
'frm_settings_privacy_header'));
175 $a_form->
addItem($privacyHeader);
178 if ($this->
settings->get(
'enable_fora_statistics')) {
180 $cb_prop->setValue(
'1');
181 $cb_prop->setInfo($this->
lng->txt(
'frm_statistics_enabled_desc'));
185 if ($this->
settings->get(
'enable_anonymous_fora') || $this->parent_obj->objProperties->isAnonymized()) {
187 $cb_prop->setValue(
'1');
188 $cb_prop->setInfo($this->
lng->txt(
'frm_anonymous_posting_desc'));
195 $this->
tabs->addSubTabTarget(
196 self::UI_SUB_TAB_ID_BASIC_SETTINGS,
197 $this->
ctrl->getLinkTarget($this->parent_obj,
'edit'),
199 [strtolower(ilObjForumGUI::class)]
202 if ($this->
settings->get(
'forum_notification') > 0 &&
203 $this->forum->isParentMembershipEnabledContainer() &&
204 $this->access->checkAccess(
'write',
'', $this->parent_obj->getRefId())) {
206 $this->
tabs->addSubTabTarget(
207 self::UI_SUB_TAB_ID_NOTIFICATIONS,
208 $this->
ctrl->getLinkTarget($this,
'showMembers'),
210 [strtolower(self::class)]
214 $this->
tabs->addSubTabTarget(
215 self::UI_SUB_TAB_ID_NEWS,
216 $this->
ctrl->getLinkTargetByClass(ilContainerNewsSettingsGUI::class),
218 [strtolower(ilContainerNewsSettingsGUI::class)]
221 $this->
tabs->addSubTabTarget(
222 self::UI_SUB_TAB_ID_STYLE,
223 $this->
ctrl->getLinkTargetByClass(strtolower(ilObjectContentStyleSettingsGUI::class),
""),
225 [strtolower(ilObjectContentStyleSettingsGUI::class)]
228 $this->
tabs->activateTab(self::UI_TAB_ID_SETTINGS);
235 $a_values[
'anonymized'] = $this->parent_obj->objProperties->isAnonymized();
236 $a_values[
'statistics_enabled'] = $this->parent_obj->objProperties->isStatisticEnabled();
237 $a_values[
'post_activation'] = $this->parent_obj->objProperties->isPostActivationEnabled();
238 $a_values[
'subject_setting'] = $this->parent_obj->objProperties->getSubjectSetting();
239 $a_values[
'mark_mod_posts'] = $this->parent_obj->objProperties->getMarkModeratorPosts();
240 $a_values[
'thread_rating'] = $this->parent_obj->objProperties->isIsThreadRatingEnabled();
242 $default_view_value = $this->parent_obj->objProperties->getDefaultView();
243 if (in_array($default_view_value, [
249 if (in_array($default_view_value, [
253 $default_view_by_date = $default_view_value;
256 $default_view = $default_view_value;
262 $a_values[
'default_view'] = $default_view;
263 if (isset($default_view_by_date)) {
264 $a_values[
'default_view_by_date'] = $default_view_by_date;
266 $a_values[
'file_upload_allowed'] = $this->parent_obj->objProperties->getFileUploadAllowed();
268 $object = $this->parent_obj->getObject();
269 $a_values[
'activation_online'] = !$object->getOfflineStatus();
274 $default_view_input_value = (
int) $a_form->
getInput(
'default_view');
275 if (in_array($default_view_input_value, [
282 $default_view_order_by_date_value = (
int) $a_form->
getInput(
'default_view_by_date');
283 if (in_array($default_view_order_by_date_value, [
287 $default_view_input_value = $default_view_order_by_date_value;
290 $default_view = $default_view_input_value;
294 $this->parent_obj->objProperties->setDefaultView($default_view);
298 $view_mode =
'viewmode_' . $this->forum->getId();
303 if ($this->
settings->get(
'enable_anonymous_fora') || $this->parent_obj->objProperties->isAnonymized()) {
304 $this->parent_obj->objProperties->setAnonymisation((
bool) $a_form->
getInput(
'anonymized'));
306 if ($this->
settings->get(
'enable_fora_statistics')) {
307 $this->parent_obj->objProperties->setStatisticsStatus((
bool) $a_form->
getInput(
'statistics_enabled'));
309 $this->parent_obj->objProperties->setPostActivation((
bool) $a_form->
getInput(
'post_activation'));
310 $this->parent_obj->objProperties->setSubjectSetting($a_form->
getInput(
'subject_setting'));
311 $this->parent_obj->objProperties->setMarkModeratorPosts((
bool) $a_form->
getInput(
'mark_mod_posts'));
312 $this->parent_obj->objProperties->setIsThreadRatingEnabled((
bool) $a_form->
getInput(
'thread_rating'));
314 $this->parent_obj->objProperties->setFileUploadAllowed((
bool) $a_form->
getInput(
'file_upload_allowed'));
316 $this->parent_obj->objProperties->update();
317 $this->obj_service->commonSettings()->legacyForm($a_form, $this->parent_obj->getObject())->saveTileImage();
319 $object = $this->parent_obj->getObject();
320 $object->setOfflineStatus(!$a_form->
getInput(
'activation_online'));
326 if (!$this->
access->checkAccess(
'write',
'', $this->parent_obj->getRefId())) {
327 $this->
error->raiseError(
328 $this->
lng->txt(
'msg_no_perm_read'),
329 $this->error->MESSAGE
333 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.forums_members_list.html',
'components/ILIAS/Forum');
338 $interested_events = $this->parent_obj->objProperties->getInterestedEvents();
361 $this->notificationSettingsForm->setValuesByArray([
362 'notification_type' => $this->parent_obj->objProperties->getNotificationType()->value,
363 'adm_force' => $this->parent_obj->objProperties->isAdminForceNoti(),
364 'usr_toggle' => $this->parent_obj->objProperties->isUserToggleNoti(),
365 'notification_events' => $form_events
369 $this->tpl->setVariable(
'NOTIFICATIONS_SETTINGS_FORM', $this->notificationSettingsForm->getHTML());
373 $forum_noti->setAdminForce($this->parent_obj->objProperties->isAdminForceNoti());
374 $forum_noti->setUserToggle($this->parent_obj->objProperties->isUserToggleNoti());
375 $forum_noti->setForumId($this->parent_obj->objProperties->getObjId());
376 $forum_noti->setInterestedEvents($this->parent_obj->objProperties->getInterestedEvents());
377 $forum_noti->update();
378 } elseif ($this->parent_obj->objProperties->getNotificationType() === NotificationType::PER_USER) {
379 $this->tpl->setVariable(
'TABLE', $this->ui_renderer->render($this->getForumNotificationTable()->getComponents()));
387 $this->
http->request(),
391 $this->parent_obj->getObject()->getRefId(),
392 $this->forum->parentParticipants(),
393 $this->forumNotificationObj,
395 $this->ctrl->getLinkTarget($this,
'handleNotificationActions')
401 $send_bad_request =
function () {
402 $this->
http->saveResponse(
403 $this->
http->response()
406 $this->
http->sendResponse();
407 $this->
http->close();
410 if (!$this->
http->wrapper()->query()->has(
'frm_notifications_table_usr_ids')) {
414 $user_ids = $this->
http->wrapper()->query()->retrieve(
415 'frm_notifications_table_usr_ids',
416 $this->dic->refinery()->kindlyTo()->listOf($this->dic->refinery()->kindlyTo()->int())
418 if (count($user_ids) !== 1) {
424 $forced_events = $this->forumNotificationObj->getForcedEventsObjectByUserId(
$user_id);
425 $interested_events = $forced_events->getInterestedEvents();
427 $this->
ctrl->getFormAction($this->parent_obj,
'saveEventsForUser'),
429 'hidden_value' => json_encode([
431 ], JSON_THROW_ON_ERROR),
442 $modal = $this->ui_factory->modal()->roundtrip(
443 $this->
lng->txt(
'notification_settings'),
445 $form_gui->getInputs(),
446 $this->ctrl->getFormAction($this,
'saveEventsForUser')
449 $this->
http->saveResponse($this->
http->response()->withBody(
450 Streams::ofString($this->ui_renderer->renderAsync($modal))
451 )->withHeader(ResponseHeader::CONTENT_TYPE,
'text/html'));
452 $this->
http->sendResponse();
453 $this->
http->close();
458 if (!$this->
access->checkAccess(
'write',
'', $this->parent_obj->getRefId())) {
459 $this->
error->raiseError(
460 $this->
lng->txt(
'msg_no_perm_read'),
461 $this->error->MESSAGE
466 $this->
ctrl->getFormAction($this,
'saveEventsForUser'),
472 if ($this->
http->request()->getMethod() ===
'POST') {
473 $form = $events_form_builder->build()->withRequest($this->
http->request());
474 $formData = $form->getData();
478 foreach ($events_form_builder->getValidEvents() as $event) {
479 $interested_events += isset($formData[$event]) && $formData[$event] ? $events_form_builder->getValueForEvent(
484 if (isset($formData[
'hidden_value']) && $formData[
'hidden_value']) {
485 $hidden_value = json_decode($formData[
'hidden_value'],
false, 512, JSON_THROW_ON_ERROR);
486 $valid_usr_ids = $this->forum->getAllForumParticipants();
488 if (in_array($hidden_value->usr_id, $valid_usr_ids)) {
490 $frm_noti->setUserId($hidden_value->usr_id);
491 $frm_noti->setForumId($this->forum->getId());
492 $frm_noti->setInterestedEvents($interested_events);
493 $frm_noti->updateInterestedEvents();
498 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->
lng->txt(
'saved_successfully'),
true);
499 $this->
ctrl->redirect($this,
'showMembers');
504 if (!$this->
access->checkAccess(
'write',
'', $this->parent_obj->getRefId())) {
505 $this->
error->raiseError(
506 $this->
lng->txt(
'msg_no_perm_read'),
507 $this->error->MESSAGE
512 if ($this->dic->http()->wrapper()->post()->has(
'user_id')) {
513 $user_ids = $this->dic->http()->wrapper()->post()->retrieve(
515 $this->dic->refinery()->kindlyTo()->listOf($this->dic->refinery()->kindlyTo()->int())
519 if (count($user_ids) === 0) {
520 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_INFO, $this->
lng->txt(
'time_limit_no_users_selected'),
true);
525 $frm_noti->setUserId((
int)
$user_id);
526 $frm_noti->setUserToggle(
false);
527 $is_enabled = $frm_noti->isAdminForceNotification();
530 $frm_noti->setAdminForce(
true);
531 $frm_noti->insertAdminForce();
535 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->
lng->txt(
'saved_successfully'),
true);
538 $this->
ctrl->redirect($this,
'showMembers');
543 if (!$this->
access->checkAccess(
'write',
'', $this->parent_obj->getRefId())) {
544 $this->
error->raiseError(
545 $this->
lng->txt(
'msg_no_perm_read'),
546 $this->error->MESSAGE
551 if ($this->dic->http()->wrapper()->post()->has(
'user_id')) {
552 $user_ids = $this->dic->http()->wrapper()->post()->retrieve(
554 $this->dic->refinery()->kindlyTo()->listOf($this->dic->refinery()->kindlyTo()->int())
558 if (count($user_ids) === 0) {
559 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_INFO, $this->
lng->txt(
'time_limit_no_users_selected'),
true);
564 $frm_noti->setUserId((
int)
$user_id);
565 $is_enabled = $frm_noti->isAdminForceNotification();
568 $frm_noti->deleteAdminForce();
572 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->
lng->txt(
'saved_successfully'),
true);
575 $this->
ctrl->redirect($this,
'showMembers');
580 if (!$this->
access->checkAccess(
'write',
'', $this->parent_obj->getRefId())) {
581 $this->
error->raiseError(
582 $this->
lng->txt(
'msg_no_perm_read'),
583 $this->error->MESSAGE
588 if ($this->dic->http()->wrapper()->query()->has(
'frm_notifications_table_usr_ids')) {
589 $user_ids = $this->dic->http()->wrapper()->query()->retrieve(
590 'frm_notifications_table_usr_ids',
591 $this->dic->refinery()->kindlyTo()->listOf($this->dic->refinery()->kindlyTo()->string())
593 if ($user_ids === [
'ALL_OBJECTS']) {
595 $user_ids = $table->getFilteredUserIds($this->ui_service->filter()->getData($table->getFilterComponent()));
599 if (count($user_ids) === 0) {
600 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_INFO, $this->
lng->txt(
'time_limit_no_users_selected'),
true);
605 $frm_noti->setUserId((
int)
$user_id);
606 $frm_noti->setUserToggle(
true);
607 $is_enabled = $frm_noti->isAdminForceNotification();
610 $frm_noti->updateUserToggle();
612 $frm_noti->setAdminForce(
true);
613 $frm_noti->insertAdminForce();
617 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->
lng->txt(
'saved_successfully'),
true);
620 $this->
ctrl->redirect($this,
'showMembers');
625 if (!$this->
access->checkAccess(
'write',
'', $this->parent_obj->getRefId())) {
626 $this->
error->raiseError(
627 $this->
lng->txt(
'msg_no_perm_read'),
628 $this->error->MESSAGE
633 if ($this->dic->http()->wrapper()->query()->has(
'frm_notifications_table_usr_ids')) {
634 $user_ids = $this->dic->http()->wrapper()->query()->retrieve(
635 'frm_notifications_table_usr_ids',
636 $this->dic->refinery()->kindlyTo()->listOf($this->dic->refinery()->kindlyTo()->string())
638 if ($user_ids === [
'ALL_OBJECTS']) {
640 $user_ids = $table->getFilteredUserIds($this->ui_service->filter()->getData($table->getFilterComponent()));
644 if (count($user_ids) === 0) {
645 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_INFO, $this->
lng->txt(
'time_limit_no_users_selected'),
true);
650 $frm_noti->setUserId((
int)
$user_id);
651 $frm_noti->setUserToggle(
false);
652 $is_enabled = $frm_noti->isAdminForceNotification();
654 $frm_noti->updateUserToggle();
656 $frm_noti->setAdminForce(
true);
657 $frm_noti->insertAdminForce();
661 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->
lng->txt(
'saved_successfully'),
true);
664 $this->
ctrl->redirect($this,
'showMembers');
669 if ($this->notificationSettingsForm ===
null) {
671 $form->setFormAction($this->
ctrl->getFormAction($this,
'updateNotificationSettings'));
672 $form->setTitle($this->
lng->txt(
'forums_notification_settings'));
675 $radio_grp->setValue(
'default');
678 $this->
lng->txt(
'user_decides_notification'),
681 $opt_0 =
new ilRadioOption($this->
lng->txt(
'settings_for_all_members'), NotificationType::ALL_USERS->value);
682 $opt_1 =
new ilRadioOption($this->
lng->txt(
'settings_per_users'), NotificationType::PER_USER->value);
684 $radio_grp->addOption($opt_default);
685 $radio_grp->addOption($opt_0);
686 $radio_grp->addOption($opt_1);
689 $chb_2->setValue(
'1');
691 $opt_0->addSubItem($chb_2);
696 $cb_grp->addOption($notify_modified);
699 $cb_grp->addOption($notify_censored);
702 $cb_grp->addOption($notify_uncensored);
705 $cb_grp->addOption($notify_post_deleted);
708 $cb_grp->addOption($notify_thread_deleted);
709 $opt_0->addSubItem($cb_grp);
711 $form->addItem($radio_grp);
713 $form->addCommandButton(
'updateNotificationSettings', $this->
lng->txt(
'save'));
715 $this->notificationSettingsForm = $form;
725 if (!$this->
access->checkAccess(
'write',
'', $this->parent_obj->getRefId())) {
726 $this->
error->raiseError(
727 $this->
lng->txt(
'msg_no_perm_read'),
728 $this->error->MESSAGE
735 if ($this->notificationSettingsForm->checkInput()) {
736 $notification_type = NotificationType::tryFrom($this->dic->http()->wrapper()->post()->retrieve(
738 $this->dic->refinery()->byTrying([
739 $this->dic->refinery()->kindlyTo()->string(),
744 if ($notification_type === NotificationType::ALL_USERS) {
745 $notification_events = $this->notificationSettingsForm->getInput(
'notification_events');
746 $interested_events = 0;
748 if (is_array($notification_events)) {
749 foreach ($notification_events as $activated_event) {
750 $interested_events += (
int) $activated_event;
754 $this->parent_obj->objProperties->setAdminForceNoti(
true);
755 $this->parent_obj->objProperties->setUserToggleNoti(
756 (
bool) $this->notificationSettingsForm->getInput(
'usr_toggle')
758 $this->parent_obj->objProperties->setNotificationType(NotificationType::ALL_USERS);
759 $this->parent_obj->objProperties->setInterestedEvents($interested_events);
760 } elseif ($notification_type === NotificationType::PER_USER) {
761 $this->parent_obj->objProperties->setNotificationType(NotificationType::PER_USER);
762 $this->parent_obj->objProperties->setAdminForceNoti(
true);
763 $this->parent_obj->objProperties->setUserToggleNoti(
false);
766 $this->parent_obj->objProperties->setAdminForceNoti(
false);
767 $this->parent_obj->objProperties->setUserToggleNoti(
false);
768 $frm_noti->deleteNotificationAllUsers();
771 $frm_noti->updateUserNotifications($this->forum->getAllForumParticipants(), $properties);
773 $this->parent_obj->objProperties->update();
775 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->
lng->txt(
'saved_successfully'),
true);
777 $this->notificationSettingsForm->setValuesByPost();
779 $this->
ctrl->redirect($this,
'showMembers');
785 'handleNotificationActions',
796 $action = $this->
http->wrapper()->query()->retrieve(
797 'frm_notifications_table_action',
798 $this->dic->refinery()->byTrying([
799 $this->dic->refinery()->kindlyTo()->string(),
800 $this->dic->refinery()->always(
null)
Stream factory which enables the user to create streams without the knowledge of the concrete class.
This class represents an option in a checkbox group.
Error Handling & global info handling.
Class ilForumNotification.
static getInstance(int $a_obj_id=0)
static isFileUploadGloballyAllowed()
@ilCtrl_Calls ilForumSettingsGUI: ilObjectContentStyleSettingsGUI
__construct(private readonly ilObjForumGUI $parent_obj, private readonly ilObjForum $forum)
handleNotificationActionsCommand()
getSafePostCommands()
This method must return a list of safe POST commands.
readonly ILIAS HTTP GlobalHttpState $http
readonly ilAccessHandler $access
readonly UiRenderer $ui_renderer
updateNotificationSettingsCommand()
readonly ILIAS UI Factory $ui_factory
getCustomForm(ilPropertyFormGUI $a_form)
readonly ilSetting $settings
saveEventsForUserCommand()
enableAdminForceNotiCommand()
readonly ilGlobalTemplateInterface $tpl
readonly ilUIService $ui_service
readonly ilObjectService $obj_service
addAvailabilitySection(ilPropertyFormGUI $form)
getUnsafeGetCommands()
This method must return a list of unsafe GET commands.
readonly ilErrorHandling $error
updateCustomValues(ilPropertyFormGUI $a_form)
disableAdminForceNotiCommand()
readonly ILIAS DI Container $dic
initForcedForumNotification()
getForumNotificationTable()
disableHideUserToggleNoti()
getCustomValues(array &$a_values)
initNotificationSettingsForm()
ilForumNotification $forumNotificationObj
ilPropertyFormGUI $notificationSettingsForm
enableHideUserToggleNoti()
readonly ilCtrlInterface $ctrl
@ilCtrl_Calls ilObjForumGUI: ilPermissionGUI, ilForumExportGUI, ilInfoScreenGUI @ilCtrl_Calls ilObjFo...
This class represents an option in a radio group.
static get(string $a_var)
static set(string $a_var, $a_val)
Set a value.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An entity that renders components to a string output.
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
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...
static http()
Fetches the global http state from ILIAS.