ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilObjMediaObjectAccess.php
Go to the documentation of this file.
1<?php
2require_once('./Services/WebAccessChecker/interfaces/interface.ilWACCheckingClass.php');
3require_once('./Services/MediaObjects/classes/class.ilObjMediaObject.php');
4
12
18 public function canBeDelivered(ilWACPath $ilWACPath) {
19 preg_match("/.\\/data\\/.*\\/mm_([0-9]*)\\/.*/ui", $ilWACPath->getPath(), $matches);
20 $obj_id = $matches[1];
21
22 return $this->checkAccessMob($obj_id);
23 }
24
25
31 protected function checkAccessMob($obj_id) {
32 foreach (ilObjMediaObject::lookupUsages($obj_id) as $usage) {
34
35 // for content snippets we must get their usages and check them
36 switch ($usage["type"]) {
37 case "auth:pg":
38 // Mobs on the Loginpage should always be delivered
39 return true;
40 case "mep:pg":
41 include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
42 $usages2 = ilMediaPoolPage::lookupUsages($usage["id"]);
43 foreach ($usages2 as $usage2) {
45 if ($this->checkAccessMobUsage($usage2, $oid2)) {
46 return true;
47 }
48 }
49 break;
50
51 default:
52 if ($this->checkAccessMobUsage($usage, $oid)) {
53 return true;
54 }
55 break;
56 }
57 }
58
59 return false;
60 }
61
62
69 protected function checkAccessMobUsage($usage, $oid) {
73 global $ilObjDataCache, $ilUser;
74 $user_id = $ilUser->getId();
75
76 switch ($usage['type']) {
77 case 'lm:pg':
78 if ($this->checkAccessObject($oid, 'lm')) {
79 return true;
80 }
81 break;
82
83 case 'news':
84 // media objects in news (media casts)
85 include_once("./Modules/MediaCast/classes/class.ilObjMediaCastAccess.php");
86 include_once("./Services/News/classes/class.ilNewsItem.php");
87
88 if ($this->checkAccessObject($oid, 'mcst')) {
89 return true;
91 return true;
92 }
93 break;
94
95 case 'frm~:html':
96 case 'exca~:html':
97 // $oid = userid
98 // foreach ($this->check_users as $user_id) {
99 if ($ilObjDataCache->lookupType($oid) == 'usr' && $oid == $user_id) {
100 return true;
101 }
102 // }
103 break;
104
105 case 'qpl:pg':
106 case 'qpl:html':
107 // test questions
108 if ($this->checkAccessTestQuestion($oid, $usage['id'])) {
109 return true;
110 }
111 break;
112
113 case 'gdf:pg':
114 // special check for glossary terms
115 if ($this->checkAccessGlossaryTerm($oid, $usage['id'])) {
116 return true;
117 }
118 break;
119
120 case 'sahs:pg':
121 // check for scorm pages
122 if ($this->checkAccessObject($oid, 'sahs')) {
123 return true;
124 }
125 break;
126
127 case 'prtf:pg':
128 // special check for portfolio pages
129 if ($this->checkAccessPortfolioPage($oid, $usage['id'])) {
130 return true;
131 }
132 break;
133
134 case 'blp:pg':
135 // special check for blog pages
136 if ($this->checkAccessBlogPage($oid, $usage['id'])) {
137 return true;
138 }
139 break;
140
141 case 'lobj:pg':
142 // special check for learning objective pages
143 if ($this->checkAccessLearningObjectivePage($oid, $usage['id'])) {
144 return true;
145 }
146 break;
147
148 case 'impr:pg':
149 include_once 'Services/Imprint/classes/class.ilImprint.php';
150
151 return (ilImprint::isActive() || $this->checkAccessObject(SYSTEM_FOLDER_ID, 'adm'));
152
153 case 'cstr:pg':
154 default:
155 // standard object check
156 if ($this->checkAccessObject($oid)) {
157
158 return true;
159 }
160 break;
161 }
162
163 return false;
164 }
165
166
174 protected function checkAccessObject($obj_id, $obj_type = '') {
175 global $ilAccess, $ilUser;
176 $user_id = $ilUser->getId();
177
178 if (! $obj_type) {
179 $obj_type = ilObject::_lookupType($obj_id);
180 }
181 $ref_ids = ilObject::_getAllReferences($obj_id);
182
183 foreach ($ref_ids as $ref_id) {
184 // foreach ($this->check_users as $user_id) {
185 if ($ilAccess->checkAccessOfUser($user_id, "read", "view", $ref_id, $obj_type, $obj_id)) {
186 return true;
187 }
188 // }
189 }
190
191 return false;
192 }
193
194
204 protected function checkAccessTestQuestion($obj_id, $usage_id = 0) {
205 global $ilAccess;
206
207 // give access if direct usage is readable
208 if ($this->checkAccessObject($obj_id)) {
209 return true;
210 }
211
212 $obj_type = ilObject::_lookupType($obj_id);
213 if ($obj_type == 'qpl') {
214 // give access if question pool is used by readable test
215 // for random selection of questions
216 include_once('./Modules/Test/classes/class.ilObjTestAccess.php');
218 foreach ($tests as $test_id) {
219 if ($this->checkAccessObject($test_id, 'tst')) {
220 return true;
221 }
222 }
223 }
224
225 return false;
226 }
227
228
238 protected function checkAccessGlossaryTerm($obj_id, $page_id) {
239 // give access if glossary is readable
240 if ($this->checkAccessObject($obj_id)) {
241 return true;
242 }
243
244 include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
245 include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
246 $term_id = ilGlossaryDefinition::_lookupTermId($page_id);
247
248 include_once('./Services/Link/classes/class.ilInternalLink.php');
249 $sources = ilInternalLink::_getSourcesOfTarget('git', $term_id, 0);
250
251 if ($sources) {
252 foreach ($sources as $src) {
253 switch ($src['type']) {
254 // Give access if term is linked by a learning module with read access.
255 // The term including media is shown by the learning module presentation!
256 case 'lm:pg':
257 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
258 $src_obj_id = ilLMObject::_lookupContObjID($src['id']);
259 if ($this->checkAccessObject($src_obj_id, 'lm')) {
260 return true;
261 }
262 break;
263
264 // Don't yet give access if the term is linked by another glossary
265 // The link will lead to the origin glossary which is already checked
266 /*
267 case 'gdf:pg':
268 $src_term_id = ilGlossaryDefinition::_lookupTermId($src['id']);
269 $src_obj_id = ilGlossaryTerm::_lookGlossaryID($src_term_id);
270 if ($this->checkAccessObject($src_obj_id, 'glo'))
271 {
272 return true;
273 }
274 break;
275 */
276 }
277 }
278 }
279 }
280
281
290 protected function checkAccessPortfolioPage($obj_id, $page_id) {
291 global $ilUser;
292 include_once "Modules/Portfolio/classes/class.ilPortfolioAccessHandler.php";
293 $access_handler = new ilPortfolioAccessHandler();
294 if ($access_handler->checkAccessOfUser($ilUser->getId(), "read", "view", $obj_id, "prtf")) {
295 return true;
296 }
297
298 return false;
299 }
300
301
310 protected function checkAccessBlogPage($obj_id) {
311 global $ilUser;
312 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
313 $tree = new ilWorkspaceTree(0);
314 $node_id = $tree->lookupNodeId($obj_id);
315 if (! $node_id) {
316 return $this->checkAccessObject($obj_id);
317 } else {
318 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
319
320 $access_handler = new ilWorkspaceAccessHandler($tree);
321 if ($access_handler->checkAccessOfUser($tree, $ilUser->getId(), "read", "view", $node_id, "blog")) {
322 return true;
323 }
324 }
325
326 return false;
327 }
328
329
336 protected function checkAccessLearningObjectivePage($obj_id, $page_id) {
337 include_once "Modules/Course/classes/class.ilCourseObjective.php";
339
340 return $this->checkAccessObject($crs_obj_id, 'crs');
341 }
342}
343
344?>
const NEWS_PUBLIC
static _lookupContainerIdByObjectiveId($a_objective_id)
Get container of object.
_lookupTermId($a_def_id)
Looks up term id for a definition id.
static isActive()
_lookupContObjID($a_id)
get learning module / digibook id for lm object
lookupUsages($a_id, $a_incl_hist=true)
Lookup usages of media object.
static _lookupVisibility($a_news_id)
Lookup News Visibility.
_lookupPublicFiles($a_id)
Check wether files should be public.
Class ilObjMediaObjectAccess.
canBeDelivered(ilWACPath $ilWACPath)
checkAccessLearningObjectivePage($obj_id, $page_id)
checkAccessGlossaryTerm($obj_id, $page_id)
Check access rights for glossary terms This checks also learning modules linking the term.
checkAccessPortfolioPage($obj_id, $page_id)
Check access rights for portfolio pages.
checkAccessTestQuestion($obj_id, $usage_id=0)
Check access rights for a test question This checks also tests with random selection of questions.
checkAccessBlogPage($obj_id)
Check access rights for blog pages.
checkAccessObject($obj_id, $obj_type='')
Check access rights for an object by its object id.
lookupUsages($a_id, $a_include_history=true)
Lookup usages of media object.
getParentObjectIdForUsage($a_usage, $a_include_all_access_obj_ids=false)
Get's the repository object ID of a parent object, if possible.
_getRandomTestsForQuestionPool($qpl_id)
Get all tests using a question pool for random selection.
static _getAllReferences($a_id)
get all reference ids of object
static _lookupType($a_id, $a_reference=false)
lookup object type
Access handler for portfolio.
Class ilWACPath.
Access handler for personal workspace.
Tree handler for personal workspace.
Class ilWACCheckingClass.
$ref_id
Definition: sahs_server.php:39
global $ilUser
Definition: imgupload.php:15