ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilOrgUnitUserAssignmentGUI Class Reference

Class ilOrgUnitUserAssignmentGUI. More...

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

Public Member Functions

 executeCommand ()
 
 addStaff ()
 
- Public Member Functions inherited from ILIAS\Modules\OrgUnit\ARHelper\BaseCommands
 getParentGui ()
 
 setParentGui ($parent_gui)
 
 executeCommand ()
 
 addSubTabs ()
 

Protected Member Functions

 index ()
 
 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

- 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 Attributes inherited from ILIAS\Modules\OrgUnit\ARHelper\BaseCommands
 $parent_gui = null
 

Detailed Description

Member Function Documentation

◆ addStaff()

ilOrgUnitUserAssignmentGUI::addStaff ( )

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

98 {
99 if (!$this->dic()->access()->checkAccess("write", "", $this->getParentRefId())) {
100 ilUtil::sendFailure($this->txt("permission_denied"), true);
101 $this->ctrl()->redirect($this, self::CMD_INDEX);
102 }
103
104 $users = explode(',', $_POST['user_login']);
105 $user_ids = array();
106 foreach ($users as $user) {
107 $user_id = ilObjUser::_lookupId($user);
108 if ($user_id) {
109 $user_ids[] = $user_id;
110 }
111 }
112
113 if (!count($user_ids)) {
114 ilUtil::sendFailure($this->txt("user_not_found"), true);
115 $this->ctrl()->redirect($this, self::CMD_INDEX);
116 }
117
118 $position_id = isset($_POST['user_type']) ? $_POST['user_type'] : 0;
119
120 if (!$position_id && !$position = ilOrgUnitPosition::find($position_id)) {
121 ilUtil::sendFailure($this->txt("user_not_found"), true);
122 $this->ctrl()->redirect($this, self::CMD_INDEX);
123 }
124 foreach ($user_ids as $user_id) {
125 ilOrgUnitUserAssignment::findOrCreateAssignment($user_id, $position_id, $this->getParentRefId());
126 }
127
128 ilUtil::sendSuccess($this->txt("users_successfuly_added"), true);
129 $this->ctrl()->redirect($this, self::CMD_INDEX);
130 }
$users
Definition: authpage.php:44
$_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.
$user
Definition: migrateto20.php:57

References $_POST, $user, $users, ilObjUser\_lookupId(), 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:

◆ cancel()

ilOrgUnitUserAssignmentGUI::cancel ( )
protected

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

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

92 {
93 $this->ctrl()->redirect($this, self::CMD_INDEX);
94 }

Referenced by delete().

+ Here is the caller graph for this function:

◆ delete()

ilOrgUnitUserAssignmentGUI::delete ( )
protected

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

81 {
82 $r = $this->http()->request();
84 ->getAssignmentOrFail($_POST['usr_id'], $r->getQueryParams()['position_id'], $this->getParentRefId());
85 $ua->delete();
86 ilUtil::sendSuccess($this->txt('remove_successful'), true);
87 $this->cancel();
88 }
$r
Definition: example_031.php:79
static http()
Fetches the global http state from ILIAS.

References $_POST, $r, 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 14 of file class.ilOrgUnitUserAssignmentGUI.php.

15 {
16 $r = $this->http()->request();
17 switch ($this->ctrl()->getNextClass()) {
18 case strtolower(ilRepositorySearchGUI::class):
19 switch ($this->ctrl()->getCmd()) {
20 case 'addUserFromAutoComplete':
21 if ($r->getQueryParams()['addusertype'] == "staff") {
22 $this->addStaff();
23 }
24 break;
25 default:
26 $repo = new ilRepositorySearchGUI();
27 $this->ctrl()->forwardCommand($repo);
28 break;
29 }
30 break;
31
32 default:
33 parent::executeCommand();
34 break;
35 }
36 }
switch( $driver)
Definition: migrateto21.php:69

References $r, addStaff(), and ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

◆ index()

ilOrgUnitUserAssignmentGUI::index ( )
protected

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

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

40 {
41 // Header
42 $types = ilOrgUnitPosition::getArray('id', 'title');
43 //$types = array();
44 $this->ctrl()->setParameterByClass(ilRepositorySearchGUI::class, 'addusertype', 'staff');
45 ilRepositorySearchGUI::fillAutoCompleteToolbar($this, $this->dic()->toolbar(), array(
46 'auto_complete_name' => $this->txt('user'),
47 'user_type' => $types,
48 'submit_name' => $this->txt('add'),
49 ));
50
51 // Tables
52 $html = '';
53 foreach (ilOrgUnitPosition::getActiveForPosition($this->getParentRefId()) as $ilOrgUnitPosition) {
54 $ilOrgUnitUserAssignmentTableGUI = new ilOrgUnitUserAssignmentTableGUI($this, self::CMD_INDEX, $ilOrgUnitPosition);
55 $html .= $ilOrgUnitUserAssignmentTableGUI->getHTML();
56 }
57 $this->setContent($html);
58 }
static getArray($key=null, $values=null)
static getActiveForPosition($orgu_ref_id)
Class ilOrgUnitUserAssignmentTableGUI.
static fillAutoCompleteToolbar($parent_object, ilToolbarGUI $toolbar=null, $a_options=array(), $a_sticky=false)
fill toolbar with
$html
Definition: example_001.php:87

References $html, 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:

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