ILIAS  trunk Revision v11.0_alpha-1851-ga8564da6fed
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilForumModeratorsGUI Class Reference

Class ilForumModeratorsGUI. More...

+ Collaboration diagram for ilForumModeratorsGUI:

Public Member Functions

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

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
 
int $ref_id = 0
 
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 (   $users = [])

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

References $user_id, ilForumNotification\_isParentNodeGrpCrs(), ilObject\_lookupObjId(), ILIAS\Repository\ctrl(), ilForumProperties\getInstance(), ILIAS\Repository\lng(), and ILIAS\Repository\user().

103  : void
104  {
105  if (!$users) {
106  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_moderators_select_one'));
107  return;
108  }
109 
110  $isCrsGrp = ilForumNotification::_isParentNodeGrpCrs($this->ref_id);
111  $objFrmProps = ilForumProperties::getInstance(ilObject::_lookupObjId($this->ref_id));
112  $frm_noti_type = $objFrmProps->getNotificationType();
113 
114  foreach ($users as $user_id) {
115  $this->oForumModerators->addModeratorRole((int) $user_id);
116  if ($isCrsGrp && $frm_noti_type !== 'default') {
117  $tmp_frm_noti = new ilForumNotification($this->ref_id);
118  $tmp_frm_noti->setUserId((int) $user_id);
119  $tmp_frm_noti->setUserIdNoti($this->user->getId());
120  $tmp_frm_noti->setUserToggle($objFrmProps->getUserToggleNoti());
121  $tmp_frm_noti->setAdminForce($objFrmProps->getAdminForceNoti());
122 
123  $tmp_frm_noti->insertAdminForce();
124  }
125  }
126 
127  $this->tpl->setOnScreenMessage('success', $this->lng->txt('frm_moderator_role_added_successfully'), true);
128  $this->ctrl->redirect($this, 'showModerators');
129  }
Class ilForumNotification.
static _lookupObjId(int $ref_id)
static getInstance(int $a_obj_id=0)
static _isParentNodeGrpCrs(int $a_ref_id)
+ Here is the call graph for this function:

◆ detachModeratorRole()

ilForumModeratorsGUI::detachModeratorRole ( )

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

References ilForumNotification\_isParentNodeGrpCrs(), ilParticipants\_isParticipant(), ilObject\_lookupObjId(), ILIAS\Repository\ctrl(), ilForumProperties\getInstance(), ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

Referenced by handleModeratorActions().

131  : void
132  {
133  $usr_ids = [];
134  if ($this->http_wrapper->query()->has('frm_moderators_table_usr_ids')) {
135  $usr_ids = $this->http_wrapper->query()->retrieve(
136  'frm_moderators_table_usr_ids',
137  $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
138  );
139  }
140 
141  if (!isset($usr_ids) || !is_array($usr_ids)) {
142  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_moderators_select_at_least_one'));
143  $this->ctrl->redirect($this, 'showModerators');
144  }
145 
146  $entries = $this->oForumModerators->getCurrentModerators();
147  if (count($usr_ids) === count($entries)) {
148  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_at_least_one_moderator'), true);
149  $this->ctrl->redirect($this, 'showModerators');
150  }
151 
152  $isCrsGrp = ilForumNotification::_isParentNodeGrpCrs($this->ref_id);
153 
154  $objFrmProps = ilForumProperties::getInstance(ilObject::_lookupObjId($this->ref_id));
155  $frm_noti_type = $objFrmProps->getNotificationType();
156 
157  foreach ($usr_ids as $usr_id) {
158  $this->oForumModerators->detachModeratorRole((int) $usr_id);
159 
160  if ($isCrsGrp && $frm_noti_type !== 'default' && !ilParticipants::_isParticipant($this->ref_id, $usr_id)) {
161  $tmp_frm_noti = new ilForumNotification($this->ref_id);
162  $tmp_frm_noti->setUserId((int) $usr_id);
163  $tmp_frm_noti->setForumId(ilObject::_lookupObjId($this->ref_id));
164 
165  $tmp_frm_noti->deleteAdminForce();
166  }
167  }
168 
169  $this->tpl->setOnScreenMessage('success', $this->lng->txt('frm_moderators_detached_role_successfully'), true);
170  $this->ctrl->redirect($this, 'showModerators');
171  }
Class ilForumNotification.
static _lookupObjId(int $ref_id)
static getInstance(int $a_obj_id=0)
static _isParentNodeGrpCrs(int $a_ref_id)
static _isParticipant(int $a_ref_id, int $a_usr_id)
Static function to check if a user is a participant of the container object.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilForumModeratorsGUI::executeCommand ( )

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

References ILIAS\Repository\ctrl().

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

◆ handleModeratorActions()

ilForumModeratorsGUI::handleModeratorActions ( )
private

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

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

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

◆ showModerators()

ilForumModeratorsGUI::showModerators ( )

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

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

173  : void
174  {
176  $this,
177  $this->toolbar,
178  [
179  'auto_complete_name' => $this->lng->txt('user'),
180  'submit_name' => $this->lng->txt('add'),
181  'add_search' => true,
182  'add_from_container' => $this->oForumModerators->getRefId()
183  ]
184  );
185  if ($this->http_wrapper->query()->has('ref_id')) {
186  $this->ref_id = $this->http_wrapper->query()->retrieve(
187  'ref_id',
188  $this->refinery->kindlyTo()->int()
189  );
190  }
191 
192  $tbl = new \ILIAS\Forum\Moderation\ForumModeratorsTable(
193  $this->oForumModerators,
194  $this->ctrl,
195  $this->lng,
196  $this->http,
197  $this->ui_factory
198  );
199 
200  $this->tpl->setContent($this->ui_renderer->render($tbl->getComponent()));
201  }
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('user'), 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 38 of file class.ilForumModeratorsGUI.php.

◆ $ctrl

readonly ilCtrlInterface ilForumModeratorsGUI::$ctrl
private

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

◆ $error

readonly ilErrorHandling ilForumModeratorsGUI::$error
private

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

◆ $http

readonly ILIAS HTTP Services ilForumModeratorsGUI::$http
private

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

◆ $http_wrapper

readonly ILIAS HTTP Wrapper WrapperFactory ilForumModeratorsGUI::$http_wrapper
private

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

◆ $lng

readonly ilLanguage ilForumModeratorsGUI::$lng
private

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

◆ $oForumModerators

readonly ilForumModerators ilForumModeratorsGUI::$oForumModerators
private

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

◆ $ref_id

int ilForumModeratorsGUI::$ref_id = 0
private

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

◆ $refinery

readonly ILIAS Refinery Factory ilForumModeratorsGUI::$refinery
private

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

◆ $tabs

readonly ilTabsGUI ilForumModeratorsGUI::$tabs
private

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

◆ $toolbar

readonly ilToolbarGUI ilForumModeratorsGUI::$toolbar
private

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

◆ $tpl

readonly ilGlobalTemplateInterface ilForumModeratorsGUI::$tpl
private

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

◆ $ui_factory

readonly ILIAS UI Factory ilForumModeratorsGUI::$ui_factory
private

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

◆ $ui_renderer

ILIAS UI Renderer ilForumModeratorsGUI::$ui_renderer
protected

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

◆ $user

readonly ilObjUser ilForumModeratorsGUI::$user
private

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


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