ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilMobStakeholder Class Reference
+ Inheritance diagram for ilMobStakeholder:
+ Collaboration diagram for ilMobStakeholder:

Public Member Functions

 getId ()
 
 getOwnerOfNewResources ()
 
 canBeAccessedByCurrentUser (ResourceIdentification $identification)
 
 resourceHasBeenDeleted (ResourceIdentification $identification)
 
 getLocationURIForResourceUsage (ResourceIdentification $identification)
 
- Public Member Functions inherited from ILIAS\ResourceStorage\Stakeholder\AbstractResourceStakeholder
 __construct (?int $user_id_of_owner=null)
 
 setOwner (int $user_id_of_owner)
 
 getFullyQualifiedClassName ()
 
 isResourceInUse (ResourceIdentification $identification)
 
 canBeAccessedByCurrentUser (ResourceIdentification $identification)
 
 resourceHasBeenDeleted (ResourceIdentification $identification)
 
 getOwnerOfResource (ResourceIdentification $identification)
 
 getConsumerNameForPresentation ()
 
 getLocationURIForResourceUsage (ResourceIdentification $identification)
 
- Public Member Functions inherited from ILIAS\ResourceStorage\Stakeholder\ResourceStakeholder
 __construct ()
 Constructor must not have any parameters. More...
 
 getId ()
 
 getConsumerNameForPresentation ()
 
 getFullyQualifiedClassName ()
 
 canBeAccessedByCurrentUser (ResourceIdentification $identification)
 
 isResourceInUse (ResourceIdentification $identification)
 
 resourceHasBeenDeleted (ResourceIdentification $identification)
 
 getOwnerOfResource (ResourceIdentification $identification)
 
 getOwnerOfNewResources ()
 
 getLocationURIForResourceUsage (ResourceIdentification $identification)
 

Protected Member Functions

 checkAccessMobUsage (array $usage, int $oid)
 
 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

ilAccessHandler $access
 
ilDBInterface $database = null
 
- Protected Attributes inherited from ILIAS\ResourceStorage\Stakeholder\AbstractResourceStakeholder
int $default_owner
 
int $current_user
 

Private Member Functions

 resolveObjectId (ResourceIdentification $identification)
 
 initDB ()
 

Detailed Description

Definition at line 22 of file class.ilMobStakeholder.php.

Member Function Documentation

◆ canBeAccessedByCurrentUser()

ilMobStakeholder::canBeAccessedByCurrentUser ( ResourceIdentification  $identification)

Reimplemented from ILIAS\ResourceStorage\Stakeholder\AbstractResourceStakeholder.

Definition at line 37 of file class.ilMobStakeholder.php.

37 : bool
38 {
39 $mob_id = $this->resolveObjectId($identification);
40 if ($mob_id === null) {
41 return true;
42 }
43
44 foreach (\ilObjMediaObject::lookupUsages($mob_id) as $usage) {
46 // for content snippets we must get their usages and check them
47 switch ($usage["type"]) {
48 case "auth:pg":
49 // Mobs on the Loginpage should always be delivered
50 return true;
51 case "mep:pg":
52 $usages2 = ilMediaPoolPage::lookupUsages($usage["id"]);
53 foreach ($usages2 as $usage2) {
55 if ($this->checkAccessMobUsage($usage2, $oid2)) {
56 return true;
57 }
58 }
59 break;
60
61 case "clip":
62 if ($usage["id"] == $this->current_user) {
63 return true;
64 }
65 break;
66
67 default:
68 if ($oid !== null && $this->checkAccessMobUsage($usage, $oid)) {
69 return true;
70 }
71
72 if ($oid === null) {
73 /*
74 $this->logger->error(
75 sprintf(
76 "Could not determine parent obj_id for usage: %s",
77 json_encode($usage, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT)
78 )
79 );*/
80 }
81 break;
82 }
83 }
84
85 return false;
86 }
static lookupUsages(int $a_id, bool $a_incl_hist=true)
Lookup usages of media object.
resolveObjectId(ResourceIdentification $identification)
checkAccessMobUsage(array $usage, int $oid)
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 checkAccessMobUsage(), ilObjMediaObject\getParentObjectIdForUsage(), ilMediaPoolPage\lookupUsages(), ilObjMediaObject\lookupUsages(), and resolveObjectId().

+ Here is the call graph for this function:

◆ checkAccessBlogPage()

ilMobStakeholder::checkAccessBlogPage ( int  $obj_id)
protected

Check access rights for blog pages.

Parameters
int$obj_idblog page id

Definition at line 326 of file class.ilMobStakeholder.php.

328 : bool {
329 $tree = new ilWorkspaceTree(0);
330 $node_id = $tree->lookupNodeId($obj_id);
331 if (!$node_id) {
332 return $this->checkAccessObject($obj_id);
333 } else {
334 $access_handler = new ilWorkspaceAccessHandler($tree);
335 if ($access_handler->checkAccessOfUser($tree, $this->current_user, "read", "view", $node_id, "blog")) {
336 return true;
337 }
338 }
339
340 return false;
341 }
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...

Referenced by checkAccessMobUsage().

+ Here is the caller graph for this function:

◆ checkAccessGlossaryTerm()

ilMobStakeholder::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 260 of file class.ilMobStakeholder.php.

263 : bool {
264 // give access if glossary is readable
265 if ($this->checkAccessObject($obj_id)) {
266 return true;
267 }
268
269 $term_id = $page_id;
270
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 $src_obj_id = ilLMObject::_lookupContObjID($src['id']);
280 if ($this->checkAccessObject($src_obj_id, 'lm')) {
281 return true;
282 }
283 break;
284
285 // Don't yet give access if the term is linked by another glossary
286 // The link will lead to the origin glossary which is already checked
287 /*
288 case 'gdf:pg':
289 $src_term_id = ilGlossaryDefinition::_lookupTermId($src['id']);
290 $src_obj_id = ilGlossaryTerm::_lookGlossaryID($src_term_id);
291 if ($this->checkAccessObject($src_obj_id, 'glo'))
292 {
293 return true;
294 }
295 break;
296 */
297 }
298 }
299 }
300 return false;
301 }
static _lookupContObjID(int $a_id)
get learning module id for lm object

Referenced by checkAccessMobUsage().

+ Here is the caller graph for this function:

◆ checkAccessLearningObjectivePage()

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

Definition at line 344 of file class.ilMobStakeholder.php.

347 : bool {
349
350 return $this->checkAccessObject($crs_obj_id, 'crs');
351 }
static _lookupContainerIdByObjectiveId(int $a_objective_id)

Referenced by checkAccessMobUsage().

+ Here is the caller graph for this function:

◆ checkAccessMobUsage()

ilMobStakeholder::checkAccessMobUsage ( array  $usage,
int  $oid 
)
protected

Definition at line 88 of file class.ilMobStakeholder.php.

91 : bool {
93
94 switch ($usage['type']) {
95 case 'lm:pg':
96 if ($this->checkAccessObject($oid, 'lm')) {
97 return true;
98 }
99 break;
100
101 case 'news':
102 // media objects in news (media casts)
103 if ($this->checkAccessObject($oid)) {
104 return true;
106 return true;
107 }
108 break;
109
110 case 'frm~:html':
111 case 'exca~:html':
112 // $oid = userid
113 // foreach ($this->check_users as $user_id) {
114 if (ilObject::_lookupType($oid) === 'usr' && $oid == $user_id) {
115 return true;
116 }
117 // }
118 break;
119
120 case 'frm~d:html':
121 $draft_id = $usage['id'];
122
123 $oDraft = ilForumPostDraft::newInstanceByDraftId($draft_id);
124 if ($user_id == $oDraft->getPostAuthorId()) {
125 return true;
126 }
127 break;
128 case 'frm~h:html':
129 $history_id = $usage['id'];
130 $oHistoryDraft = new ilForumDraftsHistory($history_id);
131 $oDraft = ilForumPostDraft::newInstanceByDraftId($oHistoryDraft->getDraftId());
132 if ($user_id == $oDraft->getPostAuthorId()) {
133 return true;
134 }
135 break;
136 case 'qpl:pg':
137 case 'qpl:html':
138 // test questions
139 if ($this->checkAccessTestQuestion($oid, $usage['id'])) {
140 return true;
141 }
142 break;
143
144 case 'term:pg':
145 // special check for glossary terms
146 if ($this->checkAccessGlossaryTerm($oid, $usage['id'])) {
147 return true;
148 }
149 break;
150
151 case 'sahs:pg':
152 // check for scorm pages
153 if ($this->checkAccessObject($oid, 'sahs')) {
154 return true;
155 }
156 break;
157
158 case 'prtf:pg':
159 // special check for portfolio pages
160 if ($this->checkAccessPortfolioPage($oid, $usage['id'])) {
161 return true;
162 }
163 break;
164
165 case 'blp:pg':
166 // special check for blog pages
167 if ($this->checkAccessBlogPage($oid)) {
168 return true;
169 }
170 break;
171
172 case 'lobj:pg':
173 // special check for learning objective pages
174 if ($this->checkAccessLearningObjectivePage($oid, $usage['id'])) {
175 return true;
176 }
177 break;
178
179 case 'impr:pg':
180 return (ilImprint::isActive() || $this->checkAccessObject(SYSTEM_FOLDER_ID, 'adm'));
181
182 case 'cstr:pg':
183 default:
184 // standard object check
185 if ($this->checkAccessObject($oid)) {
186 return true;
187 }
188 break;
189 }
190
191 return false;
192 }
const NEWS_PUBLIC
Class ilForumDraftHistory.
static newInstanceByDraftId(int $draft_id)
static isActive()
checkAccessPortfolioPage(int $obj_id, int $page_id)
Check access rights for portfolio pages.
checkAccessGlossaryTerm(int $obj_id, int $page_id)
Check access rights for glossary terms This checks also learning modules linking the term.
checkAccessBlogPage(int $obj_id)
Check access rights for blog pages.
checkAccessLearningObjectivePage(int $obj_id, int $page_id)
checkAccessTestQuestion(int $obj_id, int $usage_id=0)
Check access rights for a test question This checks also tests with random selection of questions.
static _lookupVisibility(int $a_news_id)
Lookup News Visibility.
static _lookupType(int $id, bool $reference=false)
const SYSTEM_FOLDER_ID
Definition: constants.php:35

References $user_id, ilObjMediaCastAccess\_lookupPublicFiles(), ilObject\_lookupType(), ilNewsItem\_lookupVisibility(), checkAccessBlogPage(), checkAccessGlossaryTerm(), checkAccessLearningObjectivePage(), checkAccessObject(), checkAccessPortfolioPage(), checkAccessTestQuestion(), ilImprint\isActive(), ilForumPostDraft\newInstanceByDraftId(), NEWS_PUBLIC, and SYSTEM_FOLDER_ID.

Referenced by canBeAccessedByCurrentUser().

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

◆ checkAccessObject()

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

Check access rights for an object by its object id.

Definition at line 197 of file class.ilMobStakeholder.php.

200 : bool {
201 global $DIC;
202
203 $ilAccess = $DIC->access();
205
206 if (!$obj_type) {
207 $obj_type = ilObject::_lookupType($obj_id);
208 }
209 $ref_ids = ilObject::_getAllReferences($obj_id);
210
211 foreach ($ref_ids as $ref_id) {
212 // foreach ($this->check_users as $user_id) {
213 if ($ilAccess->checkAccessOfUser($user_id, "read", "view", $ref_id, $obj_type, $obj_id)) {
214 return true;
215 }
216 // }
217 }
218
219 return false;
220 }
static _getAllReferences(int $id)
get all reference ids for object ID
$ref_id
Definition: ltiauth.php:66
global $DIC
Definition: shib_login.php:26

References ilObject\_lookupType().

Referenced by checkAccessMobUsage().

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

◆ checkAccessPortfolioPage()

ilMobStakeholder::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 309 of file class.ilMobStakeholder.php.

312 : bool {
313 $access_handler = new ilPortfolioAccessHandler();
314 if ($access_handler->checkAccessOfUser($this->current_user, "read", "view", $obj_id, "prtf")) {
315 return true;
316 }
317
318 return false;
319 }
Access handler for portfolio NOTE: This file needs to stay in the classes directory,...

Referenced by checkAccessMobUsage().

+ Here is the caller graph for this function:

◆ checkAccessTestQuestion()

ilMobStakeholder::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 228 of file class.ilMobStakeholder.php.

231 : bool {
232 // give access if direct usage is readable
233 if ($this->checkAccessObject($obj_id)) {
234 return true;
235 }
236
237 $obj_type = ilObject::_lookupType($obj_id);
238 if ($obj_type == 'qpl') {
239 // give access if question pool is used by readable test
240 // for random selection of questions
242 foreach ($tests as $test_id) {
243 if ($this->checkAccessObject($test_id, 'tst')) {
244 return true;
245 }
246 }
247 }
248
249 return false;
250 }
static _getRandomTestsForQuestionPool(int $qpl_id)
Get all tests using a question pool for random selection.

Referenced by checkAccessMobUsage().

+ Here is the caller graph for this function:

◆ getId()

ilMobStakeholder::getId ( )
Returns
string not longer than 64 characters

Implements ILIAS\ResourceStorage\Stakeholder\ResourceStakeholder.

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

27 : string
28 {
29 return 'mob';
30 }

◆ getLocationURIForResourceUsage()

ilMobStakeholder::getLocationURIForResourceUsage ( ResourceIdentification  $identification)

Reimplemented from ILIAS\ResourceStorage\Stakeholder\AbstractResourceStakeholder.

Definition at line 360 of file class.ilMobStakeholder.php.

360 : ?string
361 {
362 $this->initDB();
363 $object_id = $this->resolveObjectId($identification);
364 if ($object_id !== null) {
365 $references = ilObject::_getAllReferences($object_id);
366 $ref_id = array_shift($references);
367
368 return ilLink::_getLink($ref_id);
369 }
370 return null;
371 }

References $ref_id, and ilObject\_getAllReferences().

+ Here is the call graph for this function:

◆ getOwnerOfNewResources()

◆ initDB()

ilMobStakeholder::initDB ( )
private

Definition at line 386 of file class.ilMobStakeholder.php.

386 : void
387 {
388 global $DIC;
389 if ($this->database === null) {
390 $this->database = $DIC->database();
391 }
392 }

References $DIC, and ILIAS\Repository\database().

+ Here is the call graph for this function:

◆ resolveObjectId()

ilMobStakeholder::resolveObjectId ( ResourceIdentification  $identification)
private

Definition at line 373 of file class.ilMobStakeholder.php.

373 : ?int
374 {
375 $this->initDB();
376 $r = $this->database->queryF(
377 "SELECT id FROM mob_data WHERE rid = %s;",
378 ['text'],
379 [$identification->serialize()]
380 );
381 $d = $this->database->fetchObject($r);
382
383 return (isset($d->id) ? (int) $d->id : null);
384 }

References Vendor\Package\$d, ILIAS\Repository\database(), and ILIAS\ResourceStorage\Identification\AbstractIdentification\serialize().

Referenced by canBeAccessedByCurrentUser().

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

◆ resourceHasBeenDeleted()

ilMobStakeholder::resourceHasBeenDeleted ( ResourceIdentification  $identification)
Returns
bool true: if the Stakeholder could handle the deletion; false: if the Stakeholder could not handle the deletion of the resource.

Reimplemented from ILIAS\ResourceStorage\Stakeholder\AbstractResourceStakeholder.

Definition at line 353 of file class.ilMobStakeholder.php.

353 : bool
354 {
355 // at this place we could handle de deletion of a resource. not needed for instruction files IMO.
356
357 return true;
358 }

Field Documentation

◆ $access

ilAccessHandler ilMobStakeholder::$access
protected

Definition at line 24 of file class.ilMobStakeholder.php.

◆ $database

ilDBInterface ilMobStakeholder::$database = null
protected

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


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