ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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.

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

Referenced by executeCommand().

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  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static findOrCreateAssignment($user_id, $position_id, $orgu_id)
static _lookupId($a_user_str)
Lookup id by login.
Create styles array
The data for the language used.
$users
Definition: authpage.php:44
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cancel()

ilOrgUnitUserAssignmentGUI::cancel ( )
protected

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

Referenced by delete().

92  {
93  $this->ctrl()->redirect($this, self::CMD_INDEX);
94  }
+ Here is the caller graph for this function:

◆ delete()

ilOrgUnitUserAssignmentGUI::delete ( )
protected

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

References $_POST, $r, cancel(), ilOrgUnitUserAssignmentQueries\getInstance(), ILIAS\Modules\OrgUnit\ARHelper\BaseCommands\getParentRefId(), ILIAS\FileDelivery\http(), and ilUtil\sendSuccess().

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  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$r
Definition: example_031.php:79
static http()
Fetches the global http state from ILIAS.
$_POST["username"]
+ Here is the call graph for this function:

◆ executeCommand()

ilOrgUnitUserAssignmentGUI::executeCommand ( )

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

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

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  }
$r
Definition: example_031.php:79
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:

◆ index()

ilOrgUnitUserAssignmentGUI::index ( )
protected

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

References $html, $r, ilObjUser\_lookupLogin(), array, ilRepositorySearchGUI\fillAutoCompleteToolbar(), ActiveRecord\findOrFail(), ilOrgUnitPosition\getActiveForPosition(), ActiveRecord\getArray(), ILIAS\Modules\OrgUnit\ARHelper\BaseCommands\getParentRefId(), ILIAS\FileDelivery\http(), and ILIAS\Modules\OrgUnit\ARHelper\BaseCommands\setContent().

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 getActiveForPosition($orgu_ref_id)
Create styles array
The data for the language used.
static getArray($key=null, $values=null)
static fillAutoCompleteToolbar($parent_object, ilToolbarGUI $toolbar=null, $a_options=array(), $a_sticky=false)
fill toolbar with
$html
Definition: example_001.php:87
Class ilOrgUnitUserAssignmentTableGUI.
+ Here is the call graph for this function:

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