38 $this->ctrl = $DIC->ctrl();
39 $this->tpl = $DIC->ui()->mainTemplate();
40 $this->lng = $DIC->language();
42 $this->tabs = $DIC->tabs();
43 $this->access = $DIC->access();
44 $this->tree = $DIC->repositoryTree();
45 $this->obj_service = $DIC->object();
53 $cmd = $this->ctrl->getCmd();
55 case method_exists($this, $cmd):
61 $this->ctrl->redirect($this->parent_obj);
72 $this->tabs->activateSubTab(
"basic_settings");
73 $a_form->setTitle($this->lng->txt(
'frm_settings_form_header'));
76 $presentationHeader->setTitle($this->lng->txt(
'frm_settings_presentation_header'));
77 $a_form->addItem($presentationHeader);
79 $this->obj_service->commonSettings()->legacyForm($a_form, $this->parent_obj->object)->addTileImage();
84 $rg_pro->addOption($rg_sort_by_date);
88 $view_direction_group_gui->addOption($view_desc);
89 $view_direction_group_gui->addOption($view_asc);
90 $rg_sort_by_date->
addSubItem($view_direction_group_gui);
91 $a_form->addItem($rg_pro);
93 $userFunctionsHeader = new \ilFormSectionHeaderGUI();
94 $userFunctionsHeader->setTitle($this->lng->txt(
'frm_settings_user_functions_header'));
95 $a_form->addItem($userFunctionsHeader);
97 $frm_subject =
new ilRadioGroupInputGUI($this->lng->txt(
'frm_subject_setting'),
'subject_setting');
99 $frm_subject->addOption(
new ilRadioOption($this->lng->txt(
'add_re_to_subject'),
'add_re_to_subject'));
100 $frm_subject->addOption(
new ilRadioOption($this->lng->txt(
'empty_subject'),
'empty_subject'));
101 $a_form->addItem($frm_subject);
103 $cb_prop =
new ilCheckboxInputGUI($this->lng->txt(
'enable_thread_ratings'),
'thread_rating');
105 $cb_prop->setInfo($this->lng->txt(
'enable_thread_ratings_info'));
106 $a_form->addItem($cb_prop);
109 $frm_upload =
new ilCheckboxInputGUI($this->lng->txt(
'file_upload_allowed'),
'file_upload_allowed');
111 $frm_upload->setInfo($this->lng->txt(
'allow_file_upload_desc'));
112 $a_form->addItem($frm_upload);
115 $moderatorFunctionsHeader = new \ilFormSectionHeaderGUI();
116 $moderatorFunctionsHeader->setTitle($this->lng->txt(
'frm_settings_mod_functions_header'));
117 $a_form->addItem($moderatorFunctionsHeader);
119 $cb_prop =
new ilCheckboxInputGUI($this->lng->txt(
'activate_new_posts'),
'post_activation');
121 $cb_prop->setInfo($this->lng->txt(
'post_activation_desc'));
122 $a_form->addItem($cb_prop);
124 $cb_prop =
new ilCheckboxInputGUI($this->lng->txt(
'mark_moderator_posts'),
'mark_mod_posts');
126 $cb_prop->setInfo($this->lng->txt(
'mark_moderator_posts_desc'));
127 $a_form->addItem($cb_prop);
130 $stickyThreadSorting =
new ilRadioGroupInputGUI($this->lng->txt(
'sorting_manual_sticky'),
'thread_sorting');
131 $latestAtTop =
new ilRadioOption($this->lng->txt(
'frm_sticky_threads_latest_at_top'), 0);
132 $latestAtTop->
setInfo($this->lng->txt(
'frm_sticky_threads_latest_at_top_info'));
134 $stickyThreadSorting->addOption($latestAtTop);
135 $manualSorting =
new ilRadioOption($this->lng->txt(
'frm_sticky_threads_manual_sorting'), 1);
136 $manualSorting->
setInfo($this->lng->txt(
'frm_sticky_threads_manual_sorting_info'));
137 $stickyThreadSorting->addOption($manualSorting);
138 $a_form->addItem($stickyThreadSorting);
140 if ($this->
settings->get(
'enable_anonymous_fora') || $this->
settings->get(
'enable_fora_statistics',
false)) {
141 $privacyHeader = new \ilFormSectionHeaderGUI();
142 $privacyHeader->setTitle($this->lng->txt(
'frm_settings_privacy_header'));
143 $a_form->addItem($privacyHeader);
146 if ($this->
settings->get(
'enable_fora_statistics',
false)) {
147 $cb_prop =
new ilCheckboxInputGUI($this->lng->txt(
'frm_statistics_enabled'),
'statistics_enabled');
149 $cb_prop->setInfo($this->lng->txt(
'frm_statistics_enabled_desc'));
150 $a_form->addItem($cb_prop);
153 if ($this->
settings->get(
'enable_anonymous_fora') || $this->parent_obj->objProperties->isAnonymized()) {
154 $cb_prop =
new ilCheckboxInputGUI($this->lng->txt(
'frm_anonymous_posting'),
'anonymized');
156 $cb_prop->setInfo($this->lng->txt(
'frm_anonymous_posting_desc'));
157 $a_form->addItem($cb_prop);
166 $this->tabs->activateTab(
'settings');
167 $this->tabs->addSubTabTarget(
'basic_settings', $this->ctrl->getLinkTarget($this->parent_obj,
'edit'),
'', [
'ilobjforumgui',
'ilObjForumGUI']);
169 if ($this->
settings->get(
'forum_notification') > 0) {
171 $grp_ref_id = $this->tree->checkForParentType($this->parent_obj->ref_id,
'grp');
172 $crs_ref_id = $this->tree->checkForParentType($this->parent_obj->ref_id,
'crs');
174 if ((
int) $grp_ref_id > 0 || (
int) $crs_ref_id > 0) {
175 #show member-tab for notification if forum-notification is enabled in administration 176 if ($this->access->checkAccess(
'write',
'', $this->parent_obj->ref_id)) {
177 $mem_active = array(
'showMembers',
'forums_notification_settings');
178 (in_array(
$_GET[
'cmd'], $mem_active)) ? $force_mem_active =
true : $force_mem_active =
false;
180 $this->tabs->addSubTabTarget(
'notifications', $this->ctrl->getLinkTarget($this,
'showMembers'),
'',
'',
'', $force_mem_active);
185 $this->lng->loadLanguageModule(
'cont');
186 $this->tabs->addSubTabTarget(
'cont_news_settings', $this->ctrl->getLinkTargetByClass(
'ilcontainernewssettingsgui'),
'',
'ilcontainernewssettingsgui');
196 $a_values[
'default_view'] = $this->parent_obj->objProperties->getDefaultView();
197 $a_values[
'anonymized'] = $this->parent_obj->objProperties->isAnonymized();
198 $a_values[
'statistics_enabled'] = $this->parent_obj->objProperties->isStatisticEnabled();
199 $a_values[
'post_activation'] = $this->parent_obj->objProperties->isPostActivationEnabled();
200 $a_values[
'subject_setting'] = $this->parent_obj->objProperties->getSubjectSetting();
201 $a_values[
'mark_mod_posts'] = $this->parent_obj->objProperties->getMarkModeratorPosts();
202 $a_values[
'thread_sorting'] = $this->parent_obj->objProperties->getThreadSorting();
203 $a_values[
'thread_rating'] = $this->parent_obj->objProperties->isIsThreadRatingEnabled();
213 $a_values[
'default_view'] = $default_view;
214 $a_values[
'default_view_sort_dir'] = $default_view_sort_dir;
215 $a_values[
'file_upload_allowed'] = (bool) $this->parent_obj->objProperties->getFileUploadAllowed();
233 $this->parent_obj->objProperties->setDefaultView($default_view);
240 if ($this->
settings->get(
'enable_anonymous_fora') || $this->parent_obj->objProperties->isAnonymized()) {
241 $this->parent_obj->objProperties->setAnonymisation((
int) $a_form->
getInput(
'anonymized'));
243 if ($this->
settings->get(
'enable_fora_statistics',
false)) {
244 $this->parent_obj->objProperties->setStatisticsStatus((
int) $a_form->
getInput(
'statistics_enabled'));
246 $this->parent_obj->objProperties->setPostActivation((
int) $a_form->
getInput(
'post_activation'));
247 $this->parent_obj->objProperties->setSubjectSetting($a_form->
getInput(
'subject_setting'));
248 $this->parent_obj->objProperties->setMarkModeratorPosts((
int) $a_form->
getInput(
'mark_mod_posts'));
249 $this->parent_obj->objProperties->setThreadSorting((
int) $a_form->
getInput(
'thread_sorting'));
250 $this->parent_obj->objProperties->setIsThreadRatingEnabled((
bool) $a_form->
getInput(
'thread_rating'));
252 $this->parent_obj->objProperties->setFileUploadAllowed((
bool) $a_form->
getInput(
'file_upload_allowed'));
254 $this->parent_obj->objProperties->update();
255 $this->obj_service->commonSettings()->legacyForm($a_form, $this->parent_obj->object)->saveTileImage();
260 if (!$this->access->checkAccess(
'write',
'', $this->parent_obj->ref_id)) {
261 $this->parent_obj->error->raiseError($this->lng->txt(
'msg_no_perm_read'), $this->parent_obj->error->MESSAGE);
264 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.forums_members_list.html',
'Modules/Forum');
269 $this->notificationSettingsForm->setValuesByArray(array(
270 'notification_type' => $this->parent_obj->objProperties->getNotificationType(),
271 'adm_force' => (bool) $this->parent_obj->objProperties->isAdminForceNoti(),
272 'usr_toggle' => (bool) $this->parent_obj->objProperties->isUserToggleNoti()
277 $this->tpl->setVariable(
'NOTIFICATIONS_SETTINGS_FORM', $this->notificationSettingsForm->getHTML());
280 $oParticipants = $this->getParticipants();
284 $admin_ids = $oParticipants->getAdmins();
285 $member_ids = $oParticipants->getMembers();
286 $tutor_ids = $oParticipants->getTutors();
288 if ($this->parent_obj->objProperties->getNotificationType() ==
'default') {
291 $forum_noti->
setAdminForce($this->parent_obj->objProperties->isAdminForceNoti());
292 $forum_noti->setUserToggle($this->parent_obj->objProperties->isUserToggleNoti());
293 $forum_noti->setForumId($this->parent_obj->objProperties->getObjId());
294 } elseif ($this->parent_obj->objProperties->getNotificationType() ==
'per_user') {
306 $icon = $user_toggle_noti
307 ?
"<img src=\"" .
ilUtil::getImagePath(
"icon_ok.svg") .
"\" alt=\"" . $this->lng->txt(
"enabled") .
"\" title=\"" . $this->lng->txt(
"enabled") .
"\" border=\"0\" vspace=\"0\"/>" 308 :
"<img src=\"" .
ilUtil::getImagePath(
"icon_not_ok.svg") .
"\" alt=\"" . $this->lng->txt(
"disabled") .
"\" title=\"" . $this->lng->txt(
"disabled") .
"\" border=\"0\" vspace=\"0\"/>";
316 foreach ($user_ids as $user_id) {
319 $icon_ok = $this->
getIcon(!$user_toggle_noti);
324 $users[$counter][
'firstname'] =
$name[
'firstname'];
326 $users[$counter][
'user_toggle_noti'] = $icon_ok;
334 foreach (array_filter([
335 'moderators' => $moderators,
336 'administrator' => $admins,
338 'members' => $members
341 $tbl_mod->setId(
'tbl_id_mod');
342 $tbl_mod->setFormAction($this->ctrl->getFormAction($this,
'showMembers'));
343 $tbl_mod->setTitle($this->lng->txt(strtolower(
$type)));
345 $tbl_mod->addColumn(
'',
'',
'1%',
true);
346 $tbl_mod->addColumn($this->lng->txt(
'login'),
'',
'10%');
347 $tbl_mod->addColumn($this->lng->txt(
'firstname'),
'',
'10%');
348 $tbl_mod->addColumn($this->lng->txt(
'lastname'),
'',
'10%');
349 $tbl_mod->addColumn($this->lng->txt(
'allow_user_toggle_noti'),
'',
'10%');
350 $tbl_mod->setSelectAllCheckbox(
'user_id');
352 $tbl_mod->setRowTemplate(
'tpl.forums_members_row.html',
'Modules/Forum');
353 $tbl_mod->setData(
$data);
355 $tbl_mod->addMultiCommand(
'enableHideUserToggleNoti', $this->lng->txt(
'enable_hide_user_toggle'));
356 $tbl_mod->addMultiCommand(
'disableHideUserToggleNoti', $this->lng->txt(
'disable_hide_user_toggle'));
358 $this->tpl->setCurrentBlock(strtolower(
$type) .
'_table');
359 $this->tpl->setVariable(strtoupper(
$type), $tbl_mod->getHTML());
365 if (!$this->access->checkAccess(
'write',
'', $this->parent_obj->ref_id)) {
366 $this->parent_obj->error->raiseError($this->lng->txt(
'msg_no_perm_read'), $this->parent_obj->error->MESSAGE);
369 if (!isset(
$_POST[
'user_id']) || !is_array(
$_POST[
'user_id'])) {
374 foreach (
$_POST[
'user_id'] as $user_id) {
376 $is_enabled = $frm_noti->isAdminForceNotification();
378 $frm_noti->setUserToggle(0);
380 $frm_noti->setAdminForce(1);
381 $frm_noti->insertAdminForce();
385 ilUtil::sendSuccess($this->lng->txt(
'saved_successfully'));
393 if (!$this->access->checkAccess(
'write',
'', $this->parent_obj->ref_id)) {
394 $this->parent_obj->error->raiseError($this->lng->txt(
'msg_no_perm_read'), $this->parent_obj->error->MESSAGE);
397 if (!isset(
$_POST[
'user_id']) || !is_array(
$_POST[
'user_id'])) {
402 foreach (
$_POST[
'user_id'] as $user_id) {
404 $is_enabled = $frm_noti->isAdminForceNotification();
407 $frm_noti->deleteAdminForce();
411 ilUtil::sendSuccess($this->lng->txt(
'saved_successfully'));
419 if (!$this->access->checkAccess(
'write',
'', $this->parent_obj->ref_id)) {
420 $this->parent_obj->error->raiseError($this->lng->txt(
'msg_no_perm_read'), $this->parent_obj->error->MESSAGE);
422 if (!isset(
$_POST[
'user_id']) || !is_array(
$_POST[
'user_id'])) {
427 foreach (
$_POST[
'user_id'] as $user_id) {
429 $is_enabled = $frm_noti->isAdminForceNotification();
430 $frm_noti->setUserToggle(1);
433 $frm_noti->setAdminForce(1);
434 $frm_noti->insertAdminForce();
436 $frm_noti->updateUserToggle();
440 ilUtil::sendSuccess($this->lng->txt(
'saved_successfully'));
448 if (!$this->access->checkAccess(
'write',
'', $this->parent_obj->ref_id)) {
449 $this->parent_obj->error->raiseError($this->lng->txt(
'msg_no_perm_read'), $this->parent_obj->error->MESSAGE);
452 if (!isset(
$_POST[
'user_id']) || !is_array(
$_POST[
'user_id'])) {
457 foreach (
$_POST[
'user_id'] as $user_id) {
459 $is_enabled = $frm_noti->isAdminForceNotification();
460 $frm_noti->setUserToggle(0);
462 $frm_noti->updateUserToggle();
464 $frm_noti->setAdminForce(1);
465 $frm_noti->insertAdminForce();
469 ilUtil::sendSuccess($this->lng->txt(
'saved_successfully'));
480 public function getParticipants()
482 if ($this->parent_obj->isParentObjectCrsOrGrp() ==
false) {
483 $this->parent_obj->error->raiseError($this->lng->txt(
'msg_no_perm_read'), $this->parent_obj->error->MESSAGE);
489 $oParticipants = null;
491 $grp_ref_id = $this->tree->checkForParentType($this->parent_obj->object->getRefId(),
'grp');
492 $crs_ref_id = $this->tree->checkForParentType($this->parent_obj->object->getRefId(),
'crs');
493 if ($grp_ref_id > 0) {
496 return $oParticipants;
497 } elseif ($crs_ref_id > 0) {
501 return $oParticipants;
504 return $oParticipants;
511 $oParticipants = $this->getParticipants();
516 $admin_ids = $oParticipants->getAdmins();
517 $member_ids = $oParticipants->getMembers();
518 $tutor_ids = $oParticipants->getTutors();
520 $all_forum_users = array_merge($moderator_ids, $admin_ids, $member_ids, $tutor_ids);
521 $all_forum_users = array_unique($all_forum_users);
523 $all_notis = $frm_noti->read();
525 foreach ($all_forum_users as $user_id) {
526 $frm_noti->setUserId($user_id);
528 $frm_noti->setAdminForce(1);
529 $frm_noti->setUserToggle($this->parent_obj->objProperties->isUserToggleNoti());
531 if (array_key_exists($user_id, $all_notis) && $update_all_users) {
533 } elseif ($frm_noti->existsNotification() ==
false) {
534 $frm_noti->insertAdminForce();
541 if (null === $this->notificationSettingsForm) {
543 $form->setFormAction($this->ctrl->getFormAction($this,
'updateNotificationSettings'));
544 $form->setTitle($this->lng->txt(
'forums_notification_settings'));
547 $radio_grp->setValue(
'default');
549 $opt_default =
new ilRadioOption($this->lng->txt(
"user_decides_notification"),
'default');
550 $opt_0 =
new ilRadioOption($this->lng->txt(
"settings_for_all_members"),
'all_users');
551 $opt_1 =
new ilRadioOption($this->lng->txt(
"settings_per_users"),
'per_user');
553 $radio_grp->addOption($opt_default);
554 $radio_grp->addOption($opt_0);
555 $radio_grp->addOption($opt_1);
561 $form->addItem($radio_grp);
563 $form->addCommandButton(
'updateNotificationSettings', $this->lng->txt(
'save'));
565 $this->notificationSettingsForm =
$form;
575 if (!$this->access->checkAccess(
'write',
'', $this->parent_obj->ref_id)) {
576 $this->parent_obj->error->raiseError($this->lng->txt(
'msg_no_perm_read'), $this->parent_obj->error->MESSAGE);
583 if ($this->notificationSettingsForm->checkInput()) {
584 if (isset(
$_POST[
'notification_type']) &&
$_POST[
'notification_type'] ==
'all_users') {
586 $this->parent_obj->objProperties->setAdminForceNoti(1);
587 $this->parent_obj->objProperties->setUserToggleNoti((
int) $this->notificationSettingsForm->getInput(
'usr_toggle'));
588 $this->parent_obj->objProperties->setNotificationType(
'all_users');
590 } elseif (
$_POST[
'notification_type'] ==
'per_user') {
591 $this->parent_obj->objProperties->setNotificationType(
'per_user');
592 $this->parent_obj->objProperties->setAdminForceNoti(1);
593 $this->parent_obj->objProperties->setUserToggleNoti(0);
596 $this->parent_obj->objProperties->setNotificationType(
'default');
597 $this->parent_obj->objProperties->setAdminForceNoti(0);
598 $this->parent_obj->objProperties->setUserToggleNoti(0);
603 $this->parent_obj->objProperties->update();
606 ilUtil::sendSuccess($this->lng->txt(
'saved_successfully'));
608 $this->notificationSettingsForm->setValuesByPost();
getUserNotificationTableData($user_ids, ilForumNotification $frm_noti)
static _lookupLogin($a_user_id)
lookup login
static _lookupName($a_user_id)
lookup user name
This class represents an option in a radio group.
disableHideUserToggleNoti()
deleteNotificationAllUsers()
initNotificationSettingsForm()
isUserToggleNotification()
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
setAdminForce($a_admin_force)
Class ilForumSettingsGUI.
getIcon($user_toggle_noti)
Class ilForumNotification.
setInfo($a_info)
Set Info.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
updateUserNotifications($update_all_users=false)
addSubItem($a_item)
Add Subitem.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
updateNotificationSettings()
enableHideUserToggleNoti()
__construct(ilObjForumGUI $parent_obj)
ilForumSettingsGUI constructor.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
updateCustomValues(ilPropertyFormGUI $a_form)
getCustomValues(array &$a_values)
$notificationSettingsForm
static isFileUploadGloballyAllowed()
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _getModerators($a_ref_id)
get all users assigned to local role il_frm_moderator_<frm_ref_id> (static)
__showMembersTable(array $moderators, array $admins, array $members, array $tutors)
static formCheckbox($checked, $varname, $value, $disabled=false)
??? public