ILIAS  release_8 Revision v8.24
class.ilOrgUnitPermissionTableGUI.php
Go to the documentation of this file.
1<?php
24{
25 private int $ref_id = 0;
26
27 public function __construct(object $a_parent_obj, string $a_parent_cmd, int $a_ref_id)
28 {
29 global $ilCtrl, $tpl;
30
31 parent::__construct($a_parent_obj, $a_parent_cmd);
32
33 $this->lng->loadLanguageModule('rbac');
34 $this->lng->loadLanguageModule("orgu");
35
36 $this->ref_id = $a_ref_id;
37
38 $this->setId('objpositionperm_' . $this->ref_id);
39
40 $tpl->addJavaScript('./Services/AccessControl/js/ilPermSelect.js');
41
42 $this->setTitle($this->lng->txt('org_permission_settings'));
43 $this->setEnableHeader(true);
44 $this->disable('sort');
45 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
46 $this->disable('numinfo');
47 $this->setRowTemplate("tpl.obj_position_perm_row.html", "Modules/OrgUnit");
48 $this->setShowRowsSelector(false);
49 $this->setDisableFilterHiding(true);
50 $this->setNoEntriesText($this->lng->txt('msg_no_roles_of_type'));
51
53 }
54
55 public function getRefId(): int
56 {
57 return $this->ref_id;
58 }
59
63 public function getObjId(): int
64 {
65 return ilObject::_lookupObjId($this->getRefId());
66 }
67
68 public function getObjType(): string
69 {
70 return ilObject::_lookupType($this->getObjId());
71 }
72
76 public function fillRow(array $a_set): void
77 {
78 // Select all
79 if (isset($a_set['show_select_all'])) {
80 $this->fillSelectAll($a_set);
81
82 return;
83 }
84 if (isset($a_set['header_command'])) {
85 $this->fillHeaderCommand($a_set);
86
87 return;
88 }
89
90 $objdefinition = $this->dic()['objDefinition'];
91 $is_plugin = $objdefinition->isPlugin($this->getObjType());
92
93 foreach ($a_set as $permission) {
94 $position = $permission["position"];
95 $op_id = $permission["op_id"];
96 $operation = $permission["operation"];
97 $this->tpl->setCurrentBlock('position_td');
98 $this->tpl->setVariable('POSITION_ID', $position->getId());
99 $this->tpl->setVariable('PERM_ID', $op_id);
100
101 if ($is_plugin) {
102 $label = ilObjectPlugin::lookupTxtById($this->getObjType(), $operation->getOperationString());
103 } else {
104 $label = $this->dic()->language()->txt('org_op_' . $operation->getOperationString());
105 }
106
107 $this->tpl->setVariable('TXT_PERM', $label);
108 $this->tpl->setVariable('PERM_LONG', $op_id);
109
110 if ($permission['permission_set']) {
111 $this->tpl->setVariable('PERM_CHECKED', 'checked="checked"');
112 }
113 if ($permission['from_template']) {
114 $this->tpl->setVariable('PERM_DISABLED', 'disabled="disabled"');
115 }
116
117 $this->tpl->parseCurrentBlock();
118 }
119 }
120
121 public function collectData(): void
122 {
123 $positions = ilOrgUnitPosition::get();
124
125 $this->initColumns($positions);
126
127 $perms = [];
128
130 $ops_ids = [];
131 $from_templates = [];
132 foreach ($operations as $op) {
133 $ops_ids[] = $op->getOperationId();
134
135 $ops = [];
136 foreach ($positions as $position) {
137 $ilOrgUnitPermission = ilOrgUnitPermissionQueries::getSetForRefId(
138 $this->getRefId(),
139 $position->getId()
140 );
141
142 $is_template = $ilOrgUnitPermission->isTemplate();
143 $from_templates[$position->getId()] = $is_template;
144
145 $ops[] = [
146 "op_id" => $op->getOperationId(),
147 "operation" => $op,
148 "position" => $position,
149 "permission" => $ilOrgUnitPermission,
150 "permission_set" => $ilOrgUnitPermission->isOperationIdSelected($op->getOperationId()),
151 "from_template" => $is_template,
152 ];
153 }
154 $perms[] = $ops;
155 }
156
157 $perms[] = [
158 "show_select_all" => true,
159 "positions" => $positions,
160 "ops" => $ops_ids,
161 "template" => $from_templates,
162 ];
164 ->isPositionAccessActiveForObject($this->getObjId())
165 ) {
166 $perms[] = [
167 "header_command" => true,
168 "positions" => $positions,
169 "template" => $from_templates,
170 ];
171 }
172
173 $this->setData($perms);
174 }
175
176 protected function initColumns(array $positions): bool
177 {
178 foreach ($positions as $position) {
179 $this->addColumn($position->getTitle(), '', '', '', false, $position->getDescription());
180 }
181
182 return true;
183 }
184
185 private function dic(): \ILIAS\DI\Container
186 {
187 return $GLOBALS['DIC'];
188 }
189
193 protected function fillSelectAll(array $row): void
194 {
195 foreach ($row["positions"] as $position) {
196 assert($position instanceof ilOrgUnitPosition);
197 $this->tpl->setCurrentBlock('position_select_all');
198 $id = $position->getId();
199 $this->tpl->setVariable('JS_ROLE_ID', $id);
200 $this->tpl->setVariable('JS_SUBID', 0);
201 $this->tpl->setVariable('JS_ALL_PERMS', "['" . implode("','", $row['ops']) . "']");
202 $this->tpl->setVariable('JS_FORM_NAME', $this->getFormName());
203 $this->tpl->setVariable('TXT_SEL_ALL', $this->lng->txt('select_all'));
204 if ($row["template"][$id]) {
205 $this->tpl->setVariable('ALL_DISABLED', "disabled='disabled'");
206 }
207 $this->tpl->parseCurrentBlock();
208 }
209 }
210
214 protected function fillHeaderCommand(array $row): void
215 {
216 foreach ($row["positions"] as $position) {
217 $this->tpl->setCurrentBlock('header_command');
218 $this->tpl->setVariable('POSITION_ID', $position->getId());
219 $this->tpl->setVariable('HEADER_COMMAND_TXT', $this->dic()
220 ->language()
221 ->txt('positions_override_operations'));
222 if (ilOrgUnitPermissionQueries::hasLocalSet($this->getRefId(), $position->getId())) {
223 $this->tpl->setVariable('HEADER_CHECKED', "checked='checked'");
224 }
225
226 $this->tpl->parseCurrentBlock();
227 }
228 }
229}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
static lookupTxtById(string $plugin_id, string $lang_var)
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
static getOperationsForContextName(string $context_name)
static hasLocalSet(int $ref_id, int $position_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(object $a_parent_obj, string $a_parent_cmd, int $a_ref_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static get()
Override for correct on return value.
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.
getFormName()
get the name of the parent form
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
setFormAction(string $a_form_action, bool $a_multipart=false)
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)
setDisableFilterHiding(bool $a_val=true)
setNoEntriesText(string $a_text)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setData(array $a_data)
Set table data.
disable(string $a_module_name)
Class HTTPServicesTest.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Class ChatMainBarProvider \MainMenu\Provider.