ILIAS  release_8 Revision v8.24
ilOrgUnitUserAssignmentGUI Class Reference

Class ilOrgUnitUserAssignmentGUI. More...

+ Inheritance diagram for ilOrgUnitUserAssignmentGUI:
+ Collaboration diagram for ilOrgUnitUserAssignmentGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 
 addStaff ()
 
 addStaffFromSearch (array $user_ids, ?string $user_type=null)
 
 addSubTabs ()
 
- Public Member Functions inherited from ILIAS\Modules\OrgUnit\ARHelper\BaseCommands
 getParentGui ()
 
 setParentGui (BaseCommands $parent_gui)
 
 executeCommand ()
 
 addSubTabs ()
 

Data Fields

const CMD_ASSIGNMENTS_RECURSIVE = 'assignmentsRecursive'
 
const SUBTAB_ASSIGNMENTS = 'user_assignments'
 
const SUBTAB_ASSIGNMENTS_RECURSIVE = 'user_assignments_recursive'
 
- Data Fields inherited from ILIAS\Modules\OrgUnit\ARHelper\BaseCommands
const CMD_INDEX = "index"
 
const CMD_ADD = "add"
 
const CMD_CREATE = "create"
 
const CMD_EDIT = "edit"
 
const CMD_UPDATE = "update"
 
const CMD_CONFIRM = "confirm"
 
const CMD_CONFIRM_RECURSIVE = "confirmRecursive"
 
const CMD_DELETE = "delete"
 
const CMD_DELETE_RECURSIVE = "deleteRecursive"
 
const CMD_CANCEL = "cancel"
 
const AR_ID = "arid"
 

Protected Member Functions

 index ()
 
 assignmentsRecursive ()
 
 confirm ()
 
 confirmRecursive ()
 
 getConfirmationGUI ()
 
 delete ()
 
 deleteRecursive ()
 
 cancel ()
 
- Protected Member Functions inherited from ILIAS\Modules\OrgUnit\ARHelper\BaseCommands
 __construct ()
 
 index ()
 
 getPossibleNextClasses ()
 
 getActiveTabId ()
 
 cancel ()
 
 setContent (string $html)
 
 pushSubTab (string $subtab_id, string $url)
 
 activeSubTab (string $subtab_id)
 
 getParentRefId ()
 

Private Attributes

ilGlobalTemplateInterface $main_tpl
 
Services $http
 
ilCtrl $ctrl
 
ilToolbarGUI $toolbar
 
ilAccessHandler $access
 
ilLanguage $language
 

Additional Inherited Members

- Protected Attributes inherited from ILIAS\Modules\OrgUnit\ARHelper\BaseCommands
BaseCommands $parent_gui = null
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilOrgUnitUserAssignmentGUI::__construct ( )

Reimplemented from ILIAS\Modules\OrgUnit\ARHelper\BaseCommands.

Definition at line 42 of file class.ilOrgUnitUserAssignmentGUI.php.

43 {
44 global $DIC;
45
47
48 $this->main_tpl = $DIC->ui()->mainTemplate();
49 $this->http = $DIC->http();
50 $this->ctrl = $DIC->ctrl();
51 $this->toolbar = $DIC->toolbar();
52 $this->access = $DIC->access();
53 $this->language = $DIC->language();
54 }
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), and ILIAS\Repository\toolbar().

+ Here is the call graph for this function:

Member Function Documentation

◆ addStaff()

ilOrgUnitUserAssignmentGUI::addStaff ( )

Definition at line 207 of file class.ilOrgUnitUserAssignmentGUI.php.

207 : void
208 {
209 if (!$this->access->checkAccess("write", "", $this->getParentRefId())) {
210 $this->main_tpl->setOnScreenMessage('failure', $this->language->txt("permission_denied"), true);
211 $this->ctrl->redirect($this, self::CMD_INDEX);
212 }
213
214 $users = explode(',', $_POST['user_login']);
215 $user_ids = array();
216 foreach ($users as $user) {
217 $user_id = ilObjUser::_lookupId($user);
218 if ($user_id) {
219 $user_ids[] = $user_id;
220 }
221 }
222
223 if (!count($user_ids)) {
224 $this->main_tpl->setOnScreenMessage('failure', $this->language->txt("user_not_found"), true);
225 $this->ctrl->redirect($this, self::CMD_INDEX);
226 }
227
228 $position_id = (int) ($_POST['user_type'] ?? ilOrgUnitPosition::CORE_POSITION_EMPLOYEE);
229
230 if (!$position_id && !$position = ilOrgUnitPosition::find($position_id)) {
231 $this->main_tpl->setOnScreenMessage('failure', $this->language->txt("user_not_found"), true);
232 $this->ctrl->redirect($this, self::CMD_INDEX);
233 }
234 foreach ($user_ids as $user_id) {
235 ilOrgUnitUserAssignment::findOrCreateAssignment($user_id, $position_id, $this->getParentRefId());
236 }
237
238 $this->main_tpl->setOnScreenMessage('success', $this->language->txt("users_successfuly_added"), true);
239 $this->ctrl->redirect($this, self::CMD_INDEX);
240 }
static _lookupId($a_user_str)
static findOrCreateAssignment(int $user_id, int $position_id, int $orgu_id)

References ilObjUser\_lookupId(), ILIAS\Repository\access(), ilOrgUnitPosition\CORE_POSITION_EMPLOYEE, ILIAS\Repository\ctrl(), ilOrgUnitUserAssignment\findOrCreateAssignment(), ILIAS\Modules\OrgUnit\ARHelper\BaseCommands\getParentRefId(), ILIAS\Repository\int(), and ILIAS\UI\examples\Symbol\Glyph\Language\language().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addStaffFromSearch()

ilOrgUnitUserAssignmentGUI::addStaffFromSearch ( array  $user_ids,
?string  $user_type = null 
)
Parameters
array<int>$user_ids

Definition at line 245 of file class.ilOrgUnitUserAssignmentGUI.php.

245 : void
246 {
247 if (!$this->access->checkAccess("write", "", $this->getParentRefId())) {
248 $this->main_tpl->setOnScreenMessage('failure', $this->language->txt("permission_denied"), true);
249 $this->ctrl->redirect($this, self::CMD_INDEX);
250 }
251
252 if (!count($user_ids)) {
253 $this->main_tpl->setOnScreenMessage('failure', $this->language->txt("user_not_found"), true);
254 $this->ctrl->redirect($this, self::CMD_INDEX);
255 }
256
257 $position_id = (int) ($user_type ?? ilOrgUnitPosition::CORE_POSITION_EMPLOYEE);
258
259 if (!$position_id && !$position = ilOrgUnitPosition::find($position_id)) {
260 $this->main_tpl->setOnScreenMessage('failure', $this->language->txt("user_not_found"), true);
261 $this->ctrl->redirect($this, self::CMD_INDEX);
262 }
263 foreach ($user_ids as $user_id) {
264 ilOrgUnitUserAssignment::findOrCreateAssignment($user_id, $position_id, $this->getParentRefId());
265 }
266
267 $this->main_tpl->setOnScreenMessage('success', $this->language->txt("users_successfuly_added"), true);
268 $this->ctrl->redirect($this, self::CMD_INDEX);
269 }

References ILIAS\Repository\access(), ilOrgUnitPosition\CORE_POSITION_EMPLOYEE, ILIAS\Repository\ctrl(), ilOrgUnitUserAssignment\findOrCreateAssignment(), ILIAS\Modules\OrgUnit\ARHelper\BaseCommands\getParentRefId(), ILIAS\Repository\int(), and ILIAS\UI\examples\Symbol\Glyph\Language\language().

+ Here is the call graph for this function:

◆ addSubTabs()

ilOrgUnitUserAssignmentGUI::addSubTabs ( )

Reimplemented from ILIAS\Modules\OrgUnit\ARHelper\BaseCommands.

Definition at line 271 of file class.ilOrgUnitUserAssignmentGUI.php.

271 : void
272 {
273 $this->pushSubTab(self::SUBTAB_ASSIGNMENTS, $this->ctrl
274 ->getLinkTarget($this, self::CMD_INDEX));
275 $this->pushSubTab(self::SUBTAB_ASSIGNMENTS_RECURSIVE, $this->ctrl
276 ->getLinkTarget(
277 $this,
278 self::CMD_ASSIGNMENTS_RECURSIVE
279 ));
280 }
pushSubTab(string $subtab_id, string $url)

References ILIAS\Repository\ctrl(), and ILIAS\Modules\OrgUnit\ARHelper\BaseCommands\pushSubTab().

Referenced by assignmentsRecursive(), and index().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ assignmentsRecursive()

ilOrgUnitUserAssignmentGUI::assignmentsRecursive ( )
protected

Definition at line 118 of file class.ilOrgUnitUserAssignmentGUI.php.

118 : void
119 {
120 $this->addSubTabs();
121 $this->activeSubTab(self::SUBTAB_ASSIGNMENTS_RECURSIVE);
122 // Tables
123 $html = '';
124 foreach (ilOrgUnitPosition::getActiveForPosition($this->getParentRefId()) as $ilOrgUnitPosition) {
125 $ilOrgUnitRecursiveUserAssignmentTableGUI =
127 $this,
128 self::CMD_ASSIGNMENTS_RECURSIVE,
129 $ilOrgUnitPosition
130 );
131 $html .= $ilOrgUnitRecursiveUserAssignmentTableGUI->getHTML();
132 }
133 $this->setContent($html);
134 }
static getActiveForPosition(int $orgu_ref_id)

References ILIAS\Modules\OrgUnit\ARHelper\BaseCommands\activeSubTab(), addSubTabs(), ilOrgUnitPosition\getActiveForPosition(), ILIAS\Modules\OrgUnit\ARHelper\BaseCommands\getParentRefId(), and ILIAS\Modules\OrgUnit\ARHelper\BaseCommands\setContent().

+ Here is the call graph for this function:

◆ cancel()

ilOrgUnitUserAssignmentGUI::cancel ( )
protected
Exceptions

ilCtrlException

Reimplemented from ILIAS\Modules\OrgUnit\ARHelper\BaseCommands.

Definition at line 202 of file class.ilOrgUnitUserAssignmentGUI.php.

202 : void
203 {
204 $this->ctrl->redirect($this, self::CMD_INDEX);
205 }

References ILIAS\Repository\ctrl().

Referenced by delete(), and deleteRecursive().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirm()

ilOrgUnitUserAssignmentGUI::confirm ( )
protected

Definition at line 136 of file class.ilOrgUnitUserAssignmentGUI.php.

136 : void
137 {
138 $confirmation = $this->getConfirmationGUI();
139 $confirmation->setConfirm($this->language->txt('remove_user'), self::CMD_DELETE);
140
141 $this->setContent($confirmation->getHTML());
142 }

References getConfirmationGUI(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), and ILIAS\Modules\OrgUnit\ARHelper\BaseCommands\setContent().

+ Here is the call graph for this function:

◆ confirmRecursive()

ilOrgUnitUserAssignmentGUI::confirmRecursive ( )
protected

Definition at line 144 of file class.ilOrgUnitUserAssignmentGUI.php.

144 : void
145 {
146 $confirmation = $this->getConfirmationGUI();
147 $confirmation->setConfirm($this->language->txt('remove_user'), self::CMD_DELETE_RECURSIVE);
148
149 $this->setContent($confirmation->getHTML());
150 }

References getConfirmationGUI(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), and ILIAS\Modules\OrgUnit\ARHelper\BaseCommands\setContent().

+ Here is the call graph for this function:

◆ delete()

ilOrgUnitUserAssignmentGUI::delete ( )
protected

Definition at line 172 of file class.ilOrgUnitUserAssignmentGUI.php.

172 : void
173 {
174 $params = $this->http->request()->getQueryParams();
175 $usr_id = $_POST['usr_id'];
176 $position_id = $params['position_id'];
177
178 $ua = ilOrgUnitUserAssignmentQueries::getInstance()->getAssignmentOrFail(
179 $usr_id,
180 $position_id,
181 $this->getParentRefId()
182 );
183 $ua->delete();
184 $this->main_tpl->setOnScreenMessage('success', $this->language->txt('remove_successful'), true);
185 $this->cancel();
186 }
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:33

References $params, cancel(), ilOrgUnitUserAssignmentQueries\getInstance(), ILIAS\Modules\OrgUnit\ARHelper\BaseCommands\getParentRefId(), ILIAS\FileDelivery\http(), and ILIAS\UI\examples\Symbol\Glyph\Language\language().

+ Here is the call graph for this function:

◆ deleteRecursive()

ilOrgUnitUserAssignmentGUI::deleteRecursive ( )
protected

Definition at line 188 of file class.ilOrgUnitUserAssignmentGUI.php.

189 {
190 $r = $this->http->request();
192 ->getAssignmentsOfUserIdAndPosition((int) $_POST['usr_id'], (int) $r->getQueryParams()['position_id'])
193 ;
194
195 foreach ($assignments as $assignment) {
196 $assignment->delete();
197 }
198 $this->main_tpl->setOnScreenMessage('success', $this->language->txt('remove_successful'), true);
199 $this->cancel();
200 }

References cancel(), ilOrgUnitUserAssignmentQueries\getInstance(), ILIAS\FileDelivery\http(), and ILIAS\UI\examples\Symbol\Glyph\Language\language().

+ Here is the call graph for this function:

◆ executeCommand()

ilOrgUnitUserAssignmentGUI::executeCommand ( )
Exceptions

ilCtrlException

Reimplemented from ILIAS\Modules\OrgUnit\ARHelper\BaseCommands.

Definition at line 56 of file class.ilOrgUnitUserAssignmentGUI.php.

56 : void
57 {
58 if (!ilObjOrgUnitAccess::_checkAccessPositions((int) filter_input(
59 INPUT_GET,
60 "ref_id",
61 FILTER_SANITIZE_NUMBER_INT
62 ))) {
63 $this->main_tpl->setOnScreenMessage('failure', $this->language->txt("permission_denied"), true);
64 $this->ctrl->redirectByClass(ilObjOrgUnitGUI::class);
65 }
66
67 $r = $this->http->request();
68 switch ($this->ctrl->getNextClass()) {
69 case strtolower(ilRepositorySearchGUI::class):
70 switch ($this->ctrl->getCmd()) {
71 case 'addUserFromAutoComplete':
72 if ($r->getQueryParams()['addusertype'] == "staff") {
73 $this->addStaff();
74 }
75 break;
76 default:
77 $repo = new ilRepositorySearchGUI();
78 $repo->setCallback($this, 'addStaffFromSearch');
79 $this->ctrl->forwardCommand($repo);
80 break;
81 }
82 break;
83
84 default:
85 parent::executeCommand();
86 break;
87 }
88 }
static _checkAccessPositions(int $ref_id)

References ilObjOrgUnitAccess\_checkAccessPositions(), addStaff(), ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), and ILIAS\UI\examples\Symbol\Glyph\Language\language().

+ Here is the call graph for this function:

◆ getConfirmationGUI()

ilOrgUnitUserAssignmentGUI::getConfirmationGUI ( )
protected

Definition at line 152 of file class.ilOrgUnitUserAssignmentGUI.php.

153 {
154 $this->ctrl->saveParameter($this, 'position_id');
155 $confirmation = new ilConfirmationGUI();
156 $confirmation->setFormAction($this->ctrl->getFormAction($this));
157 $confirmation->setCancel($this->language->txt(self::CMD_CANCEL), self::CMD_CANCEL);
158
159 $params = $this->http->request()->getQueryParams();
160 $usr_id = $params['usr_id'];
161 $position_id = $params['position_id'];
162
163 $types = ilOrgUnitPosition::getArray('id', 'title');
164 $position_title = $types[$position_id];
165
166 $confirmation->setHeaderText(sprintf($this->language->txt('msg_confirm_remove_user'), $position_title));
167 $confirmation->addItem('usr_id', $usr_id, ilObjUser::_lookupLogin($usr_id));
168
169 return $confirmation;
170 }
static getArray(?string $key=null, $values=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupLogin(int $a_user_id)

References $params, ilObjUser\_lookupLogin(), ILIAS\Repository\ctrl(), ActiveRecord\getArray(), ILIAS\FileDelivery\http(), and ILIAS\UI\examples\Symbol\Glyph\Language\language().

Referenced by confirm(), and confirmRecursive().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ index()

ilOrgUnitUserAssignmentGUI::index ( )
protected

Reimplemented from ILIAS\Modules\OrgUnit\ARHelper\BaseCommands.

Definition at line 90 of file class.ilOrgUnitUserAssignmentGUI.php.

90 : void
91 {
92 $this->addSubTabs();
93 $this->activeSubTab(self::SUBTAB_ASSIGNMENTS);
94
95 // Header
96 $types = ilOrgUnitPosition::getArray('id', 'title');
97 //$types = array();
98 $this->ctrl->setParameterByClass(ilRepositorySearchGUI::class, 'addusertype', 'staff');
100 'auto_complete_name' => $this->language->txt('user'),
101 'user_type' => $types,
102 'submit_name' => $this->language->txt('add'),
103 ));
104
105 // Tables
106 $html = '';
107 foreach (ilOrgUnitPosition::getActiveForPosition($this->getParentRefId()) as $ilOrgUnitPosition) {
108 $ilOrgUnitUserAssignmentTableGUI = new ilOrgUnitUserAssignmentTableGUI(
109 $this,
110 self::CMD_INDEX,
111 $ilOrgUnitPosition
112 );
113 $html .= $ilOrgUnitUserAssignmentTableGUI->getHTML();
114 }
115 $this->setContent($html);
116 }
Class ilOrgUnitUserAssignmentTableGUI.
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...

References ILIAS\Modules\OrgUnit\ARHelper\BaseCommands\activeSubTab(), addSubTabs(), ILIAS\Repository\ctrl(), ilRepositorySearchGUI\fillAutoCompleteToolbar(), ilOrgUnitPosition\getActiveForPosition(), ActiveRecord\getArray(), ILIAS\Modules\OrgUnit\ARHelper\BaseCommands\getParentRefId(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), ILIAS\Modules\OrgUnit\ARHelper\BaseCommands\setContent(), and ILIAS\Repository\toolbar().

+ Here is the call graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilOrgUnitUserAssignmentGUI::$access
private

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

◆ $ctrl

ilCtrl ilOrgUnitUserAssignmentGUI::$ctrl
private

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

◆ $http

Services ilOrgUnitUserAssignmentGUI::$http
private

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

◆ $language

ilLanguage ilOrgUnitUserAssignmentGUI::$language
private

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

◆ $main_tpl

ilGlobalTemplateInterface ilOrgUnitUserAssignmentGUI::$main_tpl
private

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

◆ $toolbar

ilToolbarGUI ilOrgUnitUserAssignmentGUI::$toolbar
private

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

◆ CMD_ASSIGNMENTS_RECURSIVE

const ilOrgUnitUserAssignmentGUI::CMD_ASSIGNMENTS_RECURSIVE = 'assignmentsRecursive'

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

◆ SUBTAB_ASSIGNMENTS

const ilOrgUnitUserAssignmentGUI::SUBTAB_ASSIGNMENTS = 'user_assignments'

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

◆ SUBTAB_ASSIGNMENTS_RECURSIVE

const ilOrgUnitUserAssignmentGUI::SUBTAB_ASSIGNMENTS_RECURSIVE = 'user_assignments_recursive'

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


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