ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilOrgUnitPermissionTableGUI.php
Go to the documentation of this file.
1<?php
2
9{
10
14 private $ref_id = null;
15
16
24 public function __construct($a_parent_obj, $a_parent_cmd, $a_ref_id)
25 {
26 global $ilCtrl, $tpl;
27
28 parent::__construct($a_parent_obj, $a_parent_cmd);
29
30 $this->lng->loadLanguageModule('rbac');
31 $this->lng->loadLanguageModule("orgu");
32
33 $this->ref_id = $a_ref_id;
34
35 $this->setId('objpositionperm_' . $this->ref_id);
36
37 $tpl->addJavaScript('./Services/AccessControl/js/ilPermSelect.js');
38
39 $this->setTitle($this->lng->txt('org_permission_settings'));
40 $this->setEnableHeader(true);
41 $this->disable('sort');
42 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
43 $this->disable('numinfo');
44 $this->setRowTemplate("tpl.obj_position_perm_row.html", "Modules/OrgUnit");
45 $this->setShowRowsSelector(false);
46 $this->setDisableFilterHiding(true);
47 $this->setNoEntriesText($this->lng->txt('msg_no_roles_of_type'));
48
50 }
51
52
56 public function getRefId()
57 {
58 return (int) $this->ref_id;
59 }
60
61
65 public function getObjId()
66 {
67 return (int) ilObject::_lookupObjId($this->getRefId());
68 }
69
70
74 public function getObjType()
75 {
76 return (string) ilObject::_lookupType($this->getObjId());
77 }
78
79
85 public function fillRow($row)
86 {
87 // Select all
88 if (isset($row['show_select_all'])) {
89 $this->fillSelectAll($row);
90
91 return true;
92 }
93 if (isset($row['header_command'])) {
94 $this->fillHeaderCommand($row);
95
96 return true;
97 }
98
99 foreach ($row as $permission) {
104 $position = $permission["position"];
105 $op_id = $permission["op_id"];
106 $operation = $permission["operation"];
107 $this->tpl->setCurrentBlock('position_td');
108 $this->tpl->setVariable('POSITION_ID', $position->getId());
109 $this->tpl->setVariable('PERM_ID', $op_id);
110
111 $this->tpl->setVariable('TXT_PERM', $this->dic()->language()->txt('org_op_'
112 . $operation->getOperationString()));
113 $this->tpl->setVariable('PERM_LONG', $op_id);
114
115 if ($permission['permission_set']) {
116 $this->tpl->setVariable('PERM_CHECKED', 'checked="checked"');
117 }
118 if ($permission['from_template']) {
119 $this->tpl->setVariable('PERM_DISABLED', 'disabled="disabled"');
120 }
121
122 $this->tpl->parseCurrentBlock();
123 }
124 }
125
126
127 public function collectData()
128 {
129 $positions = ilOrgUnitPosition::get();
130
131 $this->initColumns($positions);
132
133 $perms = [];
134
135 $operations = ilOrgUnitOperationQueries::getOperationsForContextName($this->getObjType());
136 $ops_ids = [];
137 $from_templates = [];
138 foreach ($operations as $op) {
139 $ops_ids[] = $op->getOperationId();
140
141 $ops = [];
142 foreach ($positions as $position) {
143 $ilOrgUnitPermission = ilOrgUnitPermissionQueries::getSetForRefId($this->getRefId(), $position->getId());
144
145 $is_template = $ilOrgUnitPermission->isTemplate();
146 $from_templates[$position->getId()] = $is_template;
147
148 $ops[] = [
149 "op_id" => $op->getOperationId(),
150 "operation" => $op,
151 "position" => $position,
152 "permission" => $ilOrgUnitPermission,
153 "permission_set" => $ilOrgUnitPermission->isOperationIdSelected($op->getOperationId()),
154 "from_template" => $is_template,
155 ];
156 }
157 $perms[] = $ops;
158 }
159
160 $perms[] = [
161 "show_select_all" => true,
162 "positions" => $positions,
163 "ops" => $ops_ids,
164 "template" => $from_templates,
165 ];
167 ->isPositionAccessActiveForObject($this->getObjId())) {
168 $perms[] = [
169 "header_command" => true,
170 "positions" => $positions,
171 "template" => $from_templates,
172 ];
173 }
174
175 $this->setData($perms);
176
177 return;
178 }
179
180
186 protected function initColumns(array $positions)
187 {
188 foreach ($positions as $position) {
189 $this->addColumn($position->getTitle(), '', '', '', false, $position->getDescription());
190 }
191
192 return true;
193 }
194
195
199 private function dic()
200 {
201 return $GLOBALS['DIC'];
202 }
203
204
208 protected function fillSelectAll($row)
209 {
213 foreach ($row["positions"] as $position) {
214 $this->tpl->setCurrentBlock('position_select_all');
215 $id = $position->getId();
216 $this->tpl->setVariable('JS_ROLE_ID', $id);
217 $this->tpl->setVariable('JS_SUBID', 0);
218 $this->tpl->setVariable('JS_ALL_PERMS', "['" . implode("','", $row['ops']) . "']");
219 $this->tpl->setVariable('JS_FORM_NAME', $this->getFormName());
220 $this->tpl->setVariable('TXT_SEL_ALL', $this->lng->txt('select_all'));
221 if ($row["template"][$id]) {
222 $this->tpl->setVariable('ALL_DISABLED', "disabled='disabled'");
223 }
224 $this->tpl->parseCurrentBlock();
225 }
226 }
227
228
232 protected function fillHeaderCommand($row)
233 {
237 foreach ($row["positions"] as $position) {
238 $this->tpl->setCurrentBlock('header_command');
239 $this->tpl->setVariable('POSITION_ID', $position->getId());
240 $this->tpl->setVariable('HEADER_COMMAND_TXT', $this->dic()
241 ->language()
242 ->txt('positions_override_operations'));
243 if (ilOrgUnitPermissionQueries::hasLocalSet($this->getRefId(), $position->getId())) {
244 $this->tpl->setVariable('HEADER_CHECKED', "checked='checked'");
245 }
246
247 $this->tpl->parseCurrentBlock();
248 }
249 }
250}
An exception for terminatinating execution or to throw for unit testing.
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
static hasLocalSet($ref_id, $position_id)
Class ilOrgUnitPermissionTableGUI.
__construct($a_parent_obj, $a_parent_cmd, $a_ref_id)
ilOrgUnitPermissionTableGUI constructor.
static get()
Override for correct on return value.
Class ilTable2GUI.
getFormName()
Get Form name.
setEnableHeader($a_enableheader)
Set Enable Header.
setDisableFilterHiding($a_val=true)
Set disable filter hiding.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
fillRow($a_set)
Standard Version of Fill Row.
setNoEntriesText($a_text)
Set text for an empty table.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
disable($a_module_name)
diesables particular modules of table
if(!array_key_exists('StateId', $_REQUEST)) $id
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $ilCtrl
Definition: ilias.php:18