ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilForumSettingsGUI Class Reference

@ilCtrl_Calls ilForumSettingsGUI: ilObjectContentStyleSettingsGUI More...

+ Inheritance diagram for ilForumSettingsGUI:
+ Collaboration diagram for ilForumSettingsGUI:

Public Member Functions

 __construct (private readonly ilObjForumGUI $parent_obj, private readonly ilObjForum $forum)
 
 getRefId ()
 
 executeCommand ()
 
 getCustomForm (ilPropertyFormGUI $a_form)
 
 settingsTabs ()
 
 getCustomValues (array &$a_values)
 
 updateCustomValues (ilPropertyFormGUI $a_form)
 
 saveEventsForUserCommand ()
 
 enableAdminForceNotiCommand ()
 
 disableAdminForceNotiCommand ()
 
 getUnsafeGetCommands ()
 This method must return a list of unsafe GET commands. More...
 
 getSafePostCommands ()
 This method must return a list of safe POST commands. More...
 
 getUnsafeGetCommands ()
 This method must return a list of unsafe GET commands. More...
 
 getSafePostCommands ()
 This method must return a list of safe POST commands. More...
 

Private Member Functions

 initForcedForumNotification ()
 
 addAvailabilitySection (ilPropertyFormGUI $form)
 
 showMembersCommand ()
 
 getForumNotificationTable ()
 
 notificationSettings ()
 
 enableHideUserToggleNoti ()
 
 disableHideUserToggleNoti ()
 
 initNotificationSettingsForm ()
 
 updateNotificationSettingsCommand ()
 
 handleNotificationActionsCommand ()
 

Private Attributes

readonly ilCtrlInterface $ctrl
 
readonly ilGlobalTemplateInterface $tpl
 
readonly ilLanguage $lng
 
readonly ilSetting $settings
 
readonly ilTabsGUI $tabs
 
readonly ilAccessHandler $access
 
readonly ILIAS HTTP GlobalHttpState $http
 
ilForumNotification $forumNotificationObj
 
ilPropertyFormGUI $notificationSettingsForm = null
 
readonly ilObjectService $obj_service
 
readonly ILIAS DI Container $dic
 
readonly ilErrorHandling $error
 
readonly ILIAS UI Factory $ui_factory
 
readonly UiRenderer $ui_renderer
 
readonly ilUIService $ui_service
 

Additional Inherited Members

- Data Fields inherited from ilForumObjectConstants
const OBJ_TYPE = 'frm'
 
const UI_TAB_ID_INFO = 'info_short'
 
const UI_TAB_ID_SETTINGS = 'settings'
 
const UI_TAB_ID_MODERATORS = 'frm_moderators'
 
const UI_TAB_ID_THREADS = 'forums_threads'
 
const UI_TAB_ID_STATS = 'frm_statistics'
 
const UI_TAB_ID_EXPORT = 'export'
 
const UI_TAB_ID_PERMISSIONS = 'perm_settings'
 
const UI_SUB_TAB_ID_BASIC_SETTINGS = 'general'
 
const UI_SUB_TAB_ID_NOTIFICATIONS = 'notifications'
 
const UI_SUB_TAB_ID_NEWS = 'cont_news_settings'
 
const UI_SUB_TAB_ID_STYLE = 'cont_style'
 
const UI_CMD_COPAGE_DOWNLOAD_FILE = 'downloadFile'
 
const UI_CMD_COPAGE_DISPLAY_FULLSCREEN = 'displayMediaFullscreen'
 
const UI_CMD_COPAGE_DOWNLOAD_PARAGRAPH = 'download_paragraph'
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilForumSettingsGUI::__construct ( private readonly ilObjForumGUI  $parent_obj,
private readonly ilObjForum  $forum 
)

Definition at line 49 of file class.ilForumSettingsGUI.php.

50 {
51 global $DIC;
52
53 $this->dic = $DIC;
54
55 $this->ctrl = $DIC->ctrl();
56 $this->tpl = $DIC->ui()->mainTemplate();
57 $this->lng = $DIC->language();
58 $this->settings = $DIC->settings();
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'];
67
68 $this->lng->loadLanguageModule('style');
69 $this->lng->loadLanguageModule('cont');
70 }
error(string $a_errmsg)
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), error(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\settings(), and ILIAS\Repository\tabs().

+ Here is the call graph for this function:

Member Function Documentation

◆ addAvailabilitySection()

ilForumSettingsGUI::addAvailabilitySection ( ilPropertyFormGUI  $form)
private

Definition at line 97 of file class.ilForumSettingsGUI.php.

97 : void
98 {
99 $section = new ilFormSectionHeaderGUI();
100 $section->setTitle($this->lng->txt('rep_activation_availability'));
101 $form->addItem($section);
102
103 $online = new ilCheckboxInputGUI($this->lng->txt('rep_activation_online'), 'activation_online');
104 $online->setInfo($this->lng->txt('frm_activation_online_info'));
105 $form->addItem($online);
106 }
This class represents a checkbox property in a property form.
This class represents a section header in a property form.

References ilPropertyFormGUI\addItem(), and ILIAS\Repository\lng().

Referenced by getCustomForm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ disableAdminForceNotiCommand()

ilForumSettingsGUI::disableAdminForceNotiCommand ( )

Definition at line 541 of file class.ilForumSettingsGUI.php.

541 : void
542 {
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
547 );
548 }
549
550 $user_ids = [];
551 if ($this->dic->http()->wrapper()->post()->has('user_id')) {
552 $user_ids = $this->dic->http()->wrapper()->post()->retrieve(
553 'user_id',
554 $this->dic->refinery()->kindlyTo()->listOf($this->dic->refinery()->kindlyTo()->int())
555 );
556 }
557
558 if (count($user_ids) === 0) {
559 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_INFO, $this->lng->txt('time_limit_no_users_selected'), true);
560 } else {
561 $frm_noti = new ilForumNotification($this->forum->getRefId());
562
563 foreach ($user_ids as $user_id) {
564 $frm_noti->setUserId((int) $user_id);
565 $is_enabled = $frm_noti->isAdminForceNotification();
566
567 if ($is_enabled) {
568 $frm_noti->deleteAdminForce();
569 }
570 }
571
572 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->lng->txt('saved_successfully'), true);
573 }
574
575 $this->ctrl->redirect($this, 'showMembers');
576 }
Class ilForumNotification.

References $user_id, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), error(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ disableHideUserToggleNoti()

ilForumSettingsGUI::disableHideUserToggleNoti ( )
private

Definition at line 623 of file class.ilForumSettingsGUI.php.

623 : void
624 {
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
629 );
630 }
631
632 $user_ids = [];
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())
637 );
638 if ($user_ids === ['ALL_OBJECTS']) {
639 $table = $this->getForumNotificationTable();
640 $user_ids = $table->getFilteredUserIds($this->ui_service->filter()->getData($table->getFilterComponent()));
641 }
642 }
643
644 if (count($user_ids) === 0) {
645 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_INFO, $this->lng->txt('time_limit_no_users_selected'), true);
646 } else {
647 $frm_noti = new ilForumNotification($this->forum->getRefId());
648
649 foreach ($user_ids as $user_id) {
650 $frm_noti->setUserId((int) $user_id);
651 $frm_noti->setUserToggle(false);
652 $is_enabled = $frm_noti->isAdminForceNotification();
653 if ($is_enabled) {
654 $frm_noti->updateUserToggle();
655 } else {
656 $frm_noti->setAdminForce(true);
657 $frm_noti->insertAdminForce();
658 }
659 }
660
661 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->lng->txt('saved_successfully'), true);
662 }
663
664 $this->ctrl->redirect($this, 'showMembers');
665 }

References $user_id, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), error(), getForumNotificationTable(), and ILIAS\Repository\lng().

Referenced by handleNotificationActionsCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ enableAdminForceNotiCommand()

ilForumSettingsGUI::enableAdminForceNotiCommand ( )

Definition at line 502 of file class.ilForumSettingsGUI.php.

502 : void
503 {
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
508 );
509 }
510
511 $user_ids = [];
512 if ($this->dic->http()->wrapper()->post()->has('user_id')) {
513 $user_ids = $this->dic->http()->wrapper()->post()->retrieve(
514 'user_id',
515 $this->dic->refinery()->kindlyTo()->listOf($this->dic->refinery()->kindlyTo()->int())
516 );
517 }
518
519 if (count($user_ids) === 0) {
520 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_INFO, $this->lng->txt('time_limit_no_users_selected'), true);
521 } else {
522 $frm_noti = new ilForumNotification($this->forum->getRefId());
523
524 foreach ($user_ids as $user_id) {
525 $frm_noti->setUserId((int) $user_id);
526 $frm_noti->setUserToggle(false);
527 $is_enabled = $frm_noti->isAdminForceNotification();
528
529 if (!$is_enabled) {
530 $frm_noti->setAdminForce(true);
531 $frm_noti->insertAdminForce();
532 }
533 }
534
535 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->lng->txt('saved_successfully'), true);
536 }
537
538 $this->ctrl->redirect($this, 'showMembers');
539 }

References $user_id, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), error(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ enableHideUserToggleNoti()

ilForumSettingsGUI::enableHideUserToggleNoti ( )
private

Definition at line 578 of file class.ilForumSettingsGUI.php.

578 : void
579 {
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
584 );
585 }
586
587 $user_ids = [];
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())
592 );
593 if ($user_ids === ['ALL_OBJECTS']) {
594 $table = $this->getForumNotificationTable();
595 $user_ids = $table->getFilteredUserIds($this->ui_service->filter()->getData($table->getFilterComponent()));
596 }
597 }
598
599 if (count($user_ids) === 0) {
600 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_INFO, $this->lng->txt('time_limit_no_users_selected'), true);
601 } else {
602 $frm_noti = new ilForumNotification($this->forum->getRefId());
603
604 foreach ($user_ids as $user_id) {
605 $frm_noti->setUserId((int) $user_id);
606 $frm_noti->setUserToggle(true);
607 $is_enabled = $frm_noti->isAdminForceNotification();
608
609 if ($is_enabled) {
610 $frm_noti->updateUserToggle();
611 } else {
612 $frm_noti->setAdminForce(true);
613 $frm_noti->insertAdminForce();
614 }
615 }
616
617 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->lng->txt('saved_successfully'), true);
618 }
619
620 $this->ctrl->redirect($this, 'showMembers');
621 }

References $user_id, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), error(), getForumNotificationTable(), and ILIAS\Repository\lng().

Referenced by handleNotificationActionsCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilForumSettingsGUI::executeCommand ( )

Definition at line 83 of file class.ilForumSettingsGUI.php.

83 : void
84 {
85 $cmd = $this->ctrl->getCmd() ?? '';
86 switch (true) {
87 case method_exists($this, $cmd . 'Command'):
88 $this->settingsTabs();
89 $this->{$cmd . 'Command'}();
90 break;
91
92 default:
93 $this->ctrl->redirect($this->parent_obj);
94 }
95 }

References ILIAS\Repository\ctrl(), and settingsTabs().

+ Here is the call graph for this function:

◆ getCustomForm()

ilForumSettingsGUI::getCustomForm ( ilPropertyFormGUI  $a_form)

Definition at line 108 of file class.ilForumSettingsGUI.php.

108 : void
109 {
110 $this->settingsTabs();
111 $this->tabs->activateSubTab(self::UI_SUB_TAB_ID_BASIC_SETTINGS);
112 $a_form->setTitle($this->lng->txt('frm_settings_form_header'));
113
114 $this->addAvailabilitySection($a_form);
115
116 $presentationHeader = new ilFormSectionHeaderGUI();
117 $presentationHeader->setTitle($this->lng->txt('settings_presentation_header'));
118 $a_form->addItem($presentationHeader);
119
120 $this->obj_service->commonSettings()->legacyForm($a_form, $this->parent_obj->getObject())->addTileImage();
121
122 $rg_pro = new ilRadioGroupInputGUI($this->lng->txt('frm_default_view'), 'default_view');
123 $option_view_by_posts = new ilRadioOption($this->lng->txt('sort_by_posts'), (string) ilForumProperties::VIEW_TREE);
124 $option_view_by_posts->setInfo($this->lng->txt('sort_by_posts_desc'));
125 $rg_pro->addOption($option_view_by_posts);
126 $option_view_by_date = new ilRadioOption($this->lng->txt('sort_by_date'), (string) ilForumProperties::VIEW_DATE);
127 $option_view_by_date->setInfo($this->lng->txt('sort_by_date_desc'));
128 $sub_group = new ilRadioGroupInputGUI('', 'default_view_by_date');
129 $sub_group->addOption(new ilRadioOption($this->lng->txt('ascending_order'), (string) ilForumProperties::VIEW_DATE_ASC));
130 $sub_group->addOption(new ilRadioOption($this->lng->txt('descending_order'), (string) ilForumProperties::VIEW_DATE_DESC));
131
132 $option_view_by_date->addSubItem($sub_group);
133 $rg_pro->addOption($option_view_by_date);
134 $a_form->addItem($rg_pro);
135
136 $userFunctionsHeader = new ilFormSectionHeaderGUI();
137 $userFunctionsHeader->setTitle($this->lng->txt('frm_settings_user_functions_header'));
138 $a_form->addItem($userFunctionsHeader);
139
140 $frm_subject = new ilRadioGroupInputGUI($this->lng->txt('frm_subject_setting'), 'subject_setting');
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);
145
146 $cb_prop = new ilCheckboxInputGUI($this->lng->txt('enable_thread_ratings'), 'thread_rating');
147 $cb_prop->setValue('1');
148 $cb_prop->setInfo($this->lng->txt('enable_thread_ratings_info'));
149 $a_form->addItem($cb_prop);
150
152 $frm_upload = new ilCheckboxInputGUI($this->lng->txt('file_upload_allowed'), 'file_upload_allowed');
153 $frm_upload->setValue('1');
154 $frm_upload->setInfo($this->lng->txt('allow_file_upload_desc'));
155 $a_form->addItem($frm_upload);
156 }
157
158 $moderatorFunctionsHeader = new ilFormSectionHeaderGUI();
159 $moderatorFunctionsHeader->setTitle($this->lng->txt('frm_settings_mod_functions_header'));
160 $a_form->addItem($moderatorFunctionsHeader);
161
162 $cb_prop = new ilCheckboxInputGUI($this->lng->txt('activate_new_posts'), 'post_activation');
163 $cb_prop->setValue('1');
164 $cb_prop->setInfo($this->lng->txt('post_activation_desc'));
165 $a_form->addItem($cb_prop);
166
167 $cb_prop = new ilCheckboxInputGUI($this->lng->txt('mark_moderator_posts'), 'mark_mod_posts');
168 $cb_prop->setValue('1');
169 $cb_prop->setInfo($this->lng->txt('mark_moderator_posts_desc'));
170 $a_form->addItem($cb_prop);
171
172 if ($this->settings->get('enable_anonymous_fora') || $this->settings->get('enable_fora_statistics')) {
173 $privacyHeader = new ilFormSectionHeaderGUI();
174 $privacyHeader->setTitle($this->lng->txt('frm_settings_privacy_header'));
175 $a_form->addItem($privacyHeader);
176 }
177
178 if ($this->settings->get('enable_fora_statistics')) {
179 $cb_prop = new ilCheckboxInputGUI($this->lng->txt('frm_statistics_enabled'), 'statistics_enabled');
180 $cb_prop->setValue('1');
181 $cb_prop->setInfo($this->lng->txt('frm_statistics_enabled_desc'));
182 $a_form->addItem($cb_prop);
183 }
184
185 if ($this->settings->get('enable_anonymous_fora') || $this->parent_obj->objProperties->isAnonymized()) {
186 $cb_prop = new ilCheckboxInputGUI($this->lng->txt('frm_anonymous_posting'), 'anonymized');
187 $cb_prop->setValue('1');
188 $cb_prop->setInfo($this->lng->txt('frm_anonymous_posting_desc'));
189 $a_form->addItem($cb_prop);
190 }
191 }
addAvailabilitySection(ilPropertyFormGUI $form)
This class represents a property in a property form.
This class represents an option in a radio group.

References addAvailabilitySection(), ilPropertyFormGUI\addItem(), ilForumProperties\isFileUploadGloballyAllowed(), ILIAS\Repository\lng(), ILIAS\Repository\settings(), settingsTabs(), ilPropertyFormGUI\setTitle(), ILIAS\Repository\tabs(), ilForumProperties\VIEW_DATE, ilForumProperties\VIEW_DATE_ASC, ilForumProperties\VIEW_DATE_DESC, and ilForumProperties\VIEW_TREE.

+ Here is the call graph for this function:

◆ getCustomValues()

ilForumSettingsGUI::getCustomValues ( array &  $a_values)

Definition at line 233 of file class.ilForumSettingsGUI.php.

233 : void
234 {
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();
241
242 $default_view_value = $this->parent_obj->objProperties->getDefaultView();
243 if (in_array($default_view_value, [
248 ], true)) {
249 if (in_array($default_view_value, [
252 ], true)) {
253 $default_view_by_date = $default_view_value;
254 $default_view = ilForumProperties::VIEW_DATE;
255 } else {
256 $default_view = $default_view_value;
257 }
258 } else {
259 $default_view = ilForumProperties::VIEW_TREE;
260 }
261
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;
265 }
266 $a_values['file_upload_allowed'] = $this->parent_obj->objProperties->getFileUploadAllowed();
267
268 $object = $this->parent_obj->getObject();
269 $a_values['activation_online'] = !$object->getOfflineStatus();
270 }

References ilForumProperties\VIEW_DATE, ilForumProperties\VIEW_DATE_ASC, ilForumProperties\VIEW_DATE_DESC, and ilForumProperties\VIEW_TREE.

◆ getForumNotificationTable()

ilForumSettingsGUI::getForumNotificationTable ( )
private

Definition at line 383 of file class.ilForumSettingsGUI.php.

384 {
386 return new ForumNotificationTable(
387 $this->http->request(),
388 $this->lng,
389 $this->ui_factory,
390 new DataFactory(),
391 $this->parent_obj->getObject()->getRefId(),
392 $this->forum->parentParticipants(),
393 $this->forumNotificationObj,
394 $this->ui_service,
395 $this->ctrl->getLinkTarget($this, 'handleNotificationActions')
396 );
397 }

References ILIAS\FileDelivery\http(), and initForcedForumNotification().

Referenced by disableHideUserToggleNoti(), and enableHideUserToggleNoti().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRefId()

ilForumSettingsGUI::getRefId ( )

Definition at line 72 of file class.ilForumSettingsGUI.php.

72 : int
73 {
74 return $this->forum->getRefId();
75 }

◆ getSafePostCommands()

ilForumSettingsGUI::getSafePostCommands ( )

This method must return a list of safe POST commands.

Safe post commands returned by this method will no longer be CSRF protected and will NOT be appended by an ilCtrlToken.

Returns
string[]

Implements ilCtrlSecurityInterface.

Definition at line 789 of file class.ilForumSettingsGUI.php.

789 : array
790 {
791 return [];
792 }

◆ getUnsafeGetCommands()

ilForumSettingsGUI::getUnsafeGetCommands ( )

This method must return a list of unsafe GET commands.

Unsafe get commands returned by this method will now be CSRF protected, which means an ilCtrlToken is appended each time a link-target is generated to the class implementing this interface with a command from that list.

Tokens will be validated in

See also
ilCtrlInterface::getCmd(), whereas the fallback command will be used if the CSRF validation fails.
Returns
string[]

Implements ilCtrlSecurityInterface.

Definition at line 782 of file class.ilForumSettingsGUI.php.

782 : array
783 {
784 return [
785 'handleNotificationActions',
786 ];
787 }

◆ handleNotificationActionsCommand()

ilForumSettingsGUI::handleNotificationActionsCommand ( )
private

Definition at line 794 of file class.ilForumSettingsGUI.php.

794 : void
795 {
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)
801 ])
802 );
803
804 match ($action) {
805 'enableHideUserToggleNoti' => $this->enableHideUserToggleNoti(),
806 'disableHideUserToggleNoti' => $this->disableHideUserToggleNoti(),
807 'notificationSettings' => $this->notificationSettings(),
808 default => $this->showMembersCommand()
809 };
810 }

References disableHideUserToggleNoti(), enableHideUserToggleNoti(), ILIAS\FileDelivery\http(), notificationSettings(), and showMembersCommand().

+ Here is the call graph for this function:

◆ initForcedForumNotification()

ilForumSettingsGUI::initForcedForumNotification ( )
private

Definition at line 77 of file class.ilForumSettingsGUI.php.

77 : void
78 {
79 $this->forumNotificationObj = new ilForumNotification($this->forum->getRefId());
80 $this->forumNotificationObj->readAllForcedEvents();
81 }

Referenced by getForumNotificationTable(), and notificationSettings().

+ Here is the caller graph for this function:

◆ initNotificationSettingsForm()

ilForumSettingsGUI::initNotificationSettingsForm ( )
private

Definition at line 667 of file class.ilForumSettingsGUI.php.

667 : bool
668 {
669 if ($this->notificationSettingsForm === null) {
670 $form = new ilPropertyFormGUI();
671 $form->setFormAction($this->ctrl->getFormAction($this, 'updateNotificationSettings'));
672 $form->setTitle($this->lng->txt('forums_notification_settings'));
673
674 $radio_grp = new ilRadioGroupInputGUI('', 'notification_type');
675 $radio_grp->setValue('default');
676
677 $opt_default = new ilRadioOption(
678 $this->lng->txt('user_decides_notification'),
680 );
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);
683
684 $radio_grp->addOption($opt_default);
685 $radio_grp->addOption($opt_0);
686 $radio_grp->addOption($opt_1);
687
688 $chb_2 = new ilCheckboxInputGUI($this->lng->txt('user_toggle_noti'), 'usr_toggle');
689 $chb_2->setValue('1');
690
691 $opt_0->addSubItem($chb_2);
692
693 $cb_grp = new ilCheckboxGroupInputGUI($this->lng->txt('notification_settings'), 'notification_events');
694
695 $notify_modified = new ilCheckboxOption($this->lng->txt('notify_modified'), (string) ilForumNotificationEvents::UPDATED);
696 $cb_grp->addOption($notify_modified);
697
698 $notify_censored = new ilCheckboxOption($this->lng->txt('notify_censored'), (string) ilForumNotificationEvents::CENSORED);
699 $cb_grp->addOption($notify_censored);
700
701 $notify_uncensored = new ilCheckboxOption($this->lng->txt('notify_uncensored'), (string) ilForumNotificationEvents::UNCENSORED);
702 $cb_grp->addOption($notify_uncensored);
703
704 $notify_post_deleted = new ilCheckboxOption($this->lng->txt('notify_post_deleted'), (string) ilForumNotificationEvents::POST_DELETED);
705 $cb_grp->addOption($notify_post_deleted);
706
707 $notify_thread_deleted = new ilCheckboxOption($this->lng->txt('notify_thread_deleted'), (string) ilForumNotificationEvents::THREAD_DELETED);
708 $cb_grp->addOption($notify_thread_deleted);
709 $opt_0->addSubItem($cb_grp);
710
711 $form->addItem($radio_grp);
712
713 $form->addCommandButton('updateNotificationSettings', $this->lng->txt('save'));
714
715 $this->notificationSettingsForm = $form;
716
717 return false;
718 }
719
720 return true;
721 }
This class represents a property in a property form.
This class represents an option in a checkbox group.
This class represents a property form user interface.

References ilForumNotificationEvents\CENSORED, ILIAS\Repository\ctrl(), ILIAS\Forum\Notification\DEFAULT, ILIAS\Repository\lng(), ilForumNotificationEvents\POST_DELETED, ilForumNotificationEvents\THREAD_DELETED, ilForumNotificationEvents\UNCENSORED, and ilForumNotificationEvents\UPDATED.

Referenced by showMembersCommand(), and updateNotificationSettingsCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ notificationSettings()

ilForumSettingsGUI::notificationSettings ( )
private

Definition at line 399 of file class.ilForumSettingsGUI.php.

399 : never
400 {
401 $send_bad_request = function () {
402 $this->http->saveResponse(
403 $this->http->response()
404 ->withStatus(400)
405 );
406 $this->http->sendResponse();
407 $this->http->close();
408 };
409
410 if (!$this->http->wrapper()->query()->has('frm_notifications_table_usr_ids')) {
411 $send_bad_request();
412 }
413
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())
417 );
418 if (count($user_ids) !== 1) {
419 $send_bad_request();
420 }
421
422 $user_id = current($user_ids);
424 $forced_events = $this->forumNotificationObj->getForcedEventsObjectByUserId($user_id);
425 $interested_events = $forced_events->getInterestedEvents();
426 $form_gui = new ilForumNotificationEventsFormGUI(
427 $this->ctrl->getFormAction($this->parent_obj, 'saveEventsForUser'),
428 [
429 'hidden_value' => json_encode([
430 'usr_id' => $user_id
431 ], JSON_THROW_ON_ERROR),
432 'notify_modified' => (bool) ($interested_events & ilForumNotificationEvents::UPDATED),
433 'notify_censored' => (bool) ($interested_events & ilForumNotificationEvents::CENSORED),
434 'notify_uncensored' => (bool) ($interested_events & ilForumNotificationEvents::UNCENSORED),
435 'notify_post_deleted' => (bool) ($interested_events & ilForumNotificationEvents::POST_DELETED),
436 'notify_thread_deleted' => (bool) ($interested_events & ilForumNotificationEvents::THREAD_DELETED),
437 ],
438 $this->ui_factory,
439 $this->lng
440 );
441
442 $modal = $this->ui_factory->modal()->roundtrip(
443 $this->lng->txt('notification_settings'),
444 [],
445 $form_gui->getInputs(),
446 $this->ctrl->getFormAction($this, 'saveEventsForUser')
447 );
448
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();
454 }

References $user_id, ilForumNotificationEvents\CENSORED, ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), initForcedForumNotification(), ILIAS\Repository\lng(), ilForumNotificationEvents\POST_DELETED, ilForumNotificationEvents\THREAD_DELETED, ilForumNotificationEvents\UNCENSORED, and ilForumNotificationEvents\UPDATED.

Referenced by handleNotificationActionsCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveEventsForUserCommand()

ilForumSettingsGUI::saveEventsForUserCommand ( )

Definition at line 456 of file class.ilForumSettingsGUI.php.

456 : void
457 {
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
462 );
463 }
464
465 $events_form_builder = new ilForumNotificationEventsFormGUI(
466 $this->ctrl->getFormAction($this, 'saveEventsForUser'),
467 null,
468 $this->ui_factory,
469 $this->lng
470 );
471
472 if ($this->http->request()->getMethod() === 'POST') {
473 $form = $events_form_builder->build()->withRequest($this->http->request());
474 $formData = $form->getData();
475
476 $interested_events = ilForumNotificationEvents::DEACTIVATED;
477
478 foreach ($events_form_builder->getValidEvents() as $event) {
479 $interested_events += isset($formData[$event]) && $formData[$event] ? $events_form_builder->getValueForEvent(
480 $event
481 ) : 0;
482 }
483
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();
487
488 if (in_array($hidden_value->usr_id, $valid_usr_ids)) {
489 $frm_noti = new ilForumNotification($this->parent_obj->getRefId());
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();
494 }
495 }
496 }
497
498 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->lng->txt('saved_successfully'), true);
499 $this->ctrl->redirect($this, 'showMembers');
500 }

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ilForumNotificationEvents\DEACTIVATED, error(), ILIAS\FileDelivery\http(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ settingsTabs()

ilForumSettingsGUI::settingsTabs ( )

Definition at line 193 of file class.ilForumSettingsGUI.php.

193 : bool
194 {
195 $this->tabs->addSubTabTarget(
196 self::UI_SUB_TAB_ID_BASIC_SETTINGS,
197 $this->ctrl->getLinkTarget($this->parent_obj, 'edit'),
198 '',
199 [strtolower(ilObjForumGUI::class)]
200 );
201
202 if ($this->settings->get('forum_notification') > 0 &&
203 $this->forum->isParentMembershipEnabledContainer() &&
204 $this->access->checkAccess('write', '', $this->parent_obj->getRefId())) {
205
206 $this->tabs->addSubTabTarget(
207 self::UI_SUB_TAB_ID_NOTIFICATIONS,
208 $this->ctrl->getLinkTarget($this, 'showMembers'),
209 '',
210 [strtolower(self::class)]
211 );
212 }
213
214 $this->tabs->addSubTabTarget(
215 self::UI_SUB_TAB_ID_NEWS,
216 $this->ctrl->getLinkTargetByClass(ilContainerNewsSettingsGUI::class),
217 '',
218 [strtolower(ilContainerNewsSettingsGUI::class)]
219 );
220
221 $this->tabs->addSubTabTarget(
222 self::UI_SUB_TAB_ID_STYLE,
223 $this->ctrl->getLinkTargetByClass(strtolower(ilObjectContentStyleSettingsGUI::class), ""),
224 '',
225 [strtolower(ilObjectContentStyleSettingsGUI::class)]
226 );
227
228 $this->tabs->activateTab(self::UI_TAB_ID_SETTINGS);
229
230 return true;
231 }

References ILIAS\Repository\ctrl(), ILIAS\Repository\settings(), and ILIAS\Repository\tabs().

Referenced by executeCommand(), and getCustomForm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showMembersCommand()

ilForumSettingsGUI::showMembersCommand ( )
private

Definition at line 324 of file class.ilForumSettingsGUI.php.

324 : void
325 {
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
330 );
331 }
332
333 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.forums_members_list.html', 'components/ILIAS/Forum');
334
335 // instantiate the property form
336 if (!$this->initNotificationSettingsForm()) {
337 // if the form was just created set the values fetched from database
338 $interested_events = $this->parent_obj->objProperties->getInterestedEvents();
339
340 $form_events = [];
341 if (($interested_events & ilForumNotificationEvents::UPDATED) !== 0) {
342 $form_events[] = ilForumNotificationEvents::UPDATED;
343 }
344
345 if (($interested_events & ilForumNotificationEvents::CENSORED) !== 0) {
347 }
348
349 if (($interested_events & ilForumNotificationEvents::UNCENSORED) !== 0) {
351 }
352
353 if (($interested_events & ilForumNotificationEvents::POST_DELETED) !== 0) {
355 }
356
357 if (($interested_events & ilForumNotificationEvents::THREAD_DELETED) !== 0) {
359 }
360
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
366 ]);
367 }
368
369 $this->tpl->setVariable('NOTIFICATIONS_SETTINGS_FORM', $this->notificationSettingsForm->getHTML());
370
371 if ($this->parent_obj->objProperties->getNotificationType() === NotificationType::DEFAULT) {
372 $forum_noti = new ilForumNotification($this->forum->getRefId());
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()));
380 }
381 }

References ILIAS\Repository\access(), ilForumNotificationEvents\CENSORED, ILIAS\Forum\Notification\DEFAULT, error(), initNotificationSettingsForm(), ILIAS\Repository\lng(), ilForumNotificationEvents\POST_DELETED, ilForumNotificationEvents\THREAD_DELETED, ilForumNotificationEvents\UNCENSORED, and ilForumNotificationEvents\UPDATED.

Referenced by handleNotificationActionsCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateCustomValues()

ilForumSettingsGUI::updateCustomValues ( ilPropertyFormGUI  $a_form)

Definition at line 272 of file class.ilForumSettingsGUI.php.

272 : void
273 {
274 $default_view_input_value = (int) $a_form->getInput('default_view');
275 if (in_array($default_view_input_value, [
280 ], true)) {
281 if ($default_view_input_value === ilForumProperties::VIEW_DATE) {
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, [
286 ], true)) {
287 $default_view_input_value = $default_view_order_by_date_value;
288 }
289 }
290 $default_view = $default_view_input_value;
291 } else {
292 $default_view = ilForumProperties::VIEW_TREE;
293 }
294 $this->parent_obj->objProperties->setDefaultView($default_view);
295
296 // BUGFIX FOR 11271
297
298 $view_mode = 'viewmode_' . $this->forum->getId();
299 if (ilSession::get($view_mode)) {
300 ilSession::set($view_mode, $default_view);
301 }
302
303 if ($this->settings->get('enable_anonymous_fora') || $this->parent_obj->objProperties->isAnonymized()) {
304 $this->parent_obj->objProperties->setAnonymisation((bool) $a_form->getInput('anonymized'));
305 }
306 if ($this->settings->get('enable_fora_statistics')) {
307 $this->parent_obj->objProperties->setStatisticsStatus((bool) $a_form->getInput('statistics_enabled'));
308 }
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'));
315 }
316 $this->parent_obj->objProperties->update();
317 $this->obj_service->commonSettings()->legacyForm($a_form, $this->parent_obj->getObject())->saveTileImage();
318
319 $object = $this->parent_obj->getObject();
320 $object->setOfflineStatus(!$a_form->getInput('activation_online'));
321 $object->update();
322 }
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
static get(string $a_var)
static set(string $a_var, $a_val)
Set a value.

References ilSession\get(), ilPropertyFormGUI\getInput(), ILIAS\Repository\int(), ilForumProperties\isFileUploadGloballyAllowed(), ilSession\set(), ILIAS\Repository\settings(), ilForumProperties\VIEW_DATE, ilForumProperties\VIEW_DATE_ASC, ilForumProperties\VIEW_DATE_DESC, and ilForumProperties\VIEW_TREE.

+ Here is the call graph for this function:

◆ updateNotificationSettingsCommand()

ilForumSettingsGUI::updateNotificationSettingsCommand ( )
private

Definition at line 723 of file class.ilForumSettingsGUI.php.

723 : void
724 {
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
729 );
730 }
731
733
734 $frm_noti = new ilForumNotification($this->forum->getRefId());
735 if ($this->notificationSettingsForm->checkInput()) {
736 $notification_type = NotificationType::tryFrom($this->dic->http()->wrapper()->post()->retrieve(
737 'notification_type',
738 $this->dic->refinery()->byTrying([
739 $this->dic->refinery()->kindlyTo()->string(),
740 $this->dic->refinery()->always(NotificationType::DEFAULT->value)
741 ])
743
744 if ($notification_type === NotificationType::ALL_USERS) {
745 $notification_events = $this->notificationSettingsForm->getInput('notification_events');
746 $interested_events = 0;
747
748 if (is_array($notification_events)) {
749 foreach ($notification_events as $activated_event) {
750 $interested_events += (int) $activated_event;
751 }
752 }
753
754 $this->parent_obj->objProperties->setAdminForceNoti(true);
755 $this->parent_obj->objProperties->setUserToggleNoti(
756 (bool) $this->notificationSettingsForm->getInput('usr_toggle')
757 );
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);
764 } else {
765 $this->parent_obj->objProperties->setNotificationType(NotificationType::DEFAULT);
766 $this->parent_obj->objProperties->setAdminForceNoti(false);
767 $this->parent_obj->objProperties->setUserToggleNoti(false);
768 $frm_noti->deleteNotificationAllUsers();
769 }
770 $properties = ilForumProperties::getInstance($this->forum->getId());
771 $frm_noti->updateUserNotifications($this->forum->getAllForumParticipants(), $properties);
772
773 $this->parent_obj->objProperties->update();
774
775 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->lng->txt('saved_successfully'), true);
776 }
777 $this->notificationSettingsForm->setValuesByPost();
778
779 $this->ctrl->redirect($this, 'showMembers');
780 }
static getInstance(int $a_obj_id=0)

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\Forum\Notification\DEFAULT, error(), ilForumProperties\getInstance(), initNotificationSettingsForm(), ILIAS\Repository\int(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Field Documentation

◆ $access

readonly ilAccessHandler ilForumSettingsGUI::$access
private

Definition at line 38 of file class.ilForumSettingsGUI.php.

◆ $ctrl

readonly ilCtrlInterface ilForumSettingsGUI::$ctrl
private

Definition at line 33 of file class.ilForumSettingsGUI.php.

◆ $dic

readonly ILIAS DI Container ilForumSettingsGUI::$dic
private

Definition at line 43 of file class.ilForumSettingsGUI.php.

◆ $error

readonly ilErrorHandling ilForumSettingsGUI::$error
private

Definition at line 44 of file class.ilForumSettingsGUI.php.

◆ $forumNotificationObj

ilForumNotification ilForumSettingsGUI::$forumNotificationObj
private

Definition at line 40 of file class.ilForumSettingsGUI.php.

◆ $http

readonly ILIAS HTTP GlobalHttpState ilForumSettingsGUI::$http
private

Definition at line 39 of file class.ilForumSettingsGUI.php.

◆ $lng

readonly ilLanguage ilForumSettingsGUI::$lng
private

Definition at line 35 of file class.ilForumSettingsGUI.php.

◆ $notificationSettingsForm

ilPropertyFormGUI ilForumSettingsGUI::$notificationSettingsForm = null
private

Definition at line 41 of file class.ilForumSettingsGUI.php.

◆ $obj_service

readonly ilObjectService ilForumSettingsGUI::$obj_service
private

Definition at line 42 of file class.ilForumSettingsGUI.php.

◆ $settings

readonly ilSetting ilForumSettingsGUI::$settings
private

Definition at line 36 of file class.ilForumSettingsGUI.php.

◆ $tabs

readonly ilTabsGUI ilForumSettingsGUI::$tabs
private

Definition at line 37 of file class.ilForumSettingsGUI.php.

◆ $tpl

readonly ilGlobalTemplateInterface ilForumSettingsGUI::$tpl
private

Definition at line 34 of file class.ilForumSettingsGUI.php.

◆ $ui_factory

readonly ILIAS UI Factory ilForumSettingsGUI::$ui_factory
private

Definition at line 45 of file class.ilForumSettingsGUI.php.

◆ $ui_renderer

readonly UiRenderer ilForumSettingsGUI::$ui_renderer
private

Definition at line 46 of file class.ilForumSettingsGUI.php.

◆ $ui_service

readonly ilUIService ilForumSettingsGUI::$ui_service
private

Definition at line 47 of file class.ilForumSettingsGUI.php.


The documentation for this class was generated from the following file: