ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilObjMediaObjectAccess Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilObjMediaObjectAccess:
+ Collaboration diagram for ilObjMediaObjectAccess:

Public Member Functions

 __construct ()
 
 canBeDelivered (ilWACPath $ilWACPath)
 
 canBeDelivered (ilWACPath $ilWACPath)
 

Protected Member Functions

 checkAccessMob (int $obj_id)
 
 checkAccessObject (int $obj_id, string $obj_type='')
 Check access rights for an object by its object id. More...
 
 checkAccessTestQuestion (int $obj_id, int $usage_id=0)
 Check access rights for a test question This checks also tests with random selection of questions. More...
 
 checkAccessGlossaryTerm (int $obj_id, int $page_id)
 Check access rights for glossary terms This checks also learning modules linking the term. More...
 
 checkAccessPortfolioPage (int $obj_id, int $page_id)
 Check access rights for portfolio pages. More...
 
 checkAccessBlogPage (int $obj_id)
 Check access rights for blog pages. More...
 
 checkAccessLearningObjectivePage (int $obj_id, int $page_id)
 

Protected Attributes

ilObjectDataCache $obj_data_cache
 
ilObjUser $user
 
ilAccessHandler $access
 
ilLogger $logger
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilObjMediaObjectAccess

Author
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch

Definition at line 23 of file class.ilObjMediaObjectAccess.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjMediaObjectAccess::__construct ( )

Definition at line 30 of file class.ilObjMediaObjectAccess.php.

31 {
32 global $DIC;
33
34 $this->obj_data_cache = $DIC["ilObjDataCache"];
35 $this->user = $DIC->user();
36 $this->access = $DIC->access();
37 $this->logger = $DIC->logger()->mob();
38 }
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\access(), ILIAS\Repository\logger(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ canBeDelivered()

ilObjMediaObjectAccess::canBeDelivered ( ilWACPath  $ilWACPath)

Implements ilWACCheckingClass.

Definition at line 40 of file class.ilObjMediaObjectAccess.php.

40 : bool
41 {
42 preg_match("/.\\/public\/data\\/.*\\/mm_([0-9]*)\\/.*/ui", $ilWACPath->getPath(), $matches);
43 $obj_id = $matches[1] ?? 0;
44
45 return $this->checkAccessMob($obj_id);
46 }

References checkAccessMob(), and ilWACPath\getPath().

+ Here is the call graph for this function:

◆ checkAccessBlogPage()

ilObjMediaObjectAccess::checkAccessBlogPage ( int  $obj_id)
protected

Check access rights for blog pages.

Parameters
int$obj_idblog page id

Definition at line 340 of file class.ilObjMediaObjectAccess.php.

342 : bool {
343 $ilUser = $this->user;
344 $tree = new ilWorkspaceTree(0);
345 $node_id = $tree->lookupNodeId($obj_id);
346 if (!$node_id) {
347 return $this->checkAccessObject($obj_id);
348 } else {
349 $access_handler = new ilWorkspaceAccessHandler($tree);
350 if ($access_handler->checkAccessOfUser($tree, $ilUser->getId(), "read", "view", $node_id, "blog")) {
351 return true;
352 }
353 }
354
355 return false;
356 }
checkAccessObject(int $obj_id, string $obj_type='')
Check access rights for an object by its object id.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ checkAccessGlossaryTerm()

ilObjMediaObjectAccess::checkAccessGlossaryTerm ( int  $obj_id,
int  $page_id 
)
protected

Check access rights for glossary terms This checks also learning modules linking the term.

Parameters
int$obj_idobject id (glossary)
int$page_idpage id (definition)
Returns
bool access given (true/false)

Definition at line 273 of file class.ilObjMediaObjectAccess.php.

276 : bool {
277 // give access if glossary is readable
278 if ($this->checkAccessObject($obj_id)) {
279 return true;
280 }
281
282 $term_id = $page_id;
283
284 $sources = ilInternalLink::_getSourcesOfTarget('git', $term_id, 0);
285
286 if ($sources) {
287 foreach ($sources as $src) {
288 switch ($src['type']) {
289 // Give access if term is linked by a learning module with read access.
290 // The term including media is shown by the learning module presentation!
291 case 'lm:pg':
292 $src_obj_id = ilLMObject::_lookupContObjID($src['id']);
293 if ($this->checkAccessObject($src_obj_id, 'lm')) {
294 return true;
295 }
296 break;
297
298 // Don't yet give access if the term is linked by another glossary
299 // The link will lead to the origin glossary which is already checked
300 /*
301 case 'gdf:pg':
302 $src_term_id = ilGlossaryDefinition::_lookupTermId($src['id']);
303 $src_obj_id = ilGlossaryTerm::_lookGlossaryID($src_term_id);
304 if ($this->checkAccessObject($src_obj_id, 'glo'))
305 {
306 return true;
307 }
308 break;
309 */
310 }
311 }
312 }
313 return false;
314 }
static _lookupContObjID(int $a_id)
get learning module id for lm object

◆ checkAccessLearningObjectivePage()

ilObjMediaObjectAccess::checkAccessLearningObjectivePage ( int  $obj_id,
int  $page_id 
)
protected

Definition at line 359 of file class.ilObjMediaObjectAccess.php.

362 : bool {
364
365 return $this->checkAccessObject($crs_obj_id, 'crs');
366 }
static _lookupContainerIdByObjectiveId(int $a_objective_id)

◆ checkAccessMob()

ilObjMediaObjectAccess::checkAccessMob ( int  $obj_id)
protected

Definition at line 48 of file class.ilObjMediaObjectAccess.php.

50 : bool {
51
52 foreach (ilObjMediaObject::lookupUsages($obj_id) as $usage) {
54 // for content snippets we must get their usages and check them
55 switch ($usage["type"]) {
56 case "auth:pg":
57 // Mobs on the Loginpage should always be delivered
58 return true;
59 case "mep:pg":
60 $usages2 = ilMediaPoolPage::lookupUsages($usage["id"]);
61 foreach ($usages2 as $usage2) {
63 if ($this->checkAccessMobUsage($usage2, $oid2)) {
64 return true;
65 }
66 }
67 break;
68
69 case "clip":
70 if ($usage["id"] == $this->user->getId()) {
71 return true;
72 }
73 break;
74
75 default:
76 if ($oid !== null && $this->checkAccessMobUsage($usage, $oid)) {
77 return true;
78 }
79
80 if ($oid === null) {
81 $this->logger->error(
82 sprintf(
83 "Could not determine parent obj_id for usage: %s",
84 json_encode($usage, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT)
85 )
86 );
87 }
88 break;
89 }
90 }
91
92 return false;
93 }
static lookupUsages(int $a_id, bool $a_incl_hist=true)
Lookup usages of media object.
static getParentObjectIdForUsage(array $a_usage, bool $a_include_all_access_obj_ids=false)
Get's the repository object ID of a parent object, if possible see ilWebAccessChecker.
static lookupUsages(int $a_id, bool $a_include_history=true)
Lookup usages of media object.

References ilObjMediaObject\getParentObjectIdForUsage(), ILIAS\Repository\logger(), ilMediaPoolPage\lookupUsages(), and ILIAS\Repository\user().

Referenced by canBeDelivered().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkAccessObject()

ilObjMediaObjectAccess::checkAccessObject ( int  $obj_id,
string  $obj_type = '' 
)
protected

Check access rights for an object by its object id.

Definition at line 211 of file class.ilObjMediaObjectAccess.php.

214 : bool {
215 $ilAccess = $this->access;
216 $ilUser = $this->user;
217 $user_id = $ilUser->getId();
218
219 if (!$obj_type) {
220 $obj_type = ilObject::_lookupType($obj_id);
221 }
222 $ref_ids = ilObject::_getAllReferences($obj_id);
223
224 foreach ($ref_ids as $ref_id) {
225 // foreach ($this->check_users as $user_id) {
226 if ($ilAccess->checkAccessOfUser($user_id, "read", "view", $ref_id, $obj_type, $obj_id)) {
227 return true;
228 }
229 // }
230 }
231
232 return false;
233 }
static _lookupType(int $id, bool $reference=false)
static _getAllReferences(int $id)
get all reference ids for object ID
$ref_id
Definition: ltiauth.php:66

References ilObject\_lookupType().

+ Here is the call graph for this function:

◆ checkAccessPortfolioPage()

ilObjMediaObjectAccess::checkAccessPortfolioPage ( int  $obj_id,
int  $page_id 
)
protected

Check access rights for portfolio pages.

Parameters
int$obj_idobject id (glossary)
int$page_idpage id (definition)

Definition at line 322 of file class.ilObjMediaObjectAccess.php.

325 : bool {
326 $ilUser = $this->user;
327 $access_handler = new ilPortfolioAccessHandler();
328 if ($access_handler->checkAccessOfUser($ilUser->getId(), "read", "view", $obj_id, "prtf")) {
329 return true;
330 }
331
332 return false;
333 }
Access handler for portfolio NOTE: This file needs to stay in the classes directory,...

◆ checkAccessTestQuestion()

ilObjMediaObjectAccess::checkAccessTestQuestion ( int  $obj_id,
int  $usage_id = 0 
)
protected

Check access rights for a test question This checks also tests with random selection of questions.

Parameters
int$obj_idobject id (question pool or test)

Definition at line 241 of file class.ilObjMediaObjectAccess.php.

244 : bool {
245 // give access if direct usage is readable
246 if ($this->checkAccessObject($obj_id)) {
247 return true;
248 }
249
250 $obj_type = ilObject::_lookupType($obj_id);
251 if ($obj_type == 'qpl') {
252 // give access if question pool is used by readable test
253 // for random selection of questions
255 foreach ($tests as $test_id) {
256 if ($this->checkAccessObject($test_id, 'tst')) {
257 return true;
258 }
259 }
260 }
261
262 return false;
263 }
static _getRandomTestsForQuestionPool(int $qpl_id)
Get all tests using a question pool for random selection.

Field Documentation

◆ $access

ilAccessHandler ilObjMediaObjectAccess::$access
protected

Definition at line 27 of file class.ilObjMediaObjectAccess.php.

◆ $logger

ilLogger ilObjMediaObjectAccess::$logger
protected

Definition at line 28 of file class.ilObjMediaObjectAccess.php.

◆ $obj_data_cache

ilObjectDataCache ilObjMediaObjectAccess::$obj_data_cache
protected

Definition at line 25 of file class.ilObjMediaObjectAccess.php.

◆ $user

ilObjUser ilObjMediaObjectAccess::$user
protected

Definition at line 26 of file class.ilObjMediaObjectAccess.php.


The documentation for this class was generated from the following file: