ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilForumModeratorsGUI Class Reference

@ilCtrl_Calls ilForumModeratorsGUI: ilRepositorySearchGUI More...

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

Public Member Functions

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

Private Member Functions

 detachModeratorRole ()
 
 showModeratorsCommand ()
 
 handleModeratorActionsCommand ()
 

Private Attributes

const string CMD_SHOW_MODERATORS = 'showModerators'
 
const string CMD_ADD_MODERATOR = 'addModerator'
 
const string CMD_HANDLE_TABLE_ACTIONS = 'handleModeratorActions'
 
const string DEFAULT_CMD = self::CMD_SHOW_MODERATORS
 
readonly ilCtrlInterface $ctrl
 
readonly ilGlobalTemplateInterface $tpl
 
readonly ilLanguage $lng
 
readonly ilTabsGUI $tabs
 
readonly ilErrorHandling $error
 
readonly ilObjUser $user
 
readonly ilToolbarGUI $toolbar
 
readonly ilForumModerators $frm_moderators
 
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
 
readonly ILIAS UI Renderer $ui_renderer
 

Detailed Description

Member Function Documentation

◆ addModeratorCommand()

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

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

105 : void
106 {
107 if ($users === []) {
108 $this->tpl->setOnScreenMessage(
109 $this->tpl::MESSAGE_TYPE_FAILURE,
110 $this->lng->txt('frm_moderators_select_one')
111 );
112 return;
113 }
114
115 $frm_properties = ilForumProperties::getInstance(ilObject::_lookupObjId($this->forum->getRefId()));
116 $notificaton_type = $frm_properties->getNotificationType();
117 $is_membersip_enabled_parent = $this->forum->isParentMembershipEnabledContainer();
118 $tmp_frm_noti = new ilForumNotification($this->forum->getRefId());
119
120 foreach ($users as $usr_id) {
121 $this->frm_moderators->addModeratorRole($usr_id);
122 if ($is_membersip_enabled_parent && $notificaton_type !== NotificationType::DEFAULT) {
123 $tmp_frm_noti->setUserId($usr_id);
124 $tmp_frm_noti->setUserIdNoti($this->user->getId());
125 $tmp_frm_noti->setUserToggle($frm_properties->getUserToggleNoti());
126 $tmp_frm_noti->setAdminForce($frm_properties->getAdminForceNoti());
127 $tmp_frm_noti->insertAdminForce();
128 }
129 }
130
131 $this->tpl->setOnScreenMessage(
132 $this->tpl::MESSAGE_TYPE_SUCCESS,
133 $this->lng->txt('frm_moderator_role_added_successfully'),
134 true
135 );
136 $this->ctrl->redirect($this, self::CMD_SHOW_MODERATORS);
137 }
Class ilForumNotification.
static getInstance(int $a_obj_id=0)
static _lookupObjId(int $ref_id)

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

+ Here is the call graph for this function:

◆ detachModeratorRole()

ilForumModeratorsGUI::detachModeratorRole ( )
private

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

139 : void
140 {
141 $usr_ids = $this->http_wrapper->query()->retrieve(
142 'frm_moderators_table_usr_ids',
143 $this->refinery->byTrying([
144 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int()),
145 $this->refinery->always([])
146 ])
147 );
148
149 if ($usr_ids === []) {
150 $this->tpl->setOnScreenMessage(
151 $this->tpl::MESSAGE_TYPE_FAILURE,
152 $this->lng->txt('frm_moderators_select_at_least_one')
153 );
154 $this->ctrl->redirect($this, self::CMD_SHOW_MODERATORS);
155 }
156
157 $entries = $this->frm_moderators->getCurrentModerators();
158 if (count($usr_ids) === count($entries)) {
159 $this->tpl->setOnScreenMessage(
160 $this->tpl::MESSAGE_TYPE_FAILURE,
161 $this->lng->txt('frm_at_least_one_moderator'),
162 true
163 );
164 $this->ctrl->redirect($this, self::CMD_SHOW_MODERATORS);
165 }
166
167 $frm_properties = ilForumProperties::getInstance(ilObject::_lookupObjId($this->forum->getRefId()));
168 $obj_id = $frm_properties->getObjId();
169 $notificaton_type = $frm_properties->getNotificationType();
170 $is_membersip_enabled_parent = $this->forum->isParentMembershipEnabledContainer();
171 $need_participants = $is_membersip_enabled_parent && $notificaton_type !== NotificationType::DEFAULT;
172 $tmp_frm_noti = new ilForumNotification($this->forum->getRefId());
173
174 $participants_result = $need_participants
175 ? new \ILIAS\Data\Result\Ok($this->forum->parentParticipants())
176 : new \ILIAS\Data\Result\Error("Participants not required for ref_id {$this->forum->getRefId()}");
177
178 foreach ($usr_ids as $usr_id) {
179 $this->frm_moderators->detachModeratorRole($usr_id);
180 $participants_result->map(function (ilParticipants $participants) use ($tmp_frm_noti, $usr_id, $obj_id) {
181 if (!$participants->isAssigned($usr_id)) {
182 $tmp_frm_noti->setUserId($usr_id);
183 $tmp_frm_noti->setForumId($obj_id);
184 $tmp_frm_noti->deleteAdminForce();
185 }
186 });
187 }
188
189 $this->tpl->setOnScreenMessage(
190 $this->tpl::MESSAGE_TYPE_SUCCESS,
191 $this->lng->txt('frm_moderators_detached_role_successfully'),
192 true
193 );
194 $this->ctrl->redirect($this, self::CMD_SHOW_MODERATORS);
195 }
Base class for course and group participants.
isAssigned(int $a_usr_id)
check if user is assigned
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

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

Referenced by handleModeratorActionsCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilForumModeratorsGUI::executeCommand ( )

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

72 : void
73 {
74 if (!$this->access->checkAccess('write', '', $this->forum->getRefId())) {
75 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
76 }
77
78 $this->tabs->activateTab('frm_moderators');
79
80 $next_class = $this->ctrl->getNextClass($this) ?? '';
81 $cmd = $this->ctrl->getCmd();
82
83 switch (strtolower($next_class)) {
84 case strtolower(ilRepositorySearchGUI::class):
85 $rep_search = new ilRepositorySearchGUI();
86 $rep_search->setCallback($this, self::CMD_ADD_MODERATOR . 'Command');
87 $this->ctrl->setReturn($this, self::CMD_SHOW_MODERATORS);
88 $this->ctrl->forwardCommand($rep_search);
89 break;
90
91 default:
92 if ($cmd === null || $cmd === '' || !method_exists($this, $cmd . 'Command')) {
93 $cmd = self::DEFAULT_CMD;
94 }
95 $verified_command = $cmd . 'Command';
96
97 $this->$verified_command();
98 break;
99 }
100 }
error(string $a_errmsg)
setCallback(object $class, string $method, array $a_add_options=[], string $default_option='')

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), DEFAULT_CMD, error(), ILIAS\Repository\lng(), and ILIAS\Repository\tabs().

+ 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 246 of file class.ilForumModeratorsGUI.php.

246 : array
247 {
248 return [];
249 }

◆ 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 239 of file class.ilForumModeratorsGUI.php.

239 : array
240 {
241 return [
243 ];
244 }

References CMD_HANDLE_TABLE_ACTIONS.

◆ handleModeratorActionsCommand()

ilForumModeratorsGUI::handleModeratorActionsCommand ( )
private

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

224 : void
225 {
226 $action = $this->http_wrapper->query()->retrieve(
227 'frm_moderators_table_action',
228 $this->refinery->byTrying([
229 $this->refinery->kindlyTo()->string(),
230 $this->refinery->always('')
231 ])
232 );
233 match ($action) {
234 'detachModeratorRole' => $this->detachModeratorRole(),
235 default => $this->ctrl->redirect($this, self::CMD_SHOW_MODERATORS),
236 };
237 }

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

+ Here is the call graph for this function:

◆ showModeratorsCommand()

ilForumModeratorsGUI::showModeratorsCommand ( )
private

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

197 : void
198 {
200 $this,
201 $this->toolbar,
202 [
203 'auto_complete_name' => $this->lng->txt('user'),
204 'submit_name' => $this->lng->txt('add'),
205 'add_search' => true,
206 'add_from_container' => $this->frm_moderators->getRefId()
207 ]
208 );
209
210 $tbl = new \ILIAS\Forum\Moderation\ForumModeratorsTable(
211 $this->frm_moderators,
212 $this->lng,
213 $this->http,
214 $this->ui_factory,
215 ilUtil::_getHttpPath() . '/' . $this->ctrl->getLinkTarget(
216 $this,
217 self::CMD_HANDLE_TABLE_ACTIONS
218 )
219 );
220
221 $this->tpl->setContent($this->ui_renderer->render($tbl->getComponent()));
222 }
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...
static _getHttpPath()
static http()
Fetches the global http state from ILIAS.

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

+ Here is the call graph for this function:

Field Documentation

◆ $access

readonly ilAccessHandler ilForumModeratorsGUI::$access
private

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

◆ $ctrl

readonly ilCtrlInterface ilForumModeratorsGUI::$ctrl
private

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

◆ $error

readonly ilErrorHandling ilForumModeratorsGUI::$error
private

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

◆ $frm_moderators

readonly ilForumModerators ilForumModeratorsGUI::$frm_moderators
private

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

◆ $http

readonly ILIAS HTTP Services ilForumModeratorsGUI::$http
private

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

◆ $http_wrapper

readonly ILIAS HTTP Wrapper WrapperFactory ilForumModeratorsGUI::$http_wrapper
private

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

◆ $lng

readonly ilLanguage ilForumModeratorsGUI::$lng
private

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

◆ $refinery

readonly ILIAS Refinery Factory ilForumModeratorsGUI::$refinery
private

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

◆ $tabs

readonly ilTabsGUI ilForumModeratorsGUI::$tabs
private

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

◆ $toolbar

readonly ilToolbarGUI ilForumModeratorsGUI::$toolbar
private

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

◆ $tpl

readonly ilGlobalTemplateInterface ilForumModeratorsGUI::$tpl
private

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

◆ $ui_factory

readonly ILIAS UI Factory ilForumModeratorsGUI::$ui_factory
private

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

◆ $ui_renderer

readonly ILIAS UI Renderer ilForumModeratorsGUI::$ui_renderer
private

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

◆ $user

readonly ilObjUser ilForumModeratorsGUI::$user
private

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

◆ CMD_ADD_MODERATOR

const string ilForumModeratorsGUI::CMD_ADD_MODERATOR = 'addModerator'
private

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

◆ CMD_HANDLE_TABLE_ACTIONS

const string ilForumModeratorsGUI::CMD_HANDLE_TABLE_ACTIONS = 'handleModeratorActions'
private

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

Referenced by getUnsafeGetCommands().

◆ CMD_SHOW_MODERATORS

const string ilForumModeratorsGUI::CMD_SHOW_MODERATORS = 'showModerators'
private

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

◆ DEFAULT_CMD

const string ilForumModeratorsGUI::DEFAULT_CMD = self::CMD_SHOW_MODERATORS
private

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

Referenced by executeCommand().


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