ILIAS  trunk Revision v13.0_alpha-52-g21c366bbdd4
class.ilBookObjectInfoStakeholder.php
Go to the documentation of this file.
1<?php
2
21
23{
24 protected ?ilDBInterface $database = null;
25
26
27 public function getId(): string
28 {
29 return 'book_object_info';
30 }
31
32 public function getOwnerOfNewResources(): int
33 {
35 }
36
37 public function getConsumerNameForPresentation(): string
38 {
39 return parent::getConsumerNameForPresentation() . '/ObjectInfo';
40 }
41
42 public function canBeAccessedByCurrentUser(ResourceIdentification $identification): bool
43 {
44 global $DIC;
45
46 $object_id = $this->resolveObjectId($identification);
47 if ($object_id === null) {
48 return true;
49 }
50
51 $ref_ids = ilObject2::_getAllReferences($object_id);
52 foreach ($ref_ids as $ref_id) {
53 // one must have read permissions on the exercise to see the instruction files
54 if ($DIC->access()->checkAccessOfUser($this->current_user, 'read', '', $ref_id)) {
55 return true;
56 }
57 }
58
59 return false;
60 }
61
62 public function resourceHasBeenDeleted(ResourceIdentification $identification): bool
63 {
64 // at this place we could handle de deletion of a resource. not needed for instruction files IMO.
65
66 return true;
67 }
68
69 public function getLocationURIForResourceUsage(ResourceIdentification $identification): ?string
70 {
71 $this->initDB();
72 $object_id = $this->resolveObjectId($identification);
73 if ($object_id !== null) {
74 $references = ilObject::_getAllReferences($object_id);
75 $ref_id = array_shift($references);
76
77 // we currently deliver the goto-url of the exercise in which the resource is used. if possible, you could deliver a more speficic url wo the assignment as well.
78 return ilLink::_getLink($ref_id, 'exc');
79 }
80 return null;
81 }
82
83 private function resolveObjectId(ResourceIdentification $identification): ?int
84 {
85 $this->initDB();
86 $r = $this->database->queryF(
87 "SELECT pool_id FROM booking_object WHERE booking_object.obj_info_rid = %s;",
88 ['text'],
89 [$identification->serialize()]
90 );
91 $d = $this->database->fetchObject($r);
92
93 return (isset($d->pool_id) ? (int) $d->pool_id : null);
94 }
95
96 private function initDB(): void
97 {
98 global $DIC;
99 if ($this->database === null) {
100 $this->database = $DIC->database();
101 }
102 }
103}
resourceHasBeenDeleted(ResourceIdentification $identification)
canBeAccessedByCurrentUser(ResourceIdentification $identification)
resolveObjectId(ResourceIdentification $identification)
getLocationURIForResourceUsage(ResourceIdentification $identification)
static _getAllReferences(int $id)
get all reference ids for object ID
Interface ilDBInterface.
global $DIC
Definition: shib_login.php:26