ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilOrgUnitUserAssignmentTableGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
23 
28 {
31  protected \ilAccess $access;
32  protected int $ref_id;
33 
35  {
37  $this->dropdownbuilder = $dic['dropdownbuilder'];
38  $this->parent_obj = $parent_obj;
39  $this->ilOrgUnitPosition = $position;
40  $this->ctrl = $dic['ctrl'];
41  $this->access = $dic['access'];
42  $to_int = $dic['refinery']->kindlyTo()->int();
43  $this->ref_id = $dic['query']->retrieve('ref_id', $to_int);
44 
45  $this->setPrefix("il_orgu_" . $position->getId());
46  $this->setFormName('il_orgu_' . $position->getId());
47  $this->setId("il_orgu_" . $position->getId());
48 
49  parent::__construct($parent_obj, $parent_cmd);
50 
51  $this->setFormAction($this->ctrl->getFormAction($parent_obj));
52  $this->setTableHeaders();
53  $this->setTopCommands(true);
54  $this->setEnableHeader(true);
55  $this->setShowRowsSelector(true);
56  $this->setShowTemplates(false);
57  $this->setEnableHeader(true);
58  $this->setEnableTitle(true);
59  $this->setTitle($position->getTitle());
60  $this->setRowTemplate("tpl.staff_row.html", "Modules/OrgUnit");
61  $this->parseData();
62  }
63 
64  private function setTableHeaders(): void
65  {
66  $this->addColumn($this->lng->txt("login"), "login");
67  $this->addColumn($this->lng->txt("firstname"), "first_name");
68  $this->addColumn($this->lng->txt("lastname"), "last_name");
69  $this->addColumn($this->lng->txt("action"));
70  }
71 
72  public function parseData(): void
73  {
75  ->getAssignedUsers([(int) $_GET["ref_id"]], $this->ilOrgUnitPosition->getId()));
76  $this->setData($data);
77  }
78 
82  private function parseRows(array $user_ids): array
83  {
84  $data = [];
85  foreach ($user_ids as $user_id) {
86  $data[] = $this->getRowForUser($user_id);
87  }
88  return $data;
89  }
90 
91  private function getRowForUser(int $user_id): array
92  {
93  $user = new ilObjUser($user_id);
94  return [
95  'login' => $user->getLogin(),
96  'first_name' => $user->getFirstname(),
97  'last_name' => $user->getLastname(),
98  'user_object' => $user,
99  'user_id' => $user_id,
100  'active' => $user->getActive()
101  ];
102  }
103 
104  public function fillRow(array $a_set): void
105  {
106  $this->tpl->setVariable("LOGIN", $a_set["login"]);
107  $this->tpl->setVariable("FIRST_NAME", $a_set["first_name"]);
108  $this->tpl->setVariable("LAST_NAME", $a_set["last_name"]);
109 
110  if($a_set["active"] === false) {
111  $this->tpl->setVariable("INACTIVE", $this->lng->txt('usr_account_inactive'));
112  }
113 
114  $this->ctrl->setParameterByClass(ilOrgUnitUserAssignmentGUI::class, 'usr_id', $a_set["user_id"]);
115  $this->ctrl->setParameterByClass(ilOrgUnitUserAssignmentGUI::class, 'position_id', $this->ilOrgUnitPosition->getId());
116  $this->ctrl->setParameterByClass(ilLearningProgressGUI::class, 'obj_id', $a_set["user_id"]);
117  $dropdownbuilder = $this->dropdownbuilder
118  ->withItem(
119  'show_learning_progress',
120  $this->ctrl->getLinkTargetByClass([
121  ilAdministrationGUI::class,
122  ilObjOrgUnitGUI::class,
123  ilLearningProgressGUI::class,
124  ], ""),
125  $this->access->checkAccess("view_learning_progress", "", $this->ref_id)
128  )
129  ->withItem(
130  'remove',
131  $this->ctrl->getLinkTargetByClass(
132  ilOrgUnitUserAssignmentGUI::class,
134  ),
135  $this->access->checkAccess("write", "", $this->ref_id)
136  )
137  ->get();
138 
139  $this->tpl->setVariable("ACTIONS", $dropdownbuilder);
140  }
141 }
setData(array $a_data)
setTopCommands(bool $a_val)
$_GET["client_id"]
Definition: webdav.php:30
setFormAction(string $a_form_action, bool $a_multipart=false)
setEnableTitle(bool $a_enabletitle)
setShowTemplates(bool $a_value)
withItem(string $label_lang_var, string $url, bool $condition=true)
setFormName(string $a_name="")
This is to construct/collect the entries (=Links) of a row&#39;s action-dropdown.
setId(string $a_val)
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
__construct(VocabulariesInterface $vocabularies)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
$dic
Definition: result.php:32
__construct(BaseCommands $parent_obj, string $parent_cmd, ilOrgUnitPosition $position)
setEnableHeader(bool $a_enableheader)
Class ilOrgUnitUserAssignmentTableGUI.
setPrefix(string $a_prefix)