ILIAS  release_8 Revision v8.24
ilForumModeratorsGUI Class Reference

Class ilForumModeratorsGUI. More...

+ Collaboration diagram for ilForumModeratorsGUI:

Public Member Functions

 executeCommand ()
 
 addModerator ($users=[])
 
 detachModeratorRole ()
 

Private Attributes

ilCtrlInterface $ctrl
 
ilGlobalTemplateInterface $tpl
 
ilLanguage $lng
 
ilTabsGUI $tabs
 
ilErrorHandling $error
 
ilObjUser $user
 
ilToolbarGUI $toolbar
 
ilForumModerators $oForumModerators
 
int $ref_id = 0
 
ilAccessHandler $access
 
ILIAS HTTP Wrapper WrapperFactory $http_wrapper
 
ILIAS Refinery Factory $refinery
 

Detailed Description

Member Function Documentation

◆ addModerator()

ilForumModeratorsGUI::addModerator (   $users = [])

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

97 : void
98 {
99 if (!$users) {
100 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_moderators_select_one'));
101 return;
102 }
103
104 $isCrsGrp = ilForumNotification::_isParentNodeGrpCrs($this->ref_id);
105 $objFrmProps = ilForumProperties::getInstance(ilObject::_lookupObjId($this->ref_id));
106 $frm_noti_type = $objFrmProps->getNotificationType();
107
108 foreach ($users as $user_id) {
109 $this->oForumModerators->addModeratorRole((int) $user_id);
110 if ($isCrsGrp && $frm_noti_type !== 'default') {
111 $tmp_frm_noti = new ilForumNotification($this->ref_id);
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());
116
117 $tmp_frm_noti->insertAdminForce();
118 }
119 }
120
121 $this->tpl->setOnScreenMessage('success', $this->lng->txt('frm_moderator_role_added_successfully'), true);
122 $this->ctrl->redirect($this, 'showModerators');
123 }
static _isParentNodeGrpCrs(int $a_ref_id)
static getInstance(int $a_obj_id=0)
static _lookupObjId(int $ref_id)

References ilForumNotification\_isParentNodeGrpCrs(), ilObject\_lookupObjId(), ILIAS\Repository\ctrl(), ilForumProperties\getInstance(), ILIAS\Repository\lng(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ detachModeratorRole()

ilForumModeratorsGUI::detachModeratorRole ( )

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

125 : void
126 {
127 $usr_ids = [];
128 if ($this->http_wrapper->post()->has('usr_id')) {
129 $usr_ids = $this->http_wrapper->post()->retrieve(
130 'usr_id',
131 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
132 );
133 }
134
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');
138 }
139
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');
144 }
145
146 $isCrsGrp = ilForumNotification::_isParentNodeGrpCrs($this->ref_id);
147
148 $objFrmProps = ilForumProperties::getInstance(ilObject::_lookupObjId($this->ref_id));
149 $frm_noti_type = $objFrmProps->getNotificationType();
150
151 foreach ($usr_ids as $usr_id) {
152 $this->oForumModerators->detachModeratorRole((int) $usr_id);
153
154 if ($isCrsGrp && $frm_noti_type !== 'default' && !ilParticipants::_isParticipant($this->ref_id, $usr_id)) {
155 $tmp_frm_noti = new ilForumNotification($this->ref_id);
156 $tmp_frm_noti->setUserId((int) $usr_id);
157 $tmp_frm_noti->setForumId(ilObject::_lookupObjId($this->ref_id));
158
159 $tmp_frm_noti->deleteAdminForce();
160 }
161 }
162
163 $this->tpl->setOnScreenMessage('success', $this->lng->txt('frm_moderators_detached_role_successfully'), true);
164 $this->ctrl->redirect($this, 'showModerators');
165 }
static _isParticipant(int $a_ref_id, int $a_usr_id)
Static function to check if a user is a participant of the container object.

References ilForumNotification\_isParentNodeGrpCrs(), ilParticipants\_isParticipant(), ilObject\_lookupObjId(), ILIAS\Repository\ctrl(), ilForumProperties\getInstance(), ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ executeCommand()

ilForumModeratorsGUI::executeCommand ( )

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

75 : void
76 {
77 $next_class = $this->ctrl->getNextClass($this);
78 $cmd = $this->ctrl->getCmd();
79
80 switch (strtolower($next_class)) {
81 case strtolower(ilRepositorySearchGUI::class):
82 $rep_search = new ilRepositorySearchGUI();
83 $rep_search->setCallback($this, 'addModerator');
84 $this->ctrl->setReturn($this, 'showModerators');
85 $this->ctrl->forwardCommand($rep_search);
86 break;
87
88 default:
89 if (!$cmd) {
90 $cmd = 'showModerators';
91 }
92 $this->$cmd();
93 break;
94 }
95 }
setCallback(object $class, string $method, array $a_add_options=[], string $default_option='')

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilForumModeratorsGUI::$access
private

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

◆ $ctrl

ilCtrlInterface ilForumModeratorsGUI::$ctrl
private

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

◆ $error

ilErrorHandling ilForumModeratorsGUI::$error
private

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

◆ $http_wrapper

ILIAS HTTP Wrapper WrapperFactory ilForumModeratorsGUI::$http_wrapper
private

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

◆ $lng

ilLanguage ilForumModeratorsGUI::$lng
private

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

◆ $oForumModerators

ilForumModerators ilForumModeratorsGUI::$oForumModerators
private

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

◆ $ref_id

int ilForumModeratorsGUI::$ref_id = 0
private

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

◆ $refinery

ILIAS Refinery Factory ilForumModeratorsGUI::$refinery
private

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

◆ $tabs

ilTabsGUI ilForumModeratorsGUI::$tabs
private

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

◆ $toolbar

ilToolbarGUI ilForumModeratorsGUI::$toolbar
private

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

◆ $tpl

ilGlobalTemplateInterface ilForumModeratorsGUI::$tpl
private

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

◆ $user

ilObjUser ilForumModeratorsGUI::$user
private

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


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