ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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
 
ilOrgUnitPositionDBRepository $positionRepo
 
ilOrgUnitUserAssignmentDBRepository $assignmentRepo
 

Additional Inherited Members

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

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilOrgUnitUserAssignmentGUI::__construct ( )

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

References $DIC, $dic, ILIAS\MetaData\Repository\Validation\Data\__construct(), ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ilOrgUnitLocalDIC\dic(), ILIAS\FileDelivery\http(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), and ILIAS\Repository\toolbar().

46  {
47  global $DIC;
48 
50 
51  $this->main_tpl = $DIC->ui()->mainTemplate();
52  $this->http = $DIC->http();
53  $this->ctrl = $DIC->ctrl();
54  $this->toolbar = $DIC->toolbar();
55  $this->access = $DIC->access();
56  $this->language = $DIC->language();
57 
59  $this->positionRepo = $dic["repo.Positions"];
60  $this->assignmentRepo = $dic["repo.UserAssignments"];
61  }
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.
__construct(VocabulariesInterface $vocabularies)
$dic
Definition: result.php:32
+ Here is the call graph for this function:

Member Function Documentation

◆ addStaff()

ilOrgUnitUserAssignmentGUI::addStaff ( )

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

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

Referenced by executeCommand().

222  : void
223  {
224  if (!$this->access->checkAccess("write", "", $this->getParentRefId())) {
225  $this->main_tpl->setOnScreenMessage('failure', $this->language->txt("permission_denied"), true);
226  $this->ctrl->redirect($this, self::CMD_INDEX);
227  }
228 
229  $users = explode(',', $_POST['user_login']);
230  $user_ids = array();
231  foreach ($users as $user) {
232  $user_id = ilObjUser::_lookupId($user);
233  if ($user_id) {
234  $user_ids[] = $user_id;
235  }
236  }
237 
238  if (!count($user_ids)) {
239  $this->main_tpl->setOnScreenMessage('failure', $this->language->txt("user_not_found"), true);
240  $this->ctrl->redirect($this, self::CMD_INDEX);
241  }
242 
243  $position_id = (int) ($_POST['user_type'] ?? ilOrgUnitPosition::CORE_POSITION_EMPLOYEE);
244 
245  if ($position_id === 0 || !$this->positionRepo->getSingle($position_id, 'id')) {
246  $this->main_tpl->setOnScreenMessage('failure', $this->language->txt("user_not_found"), true);
247  $this->ctrl->redirect($this, self::CMD_INDEX);
248  }
249  foreach ($user_ids as $user_id) {
250  $assignment = $this->assignmentRepo->get($user_id, $position_id, $this->getParentRefId());
251  }
252 
253  $this->main_tpl->setOnScreenMessage('success', $this->language->txt("users_successfuly_added"), true);
254  $this->ctrl->redirect($this, self::CMD_INDEX);
255  }
static _lookupId($a_user_str)
+ 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 260 of file class.ilOrgUnitUserAssignmentGUI.php.

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

260  : void
261  {
262  if (!$this->access->checkAccess("write", "", $this->getParentRefId())) {
263  $this->main_tpl->setOnScreenMessage('failure', $this->language->txt("permission_denied"), true);
264  $this->ctrl->redirect($this, self::CMD_INDEX);
265  }
266 
267  if (!count($user_ids)) {
268  $this->main_tpl->setOnScreenMessage('failure', $this->language->txt("user_not_found"), true);
269  $this->ctrl->redirect($this, self::CMD_INDEX);
270  }
271 
272  $position_id = (int) ($user_type ?? ilOrgUnitPosition::CORE_POSITION_EMPLOYEE);
273 
274  if ($position_id === 0 || !$this->positionRepo->getSingle($position_id, 'id')) {
275  $this->main_tpl->setOnScreenMessage('failure', $this->language->txt("user_not_found"), true);
276  $this->ctrl->redirect($this, self::CMD_INDEX);
277  }
278  foreach ($user_ids as $user_id) {
279  $assignment = $this->assignmentRepo->get($user_id, $position_id, $this->getParentRefId());
280  }
281 
282  $this->main_tpl->setOnScreenMessage('success', $this->language->txt("users_successfuly_added"), true);
283  $this->ctrl->redirect($this, self::CMD_INDEX);
284  }
+ Here is the call graph for this function:

◆ addSubTabs()

ilOrgUnitUserAssignmentGUI::addSubTabs ( )

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

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

Referenced by assignmentsRecursive(), and index().

286  : void
287  {
288  $this->pushSubTab(self::SUBTAB_ASSIGNMENTS, $this->ctrl
289  ->getLinkTarget($this, self::CMD_INDEX));
290  $this->pushSubTab(self::SUBTAB_ASSIGNMENTS_RECURSIVE, $this->ctrl
291  ->getLinkTarget(
292  $this,
293  self::CMD_ASSIGNMENTS_RECURSIVE
294  ));
295  }
pushSubTab(string $subtab_id, string $url)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ assignmentsRecursive()

ilOrgUnitUserAssignmentGUI::assignmentsRecursive ( )
protected

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

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

129  : void
130  {
131  $this->addSubTabs();
132  $this->activeSubTab(self::SUBTAB_ASSIGNMENTS_RECURSIVE);
133  // Tables
134  $html = '';
135  foreach ($this->positionRepo->getPositionsForOrgUnit($this->getParentRefId()) as $ilOrgUnitPosition) {
136  $ilOrgUnitRecursiveUserAssignmentTableGUI =
138  $this,
139  self::CMD_ASSIGNMENTS_RECURSIVE,
140  $ilOrgUnitPosition
141  );
142  $html .= $ilOrgUnitRecursiveUserAssignmentTableGUI->getHTML();
143  }
144  $this->setContent($html);
145  }
+ Here is the call graph for this function:

◆ cancel()

ilOrgUnitUserAssignmentGUI::cancel ( )
protected

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

References ILIAS\Repository\ctrl().

Referenced by delete(), and deleteRecursive().

217  : void
218  {
219  $this->ctrl->redirect($this, self::CMD_INDEX);
220  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirm()

ilOrgUnitUserAssignmentGUI::confirm ( )
protected

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

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

147  : void
148  {
149  $confirmation = $this->getConfirmationGUI();
150  $confirmation->setConfirm($this->language->txt('remove_user'), self::CMD_DELETE);
151 
152  $this->setContent($confirmation->getHTML());
153  }
+ Here is the call graph for this function:

◆ confirmRecursive()

ilOrgUnitUserAssignmentGUI::confirmRecursive ( )
protected

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

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

155  : void
156  {
157  $confirmation = $this->getConfirmationGUI();
158  $confirmation->setConfirm($this->language->txt('remove_user'), self::CMD_DELETE_RECURSIVE);
159 
160  $this->setContent($confirmation->getHTML());
161  }
+ Here is the call graph for this function:

◆ delete()

ilOrgUnitUserAssignmentGUI::delete ( )
protected

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

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

183  : void
184  {
185  $params = $this->http->request()->getQueryParams();
186  $usr_id = (int) $_POST['usr_id'];
187  $position_id = (int) $params['position_id'];
188 
189  $assignment = $this->assignmentRepo->find(
190  $usr_id,
191  $position_id,
192  $this->getParentRefId()
193  );
194  if (!$assignment) {
195  $this->main_tpl->setOnScreenMessage('failure', $this->language->txt("user_not_found_to_delete"), true);
196  $this->ctrl->redirect($this, self::CMD_INDEX);
197  }
198  $this->assignmentRepo->delete($assignment);
199 
200  $this->main_tpl->setOnScreenMessage('success', $this->language->txt('remove_successful'), true);
201  $this->cancel();
202  }
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:33
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:

◆ deleteRecursive()

ilOrgUnitUserAssignmentGUI::deleteRecursive ( )
protected

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

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

204  : void
205  {
206  $r = $this->http->request();
207  $assignments = $this->assignmentRepo
208  ->getByUserAndPosition((int) $_POST['usr_id'], (int) $r->getQueryParams()['position_id']);
209 
210  foreach ($assignments as $assignment) {
211  $this->assignmentRepo->delete($assignment);
212  }
213  $this->main_tpl->setOnScreenMessage('success', $this->language->txt('remove_successful'), true);
214  $this->cancel();
215  }
static http()
Fetches the global http state from ILIAS.
$r
+ Here is the call graph for this function:

◆ executeCommand()

ilOrgUnitUserAssignmentGUI::executeCommand ( )

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

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

63  : void
64  {
65  if (
67  (int) filter_input(INPUT_GET, "ref_id", FILTER_SANITIZE_NUMBER_INT)
68  )
69  &&
71  (int) filter_input(INPUT_GET, "ref_id", FILTER_SANITIZE_NUMBER_INT)
72  )
73  ) {
74  $this->main_tpl->setOnScreenMessage('failure', $this->language->txt("permission_denied"), true);
75  $this->ctrl->redirectByClass(ilObjOrgUnitGUI::class);
76  }
77 
78  $r = $this->http->request();
79  switch ($this->ctrl->getNextClass()) {
80  case strtolower(ilRepositorySearchGUI::class):
81  switch ($this->ctrl->getCmd()) {
82  case 'addUserFromAutoComplete':
83  if ($r->getQueryParams()['addusertype'] == "staff") {
84  $this->addStaff();
85  }
86  break;
87  default:
88  $repo = new ilRepositorySearchGUI();
89  $repo->setCallback($this, 'addStaffFromSearch');
90  $this->ctrl->forwardCommand($repo);
91  break;
92  }
93  break;
94 
95  default:
96  parent::executeCommand();
97  break;
98  }
99  }
static http()
Fetches the global http state from ILIAS.
static _checkAccessStaff(int $ref_id)
static _checkAccessPositions(int $ref_id)
$r
+ Here is the call graph for this function:

◆ getConfirmationGUI()

ilOrgUnitUserAssignmentGUI::getConfirmationGUI ( )
protected

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

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

Referenced by confirm(), and confirmRecursive().

164  {
165  $this->ctrl->saveParameter($this, 'position_id');
166  $confirmation = new ilConfirmationGUI();
167  $confirmation->setFormAction($this->ctrl->getFormAction($this));
168  $confirmation->setCancel($this->language->txt(self::CMD_CANCEL), self::CMD_CANCEL);
169 
170  $params = $this->http->request()->getQueryParams();
171  $usr_id = $params['usr_id'];
172  $position_id = $params['position_id'];
173 
174  $types = $this->positionRepo->getArray('id', 'title');
175  $position_title = $types[$position_id];
176 
177  $confirmation->setHeaderText(sprintf($this->language->txt('msg_confirm_remove_user'), $position_title));
178  $confirmation->addItem('usr_id', $usr_id, ilObjUser::_lookupLogin((int) $usr_id));
179 
180  return $confirmation;
181  }
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:33
static http()
Fetches the global http state from ILIAS.
static _lookupLogin(int $a_user_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ index()

ilOrgUnitUserAssignmentGUI::index ( )
protected

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

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

101  : void
102  {
103  $this->addSubTabs();
104  $this->activeSubTab(self::SUBTAB_ASSIGNMENTS);
105 
106  // Header
107  $types = $this->positionRepo->getArray('id', 'title');
108 
109  $this->ctrl->setParameterByClass(ilRepositorySearchGUI::class, 'addusertype', 'staff');
111  'auto_complete_name' => $this->language->txt('user'),
112  'user_type' => $types,
113  'submit_name' => $this->language->txt('add'),
114  ));
115 
116  // Tables
117  $html = '';
118  foreach ($this->positionRepo->getPositionsForOrgUnit($this->getParentRefId()) as $ilOrgUnitPosition) {
119  $ilOrgUnitUserAssignmentTableGUI = new ilOrgUnitUserAssignmentTableGUI(
120  $this,
121  self::CMD_INDEX,
122  $ilOrgUnitPosition
123  );
124  $html .= $ilOrgUnitUserAssignmentTableGUI->getHTML();
125  }
126  $this->setContent($html);
127  }
static fillAutoCompleteToolbar(object $parent_object, ilToolbarGUI $toolbar=null, array $a_options=[], bool $a_sticky=false)
array( auto_complete_name = $lng->txt(&#39;user&#39;), auto_complete_size = 15, user_type = array(ilCoursePar...
Class ilOrgUnitUserAssignmentTableGUI.
+ Here is the call graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilOrgUnitUserAssignmentGUI::$access
private

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

◆ $assignmentRepo

ilOrgUnitUserAssignmentDBRepository ilOrgUnitUserAssignmentGUI::$assignmentRepo
private

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

◆ $ctrl

ilCtrl ilOrgUnitUserAssignmentGUI::$ctrl
private

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

◆ $http

Services ilOrgUnitUserAssignmentGUI::$http
private

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

◆ $language

ilLanguage ilOrgUnitUserAssignmentGUI::$language
private

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

◆ $main_tpl

ilGlobalTemplateInterface ilOrgUnitUserAssignmentGUI::$main_tpl
private

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

◆ $positionRepo

ilOrgUnitPositionDBRepository ilOrgUnitUserAssignmentGUI::$positionRepo
private

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

◆ $toolbar

ilToolbarGUI ilOrgUnitUserAssignmentGUI::$toolbar
private

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

◆ CMD_ASSIGNMENTS_RECURSIVE

const ilOrgUnitUserAssignmentGUI::CMD_ASSIGNMENTS_RECURSIVE = 'assignmentsRecursive'

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

◆ SUBTAB_ASSIGNMENTS

const ilOrgUnitUserAssignmentGUI::SUBTAB_ASSIGNMENTS = 'user_assignments'

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

◆ SUBTAB_ASSIGNMENTS_RECURSIVE

const ilOrgUnitUserAssignmentGUI::SUBTAB_ASSIGNMENTS_RECURSIVE = 'user_assignments_recursive'

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


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