19 declare(strict_types=1);
42 private readonly \ILIAS\HTTP\Services
$http;
51 $this->
ctrl = $DIC->ctrl();
52 $this->tpl = $DIC->ui()->mainTemplate();
53 $this->
lng = $DIC->language();
54 $this->
access = $DIC->access();
55 $this->
tabs = $DIC->tabs();
56 $this->error = $DIC[
'ilErr'];
57 $this->
user = $DIC->user();
58 $this->
toolbar = $DIC->toolbar();
60 $this->
tabs->activateTab(
'frm_moderators');
61 $this->
lng->loadLanguageModule(
'search');
62 $this->http_wrapper = $DIC->http()->wrapper();
63 $this->
http = $DIC->http();
65 $this->ui_renderer = $DIC->ui()->renderer();
66 $this->ui_factory = $DIC->ui()->factory();
68 if (!$this->
access->checkAccess(
'write',
'', $this->forum->getRefId())) {
69 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
77 $next_class = $this->
ctrl->getNextClass($this) ??
'';
78 $cmd = $this->
ctrl->getCmd() ??
'';
80 switch (strtolower($next_class)) {
81 case strtolower(ilRepositorySearchGUI::class):
83 $rep_search->setCallback($this,
'addModerator');
84 $this->
ctrl->setReturn($this,
'showModerators');
85 $this->
ctrl->forwardCommand($rep_search);
90 $cmd =
'showModerators';
103 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_moderators_select_one'));
108 $notificaton_type = $frm_properties->getNotificationType();
109 $is_membersip_enabled_parent = $this->forum->isParentMembershipEnabledContainer();
112 foreach ($users as $usr_id) {
113 $this->oForumModerators->addModeratorRole($usr_id);
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();
123 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'frm_moderator_role_added_successfully'),
true);
124 $this->
ctrl->redirect($this,
'showModerators');
129 $usr_ids = $this->http_wrapper->post()->retrieve(
130 'frm_moderators_table_usr_ids',
132 $this->refinery->kindlyTo()->listOf($this->
refinery->kindlyTo()->int()),
137 if ($usr_ids === []) {
138 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_moderators_select_at_least_one'));
139 $this->
ctrl->redirect($this,
'showModerators');
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');
149 $obj_id = $frm_properties->getObjId();
150 $notificaton_type = $frm_properties->getNotificationType();
151 $is_membersip_enabled_parent = $this->forum->isParentMembershipEnabledContainer();
155 $participants_result = $need_participants
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) {
163 $tmp_frm_noti->setUserId($usr_id);
164 $tmp_frm_noti->setForumId($obj_id);
165 $tmp_frm_noti->deleteAdminForce();
170 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'frm_moderators_detached_role_successfully'),
true);
171 $this->
ctrl->redirect($this,
'showModerators');
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()
187 $tbl = new \ILIAS\Forum\Moderation\ForumModeratorsTable(
188 $this->oForumModerators,
195 $this->tpl->setContent($this->ui_renderer->render($tbl->getComponent()));
200 $action = $this->http_wrapper->query()->retrieve(
201 'frm_moderators_table_action',
203 $this->refinery->kindlyTo()->string(),
209 default => $this->
ctrl->redirect($this,
'showModerators'),
216 'handleModeratorActions',
readonly ilGlobalTemplateInterface $tpl
readonly ILIAS Refinery Factory $refinery
addModerator(array $users=[])
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS UI Renderer $ui_renderer
static getInstance(int $a_ref_id)
readonly ilToolbarGUI $toolbar
readonly ILIAS HTTP Wrapper WrapperFactory $http_wrapper
readonly ilErrorHandling $error
isAssigned(int $a_usr_id)
check if user is assigned
readonly ilCtrlInterface $ctrl
static _lookupObjId(int $ref_id)
readonly ilAccessHandler $access
static getInstance(int $a_obj_id=0)
readonly ILIAS HTTP Services $http
readonly ilForumModerators $oForumModerators
static http()
Fetches the global http state from ILIAS.
getUnsafeGetCommands()
This method must return a list of unsafe GET commands.
getSafePostCommands()
This method must return a list of safe POST commands.
readonly ILIAS UI Factory $ui_factory
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...
__construct(Container $dic, ilPlugin $plugin)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...