ILIAS  release_7 Revision v7.30-3-g800a261c036
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 $objdefinition = $this->dic()['objDefinition'];
100 $is_plugin = $objdefinition->isPlugin($this->getObjType());
101
102 foreach ($row as $permission) {
107 $position = $permission["position"];
108 $op_id = $permission["op_id"];
109 $operation = $permission["operation"];
110 $this->tpl->setCurrentBlock('position_td');
111 $this->tpl->setVariable('POSITION_ID', $position->getId());
112 $this->tpl->setVariable('PERM_ID', $op_id);
113
114 if ($is_plugin) {
115 $label = ilObjectPlugin::lookupTxtById($this->getObjType(), $operation->getOperationString());
116 } else {
117 $label = $this->dic()->language()->txt('org_op_' . $operation->getOperationString());
118 }
119
120 $this->tpl->setVariable('TXT_PERM', $label);
121 $this->tpl->setVariable('PERM_LONG', $op_id);
122
123 if ($permission['permission_set']) {
124 $this->tpl->setVariable('PERM_CHECKED', 'checked="checked"');
125 }
126 if ($permission['from_template']) {
127 $this->tpl->setVariable('PERM_DISABLED', 'disabled="disabled"');
128 }
129
130 $this->tpl->parseCurrentBlock();
131 }
132 }
133
134
135 public function collectData()
136 {
137 $positions = ilOrgUnitPosition::get();
138
139 $this->initColumns($positions);
140
141 $perms = [];
142
143 $operations = ilOrgUnitOperationQueries::getOperationsForContextName($this->getObjType());
144 $ops_ids = [];
145 $from_templates = [];
146 foreach ($operations as $op) {
147 $ops_ids[] = $op->getOperationId();
148
149 $ops = [];
150 foreach ($positions as $position) {
151 $ilOrgUnitPermission = ilOrgUnitPermissionQueries::getSetForRefId($this->getRefId(), $position->getId());
152
153 $is_template = $ilOrgUnitPermission->isTemplate();
154 $from_templates[$position->getId()] = $is_template;
155
156 $ops[] = [
157 "op_id" => $op->getOperationId(),
158 "operation" => $op,
159 "position" => $position,
160 "permission" => $ilOrgUnitPermission,
161 "permission_set" => $ilOrgUnitPermission->isOperationIdSelected($op->getOperationId()),
162 "from_template" => $is_template,
163 ];
164 }
165 $perms[] = $ops;
166 }
167
168 $perms[] = [
169 "show_select_all" => true,
170 "positions" => $positions,
171 "ops" => $ops_ids,
172 "template" => $from_templates,
173 ];
175 ->isPositionAccessActiveForObject($this->getObjId())
176 ) {
177 $perms[] = [
178 "header_command" => true,
179 "positions" => $positions,
180 "template" => $from_templates,
181 ];
182 }
183
184 $this->setData($perms);
185
186 return;
187 }
188
189
195 protected function initColumns(array $positions)
196 {
197 foreach ($positions as $position) {
198 $this->addColumn($position->getTitle(), '', '', '', false, $position->getDescription());
199 }
200
201 return true;
202 }
203
204
208 private function dic()
209 {
210 return $GLOBALS['DIC'];
211 }
212
213
217 protected function fillSelectAll($row)
218 {
222 foreach ($row["positions"] as $position) {
223 $this->tpl->setCurrentBlock('position_select_all');
224 $id = $position->getId();
225 $this->tpl->setVariable('JS_ROLE_ID', $id);
226 $this->tpl->setVariable('JS_SUBID', 0);
227 $this->tpl->setVariable('JS_ALL_PERMS', "['" . implode("','", $row['ops']) . "']");
228 $this->tpl->setVariable('JS_FORM_NAME', $this->getFormName());
229 $this->tpl->setVariable('TXT_SEL_ALL', $this->lng->txt('select_all'));
230 if ($row["template"][$id]) {
231 $this->tpl->setVariable('ALL_DISABLED', "disabled='disabled'");
232 }
233 $this->tpl->parseCurrentBlock();
234 }
235 }
236
237
241 protected function fillHeaderCommand($row)
242 {
246 foreach ($row["positions"] as $position) {
247 $this->tpl->setCurrentBlock('header_command');
248 $this->tpl->setVariable('POSITION_ID', $position->getId());
249 $this->tpl->setVariable('HEADER_COMMAND_TXT', $this->dic()
250 ->language()
251 ->txt('positions_override_operations'));
252 if (ilOrgUnitPermissionQueries::hasLocalSet($this->getRefId(), $position->getId())) {
253 $this->tpl->setVariable('HEADER_CHECKED', "checked='checked'");
254 }
255
256 $this->tpl->parseCurrentBlock();
257 }
258 }
259}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
An exception for terminatinating execution or to throw for unit testing.
static lookupTxtById($plugin_id, $lang_var)
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
language()
Definition: language.php:2
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc