19 declare(strict_types=1);
    51         $this->
toolbar = $DIC->toolbar();
    54         $this->positionRepo = 
$dic[
"repo.Positions"];
    55         $this->assignmentRepo = 
$dic[
"repo.UserAssignments"];
    62                 (
int) filter_input(INPUT_GET, 
"ref_id", FILTER_SANITIZE_NUMBER_INT)
    66                 (
int) filter_input(INPUT_GET, 
"ref_id", FILTER_SANITIZE_NUMBER_INT)
    69             $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"permission_denied"), 
true);
    70             $this->
ctrl->redirectByClass(ilObjOrgUnitGUI::class);
    73         $r = $this->
http->request();
    74         switch ($this->
ctrl->getNextClass()) {
    75             case strtolower(ilRepositorySearchGUI::class):
    76                 switch ($this->
ctrl->getCmd()) {
    77                     case 'addUserFromAutoComplete':
    78                         if (
$r->getQueryParams()[
'addusertype'] == 
"staff") {
    84                         $repo->setCallback($this, 
'addStaffFromSearch');
    85                         $this->
ctrl->forwardCommand($repo);
    91                 parent::executeCommand();
    96     protected function index(): void
   101         $types = $this->positionRepo->getArray(
'id', 
'title');
   102         $this->
ctrl->setParameterByClass(ilRepositorySearchGUI::class, 
'addusertype', 
'staff');
   104         if ($this->
access->checkAccess(
"write", 
"", $this->getParentRefId())) {
   106                 'auto_complete_name' => $this->
lng->txt(
'user'),
   107                 'user_type' => $types,
   108                 'submit_name' => $this->
lng->txt(
'add'),
   113         foreach ($this->positionRepo->getPositionsForOrgUnit($this->getParentRefId()) as $ilOrgUnitPosition) {
   116         $this->
setContent($this->ui_renderer->render($tables));
   122         $this->
activeSubTab(self::SUBTAB_ASSIGNMENTS_RECURSIVE);
   126         $permission_access_staff_recursive = [];
   129         $parent = (
int) $orgu_tree->getParent($orgu_ref_id);
   131         while ($parent !== $root) {
   134                     $permission_access_staff_recursive = $permission_access_staff_recursive,
   135                     $orgu_tree->getAllChildren($parent)
   138             $parent = (
int) $orgu_tree->getParent($parent);
   141         foreach ($orgu_tree->getAllChildren($orgu_ref_id) as 
$ref_id) {
   142             $recursive = in_array(
$ref_id, $permission_access_staff_recursive);
   147                     $permission_access_staff_recursive = array_merge(
   148                         $permission_access_staff_recursive,
   149                         $orgu_tree->getAllChildren(
$ref_id)
   159         foreach ($this->positionRepo->getPositionsForOrgUnit($this->getParentRefId()) as $ilOrgUnitPosition) {
   160             $tables[] = $this->
getStaffTable($ilOrgUnitPosition, $permission_access_staff_recursive, 
true);
   162         $this->
setContent($this->ui_renderer->render($tables));
   169         $id = implode(
'_', [(
string) $position_id, (
string) $usr_id]);
   171         $pos_name = $this->positionRepo->getSingle($position_id, 
'id')->getTitle();
   173         $item = $this->ui_factory->modal()->interruptiveItem()
   174             ->keyValue(
$id, $usr_name, $pos_name);
   176         $del_command = $recursive ? self::CMD_REMOVE_RECURSIVE : self::CMD_REMOVE;
   177         $action = $this->url_builder
   178             ->withParameter($this->row_id_token, 
$id)
   179             ->withParameter($this->action_token, $del_command)
   180             ->buildURI()->__toString();
   182         echo($this->ui_renderer->renderAsync([
   183             $this->ui_factory->modal()->interruptive(
   184                 $this->
lng->txt(
'remove_user'),
   185                 sprintf($this->
lng->txt(
'msg_confirm_remove_user'), $pos_name),
   187             )->withAffectedItems([$item])
   197     protected function remove(): 
void   201         $assignment = $this->assignmentRepo->find(
   207             $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"user_not_found_to_delete"), 
true);
   208             $this->
ctrl->redirect($this, self::CMD_INDEX);
   210         $this->assignmentRepo->delete($assignment);
   212         $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'remove_successful'), 
true);
   219         $assignments = $this->assignmentRepo->getByUserAndPosition($usr_id, $position_id);
   220         foreach ($assignments as $assignment) {
   221             $this->assignmentRepo->delete($assignment);
   223         $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'remove_successful'), 
true);
   230         $this->
ctrl->setParameterByClass(ilLearningProgressGUI::class, 
'obj_id', $usr_id);
   231         $target = $this->
ctrl->getLinkTargetByClass(ilLearningProgressGUI::class, 
"");
   232         $this->
ctrl->redirectToURL($target);
   238         bool $recursive = 
false   241             'login' => $this->ui_factory->table()->column()->text($this->
lng->txt(
"login")),
   242             'firstname' => $this->ui_factory->table()->column()->text($this->
lng->txt(
"firstname")),
   243             'lastname' => $this->ui_factory->table()->column()->text($this->
lng->txt(
"lastname")),
   244             'active' => $this->ui_factory->table()->column()->boolean(
   245                 $this->
lng->txt(
"active"),
   246                 $this->ui_factory->symbol()->icon()->custom(
'assets/images/standard/icon_ok.svg', 
'', 
'small'),
   247                 $this->ui_factory->symbol()->icon()->custom(
'assets/images/standard/icon_not_ok.svg', 
'', 
'small')
   248             )->withIsOptional(
true, 
false),
   251         $remove_cmd = self::CMD_REMOVE_CONFIRM;
   253             $remove_cmd = self::CMD_REMOVE_RECURSIVELY_CONFIRM;
   254             $columns[
'orgu_title'] = $this->ui_factory->table()->column()->text($this->
lng->txt(
"obj_orgu"));
   258             'remove' => $this->ui_factory->table()->action()->single(
   259                 $this->
lng->txt(
'remove'),
   260                 $this->url_builder->withParameter($this->action_token, $remove_cmd),
   264             'show_learning_progress' => $this->ui_factory->table()->action()->single(
   265                 $this->
lng->txt(
'show_learning_progress'),
   266                 $this->url_builder->withParameter($this->action_token, self::CMD_SHOW_LP),
   271         $lp_visible = array_filter(
   273             fn(
$id) => $this->
access->checkAccess(
"view_learning_progress", 
"", 
$id)
   276         return $this->ui_factory->table()
   279             ->withActions($actions)
   280             ->withAdditionalParameters([
   281                 'position_id' => $position->
getId(),
   282                 'orgu_ids' => $orgu_ids,
   283                 'lp_visible_ref_ids' => $lp_visible,
   286             ->withRequest($this->request);
   294         if ($this->query->has($this->row_id_token->getName())) {
   295             return $this->query->retrieve(
   296                 $this->row_id_token->getName(),
   297                 $this->
refinery->custom()->transformation(
   299                         $id = is_array($v) ? array_shift($v) : $v;
   305         throw new \Exception(
'no position/user id in query');
   310         $this->
ctrl->redirect($this, self::CMD_INDEX);
   315         if (!$this->
access->checkAccess(
"write", 
"", $this->getParentRefId())) {
   316             $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"permission_denied"), 
true);
   317             $this->
ctrl->redirect($this, self::CMD_INDEX);
   320         $users = explode(
',', 
$_POST[
'user_login']);
   322         foreach ($users as $user) {
   329         if (!count($user_ids)) {
   330             $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"user_not_found"), 
true);
   331             $this->
ctrl->redirect($this, self::CMD_INDEX);
   336         if ($position_id === 0 || !$this->positionRepo->getSingle($position_id, 
'id')) {
   337             $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"user_not_found"), 
true);
   338             $this->
ctrl->redirect($this, self::CMD_INDEX);
   341             $assignment = $this->assignmentRepo->get($user_id, $position_id, $this->
getParentRefId());
   344         $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"users_successfuly_added"), 
true);
   345         $this->
ctrl->redirect($this, self::CMD_INDEX);
   353         if (!$this->
access->checkAccess(
"write", 
"", $this->getParentRefId())) {
   354             $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"permission_denied"), 
true);
   355             $this->
ctrl->redirect($this, self::CMD_INDEX);
   358         if (!count($user_ids)) {
   359             $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"user_not_found"), 
true);
   360             $this->
ctrl->redirect($this, self::CMD_INDEX);
   365         if ($position_id === 0 || !$this->positionRepo->getSingle($position_id, 
'id')) {
   366             $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"user_not_found"), 
true);
   367             $this->
ctrl->redirect($this, self::CMD_INDEX);
   370             $assignment = $this->assignmentRepo->get($user_id, $position_id, $this->
getParentRefId());
   373         $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"users_successfuly_added"), 
true);
   374         $this->
ctrl->redirect($this, self::CMD_INDEX);
   380                                                          ->getLinkTarget($this, self::CMD_INDEX));
   384                                                                        self::CMD_ASSIGNMENTS_RECURSIVE
 
static _checkAccessStaffRec(int $ref_id)
 
getStaffTable(ilOrgUnitPosition $position, array $orgu_ids, bool $recursive=false)
 
const CMD_REMOVE_RECURSIVELY_CONFIRM
 
confirmRemoveRecursively()
 
const CORE_POSITION_EMPLOYEE
 
const SUBTAB_ASSIGNMENTS_RECURSIVE
 
Class ilOrgUnitUserAssignmentGUI. 
 
pushSubTab(string $subtab_id, string $url)
 
static _lookupId($a_user_str)
 
const CMD_REMOVE_RECURSIVE
 
URLBuilderToken $row_id_token
 
getPositionAndUserIdFromTableQuery()
 
static http()
Fetches the global http state from ILIAS. 
 
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)
 
static _checkAccessPositions(int $ref_id)
 
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins 
 
__construct(Container $dic, ilPlugin $plugin)
 
confirmRemove(bool $recursive=false)
 
activeSubTab(string $subtab_id)
 
static _lookupLogin(int $a_user_id)