ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilForumModeratorsGUI Class Reference

Class ilForumModeratorsGUI. More...

+ Collaboration diagram for ilForumModeratorsGUI:

Public Member Functions

 executeCommand ()
 
 addModerator (array $users=[])
 
 detachModeratorRole ()
 

Private Attributes

ilCtrlInterface $ctrl
 
ilGlobalTemplateInterface $tpl
 
ilLanguage $lng
 
ilTabsGUI $tabs
 
ilErrorHandling $error
 
ilObjUser $user
 
ilToolbarGUI $toolbar
 
ilForumModerators $oForumModerators
 
ilAccessHandler $access
 
ILIAS HTTP Wrapper WrapperFactory $http_wrapper
 
ILIAS Refinery Factory $refinery
 

Detailed Description

Member Function Documentation

◆ addModerator()

ilForumModeratorsGUI::addModerator ( array  $users = [])
Parameters
list<int>$users

Definition at line 94 of file class.ilForumModeratorsGUI.php.

References ilObject\_lookupObjId(), ILIAS\Repository\ctrl(), ILIAS\Forum\Notification\DEFAULT, ilForumProperties\getInstance(), ILIAS\Repository\lng(), ilForumNotification\setUserId(), and ILIAS\Repository\user().

94  : void
95  {
96  if ($users === []) {
97  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_moderators_select_one'));
98  return;
99  }
100 
101  $frm_properties = ilForumProperties::getInstance(ilObject::_lookupObjId($this->forum->getRefId()));
102  $notificaton_type = $frm_properties->getNotificationType();
103  $is_membersip_enabled_parent = $this->forum->isParentMembershipEnabledContainer();
104  $tmp_frm_noti = new ilForumNotification($this->forum->getRefId());
105 
106  foreach ($users as $usr_id) {
107  $this->oForumModerators->addModeratorRole($usr_id);
108  if ($is_membersip_enabled_parent && $notificaton_type !== NotificationType::DEFAULT) {
109  $tmp_frm_noti->setUserId($usr_id);
110  $tmp_frm_noti->setUserIdNoti($this->user->getId());
111  $tmp_frm_noti->setUserToggle($frm_properties->getUserToggleNoti());
112  $tmp_frm_noti->setAdminForce($frm_properties->getAdminForceNoti());
113  $tmp_frm_noti->insertAdminForce();
114  }
115  }
116 
117  $this->tpl->setOnScreenMessage('success', $this->lng->txt('frm_moderator_role_added_successfully'), true);
118  $this->ctrl->redirect($this, 'showModerators');
119  }
Class ilForumNotification.
static _lookupObjId(int $ref_id)
static getInstance(int $a_obj_id=0)
+ Here is the call graph for this function:

◆ detachModeratorRole()

ilForumModeratorsGUI::detachModeratorRole ( )

Definition at line 121 of file class.ilForumModeratorsGUI.php.

References ilObject\_lookupObjId(), ILIAS\Repository\ctrl(), ILIAS\Forum\Notification\DEFAULT, ilRepositorySearchGUI\fillAutoCompleteToolbar(), ilLegacyFormElementsUtil\formCheckbox(), ilObjUser\getFirstname(), ilObject\getId(), ilForumProperties\getInstance(), ilObjectFactory\getInstanceByObjId(), ilObjUser\getLastname(), ilObjUser\getLogin(), ilParticipants\isAssigned(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ILIAS\Repository\toolbar().

121  : void
122  {
123  $usr_ids = $this->http_wrapper->post()->retrieve(
124  'usr_id',
125  $this->refinery->byTrying([
126  $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int()),
127  $this->refinery->always([])
128  ])
129  );
130 
131  if ($usr_ids === []) {
132  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_moderators_select_at_least_one'));
133  $this->ctrl->redirect($this, 'showModerators');
134  }
135 
136  $entries = $this->oForumModerators->getCurrentModerators();
137  if (count($usr_ids) === count($entries)) {
138  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_at_least_one_moderator'));
139  $this->ctrl->redirect($this, 'showModerators');
140  }
141 
142  $frm_properties = ilForumProperties::getInstance(ilObject::_lookupObjId($this->forum->getRefId()));
143  $obj_id = $frm_properties->getObjId();
144  $notificaton_type = $frm_properties->getNotificationType();
145  $is_membersip_enabled_parent = $this->forum->isParentMembershipEnabledContainer();
146  $need_participants = $is_membersip_enabled_parent && $notificaton_type !== NotificationType::DEFAULT;
147  $tmp_frm_noti = new ilForumNotification($this->forum->getRefId());
148 
149  $participants_result = $need_participants
150  ? new \ILIAS\Data\Result\Ok($this->forum->parentParticipants())
151  : new \ILIAS\Data\Result\Error("Participants not required for ref_id {$this->forum->getRefId()}");
152 
153  foreach ($usr_ids as $usr_id) {
154  $this->oForumModerators->detachModeratorRole($usr_id);
155  $participants_result->map(function (ilParticipants $participants) use ($tmp_frm_noti, $usr_id, $obj_id) {
156  if (!$participants->isAssigned($usr_id)) {
157  $tmp_frm_noti->setUserId($usr_id);
158  $tmp_frm_noti->setForumId($obj_id);
159  $tmp_frm_noti->deleteAdminForce();
160  }
161  });
162  }
163 
164  $this->tpl->setOnScreenMessage('success', $this->lng->txt('frm_moderators_detached_role_successfully'), true);
165  $this->ctrl->redirect($this, 'showModerators');
166  }
Class ChatMainBarProvider .
isAssigned(int $a_usr_id)
check if user is assigned
Class ilForumNotification.
static _lookupObjId(int $ref_id)
static getInstance(int $a_obj_id=0)
Base class for course and group participants.
+ Here is the call graph for this function:

◆ executeCommand()

ilForumModeratorsGUI::executeCommand ( )

Definition at line 69 of file class.ilForumModeratorsGUI.php.

References ILIAS\Repository\ctrl().

69  : void
70  {
71  $next_class = $this->ctrl->getNextClass($this);
72  $cmd = $this->ctrl->getCmd();
73 
74  switch (strtolower($next_class)) {
75  case strtolower(ilRepositorySearchGUI::class):
76  $rep_search = new ilRepositorySearchGUI();
77  $rep_search->setCallback($this, 'addModerator');
78  $this->ctrl->setReturn($this, 'showModerators');
79  $this->ctrl->forwardCommand($rep_search);
80  break;
81 
82  default:
83  if (!$cmd) {
84  $cmd = 'showModerators';
85  }
86  $this->$cmd();
87  break;
88  }
89  }
setCallback(object $class, string $method, array $a_add_options=[], string $default_option='')
+ Here is the call graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilForumModeratorsGUI::$access
private

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

◆ $ctrl

ilCtrlInterface ilForumModeratorsGUI::$ctrl
private

Definition at line 31 of file class.ilForumModeratorsGUI.php.

◆ $error

ilErrorHandling ilForumModeratorsGUI::$error
private

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

◆ $http_wrapper

ILIAS HTTP Wrapper WrapperFactory ilForumModeratorsGUI::$http_wrapper
private

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

◆ $lng

ilLanguage ilForumModeratorsGUI::$lng
private

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

◆ $oForumModerators

ilForumModerators ilForumModeratorsGUI::$oForumModerators
private

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

◆ $refinery

ILIAS Refinery Factory ilForumModeratorsGUI::$refinery
private

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

◆ $tabs

ilTabsGUI ilForumModeratorsGUI::$tabs
private

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

◆ $toolbar

ilToolbarGUI ilForumModeratorsGUI::$toolbar
private

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

◆ $tpl

ilGlobalTemplateInterface ilForumModeratorsGUI::$tpl
private

Definition at line 32 of file class.ilForumModeratorsGUI.php.

◆ $user

ilObjUser ilForumModeratorsGUI::$user
private

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


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