19 declare(strict_types=1);
48 $this->
ctrl = $DIC->ctrl();
49 $this->tpl = $DIC->ui()->mainTemplate();
50 $this->
lng = $DIC->language();
51 $this->
access = $DIC->access();
52 $this->
tabs = $DIC->tabs();
53 $this->error = $DIC[
'ilErr'];
54 $this->
user = $DIC->user();
55 $this->
toolbar = $DIC->toolbar();
57 $this->
tabs->activateTab(
'frm_moderators');
58 $this->
lng->loadLanguageModule(
'search');
59 $this->http_wrapper = $DIC->http()->wrapper();
62 if (!$this->
access->checkAccess(
'write',
'', $this->forum->getRefId())) {
63 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
71 $next_class = $this->
ctrl->getNextClass($this);
72 $cmd = $this->
ctrl->getCmd();
74 switch (strtolower($next_class)) {
75 case strtolower(ilRepositorySearchGUI::class):
77 $rep_search->setCallback($this,
'addModerator');
78 $this->
ctrl->setReturn($this,
'showModerators');
79 $this->
ctrl->forwardCommand($rep_search);
84 $cmd =
'showModerators';
97 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_moderators_select_one'));
102 $notificaton_type = $frm_properties->getNotificationType();
103 $is_membersip_enabled_parent = $this->forum->isParentMembershipEnabledContainer();
106 foreach ($users as $usr_id) {
107 $this->oForumModerators->addModeratorRole($usr_id);
110 $tmp_frm_noti->setUserIdNoti($this->
user->getId());
111 $tmp_frm_noti->setUserToggle($frm_properties->getUserToggleNoti());
112 $tmp_frm_noti->setAdminForce($frm_properties->getAdminForceNoti());
113 $tmp_frm_noti->insertAdminForce();
117 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'frm_moderator_role_added_successfully'),
true);
118 $this->
ctrl->redirect($this,
'showModerators');
123 $usr_ids = $this->http_wrapper->post()->retrieve(
126 $this->refinery->kindlyTo()->listOf($this->
refinery->kindlyTo()->int()),
131 if ($usr_ids === []) {
132 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_moderators_select_at_least_one'));
133 $this->
ctrl->redirect($this,
'showModerators');
136 $entries = $this->oForumModerators->getCurrentModerators();
137 if (count($usr_ids) === count($entries)) {
138 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_at_least_one_moderator'));
139 $this->
ctrl->redirect($this,
'showModerators');
143 $obj_id = $frm_properties->getObjId();
144 $notificaton_type = $frm_properties->getNotificationType();
145 $is_membersip_enabled_parent = $this->forum->isParentMembershipEnabledContainer();
149 $participants_result = $need_participants
150 ? new \ILIAS\Data\Result\Ok($this->forum->parentParticipants())
151 :
new \
ILIAS\Data\Result\
Error(
"Participants not required for ref_id {$this->forum->getRefId()}");
153 foreach ($usr_ids as $usr_id) {
154 $this->oForumModerators->detachModeratorRole($usr_id);
155 $participants_result->map(
function (
ilParticipants $participants) use ($tmp_frm_noti, $usr_id, $obj_id) {
157 $tmp_frm_noti->setUserId($usr_id);
158 $tmp_frm_noti->setForumId($obj_id);
159 $tmp_frm_noti->deleteAdminForce();
164 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'frm_moderators_detached_role_successfully'),
true);
165 $this->
ctrl->redirect($this,
'showModerators');
168 public function showModerators():
void 174 'auto_complete_name' => $this->
lng->txt(
'user'),
175 'submit_name' => $this->
lng->txt(
'add'),
176 'add_search' =>
true,
177 'add_from_container' => $this->oForumModerators->getRefId()
183 $entries = $this->oForumModerators->getCurrentModerators();
184 $num = count($entries);
187 foreach ($entries as $usr_id) {
191 $this->oForumModerators->detachModeratorRole($usr_id);
198 $result[$i][
'check'] =
'';
200 $result[$i][
'login'] = $user->
getLogin();
206 $tbl->setData($result);
207 $this->tpl->setContent($tbl->getHTML());
addModerator(array $users=[])
setUserId(?int $a_user_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ChatMainBarProvider .
ilForumModerators $oForumModerators
isAssigned(int $a_usr_id)
check if user is assigned
Class ilForumNotification.
static _lookupObjId(int $ref_id)
Class ilForumModeratorsTableGUI.
static getInstance(int $a_obj_id=0)
ilGlobalTemplateInterface $tpl
Class ilForumModeratorsGUI.
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...
ILIAS HTTP Wrapper WrapperFactory $http_wrapper
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
Base class for course and group participants.
Error Handling & global info handling.
ILIAS Refinery Factory $refinery