ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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;
22 
23 
26 
27  const ACTION_RECORD_EDIT = 5;
35 
36  const ACTION_FIELD_EDIT = 13;
37  const ACTION_FIELD_DELETE = 14;
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  {
73  case self::CONTEXT_MD:
74  return array($_REQUEST["ref_id"]);
75 
76  case self::CONTEXT_RECORD:
77  $set = $ilDB->query("SELECT record_id id".
78  " FROM adv_md_record");
79  break;
80 
81  case self::CONTEXT_FIELD:
82  case self::CONTEXT_SUBSTITUTION_COURSE:
83  case self::CONTEXT_SUBSTITUTION_CATEGORY:
84  $set = $ilDB->query("SELECT field_id id".
85  " FROM adv_mdf_definition");
86  break;
87 
88  case self::CONTEXT_SUBSTITUTION:
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 
202 ?>