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