19declare(strict_types=1);
44 private readonly \ILIAS\HTTP\Services
$http;
53 $this->
ctrl = $DIC->ctrl();
54 $this->tpl =
$DIC->ui()->mainTemplate();
55 $this->
lng = $DIC->language();
56 $this->
access = $DIC->access();
57 $this->
tabs = $DIC->tabs();
58 $this->
error = $DIC[
'ilErr'];
59 $this->
user = $DIC->user();
60 $this->
toolbar = $DIC->toolbar();
62 $this->
lng->loadLanguageModule(
'search');
63 $this->http_wrapper =
$DIC->http()->wrapper();
64 $this->
http = $DIC->http();
66 $this->ui_renderer =
$DIC->ui()->renderer();
67 $this->ui_factory =
$DIC->ui()->factory();
74 if (!$this->
access->checkAccess(
'write',
'', $this->forum->getRefId())) {
75 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
78 $this->
tabs->activateTab(
'frm_moderators');
80 $next_class = $this->
ctrl->getNextClass($this) ??
'';
81 $cmd = $this->
ctrl->getCmd();
83 switch (strtolower($next_class)) {
84 case strtolower(ilRepositorySearchGUI::class):
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);
92 if ($cmd ===
null || $cmd ===
'' || !method_exists($this, $cmd .
'Command')) {
95 $verified_command = $cmd .
'Command';
97 $this->$verified_command();
108 $this->tpl->setOnScreenMessage(
109 $this->tpl::MESSAGE_TYPE_FAILURE,
110 $this->
lng->txt(
'frm_moderators_select_one')
116 $notificaton_type = $frm_properties->getNotificationType();
117 $is_membersip_enabled_parent = $this->forum->isParentMembershipEnabledContainer();
120 foreach ($users as $usr_id) {
121 $this->frm_moderators->addModeratorRole($usr_id);
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();
131 $this->tpl->setOnScreenMessage(
132 $this->tpl::MESSAGE_TYPE_SUCCESS,
133 $this->
lng->txt(
'frm_moderator_role_added_successfully'),
136 $this->
ctrl->redirect($this, self::CMD_SHOW_MODERATORS);
141 $usr_ids = $this->http_wrapper->query()->retrieve(
142 'frm_moderators_table_usr_ids',
144 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int()),
145 $this->refinery->always([])
149 if ($usr_ids === []) {
150 $this->tpl->setOnScreenMessage(
151 $this->tpl::MESSAGE_TYPE_FAILURE,
152 $this->
lng->txt(
'frm_moderators_select_at_least_one')
154 $this->
ctrl->redirect($this, self::CMD_SHOW_MODERATORS);
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'),
164 $this->
ctrl->redirect($this, self::CMD_SHOW_MODERATORS);
168 $obj_id = $frm_properties->getObjId();
169 $notificaton_type = $frm_properties->getNotificationType();
170 $is_membersip_enabled_parent = $this->forum->isParentMembershipEnabledContainer();
174 $participants_result = $need_participants
175 ? new \ILIAS\Data\Result\Ok($this->forum->parentParticipants())
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) {
182 $tmp_frm_noti->setUserId($usr_id);
183 $tmp_frm_noti->setForumId($obj_id);
184 $tmp_frm_noti->deleteAdminForce();
189 $this->tpl->setOnScreenMessage(
190 $this->tpl::MESSAGE_TYPE_SUCCESS,
191 $this->
lng->txt(
'frm_moderators_detached_role_successfully'),
194 $this->
ctrl->redirect($this, self::CMD_SHOW_MODERATORS);
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()
210 $tbl = new \ILIAS\Forum\Moderation\ForumModeratorsTable(
211 $this->frm_moderators,
217 self::CMD_HANDLE_TABLE_ACTIONS
221 $this->tpl->setContent($this->ui_renderer->render($tbl->getComponent()));
226 $action = $this->http_wrapper->query()->retrieve(
227 'frm_moderators_table_action',
229 $this->refinery->kindlyTo()->string(),
230 $this->refinery->always(
'')
235 default => $this->
ctrl->redirect($this, self::CMD_SHOW_MODERATORS),
Error Handling & global info handling.
@ilCtrl_Calls ilForumModeratorsGUI: ilRepositorySearchGUI
readonly ilToolbarGUI $toolbar
readonly ilGlobalTemplateInterface $tpl
readonly ILIAS UI Renderer $ui_renderer
const string CMD_HANDLE_TABLE_ACTIONS
readonly ilCtrlInterface $ctrl
readonly ILIAS HTTP Wrapper WrapperFactory $http_wrapper
readonly ilAccessHandler $access
const string CMD_ADD_MODERATOR
const string CMD_SHOW_MODERATORS
readonly ilForumModerators $frm_moderators
getUnsafeGetCommands()
This method must return a list of unsafe GET commands.
readonly ILIAS Refinery Factory $refinery
readonly ILIAS HTTP Services $http
readonly ilErrorHandling $error
addModeratorCommand(array $users=[])
handleModeratorActionsCommand()
readonly ILIAS UI Factory $ui_factory
getSafePostCommands()
This method must return a list of safe POST commands.
Class ilForumNotification.
static getInstance(int $a_obj_id=0)
static _lookupObjId(int $ref_id)
Base class for course and group participants.
isAssigned(int $a_usr_id)
check if user is assigned
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc