ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilObjectListGUIPreloader.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/Object/classes/class.ilObjectListGUI.php");
5
13{
17 protected $obj_definition;
18
22 protected $tree;
23
27 protected $obj_data_cache;
28
32 protected $user;
33
37 protected $rbacsystem;
38
39 protected $context; // [int]
40 protected $obj_ids; // [array]
41 protected $obj_ids_by_type; // [array]
42 protected $ref_ids; // [array]
43 protected $ref_ids_by_type; // [array]
44 protected $types; // [array]
45
49 protected $fav_manager;
50
51 public function __construct($a_context)
52 {
53 global $DIC;
54
55 $this->obj_definition = $DIC["objDefinition"];
56 $this->tree = $DIC->repositoryTree();
57 $this->obj_data_cache = $DIC["ilObjDataCache"];
58 $this->user = $DIC->user();
59 $this->rbacsystem = $DIC->rbac()->system();
60 $this->context = $a_context;
61 $this->fav_manager = new ilFavouritesManager();
62 }
63
64 public function addItem($a_obj_id, $a_type, $a_ref_id = null)
65 {
66 $this->obj_ids[] = $a_obj_id;
67 $this->obj_ids_by_type[$a_type][] = $a_obj_id;
68 $this->types[] = $a_type;
69
70 if ($a_ref_id) {
71 $this->ref_ids[] = $a_ref_id;
72 $this->ref_ids_by_type[$a_type][] = $a_ref_id;
73 }
74 }
75
76 public function preload()
77 {
78 $objDefinition = $this->obj_definition;
80 $ilObjDataCache = $this->obj_data_cache;
83
84 if (!$this->obj_ids) {
85 return;
86 }
87
88 $this->obj_ids = array_unique($this->obj_ids);
89 $this->types = array_unique($this->types);
90 if ($this->ref_ids) {
91 $this->ref_ids = array_unique($this->ref_ids);
92 }
93
94 // type specific preloads
95 include_once("./Services/Conditions/classes/class.ilConditionHandler.php");
96 foreach ($this->types as $type) {
97 $this->obj_ids_by_type[$type] = array_unique($this->obj_ids_by_type[$type]);
98
99 if (is_array($this->ref_ids_by_type[$type])) {
100 $this->ref_ids_by_type[$type] = array_unique($this->ref_ids_by_type[$type]);
101 }
102
103 if ($this->context == ilObjectListGUI::CONTEXT_REPOSITORY ||
105 $this->context == ilObjectListGUI::CONTEXT_SEARCH) {
107 $type,
108 $this->obj_ids_by_type[$type]
109 );
110 }
111
112 $class = $objDefinition->getClassName($type);
113 $location = $objDefinition->getLocation($type);
114 if ($class && $location) { // #12775
115 $full_class = "ilObj" . $class . "Access";
116 include_once($location . "/class." . $full_class . ".php");
117 if (class_exists($full_class)) {
118 call_user_func(
119 array($full_class, "_preloadData"),
120 $this->obj_ids_by_type[$type],
121 $this->ref_ids_by_type[$type]
122 );
123 }
124 }
125 }
126
127 if ($this->ref_ids) {
128 $tree->preloadDeleted($this->ref_ids);
129 $tree->preloadDepthParent($this->ref_ids);
130 $ilObjDataCache->preloadReferenceCache($this->ref_ids, false);
131 $rbacsystem->preloadRbacPaCache($this->ref_ids, $ilUser->getId());
132
133 if ($ilUser->getId() != ANONYMOUS_USER_ID &&
135 $this->fav_manager->loadData($ilUser->getId(), $this->ref_ids);
136 }
137
138 include_once("./Services/Object/classes/class.ilObjectActivation.php");
139 ilObjectActivation::preloadData($this->ref_ids);
140 }
141
142 include_once("./Services/Object/classes/class.ilObjectListGUI.php");
143 ilObjectListGUI::preloadCommonProperties($this->obj_ids, $this->context);
144
145 if ($this->context == ilObjectListGUI::CONTEXT_REPOSITORY) {
146 include_once("./Services/Rating/classes/class.ilRating.php");
147 include_once("./Services/Rating/classes/class.ilRatingGUI.php");
148 ilRating::preloadListGUIData($this->obj_ids);
149
150 include_once("./Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php");
152 }
153
154 if ($this->context == ilObjectListGUI::CONTEXT_REPOSITORY ||
156 $this->context == ilObjectListGUI::CONTEXT_SEARCH) {
157 include_once("./Services/Tracking/classes/class.ilLPStatus.php");
158 ilLPStatus::preloadListGUIData($this->obj_ids);
159 }
160 }
161}
user()
Definition: user.php:4
$location
Definition: buildRTE.php:44
An exception for terminatinating execution or to throw for unit testing.
static preloadByObjIds(array $a_obj_ids)
Preload list gui data.
static preloadPersistedConditionsForTargetRecords($a_type, $a_obj_ids)
Preload conditions for target records.
Manages favourites, currently the interface for other components, needs discussion.
static preloadListGUIData($a_obj_ids)
static preloadData(array $a_ref_ids)
Preload data to internal cache.
Preloader for object list GUIs.
addItem($a_obj_id, $a_type, $a_ref_id=null)
static preloadCommonProperties($a_obj_ids, $a_context)
Preload common properties.
static preloadListGUIData(array $a_obj_ids)
Preload rating data for list guis.
$type
$ilUser
Definition: imgupload.php:18
$a_type
Definition: workflow.php:92
$DIC
Definition: xapitoken.php:46