ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
ilForumModeratorsGUI Class Reference

Class ilForumModeratorsGUI. More...

+ Inheritance diagram for ilForumModeratorsGUI:
+ Collaboration diagram for ilForumModeratorsGUI:

Public Member Functions

 executeCommand ()
 
 addModerator (array $users=[])
 
 detachModeratorRole ()
 
 showModerators ()
 
 getUnsafeGetCommands ()
 This method must return a list of unsafe GET commands. More...
 
 getSafePostCommands ()
 This method must return a list of safe POST commands. More...
 

Protected Attributes

ILIAS UI Renderer $ui_renderer
 

Private Member Functions

 handleModeratorActions ()
 

Private Attributes

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

Detailed Description

Member Function Documentation

◆ addModerator()

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

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

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

100  : void
101  {
102  if ($users === []) {
103  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_moderators_select_one'));
104  return;
105  }
106 
107  $frm_properties = ilForumProperties::getInstance(ilObject::_lookupObjId($this->forum->getRefId()));
108  $notificaton_type = $frm_properties->getNotificationType();
109  $is_membersip_enabled_parent = $this->forum->isParentMembershipEnabledContainer();
110  $tmp_frm_noti = new ilForumNotification($this->forum->getRefId());
111 
112  foreach ($users as $usr_id) {
113  $this->oForumModerators->addModeratorRole($usr_id);
114  if ($is_membersip_enabled_parent && $notificaton_type !== NotificationType::DEFAULT) {
115  $tmp_frm_noti->setUserId($usr_id);
116  $tmp_frm_noti->setUserIdNoti($this->user->getId());
117  $tmp_frm_noti->setUserToggle($frm_properties->getUserToggleNoti());
118  $tmp_frm_noti->setAdminForce($frm_properties->getAdminForceNoti());
119  $tmp_frm_noti->insertAdminForce();
120  }
121  }
122 
123  $this->tpl->setOnScreenMessage('success', $this->lng->txt('frm_moderator_role_added_successfully'), true);
124  $this->ctrl->redirect($this, 'showModerators');
125  }
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 127 of file class.ilForumModeratorsGUI.php.

References ilObject\_lookupObjId(), ILIAS\Repository\ctrl(), ILIAS\Forum\Notification\DEFAULT, ilForumProperties\getInstance(), ilParticipants\getInstance(), ilParticipants\isAssigned(), ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

Referenced by handleModeratorActions().

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

◆ executeCommand()

ilForumModeratorsGUI::executeCommand ( )

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

References ILIAS\Repository\ctrl().

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

◆ getSafePostCommands()

ilForumModeratorsGUI::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 220 of file class.ilForumModeratorsGUI.php.

220  : array
221  {
222  return [];
223  }

◆ getUnsafeGetCommands()

ilForumModeratorsGUI::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 213 of file class.ilForumModeratorsGUI.php.

213  : array
214  {
215  return [
216  'handleModeratorActions',
217  ];
218  }

◆ handleModeratorActions()

ilForumModeratorsGUI::handleModeratorActions ( )
private

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

References ILIAS\Repository\ctrl(), detachModeratorRole(), and ILIAS\Repository\refinery().

198  : void
199  {
200  $action = $this->http_wrapper->query()->retrieve(
201  'frm_moderators_table_action',
202  $this->refinery->byTrying([
203  $this->refinery->kindlyTo()->string(),
204  $this->refinery->always('')
205  ])
206  );
207  match ($action) {
208  'detachModeratorRole' => $this->detachModeratorRole(),
209  default => $this->ctrl->redirect($this, 'showModerators'),
210  };
211  }
+ Here is the call graph for this function:

◆ showModerators()

ilForumModeratorsGUI::showModerators ( )

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

References ILIAS\Repository\ctrl(), ilRepositorySearchGUI\fillAutoCompleteToolbar(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

174  : void
175  {
177  $this,
178  $this->toolbar,
179  [
180  'auto_complete_name' => $this->lng->txt('user'),
181  'submit_name' => $this->lng->txt('add'),
182  'add_search' => true,
183  'add_from_container' => $this->oForumModerators->getRefId()
184  ]
185  );
186 
187  $tbl = new \ILIAS\Forum\Moderation\ForumModeratorsTable(
188  $this->oForumModerators,
189  $this->ctrl,
190  $this->lng,
191  $this->http,
192  $this->ui_factory
193  );
194 
195  $this->tpl->setContent($this->ui_renderer->render($tbl->getComponent()));
196  }
static http()
Fetches the global http state from ILIAS.
static fillAutoCompleteToolbar(object $parent_object, ?ilToolbarGUI $toolbar=null, array $a_options=[], bool $a_sticky=false)
array( auto_complete_name = $lng->txt(&#39;user&#39;), auto_complete_size = 15, user_type = array(ilCoursePar...
+ Here is the call graph for this function:

Field Documentation

◆ $access

readonly ilAccessHandler ilForumModeratorsGUI::$access
private

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

◆ $ctrl

readonly ilCtrlInterface ilForumModeratorsGUI::$ctrl
private

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

◆ $error

readonly ilErrorHandling ilForumModeratorsGUI::$error
private

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

◆ $http

readonly ILIAS HTTP Services ilForumModeratorsGUI::$http
private

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

◆ $http_wrapper

readonly ILIAS HTTP Wrapper WrapperFactory ilForumModeratorsGUI::$http_wrapper
private

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

◆ $lng

readonly ilLanguage ilForumModeratorsGUI::$lng
private

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

◆ $oForumModerators

readonly ilForumModerators ilForumModeratorsGUI::$oForumModerators
private

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

◆ $refinery

readonly ILIAS Refinery Factory ilForumModeratorsGUI::$refinery
private

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

◆ $tabs

readonly ilTabsGUI ilForumModeratorsGUI::$tabs
private

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

◆ $toolbar

readonly ilToolbarGUI ilForumModeratorsGUI::$toolbar
private

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

◆ $tpl

readonly ilGlobalTemplateInterface ilForumModeratorsGUI::$tpl
private

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

◆ $ui_factory

readonly ILIAS UI Factory ilForumModeratorsGUI::$ui_factory
private

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

◆ $ui_renderer

ILIAS UI Renderer ilForumModeratorsGUI::$ui_renderer
protected

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

◆ $user

readonly ilObjUser ilForumModeratorsGUI::$user
private

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


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