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