ILIAS  release_7 Revision v7.30-3-g800a261c036
ilOrgUnitUserAssignmentGUI Class Reference

Class ilOrgUnitUserAssignmentGUI. More...

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

Public Member Functions

 executeCommand ()
 
 addStaff ()
 
 addStaffFromSearch (array $user_ids, ?string $user_type=null)
 
 addSubTabs ()
 
- Public Member Functions inherited from ILIAS\Modules\OrgUnit\ARHelper\BaseCommands
 getParentGui ()
 
 setParentGui ($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_DELETE = "delete"
 
const CMD_CANCEL = "cancel"
 
const AR_ID = "arid"
 

Protected Member Functions

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

Additional Inherited Members

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

Detailed Description

Member Function Documentation

◆ addStaff()

ilOrgUnitUserAssignmentGUI::addStaff ( )

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

129 {
130 if (!$this->dic()->access()->checkAccess("write", "", $this->getParentRefId())) {
131 ilUtil::sendFailure($this->txt("permission_denied"), true);
132 $this->ctrl()->redirect($this, self::CMD_INDEX);
133 }
134
135 $users = explode(',', $_POST['user_login']);
136 $user_ids = array();
137 foreach ($users as $user) {
138 $user_id = ilObjUser::_lookupId($user);
139 if ($user_id) {
140 $user_ids[] = $user_id;
141 }
142 }
143
144 if (!count($user_ids)) {
145 ilUtil::sendFailure($this->txt("user_not_found"), true);
146 $this->ctrl()->redirect($this, self::CMD_INDEX);
147 }
148
149 $position_id = (int) ($_POST['user_type'] ?? ilOrgUnitPosition::CORE_POSITION_EMPLOYEE);
150
151 if (!$position_id && !$position = ilOrgUnitPosition::find($position_id)) {
152 ilUtil::sendFailure($this->txt("user_not_found"), true);
153 $this->ctrl()->redirect($this, self::CMD_INDEX);
154 }
155 foreach ($user_ids as $user_id) {
156 ilOrgUnitUserAssignment::findOrCreateAssignment($user_id, $position_id, $this->getParentRefId());
157 }
158
159 ilUtil::sendSuccess($this->txt("users_successfuly_added"), true);
160 $this->ctrl()->redirect($this, self::CMD_INDEX);
161 }
$_POST["username"]
static _lookupId($a_user_str)
Lookup id by login.
static findOrCreateAssignment($user_id, $position_id, $orgu_id)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.

References $_POST, ilObjUser\_lookupId(), ilOrgUnitPosition\CORE_POSITION_EMPLOYEE, ilOrgUnitUserAssignment\findOrCreateAssignment(), ILIAS\Modules\OrgUnit\ARHelper\BaseCommands\getParentRefId(), and ilUtil\sendFailure().

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 166 of file class.ilOrgUnitUserAssignmentGUI.php.

167 {
168 if (!$this->dic()->access()->checkAccess("write", "", $this->getParentRefId())) {
169 ilUtil::sendFailure($this->txt("permission_denied"), true);
170 $this->ctrl()->redirect($this, self::CMD_INDEX);
171 }
172
173 if (!count($user_ids)) {
174 ilUtil::sendFailure($this->txt("user_not_found"), true);
175 $this->ctrl()->redirect($this, self::CMD_INDEX);
176 }
177
178 $position_id = (int) ($user_type ?? ilOrgUnitPosition::CORE_POSITION_EMPLOYEE);
179
180 if (!$position_id && !$position = ilOrgUnitPosition::find($position_id)) {
181 ilUtil::sendFailure($this->txt("user_not_found"), true);
182 $this->ctrl()->redirect($this, self::CMD_INDEX);
183 }
184 foreach ($user_ids as $user_id) {
185 ilOrgUnitUserAssignment::findOrCreateAssignment($user_id, $position_id, $this->getParentRefId());
186 }
187
188 ilUtil::sendSuccess($this->txt("users_successfuly_added"), true);
189 $this->ctrl()->redirect($this, self::CMD_INDEX);
190 }

References ilOrgUnitPosition\CORE_POSITION_EMPLOYEE, ilOrgUnitUserAssignment\findOrCreateAssignment(), ILIAS\Modules\OrgUnit\ARHelper\BaseCommands\getParentRefId(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ addSubTabs()

ilOrgUnitUserAssignmentGUI::addSubTabs ( )

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

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

193 {
194 $this->pushSubTab(self::SUBTAB_ASSIGNMENTS, $this->ctrl()
195 ->getLinkTarget($this, self::CMD_INDEX));
196 $this->pushSubTab(self::SUBTAB_ASSIGNMENTS_RECURSIVE, $this->ctrl()
197 ->getLinkTarget($this, self::CMD_ASSIGNMENTS_RECURSIVE));
198 }

References 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 75 of file class.ilOrgUnitUserAssignmentGUI.php.

76 {
77 $this->addSubTabs();
78 $this->activeSubTab(self::SUBTAB_ASSIGNMENTS_RECURSIVE);
79 // Tables
80 $html = '';
81 foreach (ilOrgUnitPosition::getActiveForPosition($this->getParentRefId()) as $ilOrgUnitPosition) {
82 $ilOrgUnitRecursiveUserAssignmentTableGUI =
84 self::CMD_ASSIGNMENTS_RECURSIVE,
85 $ilOrgUnitPosition);
86 $html .= $ilOrgUnitRecursiveUserAssignmentTableGUI->getHTML();
87 }
88 $this->setContent($html);
89 }
static getActiveForPosition($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

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

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

123 {
124 $this->ctrl()->redirect($this, self::CMD_INDEX);
125 }

Referenced by delete().

+ Here is the caller graph for this function:

◆ delete()

ilOrgUnitUserAssignmentGUI::delete ( )
protected

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

112 {
113 $r = $this->http()->request();
115 ->getAssignmentOrFail($_POST['usr_id'], $r->getQueryParams()['position_id'], $this->getParentRefId());
116 $ua->delete();
117 ilUtil::sendSuccess($this->txt('remove_successful'), true);
118 $this->cancel();
119 }
static http()
Fetches the global http state from ILIAS.

References $_POST, cancel(), ilOrgUnitUserAssignmentQueries\getInstance(), and ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

◆ executeCommand()

ilOrgUnitUserAssignmentGUI::executeCommand ( )

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

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

21 {
22 if (!ilObjOrgUnitAccess::_checkAccessPositions((int) filter_input(INPUT_GET, "ref_id", FILTER_SANITIZE_NUMBER_INT))) {
23 ilUtil::sendFailure($this->lng()->txt("permission_denied"), true);
24 $this->ctrl()->redirectByClass(ilObjOrgUnitGUI::class);
25 }
26
27 $r = $this->http()->request();
28 switch ($this->ctrl()->getNextClass()) {
29 case strtolower(ilRepositorySearchGUI::class):
30 switch ($this->ctrl()->getCmd()) {
31 case 'addUserFromAutoComplete':
32 if ($r->getQueryParams()['addusertype'] == "staff") {
33 $this->addStaff();
34 }
35 break;
36 default:
37 $repo = new ilRepositorySearchGUI();
38 $repo->setCallback($this, 'addStaffFromSearch');
39 $this->ctrl()->forwardCommand($repo);
40 break;
41 }
42 break;
43
44 default:
45 parent::executeCommand();
46 break;
47 }
48 }
static _checkAccessPositions(int $ref_id)

References ilObjOrgUnitAccess\_checkAccessPositions(), addStaff(), ILIAS\FileDelivery\http(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ index()

ilOrgUnitUserAssignmentGUI::index ( )
protected

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

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

52 {
53 $this->addSubTabs();
54 $this->activeSubTab(self::SUBTAB_ASSIGNMENTS);
55
56 // Header
57 $types = ilOrgUnitPosition::getArray('id', 'title');
58 //$types = array();
59 $this->ctrl()->setParameterByClass(ilRepositorySearchGUI::class, 'addusertype', 'staff');
60 ilRepositorySearchGUI::fillAutoCompleteToolbar($this, $this->dic()->toolbar(), array(
61 'auto_complete_name' => $this->txt('user'),
62 'user_type' => $types,
63 'submit_name' => $this->txt('add'),
64 ));
65
66 // Tables
67 $html = '';
68 foreach (ilOrgUnitPosition::getActiveForPosition($this->getParentRefId()) as $ilOrgUnitPosition) {
69 $ilOrgUnitUserAssignmentTableGUI = new ilOrgUnitUserAssignmentTableGUI($this, self::CMD_INDEX, $ilOrgUnitPosition);
70 $html .= $ilOrgUnitUserAssignmentTableGUI->getHTML();
71 }
72 $this->setContent($html);
73 }
static getArray($key=null, $values=null)
Class ilOrgUnitUserAssignmentTableGUI.
static fillAutoCompleteToolbar($parent_object, ilToolbarGUI $toolbar=null, $a_options=array(), $a_sticky=false)
fill toolbar with

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

+ Here is the call graph for this function:

Field Documentation

◆ CMD_ASSIGNMENTS_RECURSIVE

const ilOrgUnitUserAssignmentGUI::CMD_ASSIGNMENTS_RECURSIVE = 'assignmentsRecursive'

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

◆ SUBTAB_ASSIGNMENTS

const ilOrgUnitUserAssignmentGUI::SUBTAB_ASSIGNMENTS = 'user_assignments'

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

◆ SUBTAB_ASSIGNMENTS_RECURSIVE

const ilOrgUnitUserAssignmentGUI::SUBTAB_ASSIGNMENTS_RECURSIVE = 'user_assignments_recursive'

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


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