19 declare(strict_types=1);
47 $this->
ctrl = $DIC->ctrl();
48 $this->tpl = $DIC->ui()->mainTemplate();
49 $this->
lng = $DIC->language();
50 $this->
access = $DIC->access();
51 $this->
tabs = $DIC->tabs();
52 $this->error = $DIC[
'ilErr'];
53 $this->
user = $DIC->user();
54 $this->
toolbar = $DIC->toolbar();
56 $this->
tabs->activateTab(
'frm_moderators');
57 $this->
lng->loadLanguageModule(
'search');
58 $this->http_wrapper = $DIC->http()->wrapper();
61 if ($this->http_wrapper->query()->has(
'ref_id')) {
62 $this->ref_id = $this->http_wrapper->query()->retrieve(
68 if (!$this->
access->checkAccess(
'write',
'', (
int) $this->ref_id)) {
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';
100 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_moderators_select_one'));
106 $frm_noti_type = $objFrmProps->getNotificationType();
108 foreach ($users as $user_id) {
109 $this->oForumModerators->addModeratorRole((
int) $user_id);
110 if ($isCrsGrp && $frm_noti_type !==
'default') {
112 $tmp_frm_noti->setUserId((
int) $user_id);
113 $tmp_frm_noti->setUserIdNoti($this->
user->getId());
114 $tmp_frm_noti->setUserToggle($objFrmProps->getUserToggleNoti());
115 $tmp_frm_noti->setAdminForce($objFrmProps->getAdminForceNoti());
117 $tmp_frm_noti->insertAdminForce();
121 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'frm_moderator_role_added_successfully'),
true);
122 $this->
ctrl->redirect($this,
'showModerators');
128 if ($this->http_wrapper->post()->has(
'usr_id')) {
129 $usr_ids = $this->http_wrapper->post()->retrieve(
135 if (!isset($usr_ids) || !is_array($usr_ids)) {
136 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_moderators_select_at_least_one'));
137 $this->
ctrl->redirect($this,
'showModerators');
140 $entries = $this->oForumModerators->getCurrentModerators();
141 if (count($usr_ids) === count($entries)) {
142 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_at_least_one_moderator'));
143 $this->
ctrl->redirect($this,
'showModerators');
149 $frm_noti_type = $objFrmProps->getNotificationType();
151 foreach ($usr_ids as $usr_id) {
152 $this->oForumModerators->detachModeratorRole((
int) $usr_id);
156 $tmp_frm_noti->setUserId((
int) $usr_id);
159 $tmp_frm_noti->deleteAdminForce();
163 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'frm_moderators_detached_role_successfully'),
true);
164 $this->
ctrl->redirect($this,
'showModerators');
167 public function showModerators():
void 173 'auto_complete_name' => $this->
lng->txt(
'user'),
174 'submit_name' => $this->
lng->txt(
'add'),
175 'add_search' =>
true,
176 'add_from_container' => $this->oForumModerators->getRefId()
179 if ($this->http_wrapper->query()->has(
'ref_id')) {
180 $this->ref_id = $this->http_wrapper->query()->retrieve(
187 $entries = $this->oForumModerators->getCurrentModerators();
188 $num = count($entries);
191 foreach ($entries as $usr_id) {
195 $this->oForumModerators->detachModeratorRole($usr_id);
202 $result[
$i][
'check'] =
'';
210 $tbl->setData($result);
211 $this->tpl->setContent($tbl->getHTML());
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilForumModerators $oForumModerators
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...
static _isParentNodeGrpCrs(int $a_ref_id)
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
Error Handling & global info handling uses PEAR error class.
__construct(Container $dic, ilPlugin $plugin)
static _isParticipant(int $a_ref_id, int $a_usr_id)
Static function to check if a user is a participant of the container object.
ILIAS Refinery Factory $refinery