ILIAS  trunk Revision v11.0_alpha-1753-gb21ca8c4367
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilLSLPEventHandler.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
25 {
26  protected ilTree $tree;
28  protected array $cached_parent_lso = [];
29  protected array $cached_refs_for_obj = [];
30 
31  public function __construct(
32  ilTree $tree,
33  ilLPStatusWrapper $lp_status_wrapper
34  ) {
35  $this->tree = $tree;
36  $this->lpstatus = $lp_status_wrapper;
37  }
38 
39  public function updateLPForChildEvent(array $parameter): void
40  {
41  $refs = $this->getRefIdsOfObjId((int) $parameter['obj_id']);
42  foreach ($refs as $ref_id) {
43  $lso_id = $this->getParentLSOObjId((int) $ref_id);
44  if ($lso_id !== null) {
45  $usr_id = $parameter['usr_id'];
46  $this->lpstatus::_updateStatus($lso_id, $usr_id);
47  }
48  }
49  }
50 
54  protected function getParentLSOObjId(int $child_ref_id): ?int
55  {
56  if (!array_key_exists($child_ref_id, $this->cached_parent_lso)) {
57  $this->cached_parent_lso[$child_ref_id] = $this->getParentLSOIdFromTree($child_ref_id);
58  }
59  return $this->cached_parent_lso[$child_ref_id];
60  }
61 
62  private function getParentLSOIdFromTree(int $child_ref_id): ?int
63  {
64  $parent_nd = $this->tree->getParentNodeData($child_ref_id);
65  if (isset($parent_nd['type']) && $parent_nd['type'] === 'lso') {
66  return (int) $parent_nd['obj_id'];
67  }
68  return null;
69  }
70 
74  protected function getRefIdsOfObjId(int $triggerer_obj_id): array
75  {
76  if (!array_key_exists($triggerer_obj_id, $this->cached_refs_for_obj)) {
77  $this->cached_refs_for_obj[$triggerer_obj_id] = ilObject::_getAllReferences($triggerer_obj_id);
78  }
79  return $this->cached_refs_for_obj[$triggerer_obj_id];
80  }
81 }
getParentLSOObjId(int $child_ref_id)
get the LSO up from $child_ref_if
static _getAllReferences(int $id)
get all reference ids for object ID
getParentLSOIdFromTree(int $child_ref_id)
getRefIdsOfObjId(int $triggerer_obj_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
__construct(ilTree $tree, ilLPStatusWrapper $lp_status_wrapper)
$ref_id
Definition: ltiauth.php:65
updateLPForChildEvent(array $parameter)