ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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;
23
24
27
36
40
44
47
50
53
57
62
65
66
67
68 // caching
69
70 protected function readContextIds($a_context_type)
71 {
72 global $ilDB;
73
74 switch ($a_context_type) {
76 return array($_REQUEST["ref_id"]);
77
79 $set = $ilDB->query("SELECT record_id id" .
80 " FROM adv_md_record");
81 break;
82
87 $set = $ilDB->query("SELECT field_id id" .
88 " FROM adv_mdf_definition");
89 break;
90
92 return ['crs','cat','sess'];
93
94 default:
95 return array();
96 }
97
98 $res = array();
99 while ($row = $ilDB->fetchAssoc($set)) {
100 $res[] = $row["id"];
101 }
102 return $res;
103 }
104
105
106 // permissions
107
108 protected function buildPermissionMap()
109 {
110 return array(
111 self::CONTEXT_MD => array(
112 "actions" => array(
113 self::ACTION_MD_CREATE_RECORD
114 ,self::ACTION_MD_IMPORT_RECORDS
115 )
116 ),
117 self::CONTEXT_RECORD => array(
118 "actions" => array(
119 self::ACTION_RECORD_EDIT
120 ,self::ACTION_RECORD_DELETE
121 ,self::ACTION_RECORD_EXPORT
122 ,self::ACTION_RECORD_TOGGLE_ACTIVATION
123 ,self::ACTION_RECORD_EDIT_FIELDS
124 ,self::ACTION_RECORD_FIELD_POSITIONS
125 ,self::ACTION_RECORD_CREATE_FIELD
126 ),
127 "subactions" => array(
128 self::ACTION_RECORD_EDIT_PROPERTY =>
129 array(
130 self::SUBACTION_RECORD_TITLE
131 ,self::SUBACTION_RECORD_DESCRIPTION
132 ,self::SUBACTION_RECORD_OBJECT_TYPES
133 )
134 )
135 ),
136 self::CONTEXT_FIELD => array(
137 "actions" => array(
138 self::ACTION_FIELD_EDIT,
139 self::ACTION_FIELD_DELETE
140 ),
141 "subactions" => array(
142 self::ACTION_FIELD_EDIT_PROPERTY =>
143 array(
144 self::SUBACTION_FIELD_TITLE
145 ,self::SUBACTION_FIELD_DESCRIPTION
146 ,self::SUBACTION_FIELD_SEARCHABLE
147 ,self::SUBACTION_FIELD_PROPERTIES
148 )
149 )
150 ),
151 self::CONTEXT_SUBSTITUTION => array(
152 "actions" => array(
153 self::ACTION_SUBSTITUTION_SHOW_DESCRIPTION
154 ,self::ACTION_SUBSTITUTION_SHOW_FIELDNAMES
155 ,self::ACTION_SUBSTITUTION_FIELD_POSITIONS
156 )
157 ),
158 self::CONTEXT_SUBSTITUTION_COURSE => array(
159 "actions" => array(
160 self::ACTION_SUBSTITUTION_COURSE_SHOW_FIELD
161 ),
162 "subactions" => array(
163 self::ACTION_SUBSTITUTION_COURSE_EDIT_FIELD_PROPERTY =>
164 array(
165 self::SUBACTION_SUBSTITUTION_BOLD
166 ,self::SUBACTION_SUBSTITUTION_NEWLINE
167 )
168 )
169 ),
170 self::CONTEXT_SUBSTITUTION_CATEGORY => array(
171 "actions" => array(
172 self::ACTION_SUBSTITUTION_CATEGORY_SHOW_FIELD
173 ),
174 "subactions" => array(
175 self::ACTION_SUBSTITUTION_CATEGORY_EDIT_FIELD_PROPERTY =>
176 array(
177 self::SUBACTION_SUBSTITUTION_BOLD
178 ,self::SUBACTION_SUBSTITUTION_NEWLINE
179 )
180 )
181 ),
182 self::CONTEXT_SUBSTITUTION_SESSION => array(
183 "actions" => array(
184 self::ACTION_SUBSTITUTION_SESSION_SHOW_FIELD
185 ),
186 "subactions" => array(
187 self::ACTION_SUBSTITUTION_SESSION_EDIT_FIELD_PROPERTY =>
188 array(
189 self::SUBACTION_SUBSTITUTION_BOLD
190 ,self::SUBACTION_SUBSTITUTION_NEWLINE
191 )
192 )
193 )
194
195 );
196 }
197
198
199 // plugins
200
201 protected function getActivePlugins()
202 {
203 global $ilPluginAdmin;
204
205 $res = array();
206
207 foreach ($ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "AdvancedMetaData", "amdc") as $plugin_name) {
208 $res[] = $ilPluginAdmin->getPluginObject(
210 "AdvancedMetaData",
211 "amdc",
212 $plugin_name
213 );
214 }
215
216 return $res;
217 }
218
219 protected function checkPermission($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id = null)
220 {
221 global $ilAccess;
222
223 if (!$this->checkPlugins($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id)) {
224 return false;
225 }
226
227 // export is considered read-action
230 return $ilAccess->checkAccessOfUser($this->getUserId(), "read", "", $this->getRefId());
231 }
232
233 return $this->checkRBAC();
234 }
235}
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.
foreach($_POST as $key=> $value) $res
global $ilDB
$a_context_id
Definition: workflow.php:97
$a_context_type
Definition: workflow.php:96