ILIAS  release_8 Revision v8.24
class.ilObjectListGUIPreloader.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
27{
29 protected ilTree $tree;
31 protected ilObjUser $user;
34
35 protected int $context;
36
37 protected array $obj_ids = [];
38 protected array $obj_ids_by_type = [];
39 protected array $ref_ids = [];
40 protected array $ref_ids_by_type = [];
41 protected array $types = [];
42
43 public function __construct(int $context)
44 {
45 global $DIC;
46
47 $this->obj_definition = $DIC["objDefinition"];
48 $this->tree = $DIC->repositoryTree();
49 $this->obj_data_cache = $DIC["ilObjDataCache"];
50 $this->user = $DIC->user();
51 $this->rbacsystem = $DIC->rbac()->system();
52 $this->fav_manager = new ilFavouritesManager();
53 $this->context = $context;
54 }
55
56 public function addItem(int $obj_id, string $type, ?int $ref_id = null): void
57 {
58 $this->obj_ids[] = $obj_id;
59 $this->obj_ids_by_type[$type][] = $obj_id;
60 $this->types[] = $type;
61
62 if ($ref_id) {
63 $this->ref_ids[] = $ref_id;
64 $this->ref_ids_by_type[$type][] = $ref_id;
65 }
66 }
67
68 public function preload(): void
69 {
70 if (!$this->obj_ids) {
71 return;
72 }
73
74 $this->obj_ids = array_unique($this->obj_ids);
75 $this->types = array_unique($this->types);
76 if ($this->ref_ids) {
77 $this->ref_ids = array_unique($this->ref_ids);
78 }
79
80 // type specific preloads
81 foreach ($this->types as $type) {
82 $this->obj_ids_by_type[$type] = array_unique($this->obj_ids_by_type[$type]);
83
84 if (isset($this->ref_ids_by_type[$type])) {
85 $this->ref_ids_by_type[$type] = array_unique($this->ref_ids_by_type[$type]);
86 }
87
88 if ($this->context == ilObjectListGUI::CONTEXT_REPOSITORY ||
90 $this->context == ilObjectListGUI::CONTEXT_SEARCH) {
92 $type,
93 $this->obj_ids_by_type[$type]
94 );
95 }
96
97 $class = $this->obj_definition->getClassName($type);
98 $location = $this->obj_definition->getLocation($type);
99 if ($class && $location) { // #12775
100 $full_class = "ilObj" . $class . "Access";
101 if (is_file($location . "/class." . $full_class . ".php")) {
102 include_once($location . "/class." . $full_class . ".php");
103 }
104 if (class_exists($full_class)) {
105 call_user_func(
106 array($full_class, "_preloadData"),
107 $this->obj_ids_by_type[$type] ?? [],
108 $this->ref_ids_by_type[$type] ?? []
109 );
110 }
111 }
112 }
113
114 if ($this->ref_ids) {
115 $this->tree->preloadDeleted($this->ref_ids);
116 $this->tree->preloadDepthParent($this->ref_ids);
117 $this->obj_data_cache->preloadReferenceCache($this->ref_ids, false);
118 $this->rbacsystem->preloadRbacPaCache($this->ref_ids, $this->user->getId());
119
120 if ($this->user->getId() != ANONYMOUS_USER_ID &&
122 $this->fav_manager->loadData($this->user->getId(), $this->ref_ids);
123 }
124
125 ilObjectActivation::preloadData($this->ref_ids);
126 }
127
128 ilObjectListGUI::preloadCommonProperties($this->obj_ids, $this->context);
129
130 if ($this->context == ilObjectListGUI::CONTEXT_REPOSITORY) {
131 ilRating::preloadListGUIData($this->obj_ids);
132
134 }
135
136 if ($this->context == ilObjectListGUI::CONTEXT_REPOSITORY ||
138 $this->context == ilObjectListGUI::CONTEXT_SEARCH) {
139 ilLPStatus::preloadListGUIData($this->obj_ids);
140 }
141 }
142}
$location
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: buildRTE.php:22
static preloadByObjIds(array $a_obj_ids)
Preload list gui data.
static preloadPersistedConditionsForTargetRecords(string $a_type, array $a_obj_ids)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static preloadListGUIData(array $a_obj_ids)
User class.
static preloadData(array $ref_ids)
Preload data to internal cache.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
parses the objects.xml it handles the xml-description of all ilias objects
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addItem(int $obj_id, string $type, ?int $ref_id=null)
static preloadCommonProperties(array $obj_ids, int $context)
static preloadListGUIData(array $a_obj_ids)
Preload rating data for list guis.
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const ANONYMOUS_USER_ID
Definition: constants.php:27
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
$type