ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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_' . $operation->getOperationString()));
112 //$this->tpl->setVariable('PERM_LONG', $op_id);
113
114 if ($permission['permission_set']) {
115 $this->tpl->setVariable('PERM_CHECKED', 'checked="checked"');
116 }
117 if ($permission['from_template']) {
118 $this->tpl->setVariable('PERM_DISABLED', 'disabled="disabled"');
119 }
120
121 $this->tpl->parseCurrentBlock();
122 }
123 }
124
125
126 public function collectData()
127 {
128 $positions = ilOrgUnitPosition::get();
129
130 $this->initColumns($positions);
131
132 $perms = [];
133
134 $operations = ilOrgUnitOperationQueries::getOperationsForContextName($this->getObjType());
135 $ops_ids = [];
136 $from_templates = [];
137 foreach ($operations as $op) {
138 $ops_ids[] = $op->getOperationId();
139
140 $ops = [];
141 foreach ($positions as $position) {
142 $ilOrgUnitPermission = ilOrgUnitPermissionQueries::getSetForRefId($this->getRefId(), $position->getId());
143
144 $is_template = $ilOrgUnitPermission->isTemplate();
145 $from_templates[$position->getId()] = $is_template;
146
147 $ops[] = [
148 "op_id" => $op->getOperationId(),
149 "operation" => $op,
150 "position" => $position,
151 "permission" => $ilOrgUnitPermission,
152 "permission_set" => $ilOrgUnitPermission->isOperationIdSelected($op->getOperationId()),
153 "from_template" => $is_template,
154 ];
155 }
156 $perms[] = $ops;
157 }
158
159 $perms[] = [
160 "show_select_all" => true,
161 "positions" => $positions,
162 "ops" => $ops_ids,
163 "template" => $from_templates,
164 ];
166 ->isPositionAccessActiveForObject($this->getObjId())) {
167 $perms[] = [
168 "header_command" => true,
169 "positions" => $positions,
170 "template" => $from_templates,
171 ];
172 }
173
174 $this->setData($perms);
175
176 return;
177 }
178
179
185 protected function initColumns(array $positions)
186 {
187 foreach ($positions as $position) {
188 $this->addColumn($position->getTitle(), '', '', '', false, $position->getDescription());
189 }
190
191 return true;
192 }
193
194
198 private function dic()
199 {
200 return $GLOBALS['DIC'];
201 }
202
203
207 protected function fillSelectAll($row)
208 {
212 foreach ($row["positions"] as $position) {
213 $this->tpl->setCurrentBlock('position_select_all');
214 $id = $position->getId();
215 $this->tpl->setVariable('JS_ROLE_ID', $id);
216 $this->tpl->setVariable('JS_SUBID', 0);
217 $this->tpl->setVariable('JS_ALL_PERMS', "['" . implode("','", $row['ops']) . "']");
218 $this->tpl->setVariable('JS_FORM_NAME', $this->getFormName());
219 $this->tpl->setVariable('TXT_SEL_ALL', $this->lng->txt('select_all'));
220 if ($row["template"][$id]) {
221 $this->tpl->setVariable('ALL_DISABLED', "disabled='disabled'");
222 }
223 $this->tpl->parseCurrentBlock();
224 }
225 }
226
227
231 protected function fillHeaderCommand($row)
232 {
236 foreach ($row["positions"] as $position) {
237 $this->tpl->setCurrentBlock('header_command');
238 $this->tpl->setVariable('POSITION_ID', $position->getId());
239 $this->tpl->setVariable('HEADER_COMMAND_TXT', $this->dic()
240 ->language()
241 ->txt('positions_override_operations'));
242 if (ilOrgUnitPermissionQueries::hasLocalSet($this->getRefId(), $position->getId())) {
243 $this->tpl->setVariable('HEADER_CHECKED', "checked='checked'");
244 }
245
246 $this->tpl->parseCurrentBlock();
247 }
248 }
249}
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
global $ilCtrl
Definition: ilias.php:18
$row
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.