ILIAS  trunk Revision v13.0_alpha-52-g21c366bbdd4
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 getConsumerNameForPresentation(): string
37 {
38 return parent::getConsumerNameForPresentation() . '/BookingInfo';
39 }
40
41 public function canBeAccessedByCurrentUser(ResourceIdentification $identification): bool
42 {
43 global $DIC;
44
45 $object_id = $this->resolveObjectId($identification);
46 if ($object_id === null) {
47 return true;
48 }
49
50 $ref_ids = ilObject2::_getAllReferences($object_id);
51 foreach ($ref_ids as $ref_id) {
52 // one must have read permissions on the exercise to see the instruction files
53 if ($DIC->access()->checkAccessOfUser($this->current_user, 'read', '', $ref_id)) {
54 return true;
55 }
56 }
57
58 return false;
59 }
60
61 public function resourceHasBeenDeleted(ResourceIdentification $identification): bool
62 {
63 // at this place we could handle de deletion of a resource. not needed for instruction files IMO.
64
65 return true;
66 }
67
68 public function getLocationURIForResourceUsage(ResourceIdentification $identification): ?string
69 {
70 $this->initDB();
71 $object_id = $this->resolveObjectId($identification);
72 if ($object_id !== null) {
73 $references = ilObject::_getAllReferences($object_id);
74 $ref_id = array_shift($references);
75
76 // 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.
77 return ilLink::_getLink($ref_id, 'exc');
78 }
79 return null;
80 }
81
82 private function resolveObjectId(ResourceIdentification $identification): ?int
83 {
84 $this->initDB();
85 $r = $this->database->queryF(
86 "SELECT pool_id FROM booking_object WHERE booking_object.book_info_rid = %s;",
87 ['text'],
88 [$identification->serialize()]
89 );
90 $d = $this->database->fetchObject($r);
91
92 return (isset($d->pool_id) ? (int) $d->pool_id : null);
93 }
94
95 private function initDB(): void
96 {
97 global $DIC;
98 if ($this->database === null) {
99 $this->database = $DIC->database();
100 }
101 }
102}
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.
global $DIC
Definition: shib_login.php:26