19 declare(strict_types=1);
41 private readonly \ILIAS\HTTP\GlobalHttpState
$http;
45 private readonly \ILIAS\DI\Container
$dic;
57 $this->
ctrl = $DIC->ctrl();
58 $this->tpl = $DIC->ui()->mainTemplate();
59 $this->
lng = $DIC->language();
61 $this->
tabs = $DIC->tabs();
62 $this->
access = $DIC->access();
63 $this->obj_service = $this->dic->object();
64 $this->
http = $DIC->http();
65 $this->ui_factory = $DIC->ui()->factory();
66 $this->ui_renderer = $DIC->ui()->renderer();
67 $this->ui_service = $DIC->uiService();
68 $this->error = $DIC[
'ilErr'];
70 $this->
lng->loadLanguageModule(
'style');
71 $this->
lng->loadLanguageModule(
'cont');
76 return $this->forum->getRefId();
82 $this->forumNotificationObj->readAllForcedEvents();
87 $cmd = $this->
ctrl->getCmd();
88 if ($this->
http->wrapper()->query()->has(
'forum_notification_table_action')) {
89 $cmd = $this->
http->wrapper()->query()->retrieve(
90 'forum_notification_table_action',
91 $this->dic->refinery()->kindlyTo()->string()
96 case method_exists($this, $cmd):
102 $this->
ctrl->redirect($this->parent_obj);
109 $section->setTitle($this->
lng->txt(
'rep_activation_availability'));
113 $online->setInfo($this->
lng->txt(
'frm_activation_online_info'));
120 $this->
tabs->activateSubTab(self::UI_SUB_TAB_ID_BASIC_SETTINGS);
121 $a_form->
setTitle($this->
lng->txt(
'frm_settings_form_header'));
126 $presentationHeader->setTitle($this->
lng->txt(
'settings_presentation_header'));
127 $a_form->
addItem($presentationHeader);
129 $this->obj_service->commonSettings()->legacyForm($a_form, $this->parent_obj->getObject())->addTileImage();
133 $option_view_by_posts->
setInfo($this->
lng->txt(
'sort_by_posts_desc'));
134 $rg_pro->addOption($option_view_by_posts);
136 $option_view_by_date->setInfo($this->
lng->txt(
'sort_by_date_desc'));
141 $option_view_by_date->addSubItem($sub_group);
142 $rg_pro->addOption($option_view_by_date);
146 $userFunctionsHeader->setTitle($this->
lng->txt(
'frm_settings_user_functions_header'));
147 $a_form->
addItem($userFunctionsHeader);
151 $frm_subject->addOption(
new ilRadioOption($this->
lng->txt(
'add_re_to_subject'),
'add_re_to_subject'));
152 $frm_subject->addOption(
new ilRadioOption($this->
lng->txt(
'empty_subject'),
'empty_subject'));
153 $a_form->
addItem($frm_subject);
156 $cb_prop->setValue(
'1');
157 $cb_prop->setInfo($this->
lng->txt(
'enable_thread_ratings_info'));
162 $frm_upload->setValue(
'1');
163 $frm_upload->setInfo($this->
lng->txt(
'allow_file_upload_desc'));
168 $moderatorFunctionsHeader->setTitle($this->
lng->txt(
'frm_settings_mod_functions_header'));
169 $a_form->
addItem($moderatorFunctionsHeader);
172 $cb_prop->setValue(
'1');
173 $cb_prop->setInfo($this->
lng->txt(
'post_activation_desc'));
177 $cb_prop->setValue(
'1');
178 $cb_prop->setInfo($this->
lng->txt(
'mark_moderator_posts_desc'));
181 if ($this->
settings->get(
'enable_anonymous_fora') || $this->
settings->get(
'enable_fora_statistics')) {
183 $privacyHeader->setTitle($this->
lng->txt(
'frm_settings_privacy_header'));
184 $a_form->
addItem($privacyHeader);
187 if ($this->
settings->get(
'enable_fora_statistics')) {
189 $cb_prop->setValue(
'1');
190 $cb_prop->setInfo($this->
lng->txt(
'frm_statistics_enabled_desc'));
194 if ($this->
settings->get(
'enable_anonymous_fora') || $this->parent_obj->objProperties->isAnonymized()) {
196 $cb_prop->setValue(
'1');
197 $cb_prop->setInfo($this->
lng->txt(
'frm_anonymous_posting_desc'));
204 $this->
tabs->addSubTabTarget(
205 self::UI_SUB_TAB_ID_BASIC_SETTINGS,
206 $this->
ctrl->getLinkTarget($this->parent_obj,
'edit'),
208 [strtolower(ilObjForumGUI::class)]
211 if ($this->
settings->get(
'forum_notification') > 0 &&
212 $this->forum->isParentMembershipEnabledContainer() &&
213 $this->
access->checkAccess(
'write',
'', $this->parent_obj->getRefId())) {
214 $cmd = $this->dic->http()->wrapper()->query()->retrieve(
216 $this->dic->refinery()->byTrying([
217 $this->dic->refinery()->kindlyTo()->string(),
218 $this->dic->refinery()->always(
'showMembers')
221 $this->
tabs->addSubTabTarget(
222 self::UI_SUB_TAB_ID_NOTIFICATIONS,
223 $this->
ctrl->getLinkTarget($this,
'showMembers'),
225 [strtolower(self::class)],
227 in_array($cmd, [
'showMembers',
'forums_notification_settings'],
true)
231 $this->
tabs->addSubTabTarget(
232 self::UI_SUB_TAB_ID_NEWS,
233 $this->
ctrl->getLinkTargetByClass(ilContainerNewsSettingsGUI::class),
235 [strtolower(ilContainerNewsSettingsGUI::class)]
238 $this->
tabs->addSubTabTarget(
239 self::UI_SUB_TAB_ID_STYLE,
240 $this->
ctrl->getLinkTargetByClass(strtolower(ilObjectContentStyleSettingsGUI::class),
""),
242 [strtolower(ilObjectContentStyleSettingsGUI::class)]
245 $this->
tabs->activateTab(self::UI_TAB_ID_SETTINGS);
252 $a_values[
'anonymized'] = $this->parent_obj->objProperties->isAnonymized();
253 $a_values[
'statistics_enabled'] = $this->parent_obj->objProperties->isStatisticEnabled();
254 $a_values[
'post_activation'] = $this->parent_obj->objProperties->isPostActivationEnabled();
255 $a_values[
'subject_setting'] = $this->parent_obj->objProperties->getSubjectSetting();
256 $a_values[
'mark_mod_posts'] = $this->parent_obj->objProperties->getMarkModeratorPosts();
257 $a_values[
'thread_rating'] = $this->parent_obj->objProperties->isIsThreadRatingEnabled();
259 $default_view_value = $this->parent_obj->objProperties->getDefaultView();
260 if (in_array($default_view_value, [
266 if (in_array($default_view_value, [
270 $default_view_by_date = $default_view_value;
273 $default_view = $default_view_value;
279 $a_values[
'default_view'] = $default_view;
280 if (isset($default_view_by_date)) {
281 $a_values[
'default_view_by_date'] = $default_view_by_date;
283 $a_values[
'file_upload_allowed'] = $this->parent_obj->objProperties->getFileUploadAllowed();
285 $object = $this->parent_obj->getObject();
286 $a_values[
'activation_online'] = !$object->getOfflineStatus();
291 $default_view_input_value = (
int) $a_form->
getInput(
'default_view');
292 if (in_array($default_view_input_value, [
299 $default_view_order_by_date_value = (
int) $a_form->
getInput(
'default_view_by_date');
300 if (in_array($default_view_order_by_date_value, [
304 $default_view_input_value = $default_view_order_by_date_value;
307 $default_view = $default_view_input_value;
311 $this->parent_obj->objProperties->setDefaultView($default_view);
315 $view_mode =
'viewmode_' . $this->forum->getId();
320 if ($this->
settings->get(
'enable_anonymous_fora') || $this->parent_obj->objProperties->isAnonymized()) {
321 $this->parent_obj->objProperties->setAnonymisation((
bool) $a_form->
getInput(
'anonymized'));
323 if ($this->
settings->get(
'enable_fora_statistics')) {
324 $this->parent_obj->objProperties->setStatisticsStatus((
bool) $a_form->
getInput(
'statistics_enabled'));
326 $this->parent_obj->objProperties->setPostActivation((
bool) $a_form->
getInput(
'post_activation'));
327 $this->parent_obj->objProperties->setSubjectSetting($a_form->
getInput(
'subject_setting'));
328 $this->parent_obj->objProperties->setMarkModeratorPosts((
bool) $a_form->
getInput(
'mark_mod_posts'));
329 $this->parent_obj->objProperties->setIsThreadRatingEnabled((
bool) $a_form->
getInput(
'thread_rating'));
331 $this->parent_obj->objProperties->setFileUploadAllowed((
bool) $a_form->
getInput(
'file_upload_allowed'));
333 $this->parent_obj->objProperties->update();
334 $this->obj_service->commonSettings()->legacyForm($a_form, $this->parent_obj->getObject())->saveTileImage();
336 $object = $this->parent_obj->getObject();
337 $object->setOfflineStatus(!(
bool) $a_form->
getInput(
'activation_online'));
343 if (!$this->
access->checkAccess(
'write',
'', $this->parent_obj->getRefId())) {
344 $this->error->raiseError(
345 $this->
lng->txt(
'msg_no_perm_read'),
346 $this->error->MESSAGE
350 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.forums_members_list.html',
'components/ILIAS/Forum');
355 $interested_events = $this->parent_obj->objProperties->getInterestedEvents();
378 $this->notificationSettingsForm->setValuesByArray([
379 'notification_type' => $this->parent_obj->objProperties->getNotificationType()->value,
380 'adm_force' => $this->parent_obj->objProperties->isAdminForceNoti(),
381 'usr_toggle' => $this->parent_obj->objProperties->isUserToggleNoti(),
382 'notification_events' => $form_events
386 $this->tpl->setVariable(
'NOTIFICATIONS_SETTINGS_FORM', $this->notificationSettingsForm->getHTML());
390 $forum_noti->setAdminForce($this->parent_obj->objProperties->isAdminForceNoti());
391 $forum_noti->setUserToggle($this->parent_obj->objProperties->isUserToggleNoti());
392 $forum_noti->setForumId($this->parent_obj->objProperties->getObjId());
393 $forum_noti->setInterestedEvents($this->parent_obj->objProperties->getInterestedEvents());
394 $forum_noti->update();
395 } elseif ($this->parent_obj->objProperties->getNotificationType() === NotificationType::PER_USER) {
396 $this->tpl->setVariable(
'TABLE', $this->ui_renderer->render($this->getForumNotificationTable()->getComponents()));
404 $this->
http->request(),
408 $this->parent_obj->getObject()->getRefId(),
409 $this->forum->parentParticipants(),
412 $this->
ctrl->getLinkTarget($this,
'handleNotificationActions')
418 $send_bad_request =
function () {
419 $this->
http->saveResponse(
420 $this->
http->response()
423 $this->
http->sendResponse();
424 $this->
http->close();
427 if (!$this->
http->wrapper()->query()->has(
'frm_notifications_table_usr_ids')) {
431 $user_ids = $this->
http->wrapper()->query()->retrieve(
432 'frm_notifications_table_usr_ids',
433 $this->dic->refinery()->kindlyTo()->listOf($this->dic->refinery()->kindlyTo()->int())
435 if (count($user_ids) !== 1) {
441 $forced_events = $this->forumNotificationObj->getForcedEventsObjectByUserId(
$user_id);
442 $interested_events = $forced_events->getInterestedEvents();
444 $this->
ctrl->getFormAction($this->parent_obj,
'saveEventsForUser'),
446 'hidden_value' => json_encode([
448 ], JSON_THROW_ON_ERROR),
459 $modal = $this->ui_factory->modal()->roundtrip(
460 $this->
lng->txt(
'notification_settings'),
462 $form_gui->getInputs(),
463 $this->
ctrl->getFormAction($this,
'saveEventsForUser')
466 $this->
http->saveResponse($this->
http->response()->withBody(
467 Streams::ofString($this->ui_renderer->renderAsync($modal))
468 )->withHeader(ResponseHeader::CONTENT_TYPE,
'text/html'));
469 $this->
http->sendResponse();
470 $this->
http->close();
475 if (!$this->
access->checkAccess(
'write',
'', $this->parent_obj->getRefId())) {
476 $this->error->raiseError(
477 $this->
lng->txt(
'msg_no_perm_read'),
478 $this->error->MESSAGE
483 $this->
ctrl->getFormAction($this,
'saveEventsForUser'),
489 if ($this->
http->request()->getMethod() ===
'POST') {
490 $form = $events_form_builder->
build()->withRequest($this->
http->request());
491 $formData = $form->getData();
495 foreach ($events_form_builder->getValidEvents() as $event) {
496 $interested_events += isset($formData[$event]) && $formData[$event] ? $events_form_builder->getValueForEvent(
501 if (isset($formData[
'hidden_value']) && $formData[
'hidden_value']) {
502 $hidden_value = json_decode($formData[
'hidden_value'],
false, 512, JSON_THROW_ON_ERROR);
503 $valid_usr_ids = $this->forum->getAllForumParticipants();
505 if (in_array($hidden_value->usr_id, $valid_usr_ids)) {
507 $frm_noti->setUserId($hidden_value->usr_id);
508 $frm_noti->setForumId($this->forum->getId());
509 $frm_noti->setInterestedEvents($interested_events);
510 $frm_noti->updateInterestedEvents();
515 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'),
true);
522 if (!$this->
access->checkAccess(
'write',
'', $this->parent_obj->getRefId())) {
523 $this->error->raiseError(
524 $this->
lng->txt(
'msg_no_perm_read'),
525 $this->error->MESSAGE
530 if ($this->dic->http()->wrapper()->post()->has(
'user_id')) {
531 $user_ids = $this->dic->http()->wrapper()->post()->retrieve(
533 $this->dic->refinery()->kindlyTo()->listOf($this->dic->refinery()->kindlyTo()->int())
537 if (count($user_ids) === 0) {
538 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'time_limit_no_users_selected'),
true);
543 $frm_noti->setUserId((
int) $user_id);
544 $frm_noti->setUserToggle(
false);
545 $is_enabled = $frm_noti->isAdminForceNotification();
548 $frm_noti->setAdminForce(
true);
549 $frm_noti->insertAdminForce();
553 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'));
561 if (!$this->
access->checkAccess(
'write',
'', $this->parent_obj->getRefId())) {
562 $this->error->raiseError(
563 $this->
lng->txt(
'msg_no_perm_read'),
564 $this->error->MESSAGE
569 if ($this->dic->http()->wrapper()->post()->has(
'user_id')) {
570 $user_ids = $this->dic->http()->wrapper()->post()->retrieve(
572 $this->dic->refinery()->kindlyTo()->listOf($this->dic->refinery()->kindlyTo()->int())
576 if (count($user_ids) === 0) {
577 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'time_limit_no_users_selected'));
582 $frm_noti->setUserId((
int) $user_id);
583 $is_enabled = $frm_noti->isAdminForceNotification();
586 $frm_noti->deleteAdminForce();
590 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'));
598 if (!$this->
access->checkAccess(
'write',
'', $this->parent_obj->getRefId())) {
599 $this->error->raiseError(
600 $this->
lng->txt(
'msg_no_perm_read'),
601 $this->error->MESSAGE
606 if ($this->dic->http()->wrapper()->query()->has(
'frm_notifications_table_usr_ids')) {
607 $user_ids = $this->dic->http()->wrapper()->query()->retrieve(
608 'frm_notifications_table_usr_ids',
609 $this->dic->refinery()->kindlyTo()->listOf($this->dic->refinery()->kindlyTo()->string())
611 if ($user_ids === [
'ALL_OBJECTS']) {
613 $user_ids = $table->getFilteredUserIds($this->ui_service->filter()->getData($table->getFilterComponent()));
617 if (count($user_ids) === 0) {
618 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'time_limit_no_users_selected'));
623 $frm_noti->setUserId((
int) $user_id);
624 $frm_noti->setUserToggle(
true);
625 $is_enabled = $frm_noti->isAdminForceNotification();
628 $frm_noti->updateUserToggle();
630 $frm_noti->setAdminForce(
true);
631 $frm_noti->insertAdminForce();
635 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'));
643 if (!$this->
access->checkAccess(
'write',
'', $this->parent_obj->getRefId())) {
644 $this->error->raiseError(
645 $this->
lng->txt(
'msg_no_perm_read'),
646 $this->error->MESSAGE
651 if ($this->dic->http()->wrapper()->query()->has(
'frm_notifications_table_usr_ids')) {
652 $user_ids = $this->dic->http()->wrapper()->query()->retrieve(
653 'frm_notifications_table_usr_ids',
654 $this->dic->refinery()->kindlyTo()->listOf($this->dic->refinery()->kindlyTo()->string())
656 if ($user_ids === [
'ALL_OBJECTS']) {
658 $user_ids = $table->getFilteredUserIds($this->ui_service->filter()->getData($table->getFilterComponent()));
662 if (count($user_ids) === 0) {
663 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'time_limit_no_users_selected'));
668 $frm_noti->setUserId((
int) $user_id);
669 $frm_noti->setUserToggle(
false);
670 $is_enabled = $frm_noti->isAdminForceNotification();
672 $frm_noti->updateUserToggle();
674 $frm_noti->setAdminForce(
true);
675 $frm_noti->insertAdminForce();
679 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'));
687 if ($this->notificationSettingsForm ===
null) {
689 $form->setFormAction($this->
ctrl->getFormAction($this,
'updateNotificationSettings'));
690 $form->setTitle($this->
lng->txt(
'forums_notification_settings'));
693 $radio_grp->setValue(
'default');
696 $this->
lng->txt(
'user_decides_notification'),
699 $opt_0 =
new ilRadioOption($this->
lng->txt(
'settings_for_all_members'), NotificationType::ALL_USERS->value);
700 $opt_1 =
new ilRadioOption($this->
lng->txt(
'settings_per_users'), NotificationType::PER_USER->value);
702 $radio_grp->addOption($opt_default);
703 $radio_grp->addOption($opt_0);
704 $radio_grp->addOption($opt_1);
707 $chb_2->setValue(
'1');
714 $cb_grp->addOption($notify_modified);
717 $cb_grp->addOption($notify_censored);
720 $cb_grp->addOption($notify_uncensored);
723 $cb_grp->addOption($notify_post_deleted);
726 $cb_grp->addOption($notify_thread_deleted);
729 $form->addItem($radio_grp);
731 $form->addCommandButton(
'updateNotificationSettings', $this->
lng->txt(
'save'));
733 $this->notificationSettingsForm = $form;
743 if (!$this->
access->checkAccess(
'write',
'', $this->parent_obj->getRefId())) {
744 $this->error->raiseError(
745 $this->
lng->txt(
'msg_no_perm_read'),
746 $this->error->MESSAGE
753 if ($this->notificationSettingsForm->checkInput()) {
754 $notification_type = NotificationType::tryFrom($this->dic->http()->wrapper()->post()->retrieve(
756 $this->dic->refinery()->byTrying([
757 $this->dic->refinery()->kindlyTo()->string(),
762 if ($notification_type === NotificationType::ALL_USERS) {
763 $notification_events = $this->notificationSettingsForm->getInput(
'notification_events');
764 $interested_events = 0;
766 if (is_array($notification_events)) {
767 foreach ($notification_events as $activated_event) {
768 $interested_events += (
int) $activated_event;
772 $this->parent_obj->objProperties->setAdminForceNoti(
true);
773 $this->parent_obj->objProperties->setUserToggleNoti(
774 (
bool) $this->notificationSettingsForm->getInput(
'usr_toggle')
776 $this->parent_obj->objProperties->setNotificationType(NotificationType::ALL_USERS);
777 $this->parent_obj->objProperties->setInterestedEvents($interested_events);
778 } elseif ($notification_type === NotificationType::PER_USER) {
779 $this->parent_obj->objProperties->setNotificationType(NotificationType::PER_USER);
780 $this->parent_obj->objProperties->setAdminForceNoti(
true);
781 $this->parent_obj->objProperties->setUserToggleNoti(
false);
784 $this->parent_obj->objProperties->setAdminForceNoti(
false);
785 $this->parent_obj->objProperties->setUserToggleNoti(
false);
786 $frm_noti->deleteNotificationAllUsers();
789 $frm_noti->updateUserNotifications($this->forum->getAllForumParticipants(), $properties);
791 $this->parent_obj->objProperties->update();
793 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'));
795 $this->notificationSettingsForm->setValuesByPost();
802 return [
'handleNotificationActions'];
812 $action = $this->
http->wrapper()->query()->retrieve(
813 'frm_notifications_table_action',
814 $this->dic->refinery()->byTrying([
815 $this->dic->refinery()->kindlyTo()->string(),
816 $this->dic->refinery()->always(
null)
824 default => $this->
ctrl->redirect($this,
'showMembers'),
static get(string $a_var)
This class represents an option in a radio group.
readonly ILIAS HTTP GlobalHttpState $http
disableHideUserToggleNoti()
initNotificationSettingsForm()
This class represents an option in a checkbox group.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getForumNotificationTable()
readonly ILIAS UI Factory $ui_factory
readonly ilUIService $ui_service
readonly ilObjectService $obj_service
ilPropertyFormGUI $notificationSettingsForm
ilForumNotification $forumNotificationObj
readonly ilGlobalTemplateInterface $tpl
getSafePostCommands()
This method must return a list of safe POST commands.
Class ilForumSettingsGUI.
addAvailabilitySection(ilPropertyFormGUI $form)
static getInstance(int $a_obj_id=0)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static http()
Fetches the global http state from ILIAS.
readonly UiRenderer $ui_renderer
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
updateNotificationSettings()
readonly ilSetting $settings
handleNotificationActions()
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)
getUnsafeGetCommands()
This method must return a list of unsafe GET commands.
readonly ilAccessHandler $access
static isFileUploadGloballyAllowed()
initForcedForumNotification()
readonly ilErrorHandling $error
readonly ILIAS DI Container $dic
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static set(string $a_var, $a_val)
Set a value.