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 
4 include_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 
28  const ACTION_RECORD_EDIT = 5;
36 
37  const ACTION_FIELD_EDIT = 13;
38  const ACTION_FIELD_DELETE = 14;
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) {
75  case self::CONTEXT_MD:
76  return array($_REQUEST["ref_id"]);
77 
78  case self::CONTEXT_RECORD:
79  $set = $ilDB->query("SELECT record_id id" .
80  " FROM adv_md_record");
81  break;
82 
83  case self::CONTEXT_FIELD:
84  case self::CONTEXT_SUBSTITUTION_COURSE:
85  case self::CONTEXT_SUBSTITUTION_CATEGORY:
86  case self::CONTEXT_SUBSTITUTION_SESSION:
87  $set = $ilDB->query("SELECT field_id id" .
88  " FROM adv_mdf_definition");
89  break;
90 
91  case self::CONTEXT_SUBSTITUTION:
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 }
Claiming permission helper base class.
$a_context_id
Definition: workflow.php:97
Advanced metadata permission helper.
foreach($_POST as $key=> $value) $res
checkRBAC()
Check permission against RBAC.
Create styles array
The data for the language used.
checkPlugins($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id=null)
Check permission against plugins.
$a_context_type
Definition: workflow.php:96
checkPermission($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id=null)
global $ilDB
const IL_COMP_SERVICE