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