ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilForumSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2017 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
9 {
10  private $ctrl;
11  private $tpl;
12  private $lng;
13  private $settings;
14  private $tabs;
15  private $access;
16  private $tree;
17  private $parent_obj;
18 
22  protected $form;
23 
28 
34  {
35  global $DIC;
36 
37  $this->parent_obj = $parent_obj;
38  $this->ctrl = $DIC->ctrl();
39  $this->tpl = $DIC->ui()->mainTemplate();
40  $this->lng = $DIC->language();
41  $this->settings = $DIC->settings();
42  $this->tabs = $DIC->tabs();
43  $this->access = $DIC->access();
44  $this->tree = $DIC->repositoryTree();
45  $this->obj_service = $DIC->object();
46  }
47 
51  public function executeCommand()
52  {
53  $cmd = $this->ctrl->getCmd();
54  switch (true) {
55  case method_exists($this, $cmd):
56  $this->settingsTabs();
57  $this->{$cmd}();
58  break;
59 
60  default:
61  $this->ctrl->redirect($this->parent_obj);
62  break;
63  }
64  }
65 
69  public function getCustomForm(&$a_form)
70  {
71  $this->settingsTabs();
72  $this->tabs->activateSubTab("basic_settings");
73  $a_form->setTitle($this->lng->txt('frm_settings_form_header'));
74 
75  $presentationHeader = new ilFormSectionHeaderGUI();
76  $presentationHeader->setTitle($this->lng->txt('frm_settings_presentation_header'));
77  $a_form->addItem($presentationHeader);
78 
79  $this->obj_service->commonSettings()->legacyForm($a_form, $this->parent_obj->object)->addTileImage();
80 
81  $rg_pro = new ilRadioGroupInputGUI($this->lng->txt('frm_default_view'), 'default_view');
82  $rg_pro->addOption(new ilRadioOption($this->lng->txt('sort_by_posts'), ilForumProperties::VIEW_TREE));
83  $rg_sort_by_date = new ilRadioOption($this->lng->txt('sort_by_date'), ilForumProperties::VIEW_DATE);
84  $rg_pro->addOption($rg_sort_by_date);
85  $view_direction_group_gui = new ilRadioGroupInputGUI('', 'default_view_sort_dir');
86  $view_desc = new ilRadioOption($this->lng->txt('descending_order'), ilForumProperties::VIEW_DATE_DESC);
87  $view_asc = new ilRadioOption($this->lng->txt('ascending_order'), ilForumProperties::VIEW_DATE_ASC);
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);
92 
93  $userFunctionsHeader = new \ilFormSectionHeaderGUI();
94  $userFunctionsHeader->setTitle($this->lng->txt('frm_settings_user_functions_header'));
95  $a_form->addItem($userFunctionsHeader);
96 
97  $frm_subject = new ilRadioGroupInputGUI($this->lng->txt('frm_subject_setting'), 'subject_setting');
98  $frm_subject->addOption(new ilRadioOption($this->lng->txt('preset_subject'), 'preset_subject'));
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);
102 
103  $cb_prop = new ilCheckboxInputGUI($this->lng->txt('enable_thread_ratings'), 'thread_rating');
104  $cb_prop->setValue(1);
105  $cb_prop->setInfo($this->lng->txt('enable_thread_ratings_info'));
106  $a_form->addItem($cb_prop);
107 
109  $frm_upload = new ilCheckboxInputGUI($this->lng->txt('file_upload_allowed'), 'file_upload_allowed');
110  $frm_upload->setValue(1);
111  $frm_upload->setInfo($this->lng->txt('allow_file_upload_desc'));
112  $a_form->addItem($frm_upload);
113  }
114 
115  $moderatorFunctionsHeader = new \ilFormSectionHeaderGUI();
116  $moderatorFunctionsHeader->setTitle($this->lng->txt('frm_settings_mod_functions_header'));
117  $a_form->addItem($moderatorFunctionsHeader);
118 
119  $cb_prop = new ilCheckboxInputGUI($this->lng->txt('activate_new_posts'), 'post_activation');
120  $cb_prop->setValue(1);
121  $cb_prop->setInfo($this->lng->txt('post_activation_desc'));
122  $a_form->addItem($cb_prop);
123 
124  $cb_prop = new ilCheckboxInputGUI($this->lng->txt('mark_moderator_posts'), 'mark_mod_posts');
125  $cb_prop->setValue(1);
126  $cb_prop->setInfo($this->lng->txt('mark_moderator_posts_desc'));
127  $a_form->addItem($cb_prop);
128 
129 
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'));
133  $latestAtTop->setValue(0);
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);
139 
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);
144  }
145 
146  if ($this->settings->get('enable_fora_statistics', false)) {
147  $cb_prop = new ilCheckboxInputGUI($this->lng->txt('frm_statistics_enabled'), 'statistics_enabled');
148  $cb_prop->setValue(1);
149  $cb_prop->setInfo($this->lng->txt('frm_statistics_enabled_desc'));
150  $a_form->addItem($cb_prop);
151  }
152 
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');
155  $cb_prop->setValue(1);
156  $cb_prop->setInfo($this->lng->txt('frm_anonymous_posting_desc'));
157  $a_form->addItem($cb_prop);
158  }
159  }
160 
164  public function settingsTabs()
165  {
166  $this->tabs->activateTab('settings');
167  $this->tabs->addSubTabTarget('basic_settings', $this->ctrl->getLinkTarget($this->parent_obj, 'edit'), '', ['ilobjforumgui', 'ilObjForumGUI']);
168 
169  if ($this->settings->get('forum_notification') > 0) {
170  // check if there a parent-node is a grp or crs
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');
173 
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;
179 
180  $this->tabs->addSubTabTarget('notifications', $this->ctrl->getLinkTarget($this, 'showMembers'), '', '', '', $force_mem_active);
181  }
182  }
183  }
184 
185  $this->lng->loadLanguageModule('cont');
186  $this->tabs->addSubTabTarget('cont_news_settings', $this->ctrl->getLinkTargetByClass('ilcontainernewssettingsgui'), '', 'ilcontainernewssettingsgui');
187 
188  return true;
189  }
190 
194  public function getCustomValues(array &$a_values)
195  {
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();
204 
205  $default_view = (int) $this->parent_obj->objProperties->getDefaultView() > ilForumProperties::VIEW_TREE
208 
209  $default_view_sort_dir = (int) $this->parent_obj->objProperties->getDefaultView() > ilForumProperties::VIEW_DATE_ASC
212 
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();
216  }
217 
221  public function updateCustomValues(ilPropertyFormGUI $a_form)
222  {
223  $default_view = (int) $a_form->getInput('default_view') > ilForumProperties::VIEW_TREE
226 
227  if ($default_view == ilForumProperties::VIEW_DATE) {
228  (int) $a_form->getInput('default_view_sort_dir') > ilForumProperties::VIEW_DATE_ASC
229  ? $default_view = ilForumProperties::VIEW_DATE_DESC
230  : $default_view = ilForumProperties::VIEW_DATE_ASC;
231  }
232 
233  $this->parent_obj->objProperties->setDefaultView($default_view);
234 
235  // BUGFIX FOR 11271
236  if (isset($_SESSION['viewmode'])) {
237  $_SESSION['viewmode'] = $default_view;
238  }
239 
240  if ($this->settings->get('enable_anonymous_fora') || $this->parent_obj->objProperties->isAnonymized()) {
241  $this->parent_obj->objProperties->setAnonymisation((int) $a_form->getInput('anonymized'));
242  }
243  if ($this->settings->get('enable_fora_statistics', false)) {
244  $this->parent_obj->objProperties->setStatisticsStatus((int) $a_form->getInput('statistics_enabled'));
245  }
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'));
253  }
254  $this->parent_obj->objProperties->update();
255  $this->obj_service->commonSettings()->legacyForm($a_form, $this->parent_obj->object)->saveTileImage();
256  }
257 
258  public function showMembers()
259  {
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);
262  }
263 
264  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.forums_members_list.html', 'Modules/Forum');
265 
266  // instantiate the property form
267  if (!$this->initNotificationSettingsForm()) {
268  // if the form was just created set the values fetched from database
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()
273  ));
274  }
275 
276  // set form html into template
277  $this->tpl->setVariable('NOTIFICATIONS_SETTINGS_FORM', $this->notificationSettingsForm->getHTML());
278 
279  $frm_noti = new ilForumNotification($this->parent_obj->object->getRefId());
280  $oParticipants = $this->getParticipants();
281 
282  $moderator_ids = ilForum::_getModerators($this->parent_obj->object->getRefId());
283 
284  $admin_ids = $oParticipants->getAdmins();
285  $member_ids = $oParticipants->getMembers();
286  $tutor_ids = $oParticipants->getTutors();
287 
288  if ($this->parent_obj->objProperties->getNotificationType() == 'default') {
289  // update forum_notification table
290  $forum_noti = new ilForumNotification($this->parent_obj->object->getRefId());
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') {
295  $moderators = $this->getUserNotificationTableData($moderator_ids, $frm_noti);
296  $admins = $this->getUserNotificationTableData($admin_ids, $frm_noti);
297  $members = $this->getUserNotificationTableData($member_ids, $frm_noti);
298  $tutors = $this->getUserNotificationTableData($tutor_ids, $frm_noti);
299 
300  $this->__showMembersTable($moderators, $admins, $members, $tutors);
301  }
302  }
303 
304  protected function getIcon($user_toggle_noti)
305  {
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\"/>";
309  return $icon;
310  }
311 
312  private function getUserNotificationTableData($user_ids, ilForumNotification $frm_noti)
313  {
314  $counter = 0;
315  $users = array();
316  foreach ($user_ids as $user_id) {
317  $frm_noti->setUserId($user_id);
318  $user_toggle_noti = $frm_noti->isUserToggleNotification();
319  $icon_ok = $this->getIcon(!$user_toggle_noti);
320 
321  $users[$counter]['user_id'] = ilUtil::formCheckbox(0, 'user_id[]', $user_id);
322  $users[$counter]['login'] = ilObjUser::_lookupLogin($user_id);
323  $name = ilObjUser::_lookupName($user_id);
324  $users[$counter]['firstname'] = $name['firstname'];
325  $users[$counter]['lastname'] = $name['lastname'];
326  $users[$counter]['user_toggle_noti'] = $icon_ok;
327  $counter++;
328  }
329  return $users;
330  }
331 
332  private function __showMembersTable(array $moderators, array $admins, array $members, array $tutors)
333  {
334  foreach (array_filter([
335  'moderators' => $moderators,
336  'administrator' => $admins,
337  'tutors' => $tutors,
338  'members' => $members
339  ]) as $type => $data) {
340  $tbl_mod = new ilTable2GUI($this, 'showMembers');
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)));
344 
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');
351 
352  $tbl_mod->setRowTemplate('tpl.forums_members_row.html', 'Modules/Forum');
353  $tbl_mod->setData($data);
354 
355  $tbl_mod->addMultiCommand('enableHideUserToggleNoti', $this->lng->txt('enable_hide_user_toggle'));
356  $tbl_mod->addMultiCommand('disableHideUserToggleNoti', $this->lng->txt('disable_hide_user_toggle'));
357 
358  $this->tpl->setCurrentBlock(strtolower($type) . '_table');
359  $this->tpl->setVariable(strtoupper($type), $tbl_mod->getHTML());
360  }
361  }
362 
363  public function enableAdminForceNoti()
364  {
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);
367  }
368 
369  if (!isset($_POST['user_id']) || !is_array($_POST['user_id'])) {
370  ilUtil::sendInfo($this->lng->txt('time_limit_no_users_selected'), true);
371  } else {
372  $frm_noti = new ilForumNotification($this->parent_obj->object->getRefId());
373 
374  foreach ($_POST['user_id'] as $user_id) {
375  $frm_noti->setUserId((int) $user_id);
376  $is_enabled = $frm_noti->isAdminForceNotification();
377 
378  $frm_noti->setUserToggle(0);
379  if (!$is_enabled) {
380  $frm_noti->setAdminForce(1);
381  $frm_noti->insertAdminForce();
382  }
383  }
384 
385  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
386  }
387 
388  $this->showMembers();
389  }
390 
391  public function disableAdminForceNoti()
392  {
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);
395  }
396 
397  if (!isset($_POST['user_id']) || !is_array($_POST['user_id'])) {
398  ilUtil::sendInfo($this->lng->txt('time_limit_no_users_selected'));
399  } else {
400  $frm_noti = new ilForumNotification($this->parent_obj->object->getRefId());
401 
402  foreach ($_POST['user_id'] as $user_id) {
403  $frm_noti->setUserId((int) $user_id);
404  $is_enabled = $frm_noti->isAdminForceNotification();
405 
406  if ($is_enabled) {
407  $frm_noti->deleteAdminForce();
408  }
409  }
410 
411  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
412  }
413 
414  $this->showMembers();
415  }
416 
417  public function enableHideUserToggleNoti()
418  {
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);
421  }
422  if (!isset($_POST['user_id']) || !is_array($_POST['user_id'])) {
423  ilUtil::sendInfo($this->lng->txt('time_limit_no_users_selected'));
424  } else {
425  $frm_noti = new ilForumNotification($this->parent_obj->object->getRefId());
426 
427  foreach ($_POST['user_id'] as $user_id) {
428  $frm_noti->setUserId((int) $user_id);
429  $is_enabled = $frm_noti->isAdminForceNotification();
430  $frm_noti->setUserToggle(1);
431 
432  if (!$is_enabled) {
433  $frm_noti->setAdminForce(1);
434  $frm_noti->insertAdminForce();
435  } else {
436  $frm_noti->updateUserToggle();
437  }
438  }
439 
440  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
441  }
442 
443  $this->showMembers();
444  }
445 
446  public function disableHideUserToggleNoti()
447  {
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);
450  }
451 
452  if (!isset($_POST['user_id']) || !is_array($_POST['user_id'])) {
453  ilUtil::sendInfo($this->lng->txt('time_limit_no_users_selected'));
454  } else {
455  $frm_noti = new ilForumNotification($this->parent_obj->object->getRefId());
456 
457  foreach ($_POST['user_id'] as $user_id) {
458  $frm_noti->setUserId((int) $user_id);
459  $is_enabled = $frm_noti->isAdminForceNotification();
460  $frm_noti->setUserToggle(0);
461  if ($is_enabled) {
462  $frm_noti->updateUserToggle();
463  } else {
464  $frm_noti->setAdminForce(1);
465  $frm_noti->insertAdminForce();
466  }
467  }
468 
469  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
470  }
471 
472  $this->showMembers();
473  }
474 
475 
476 
480  public function getParticipants()
481  {
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);
484  }
485 
489  $oParticipants = null;
490 
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) {
495  $oParticipants = ilGroupParticipants::_getInstanceByObjId($parent_obj->getId());
496  return $oParticipants;
497  } elseif ($crs_ref_id > 0) {
499 
500  $oParticipants = ilCourseParticipants::_getInstanceByObjId($parent_obj->getId());
501  return $oParticipants;
502  }
503 
504  return $oParticipants;
505  }
506 
507 
508 
509  private function updateUserNotifications($update_all_users = false)
510  {
511  $oParticipants = $this->getParticipants();
512 
513  $frm_noti = new ilForumNotification($this->parent_obj->object->getRefId());
514  $moderator_ids = ilForum::_getModerators($this->parent_obj->object->getRefId());
515 
516  $admin_ids = $oParticipants->getAdmins();
517  $member_ids = $oParticipants->getMembers();
518  $tutor_ids = $oParticipants->getTutors();
519 
520  $all_forum_users = array_merge($moderator_ids, $admin_ids, $member_ids, $tutor_ids);
521  $all_forum_users = array_unique($all_forum_users);
522 
523  $all_notis = $frm_noti->read();
524 
525  foreach ($all_forum_users as $user_id) {
526  $frm_noti->setUserId($user_id);
527 
528  $frm_noti->setAdminForce(1);
529  $frm_noti->setUserToggle($this->parent_obj->objProperties->isUserToggleNoti());
530 
531  if (array_key_exists($user_id, $all_notis) && $update_all_users) {
532  $frm_noti->update();
533  } elseif ($frm_noti->existsNotification() == false) {
534  $frm_noti->insertAdminForce();
535  }
536  }
537  }
538 
539  private function initNotificationSettingsForm()
540  {
541  if (null === $this->notificationSettingsForm) {
542  $form = new ilPropertyFormGUI();
543  $form->setFormAction($this->ctrl->getFormAction($this, 'updateNotificationSettings'));
544  $form->setTitle($this->lng->txt('forums_notification_settings'));
545 
546  $radio_grp = new ilRadioGroupInputGUI('', 'notification_type');
547  $radio_grp->setValue('default');
548 
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');
552 
553  $radio_grp->addOption($opt_default);
554  $radio_grp->addOption($opt_0);
555  $radio_grp->addOption($opt_1);
556 
557  $chb_2 = new ilCheckboxInputGUI($this->lng->txt('user_toggle_noti'), 'usr_toggle');
558  $chb_2->setValue(1);
559 
560  $opt_0->addSubItem($chb_2);
561  $form->addItem($radio_grp);
562 
563  $form->addCommandButton('updateNotificationSettings', $this->lng->txt('save'));
564 
565  $this->notificationSettingsForm = $form;
566 
567  return false;
568  }
569 
570  return true;
571  }
572 
573  public function updateNotificationSettings()
574  {
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);
577  }
578 
579  // instantiate the property form
581 
582  // check input
583  if ($this->notificationSettingsForm->checkInput()) {
584  if (isset($_POST['notification_type']) && $_POST['notification_type'] == 'all_users') {
585  // set values and call update
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');
589  $this->updateUserNotifications(true);
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);
594  $this->updateUserNotifications();
595  } else { // if($_POST['notification_type'] == 'default')
596  $this->parent_obj->objProperties->setNotificationType('default');
597  $this->parent_obj->objProperties->setAdminForceNoti(0);
598  $this->parent_obj->objProperties->setUserToggleNoti(0);
599  $frm_noti = new ilForumNotification($this->parent_obj->object->getRefId());
600  $frm_noti->deleteNotificationAllUsers();
601  }
602 
603  $this->parent_obj->objProperties->update();
604 
605  // print success message
606  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
607  }
608  $this->notificationSettingsForm->setValuesByPost();
609 
610  $this->showMembers();
611  return;
612  }
613 }
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.
settings()
Definition: settings.php:2
$_SESSION["AccountId"]
This class represents a property form user interface.
$type
global $DIC
Definition: saml.php:7
$_GET["client_id"]
This class represents a section header in a property form.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
This class represents a checkbox property in a property form.
Class ilForumSettingsGUI.
Class ilForumNotification.
setInfo($a_info)
Set Info.
setInfo($a_info)
Set Information Text.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
updateUserNotifications($update_all_users=false)
This class represents a property in a property form.
addOption($a_option)
Add Option.
Class ilTable2GUI.
addSubItem($a_item)
Add Subitem.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
Class ilObjForumGUI.
setValue($a_value)
Set Value.
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
__construct(ilObjForumGUI $parent_obj)
ilForumSettingsGUI constructor.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
$users
Definition: authpage.php:44
updateCustomValues(ilPropertyFormGUI $a_form)
getCustomValues(array &$a_values)
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)
$_POST["username"]
static formCheckbox($checked, $varname, $value, $disabled=false)
??? public
$data
Definition: bench.php:6