ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilAdvancedMDPermissionHelper.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once "Services/Component/classes/class.ilClaimingPermissionHelper.php";
5
15{
16 const CONTEXT_MD = 1;
17 const CONTEXT_RECORD = 2;
18 const CONTEXT_FIELD = 3;
25
26
29
38
42
46
49
52
55
58
61
65
70
73
74
75
76 // caching
77
78 protected function readContextIds($a_context_type)
79 {
80 global $DIC;
81
82 $ilDB = $DIC['ilDB'];
83
84 switch ($a_context_type) {
86 return array($_REQUEST["ref_id"]);
87
89 $set = $ilDB->query("SELECT record_id id" .
90 " FROM adv_md_record");
91 break;
92
99 $set = $ilDB->query("SELECT field_id id" .
100 " FROM adv_mdf_definition");
101 break;
102
104 return ['crs','cat','sess','iass','grp'];
105
106 default:
107 return array();
108 }
109
110 $res = array();
111 while ($row = $ilDB->fetchAssoc($set)) {
112 $res[] = $row["id"];
113 }
114 return $res;
115 }
116
117
118 // permissions
119
120 protected function buildPermissionMap()
121 {
122 return array(
123 self::CONTEXT_MD => array(
124 "actions" => array(
125 self::ACTION_MD_CREATE_RECORD
126 ,self::ACTION_MD_IMPORT_RECORDS
127 )
128 ),
129 self::CONTEXT_RECORD => array(
130 "actions" => array(
131 self::ACTION_RECORD_EDIT
132 ,self::ACTION_RECORD_DELETE
133 ,self::ACTION_RECORD_EXPORT
134 ,self::ACTION_RECORD_TOGGLE_ACTIVATION
135 ,self::ACTION_RECORD_EDIT_FIELDS
136 ,self::ACTION_RECORD_FIELD_POSITIONS
137 ,self::ACTION_RECORD_CREATE_FIELD
138 ),
139 "subactions" => array(
140 self::ACTION_RECORD_EDIT_PROPERTY =>
141 array(
142 self::SUBACTION_RECORD_TITLE
143 ,self::SUBACTION_RECORD_DESCRIPTION
144 ,self::SUBACTION_RECORD_OBJECT_TYPES
145 )
146 )
147 ),
148 self::CONTEXT_FIELD => array(
149 "actions" => array(
150 self::ACTION_FIELD_EDIT,
151 self::ACTION_FIELD_DELETE
152 ),
153 "subactions" => array(
154 self::ACTION_FIELD_EDIT_PROPERTY =>
155 array(
156 self::SUBACTION_FIELD_TITLE
157 ,self::SUBACTION_FIELD_DESCRIPTION
158 ,self::SUBACTION_FIELD_SEARCHABLE
159 ,self::SUBACTION_FIELD_PROPERTIES
160 )
161 )
162 ),
163 self::CONTEXT_SUBSTITUTION => array(
164 "actions" => array(
165 self::ACTION_SUBSTITUTION_SHOW_DESCRIPTION
166 ,self::ACTION_SUBSTITUTION_SHOW_FIELDNAMES
167 ,self::ACTION_SUBSTITUTION_FIELD_POSITIONS
168 )
169 ),
170 self::CONTEXT_SUBSTITUTION_COURSE => array(
171 "actions" => array(
172 self::ACTION_SUBSTITUTION_COURSE_SHOW_FIELD
173 ),
174 "subactions" => array(
175 self::ACTION_SUBSTITUTION_COURSE_EDIT_FIELD_PROPERTY =>
176 array(
177 self::SUBACTION_SUBSTITUTION_BOLD
178 ,self::SUBACTION_SUBSTITUTION_NEWLINE
179 )
180 )
181 ),
182 self::CONTEXT_SUBSTITUTION_CATEGORY => array(
183 "actions" => array(
184 self::ACTION_SUBSTITUTION_CATEGORY_SHOW_FIELD
185 ),
186 "subactions" => array(
187 self::ACTION_SUBSTITUTION_CATEGORY_EDIT_FIELD_PROPERTY =>
188 array(
189 self::SUBACTION_SUBSTITUTION_BOLD
190 ,self::SUBACTION_SUBSTITUTION_NEWLINE
191 )
192 )
193 ),
194 self::CONTEXT_SUBSTITUTION_SESSION => array(
195 "actions" => array(
196 self::ACTION_SUBSTITUTION_SESSION_SHOW_FIELD
197 ),
198 "subactions" => array(
199 self::ACTION_SUBSTITUTION_SESSION_EDIT_FIELD_PROPERTY =>
200 array(
201 self::SUBACTION_SUBSTITUTION_BOLD
202 ,self::SUBACTION_SUBSTITUTION_NEWLINE
203 )
204 )
205 ),
206 self::CONTEXT_SUBSTITUTION_GROUP => array(
207 "actions" => array(
208 self::ACTION_SUBSTITUTION_GROUP_SHOW_FIELD
209 ),
210 "subactions" => array(
211 self::ACTION_SUBSTITUTION_GROUP_EDIT_FIELD_PROPERTY =>
212 array(
213 self::SUBACTION_SUBSTITUTION_BOLD
214 ,self::SUBACTION_SUBSTITUTION_NEWLINE
215 )
216 )
217 ),
218 self::CONTEXT_SUBSTITUTION_IASS => array(
219 "actions" => array(
220 self::ACTION_SUBSTITUTION_IASS_SHOW_FIELD
221 ),
222 "subactions" => array(
223 self::ACTION_SUBSTITUTION_IASS_EDIT_FIELD_PROPERTY =>
224 array(
225 self::SUBACTION_SUBSTITUTION_BOLD
226 ,self::SUBACTION_SUBSTITUTION_NEWLINE
227 )
228 )
229 )
230 );
231 }
232
233
234 // plugins
235
236 protected function getActivePlugins()
237 {
238 global $DIC;
239
240 $ilPluginAdmin = $DIC['ilPluginAdmin'];
241
242 $res = array();
243
244 foreach ($ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "AdvancedMetaData", "amdc") as $plugin_name) {
245 $res[] = $ilPluginAdmin->getPluginObject(
247 "AdvancedMetaData",
248 "amdc",
249 $plugin_name
250 );
251 }
252
253 return $res;
254 }
255
256 protected function checkPermission($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id = null)
257 {
258 global $DIC;
259
260 $ilAccess = $DIC['ilAccess'];
261
262 if (!$this->checkPlugins($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id)) {
263 return false;
264 }
265
266 // export is considered read-action
269 return $ilAccess->checkAccessOfUser($this->getUserId(), "read", "", $this->getRefId());
270 }
271
272 return $this->checkRBAC();
273 }
274}
An exception for terminatinating execution or to throw for unit testing.
const IL_COMP_SERVICE
Advanced metadata permission helper.
buildPermissionMap()
Build map of context and actions.
checkPermission($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id=null)
Check permission (helper: rbac, plugins)
readContextIds($a_context_type)
Get all context ids for context type (from DB, is cached)
getActivePlugins()
Get active plugins (for current slot)
Claiming permission helper base class.
checkPlugins($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id=null)
Check permission against plugins.
checkRBAC()
Check permission against RBAC.
$row
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
global $ilDB
$a_context_id
Definition: workflow.php:97
$a_context_type
Definition: workflow.php:96