ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilForumSettingsGUI Class Reference

Class ilForumSettingsGUI. 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)
 
 showMembers ()
 
 getForumNotificationTable ()
 
 notificationSettings ()
 
 saveEventsForUser ()
 
 enableAdminForceNoti ()
 
 disableAdminForceNoti ()
 
 enableHideUserToggleNoti ()
 
 disableHideUserToggleNoti ()
 
 updateNotificationSettings ()
 
 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)
 
 initNotificationSettingsForm ()
 
 handleNotificationActions ()
 

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 51 of file class.ilForumSettingsGUI.php.

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

52  {
53  global $DIC;
54 
55  $this->dic = $DIC;
56 
57  $this->ctrl = $DIC->ctrl();
58  $this->tpl = $DIC->ui()->mainTemplate();
59  $this->lng = $DIC->language();
60  $this->settings = $DIC->settings();
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'];
69 
70  $this->lng->loadLanguageModule('style');
71  $this->lng->loadLanguageModule('cont');
72  }
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26
+ Here is the call graph for this function:

Member Function Documentation

◆ addAvailabilitySection()

ilForumSettingsGUI::addAvailabilitySection ( ilPropertyFormGUI  $form)
private

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

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

Referenced by getCustomForm().

106  : void
107  {
108  $section = new ilFormSectionHeaderGUI();
109  $section->setTitle($this->lng->txt('rep_activation_availability'));
110  $form->addItem($section);
111 
112  $online = new ilCheckboxInputGUI($this->lng->txt('rep_activation_online'), 'activation_online');
113  $online->setInfo($this->lng->txt('frm_activation_online_info'));
114  $form->addItem($online);
115  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ disableAdminForceNoti()

ilForumSettingsGUI::disableAdminForceNoti ( )

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

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

559  : void
560  {
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
565  );
566  }
567 
568  $user_ids = [];
569  if ($this->dic->http()->wrapper()->post()->has('user_id')) {
570  $user_ids = $this->dic->http()->wrapper()->post()->retrieve(
571  'user_id',
572  $this->dic->refinery()->kindlyTo()->listOf($this->dic->refinery()->kindlyTo()->int())
573  );
574  }
575 
576  if (count($user_ids) === 0) {
577  $this->tpl->setOnScreenMessage('info', $this->lng->txt('time_limit_no_users_selected'));
578  } else {
579  $frm_noti = new ilForumNotification($this->forum->getRefId());
580 
581  foreach ($user_ids as $user_id) {
582  $frm_noti->setUserId((int) $user_id);
583  $is_enabled = $frm_noti->isAdminForceNotification();
584 
585  if ($is_enabled) {
586  $frm_noti->deleteAdminForce();
587  }
588  }
589 
590  $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'));
591  }
592 
593  $this->showMembers();
594  }
+ Here is the call graph for this function:

◆ disableHideUserToggleNoti()

ilForumSettingsGUI::disableHideUserToggleNoti ( )

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

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

Referenced by handleNotificationActions().

641  : void
642  {
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
647  );
648  }
649 
650  $user_ids = [];
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())
655  );
656  if ($user_ids === ['ALL_OBJECTS']) {
657  $table = $this->getForumNotificationTable();
658  $user_ids = $table->getFilteredUserIds($this->ui_service->filter()->getData($table->getFilterComponent()));
659  }
660  }
661 
662  if (count($user_ids) === 0) {
663  $this->tpl->setOnScreenMessage('info', $this->lng->txt('time_limit_no_users_selected'));
664  } else {
665  $frm_noti = new ilForumNotification($this->forum->getRefId());
666 
667  foreach ($user_ids as $user_id) {
668  $frm_noti->setUserId((int) $user_id);
669  $frm_noti->setUserToggle(false);
670  $is_enabled = $frm_noti->isAdminForceNotification();
671  if ($is_enabled) {
672  $frm_noti->updateUserToggle();
673  } else {
674  $frm_noti->setAdminForce(true);
675  $frm_noti->insertAdminForce();
676  }
677  }
678 
679  $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'));
680  }
681 
682  $this->showMembers();
683  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ enableAdminForceNoti()

ilForumSettingsGUI::enableAdminForceNoti ( )

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

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

520  : void
521  {
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
526  );
527  }
528 
529  $user_ids = [];
530  if ($this->dic->http()->wrapper()->post()->has('user_id')) {
531  $user_ids = $this->dic->http()->wrapper()->post()->retrieve(
532  'user_id',
533  $this->dic->refinery()->kindlyTo()->listOf($this->dic->refinery()->kindlyTo()->int())
534  );
535  }
536 
537  if (count($user_ids) === 0) {
538  $this->tpl->setOnScreenMessage('info', $this->lng->txt('time_limit_no_users_selected'), true);
539  } else {
540  $frm_noti = new ilForumNotification($this->forum->getRefId());
541 
542  foreach ($user_ids as $user_id) {
543  $frm_noti->setUserId((int) $user_id);
544  $frm_noti->setUserToggle(false);
545  $is_enabled = $frm_noti->isAdminForceNotification();
546 
547  if (!$is_enabled) {
548  $frm_noti->setAdminForce(true);
549  $frm_noti->insertAdminForce();
550  }
551  }
552 
553  $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'));
554  }
555 
556  $this->showMembers();
557  }
+ Here is the call graph for this function:

◆ enableHideUserToggleNoti()

ilForumSettingsGUI::enableHideUserToggleNoti ( )

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

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

Referenced by handleNotificationActions().

596  : void
597  {
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
602  );
603  }
604 
605  $user_ids = [];
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())
610  );
611  if ($user_ids === ['ALL_OBJECTS']) {
612  $table = $this->getForumNotificationTable();
613  $user_ids = $table->getFilteredUserIds($this->ui_service->filter()->getData($table->getFilterComponent()));
614  }
615  }
616 
617  if (count($user_ids) === 0) {
618  $this->tpl->setOnScreenMessage('info', $this->lng->txt('time_limit_no_users_selected'));
619  } else {
620  $frm_noti = new ilForumNotification($this->forum->getRefId());
621 
622  foreach ($user_ids as $user_id) {
623  $frm_noti->setUserId((int) $user_id);
624  $frm_noti->setUserToggle(true);
625  $is_enabled = $frm_noti->isAdminForceNotification();
626 
627  if ($is_enabled) {
628  $frm_noti->updateUserToggle();
629  } else {
630  $frm_noti->setAdminForce(true);
631  $frm_noti->insertAdminForce();
632  }
633  }
634 
635  $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'));
636  }
637 
638  $this->showMembers();
639  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilForumSettingsGUI::executeCommand ( )

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

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

85  : void
86  {
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()
92  );
93  }
94 
95  switch (true) {
96  case method_exists($this, $cmd):
97  $this->settingsTabs();
98  $this->{$cmd}();
99  break;
100 
101  default:
102  $this->ctrl->redirect($this->parent_obj);
103  }
104  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:

◆ getCustomForm()

ilForumSettingsGUI::getCustomForm ( ilPropertyFormGUI  $a_form)

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

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

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

◆ getCustomValues()

ilForumSettingsGUI::getCustomValues ( array &  $a_values)

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

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

250  : void
251  {
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();
258 
259  $default_view_value = $this->parent_obj->objProperties->getDefaultView();
260  if (in_array($default_view_value, [
265  ], true)) {
266  if (in_array($default_view_value, [
269  ], true)) {
270  $default_view_by_date = $default_view_value;
271  $default_view = ilForumProperties::VIEW_DATE;
272  } else {
273  $default_view = $default_view_value;
274  }
275  } else {
276  $default_view = ilForumProperties::VIEW_TREE;
277  }
278 
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;
282  }
283  $a_values['file_upload_allowed'] = $this->parent_obj->objProperties->getFileUploadAllowed();
284 
285  $object = $this->parent_obj->getObject();
286  $a_values['activation_online'] = !$object->getOfflineStatus();
287  }

◆ getForumNotificationTable()

ilForumSettingsGUI::getForumNotificationTable ( )

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

References $forumNotificationObj, $lng, $ui_factory, $ui_service, ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), and initForcedForumNotification().

Referenced by disableHideUserToggleNoti(), and enableHideUserToggleNoti().

401  {
403  return new ForumNotificationTable(
404  $this->http->request(),
405  $this->lng,
407  new DataFactory(),
408  $this->parent_obj->getObject()->getRefId(),
409  $this->forum->parentParticipants(),
412  $this->ctrl->getLinkTarget($this, 'handleNotificationActions')
413  );
414  }
readonly ILIAS UI Factory $ui_factory
readonly ilUIService $ui_service
readonly ilLanguage $lng
ilForumNotification $forumNotificationObj
static http()
Fetches the global http state from ILIAS.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRefId()

ilForumSettingsGUI::getRefId ( )

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

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

◆ 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 805 of file class.ilForumSettingsGUI.php.

805  : array
806  {
807  return [];
808  }

◆ 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 800 of file class.ilForumSettingsGUI.php.

800  : array
801  {
802  return ['handleNotificationActions'];
803  }

◆ handleNotificationActions()

ilForumSettingsGUI::handleNotificationActions ( )
private

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

References ILIAS\Repository\ctrl(), disableHideUserToggleNoti(), enableHideUserToggleNoti(), ILIAS\FileDelivery\http(), notificationSettings(), and null.

810  : void
811  {
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)
817  ])
818  );
819 
820  match ($action) {
821  'enableHideUserToggleNoti' => $this->enableHideUserToggleNoti(),
822  'disableHideUserToggleNoti' => $this->disableHideUserToggleNoti(),
823  'notificationSettings' => $this->notificationSettings(),
824  default => $this->ctrl->redirect($this, 'showMembers'),
825  };
826  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:

◆ initForcedForumNotification()

ilForumSettingsGUI::initForcedForumNotification ( )
private

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

Referenced by getForumNotificationTable(), and notificationSettings().

79  : void
80  {
81  $this->forumNotificationObj = new ilForumNotification($this->forum->getRefId());
82  $this->forumNotificationObj->readAllForcedEvents();
83  }
+ Here is the caller graph for this function:

◆ initNotificationSettingsForm()

ilForumSettingsGUI::initNotificationSettingsForm ( )
private

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

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

Referenced by showMembers(), and updateNotificationSettings().

685  : bool
686  {
687  if ($this->notificationSettingsForm === null) {
688  $form = new ilPropertyFormGUI();
689  $form->setFormAction($this->ctrl->getFormAction($this, 'updateNotificationSettings'));
690  $form->setTitle($this->lng->txt('forums_notification_settings'));
691 
692  $radio_grp = new ilRadioGroupInputGUI('', 'notification_type');
693  $radio_grp->setValue('default');
694 
695  $opt_default = new ilRadioOption(
696  $this->lng->txt('user_decides_notification'),
698  );
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);
701 
702  $radio_grp->addOption($opt_default);
703  $radio_grp->addOption($opt_0);
704  $radio_grp->addOption($opt_1);
705 
706  $chb_2 = new ilCheckboxInputGUI($this->lng->txt('user_toggle_noti'), 'usr_toggle');
707  $chb_2->setValue('1');
708 
709  $opt_0->addSubItem($chb_2);
710 
711  $cb_grp = new ilCheckboxGroupInputGUI($this->lng->txt('notification_settings'), 'notification_events');
712 
713  $notify_modified = new ilCheckboxOption($this->lng->txt('notify_modified'), (string) ilForumNotificationEvents::UPDATED);
714  $cb_grp->addOption($notify_modified);
715 
716  $notify_censored = new ilCheckboxOption($this->lng->txt('notify_censored'), (string) ilForumNotificationEvents::CENSORED);
717  $cb_grp->addOption($notify_censored);
718 
719  $notify_uncensored = new ilCheckboxOption($this->lng->txt('notify_uncensored'), (string) ilForumNotificationEvents::UNCENSORED);
720  $cb_grp->addOption($notify_uncensored);
721 
722  $notify_post_deleted = new ilCheckboxOption($this->lng->txt('notify_post_deleted'), (string) ilForumNotificationEvents::POST_DELETED);
723  $cb_grp->addOption($notify_post_deleted);
724 
725  $notify_thread_deleted = new ilCheckboxOption($this->lng->txt('notify_thread_deleted'), (string) ilForumNotificationEvents::THREAD_DELETED);
726  $cb_grp->addOption($notify_thread_deleted);
727  $opt_0->addSubItem($cb_grp);
728 
729  $form->addItem($radio_grp);
730 
731  $form->addCommandButton('updateNotificationSettings', $this->lng->txt('save'));
732 
733  $this->notificationSettingsForm = $form;
734 
735  return false;
736  }
737 
738  return true;
739  }
This class represents an option in a radio group.
This class represents an option in a checkbox group.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This class represents a property in a property form.
This class represents a property in a property form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ notificationSettings()

ilForumSettingsGUI::notificationSettings ( )

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

References $lng, $ui_factory, $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 handleNotificationActions().

416  : never
417  {
418  $send_bad_request = function () {
419  $this->http->saveResponse(
420  $this->http->response()
421  ->withStatus(400)
422  );
423  $this->http->sendResponse();
424  $this->http->close();
425  };
426 
427  if (!$this->http->wrapper()->query()->has('frm_notifications_table_usr_ids')) {
428  $send_bad_request();
429  }
430 
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())
434  );
435  if (count($user_ids) !== 1) {
436  $send_bad_request();
437  }
438 
439  $user_id = current($user_ids);
441  $forced_events = $this->forumNotificationObj->getForcedEventsObjectByUserId($user_id);
442  $interested_events = $forced_events->getInterestedEvents();
443  $form_gui = new ilForumNotificationEventsFormGUI(
444  $this->ctrl->getFormAction($this->parent_obj, 'saveEventsForUser'),
445  [
446  'hidden_value' => json_encode([
447  'usr_id' => $user_id
448  ], JSON_THROW_ON_ERROR),
449  'notify_modified' => (bool) ($interested_events & ilForumNotificationEvents::UPDATED),
450  'notify_censored' => (bool) ($interested_events & ilForumNotificationEvents::CENSORED),
451  'notify_uncensored' => (bool) ($interested_events & ilForumNotificationEvents::UNCENSORED),
452  'notify_post_deleted' => (bool) ($interested_events & ilForumNotificationEvents::POST_DELETED),
453  'notify_thread_deleted' => (bool) ($interested_events & ilForumNotificationEvents::THREAD_DELETED),
454  ],
456  $this->lng
457  );
458 
459  $modal = $this->ui_factory->modal()->roundtrip(
460  $this->lng->txt('notification_settings'),
461  [],
462  $form_gui->getInputs(),
463  $this->ctrl->getFormAction($this, 'saveEventsForUser')
464  );
465 
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();
471  }
readonly ILIAS UI Factory $ui_factory
readonly ilLanguage $lng
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveEventsForUser()

ilForumSettingsGUI::saveEventsForUser ( )

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

References $lng, $ui_factory, ILIAS\Repository\access(), ilForumNotificationEventsFormGUI\build(), ILIAS\Repository\ctrl(), ilForumNotificationEvents\DEACTIVATED, ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), null, and showMembers().

473  : void
474  {
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
479  );
480  }
481 
482  $events_form_builder = new ilForumNotificationEventsFormGUI(
483  $this->ctrl->getFormAction($this, 'saveEventsForUser'),
484  null,
486  $this->lng
487  );
488 
489  if ($this->http->request()->getMethod() === 'POST') {
490  $form = $events_form_builder->build()->withRequest($this->http->request());
491  $formData = $form->getData();
492 
493  $interested_events = ilForumNotificationEvents::DEACTIVATED;
494 
495  foreach ($events_form_builder->getValidEvents() as $event) {
496  $interested_events += isset($formData[$event]) && $formData[$event] ? $events_form_builder->getValueForEvent(
497  $event
498  ) : 0;
499  }
500 
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();
504 
505  if (in_array($hidden_value->usr_id, $valid_usr_ids)) {
506  $frm_noti = new ilForumNotification($this->parent_obj->getRefId());
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();
511  }
512  }
513  }
514 
515  $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'), true);
516 
517  $this->showMembers();
518  }
readonly ILIAS UI Factory $ui_factory
readonly ilLanguage $lng
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:

◆ settingsTabs()

ilForumSettingsGUI::settingsTabs ( )

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

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

Referenced by executeCommand(), getCustomForm(), and ilObjForumGUI\getSafePostCommands().

202  : bool
203  {
204  $this->tabs->addSubTabTarget(
205  self::UI_SUB_TAB_ID_BASIC_SETTINGS,
206  $this->ctrl->getLinkTarget($this->parent_obj, 'edit'),
207  '',
208  [strtolower(ilObjForumGUI::class)]
209  );
210 
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(
215  'cmd',
216  $this->dic->refinery()->byTrying([
217  $this->dic->refinery()->kindlyTo()->string(),
218  $this->dic->refinery()->always('showMembers')
219  ])
220  );
221  $this->tabs->addSubTabTarget(
222  self::UI_SUB_TAB_ID_NOTIFICATIONS,
223  $this->ctrl->getLinkTarget($this, 'showMembers'),
224  '',
225  [strtolower(self::class)],
226  '',
227  in_array($cmd, ['showMembers', 'forums_notification_settings'], true)
228  );
229  }
230 
231  $this->tabs->addSubTabTarget(
232  self::UI_SUB_TAB_ID_NEWS,
233  $this->ctrl->getLinkTargetByClass(ilContainerNewsSettingsGUI::class),
234  '',
235  [strtolower(ilContainerNewsSettingsGUI::class)]
236  );
237 
238  $this->tabs->addSubTabTarget(
239  self::UI_SUB_TAB_ID_STYLE,
240  $this->ctrl->getLinkTargetByClass(strtolower(ilObjectContentStyleSettingsGUI::class), ""),
241  '',
242  [strtolower(ilObjectContentStyleSettingsGUI::class)]
243  );
244 
245  $this->tabs->activateTab(self::UI_TAB_ID_SETTINGS);
246 
247  return true;
248  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showMembers()

ilForumSettingsGUI::showMembers ( )

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

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

Referenced by disableAdminForceNoti(), disableHideUserToggleNoti(), enableAdminForceNoti(), enableHideUserToggleNoti(), saveEventsForUser(), and updateNotificationSettings().

341  : void
342  {
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
347  );
348  }
349 
350  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.forums_members_list.html', 'components/ILIAS/Forum');
351 
352  // instantiate the property form
353  if (!$this->initNotificationSettingsForm()) {
354  // if the form was just created set the values fetched from database
355  $interested_events = $this->parent_obj->objProperties->getInterestedEvents();
356 
357  $form_events = [];
358  if (($interested_events & ilForumNotificationEvents::UPDATED) !== 0) {
359  $form_events[] = ilForumNotificationEvents::UPDATED;
360  }
361 
362  if (($interested_events & ilForumNotificationEvents::CENSORED) !== 0) {
363  $form_events[] = ilForumNotificationEvents::CENSORED;
364  }
365 
366  if (($interested_events & ilForumNotificationEvents::UNCENSORED) !== 0) {
367  $form_events[] = ilForumNotificationEvents::UNCENSORED;
368  }
369 
370  if (($interested_events & ilForumNotificationEvents::POST_DELETED) !== 0) {
372  }
373 
374  if (($interested_events & ilForumNotificationEvents::THREAD_DELETED) !== 0) {
376  }
377 
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
383  ]);
384  }
385 
386  $this->tpl->setVariable('NOTIFICATIONS_SETTINGS_FORM', $this->notificationSettingsForm->getHTML());
387 
388  if ($this->parent_obj->objProperties->getNotificationType() === NotificationType::DEFAULT) {
389  $forum_noti = new ilForumNotification($this->forum->getRefId());
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()));
397  }
398  }
+ 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 289 of file class.ilForumSettingsGUI.php.

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.

289  : void
290  {
291  $default_view_input_value = (int) $a_form->getInput('default_view');
292  if (in_array($default_view_input_value, [
297  ], true)) {
298  if ($default_view_input_value === ilForumProperties::VIEW_DATE) {
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, [
303  ], true)) {
304  $default_view_input_value = $default_view_order_by_date_value;
305  }
306  }
307  $default_view = $default_view_input_value;
308  } else {
309  $default_view = ilForumProperties::VIEW_TREE;
310  }
311  $this->parent_obj->objProperties->setDefaultView($default_view);
312 
313  // BUGFIX FOR 11271
314 
315  $view_mode = 'viewmode_' . $this->forum->getId();
316  if (ilSession::get($view_mode)) {
317  ilSession::set($view_mode, $default_view);
318  }
319 
320  if ($this->settings->get('enable_anonymous_fora') || $this->parent_obj->objProperties->isAnonymized()) {
321  $this->parent_obj->objProperties->setAnonymisation((bool) $a_form->getInput('anonymized'));
322  }
323  if ($this->settings->get('enable_fora_statistics')) {
324  $this->parent_obj->objProperties->setStatisticsStatus((bool) $a_form->getInput('statistics_enabled'));
325  }
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'));
332  }
333  $this->parent_obj->objProperties->update();
334  $this->obj_service->commonSettings()->legacyForm($a_form, $this->parent_obj->getObject())->saveTileImage();
335 
336  $object = $this->parent_obj->getObject();
337  $object->setOfflineStatus(!(bool) $a_form->getInput('activation_online'));
338  $object->update();
339  }
static get(string $a_var)
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 set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:

◆ updateNotificationSettings()

ilForumSettingsGUI::updateNotificationSettings ( )

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

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

741  : void
742  {
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
747  );
748  }
749 
751 
752  $frm_noti = new ilForumNotification($this->forum->getRefId());
753  if ($this->notificationSettingsForm->checkInput()) {
754  $notification_type = NotificationType::tryFrom($this->dic->http()->wrapper()->post()->retrieve(
755  'notification_type',
756  $this->dic->refinery()->byTrying([
757  $this->dic->refinery()->kindlyTo()->string(),
758  $this->dic->refinery()->always(NotificationType::DEFAULT->value)
759  ])
761 
762  if ($notification_type === NotificationType::ALL_USERS) {
763  $notification_events = $this->notificationSettingsForm->getInput('notification_events');
764  $interested_events = 0;
765 
766  if (is_array($notification_events)) {
767  foreach ($notification_events as $activated_event) {
768  $interested_events += (int) $activated_event;
769  }
770  }
771 
772  $this->parent_obj->objProperties->setAdminForceNoti(true);
773  $this->parent_obj->objProperties->setUserToggleNoti(
774  (bool) $this->notificationSettingsForm->getInput('usr_toggle')
775  );
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);
782  } else {
783  $this->parent_obj->objProperties->setNotificationType(NotificationType::DEFAULT);
784  $this->parent_obj->objProperties->setAdminForceNoti(false);
785  $this->parent_obj->objProperties->setUserToggleNoti(false);
786  $frm_noti->deleteNotificationAllUsers();
787  }
788  $properties = ilForumProperties::getInstance($this->forum->getId());
789  $frm_noti->updateUserNotifications($this->forum->getAllForumParticipants(), $properties);
790 
791  $this->parent_obj->objProperties->update();
792 
793  $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'));
794  }
795  $this->notificationSettingsForm->setValuesByPost();
796 
797  $this->showMembers();
798  }
static getInstance(int $a_obj_id=0)
+ Here is the call graph for this function:

Field Documentation

◆ $access

readonly ilAccessHandler ilForumSettingsGUI::$access
private

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

◆ $ctrl

readonly ilCtrlInterface ilForumSettingsGUI::$ctrl
private

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

◆ $dic

readonly ILIAS DI Container ilForumSettingsGUI::$dic
private

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

◆ $error

readonly ilErrorHandling ilForumSettingsGUI::$error
private

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

◆ $forumNotificationObj

ilForumNotification ilForumSettingsGUI::$forumNotificationObj
private

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

Referenced by getForumNotificationTable().

◆ $http

readonly ILIAS HTTP GlobalHttpState ilForumSettingsGUI::$http
private

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

◆ $lng

readonly ilLanguage ilForumSettingsGUI::$lng
private

◆ $notificationSettingsForm

ilPropertyFormGUI ilForumSettingsGUI::$notificationSettingsForm = null
private

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

◆ $obj_service

readonly ilObjectService ilForumSettingsGUI::$obj_service
private

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

◆ $settings

readonly ilSetting ilForumSettingsGUI::$settings
private

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

◆ $tabs

readonly ilTabsGUI ilForumSettingsGUI::$tabs
private

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

◆ $tpl

readonly ilGlobalTemplateInterface ilForumSettingsGUI::$tpl
private

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

◆ $ui_factory

readonly ILIAS UI Factory ilForumSettingsGUI::$ui_factory
private

◆ $ui_renderer

readonly UiRenderer ilForumSettingsGUI::$ui_renderer
private

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

◆ $ui_service

readonly ilUIService ilForumSettingsGUI::$ui_service
private

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

Referenced by getForumNotificationTable().


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