ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 'frm~d:html':
106 $draft_id = $usage['id'];
107
108 include_once 'Modules/Forum/classes/class.ilForumPostDraft.php';
109 $oDraft = ilForumPostDraft::newInstanceByDraftId($draft_id);
110 if($user_id == $oDraft->getPostAuthorId())
111 {
112 return true;
113 }
114 break;
115 case 'frm~h:html':
116 $history_id = $usage['id'];
117 include_once 'Modules/Forum/classes/class.ilForumDraftsHistory.php';
118 include_once 'Modules/Forum/classes/class.ilForumPostDraft.php';
119
120 $oHistoryDraft = new ilForumDraftsHistory($history_id);
121 $oDraft = ilForumPostDraft::newInstanceByDraftId($oHistoryDraft->getDraftId());
122 if($user_id == $oDraft->getPostAuthorId())
123 {
124 return true;
125 }
126 break;
127 case 'qpl:pg':
128 case 'qpl:html':
129 // test questions
130 if ($this->checkAccessTestQuestion($oid, $usage['id'])) {
131 return true;
132 }
133 break;
134
135 case 'gdf:pg':
136 // special check for glossary terms
137 if ($this->checkAccessGlossaryTerm($oid, $usage['id'])) {
138 return true;
139 }
140 break;
141
142 case 'sahs:pg':
143 // check for scorm pages
144 if ($this->checkAccessObject($oid, 'sahs')) {
145 return true;
146 }
147 break;
148
149 case 'prtf:pg':
150 // special check for portfolio pages
151 if ($this->checkAccessPortfolioPage($oid, $usage['id'])) {
152 return true;
153 }
154 break;
155
156 case 'blp:pg':
157 // special check for blog pages
158 if ($this->checkAccessBlogPage($oid, $usage['id'])) {
159 return true;
160 }
161 break;
162
163 case 'lobj:pg':
164 // special check for learning objective pages
165 if ($this->checkAccessLearningObjectivePage($oid, $usage['id'])) {
166 return true;
167 }
168 break;
169
170 case 'impr:pg':
171 include_once 'Services/Imprint/classes/class.ilImprint.php';
172
173 return (ilImprint::isActive() || $this->checkAccessObject(SYSTEM_FOLDER_ID, 'adm'));
174
175 case 'cstr:pg':
176 default:
177 // standard object check
178 if ($this->checkAccessObject($oid)) {
179
180 return true;
181 }
182 break;
183 }
184
185 return false;
186 }
187
188
196 protected function checkAccessObject($obj_id, $obj_type = '') {
197 global $ilAccess, $ilUser;
198 $user_id = $ilUser->getId();
199
200 if (! $obj_type) {
201 $obj_type = ilObject::_lookupType($obj_id);
202 }
203 $ref_ids = ilObject::_getAllReferences($obj_id);
204
205 foreach ($ref_ids as $ref_id) {
206 // foreach ($this->check_users as $user_id) {
207 if ($ilAccess->checkAccessOfUser($user_id, "read", "view", $ref_id, $obj_type, $obj_id)) {
208 return true;
209 }
210 // }
211 }
212
213 return false;
214 }
215
216
226 protected function checkAccessTestQuestion($obj_id, $usage_id = 0) {
227 global $ilAccess;
228
229 // give access if direct usage is readable
230 if ($this->checkAccessObject($obj_id)) {
231 return true;
232 }
233
234 $obj_type = ilObject::_lookupType($obj_id);
235 if ($obj_type == 'qpl') {
236 // give access if question pool is used by readable test
237 // for random selection of questions
238 include_once('./Modules/Test/classes/class.ilObjTestAccess.php');
240 foreach ($tests as $test_id) {
241 if ($this->checkAccessObject($test_id, 'tst')) {
242 return true;
243 }
244 }
245 }
246
247 return false;
248 }
249
250
260 protected function checkAccessGlossaryTerm($obj_id, $page_id) {
261 // give access if glossary is readable
262 if ($this->checkAccessObject($obj_id)) {
263 return true;
264 }
265
266 include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
267 include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
268 $term_id = ilGlossaryDefinition::_lookupTermId($page_id);
269
270 include_once('./Services/Link/classes/class.ilInternalLink.php');
271 $sources = ilInternalLink::_getSourcesOfTarget('git', $term_id, 0);
272
273 if ($sources) {
274 foreach ($sources as $src) {
275 switch ($src['type']) {
276 // Give access if term is linked by a learning module with read access.
277 // The term including media is shown by the learning module presentation!
278 case 'lm:pg':
279 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
280 $src_obj_id = ilLMObject::_lookupContObjID($src['id']);
281 if ($this->checkAccessObject($src_obj_id, 'lm')) {
282 return true;
283 }
284 break;
285
286 // Don't yet give access if the term is linked by another glossary
287 // The link will lead to the origin glossary which is already checked
288 /*
289 case 'gdf:pg':
290 $src_term_id = ilGlossaryDefinition::_lookupTermId($src['id']);
291 $src_obj_id = ilGlossaryTerm::_lookGlossaryID($src_term_id);
292 if ($this->checkAccessObject($src_obj_id, 'glo'))
293 {
294 return true;
295 }
296 break;
297 */
298 }
299 }
300 }
301 }
302
303
312 protected function checkAccessPortfolioPage($obj_id, $page_id) {
313 global $ilUser;
314 include_once "Modules/Portfolio/classes/class.ilPortfolioAccessHandler.php";
315 $access_handler = new ilPortfolioAccessHandler();
316 if ($access_handler->checkAccessOfUser($ilUser->getId(), "read", "view", $obj_id, "prtf")) {
317 return true;
318 }
319
320 return false;
321 }
322
323
332 protected function checkAccessBlogPage($obj_id) {
333 global $ilUser;
334 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
335 $tree = new ilWorkspaceTree(0);
336 $node_id = $tree->lookupNodeId($obj_id);
337 if (! $node_id) {
338 return $this->checkAccessObject($obj_id);
339 } else {
340 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
341
342 $access_handler = new ilWorkspaceAccessHandler($tree);
343 if ($access_handler->checkAccessOfUser($tree, $ilUser->getId(), "read", "view", $node_id, "blog")) {
344 return true;
345 }
346 }
347
348 return false;
349 }
350
351
358 protected function checkAccessLearningObjectivePage($obj_id, $page_id) {
359 include_once "Modules/Course/classes/class.ilCourseObjective.php";
361
362 return $this->checkAccessObject($crs_obj_id, 'crs');
363 }
364}
365
366?>
An exception for terminatinating execution or to throw for unit testing.
const NEWS_PUBLIC
static _lookupContainerIdByObjectiveId($a_objective_id)
Get container of object.
Class ilForumDraftHistory.
static _lookupTermId($a_def_id)
Looks up term id for a definition id.
static isActive()
static _lookupContObjID($a_id)
get learning module / digibook id for lm object
static lookupUsages($a_id, $a_incl_hist=true)
Lookup usages of media object.
static _lookupVisibility($a_news_id)
Lookup News Visibility.
static _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.
static getParentObjectIdForUsage($a_usage, $a_include_all_access_obj_ids=false)
Get's the repository object ID of a parent object, if possible.
static lookupUsages($a_id, $a_include_history=true)
Lookup usages of media object.
static _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
$ilUser
Definition: imgupload.php:18