ILIAS  release_8 Revision v8.24
class.ilOrgUnitOtherRolesTableGUI.php
Go to the documentation of this file.
1<?php
18/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
19
26{
27 protected ilTabsGUI $tabs;
29 protected \ILIAS\HTTP\Services $http;
30 protected \ILIAS\Refinery\Factory $refinery;
31
32 public function __construct(
34 string $parent_cmd,
35 string $role_id,
36 string $template_context = ""
37 ) {
38 parent::__construct($parent_obj, $parent_cmd, $template_context);
39
40 global $DIC;
41 $this->ctrl = $DIC->ctrl();
42 $this->tabs = $DIC->tabs();
43 $this->lng = $DIC->language();
44 $this->ilAccess = $DIC->access();
45 $this->http = $DIC->http();
46 $this->refinery = $DIC->refinery();
47
48 $this->setPrefix("sr_other_role_" . $role_id);
49 $this->setFormName('sr_other_role_' . $role_id);
50 $this->setId("sr_other_role_" . $role_id);
51 $this->setRoleId($role_id);
52
53 $this->setTableHeaders();
54 $this->setTopCommands(true);
55 $this->setEnableHeader(true);
56 $this->setShowRowsSelector(true);
57 $this->setShowTemplates(false);
58 $this->setEnableHeader(true);
59 $this->setDefaultOrderField("role");
60 $this->setEnableTitle(true);
61 $this->setTitle(ilObjRole::_lookupTitle($role_id));
62 $this->setRowTemplate("tpl.staff_row.html", "Modules/OrgUnit");
63 }
64
65 private function setTableHeaders(): void
66 {
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 readData(): void
73 {
74 $this->parseData();
75 }
76
77 private function parseData(): void
78 {
79 global $DIC;
80 $rbacreview = $DIC['rbacreview'];
81
82 $data = $this->parseRows($rbacreview->assignedUsers($this->getRoleId()));
83
84 $this->setData($data);
85 }
86
91 private function parseRows(array $user_ids): array
92 {
93 $data = array();
94 foreach ($user_ids as $user_id) {
95 $set = array();
96 $data[] = $this->getRowForUser($user_id);
97 }
98
99 return $data;
100 }
101
102 public function setRoleId(int $role_id): void
103 {
104 $this->role_id = $role_id;
105 }
106
107 public function getRoleId(): int
108 {
109 return $this->role_id;
110 }
111
112 private function getRowForUser(int $user_id): array
113 {
114 $user = new ilObjUser($user_id);
115 $set = [];
116 $set["first_name"] = $user->getFirstname();
117 $set["last_name"] = $user->getLastname();
118 $set["user_object"] = $user;
119 $set["user_id"] = $user_id;
120 return $set;
121 }
122
123 public function fillRow(array $a_set): void
124 {
125 $this->tpl->setVariable("FIRST_NAME", $a_set["first_name"]);
126 $this->tpl->setVariable("LAST_NAME", $a_set["last_name"]);
127
128 if ($this->ilAccess->checkAccess("write", "", $this->http->wrapper()->query()->retrieve('ref_id', $this->refinery->to()->int()))) {
129 $this->ctrl->setParameterByClass("ilobjorgunitgui", "obj_id", $a_set["user_id"]);
130 $this->ctrl->setParameterByClass("ilObjOrgUnitGUI", "role_id", $this->role_id);
131
132 $selection = new ilAdvancedSelectionListGUI();
133 $selection->setListTitle($this->lng->txt("Actions"));
134 $selection->setId("selection_list_user_other_roles_" . $a_set["user_id"]);
135 $selection->addItem(
136 $this->lng->txt("remove"),
137 "delete_from_role",
138 $this->ctrl->getLinkTargetByClass("ilOrgUnitStaffGUI", "confirmRemoveFromRole")
139 );
140 }
141 $this->tpl->setVariable("ACTIONS", $selection->getHTML());
142 }
143}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
checkAccess(string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=null, ?int $a_tree_id=null)
check access for an object (provide $a_type and $a_obj_id if available for better performance)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
User class.
Class ilObjectGUI Basic methods of all Output classes.
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(ilObjectGUI $parent_obj, string $parent_cmd, string $role_id, string $template_context="")
fillRow(array $a_set)
Standard Version of Fill Row.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
setEnableTitle(bool $a_enabletitle)
setFormName(string $a_name="")
setShowTemplates(bool $a_value)
setPrefix(string $a_prefix)
set prefix for sort and offset fields (if you have two or more tables on a page that you want to sort...
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)
setEnableHeader(bool $a_enableheader)
setDefaultOrderField(string $a_defaultorderfield)
setTopCommands(bool $a_val)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setData(array $a_data)
Set table data.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc