19 declare(strict_types=1);
    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();
    59         $this->positionRepo = 
$dic[
"repo.Positions"];
    60         $this->assignmentRepo = 
$dic[
"repo.UserAssignments"];
    67                 (
int) filter_input(INPUT_GET, 
"ref_id", FILTER_SANITIZE_NUMBER_INT)
    71                 (
int) filter_input(INPUT_GET, 
"ref_id", FILTER_SANITIZE_NUMBER_INT)
    74             $this->main_tpl->setOnScreenMessage(
'failure', $this->
language->txt(
"permission_denied"), 
true);
    75             $this->
ctrl->redirectByClass(ilObjOrgUnitGUI::class);
    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") {
    89                         $repo->setCallback($this, 
'addStaffFromSearch');
    90                         $this->
ctrl->forwardCommand($repo);
    96                 parent::executeCommand();
   107         $types = $this->positionRepo->getArray(
'id', 
'title');
   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'),
   118         foreach ($this->positionRepo->getPositionsForOrgUnit($this->getParentRefId()) as $ilOrgUnitPosition) {
   124             $html .= $ilOrgUnitUserAssignmentTableGUI->getHTML();
   132         $this->
activeSubTab(self::SUBTAB_ASSIGNMENTS_RECURSIVE);
   135         foreach ($this->positionRepo->getPositionsForOrgUnit($this->getParentRefId()) as $ilOrgUnitPosition) {
   136             $ilOrgUnitRecursiveUserAssignmentTableGUI =
   139                     self::CMD_ASSIGNMENTS_RECURSIVE,
   142             $html .= $ilOrgUnitRecursiveUserAssignmentTableGUI->getHTML();
   150         $confirmation->setConfirm($this->
language->txt(
'remove_user'), self::CMD_DELETE);
   158         $confirmation->setConfirm($this->
language->txt(
'remove_user'), self::CMD_DELETE_RECURSIVE);
   165         $this->
ctrl->saveParameter($this, 
'position_id');
   167         $confirmation->setFormAction($this->
ctrl->getFormAction($this));
   168         $confirmation->setCancel($this->
language->txt(self::CMD_CANCEL), self::CMD_CANCEL);
   170         $params = $this->
http->request()->getQueryParams();
   172         $position_id = 
$params[
'position_id'];
   174         $types = $this->positionRepo->getArray(
'id', 
'title');
   175         $position_title = $types[$position_id];
   177         $confirmation->setHeaderText(sprintf($this->
language->txt(
'msg_confirm_remove_user'), $position_title));
   180         return $confirmation;
   183     protected function delete(): 
void   185         $params = $this->
http->request()->getQueryParams();
   186         $usr_id = (
int) $_POST[
'usr_id'];
   189         $assignment = $this->assignmentRepo->find(
   195             $this->main_tpl->setOnScreenMessage(
'failure', $this->
language->txt(
"user_not_found_to_delete"), 
true);
   196             $this->
ctrl->redirect($this, self::CMD_INDEX);
   198         $this->assignmentRepo->delete($assignment);
   200         $this->main_tpl->setOnScreenMessage(
'success', $this->
language->txt(
'remove_successful'), 
true);
   206         $r = $this->
http->request();
   207         $assignments = $this->assignmentRepo
   208             ->getByUserAndPosition((
int) $_POST[
'usr_id'], (
int) 
$r->getQueryParams()[
'position_id']);
   210         foreach ($assignments as $assignment) {
   211             $this->assignmentRepo->delete($assignment);
   213         $this->main_tpl->setOnScreenMessage(
'success', $this->
language->txt(
'remove_successful'), 
true);
   219         $this->
ctrl->redirect($this, self::CMD_INDEX);
   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);
   229         $users = explode(
',', $_POST[
'user_login']);
   231         foreach ($users as $user) {
   234                 $user_ids[] = $user_id;
   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);
   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);
   249         foreach ($user_ids as $user_id) {
   250             $assignment = $this->assignmentRepo->get($user_id, $position_id, $this->
getParentRefId());
   253         $this->main_tpl->setOnScreenMessage(
'success', $this->
language->txt(
"users_successfuly_added"), 
true);
   254         $this->
ctrl->redirect($this, self::CMD_INDEX);
   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);
   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);
   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);
   278         foreach ($user_ids as $user_id) {
   279             $assignment = $this->assignmentRepo->get($user_id, $position_id, $this->
getParentRefId());
   282         $this->main_tpl->setOnScreenMessage(
'success', $this->
language->txt(
"users_successfuly_added"), 
true);
   283         $this->
ctrl->redirect($this, self::CMD_INDEX);
   289                                                          ->getLinkTarget($this, self::CMD_INDEX));
   293                                                                        self::CMD_ASSIGNMENTS_RECURSIVE
 
activeSubTab(string $subtab_id)
 
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
 
const CORE_POSITION_EMPLOYEE
 
const SUBTAB_ASSIGNMENTS_RECURSIVE
 
Class ilOrgUnitUserAssignmentGUI. 
 
static _lookupId($a_user_str)
 
pushSubTab(string $subtab_id, string $url)
 
static http()
Fetches the global http state from ILIAS. 
 
ilGlobalTemplateInterface $main_tpl
 
const CMD_ASSIGNMENTS_RECURSIVE
 
ilOrgUnitPositionDBRepository $positionRepo
 
addStaffFromSearch(array $user_ids, ?string $user_type=null)
 
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...
 
ilOrgUnitUserAssignmentDBRepository $assignmentRepo
 
static _checkAccessStaff(int $ref_id)
 
Class ilOrgUnitRecursiveUserAssignmentTableGUI. 
 
static _checkAccessPositions(int $ref_id)
 
Class ilOrgUnitUserAssignmentTableGUI. 
 
static _lookupLogin(int $a_user_id)