19declare(strict_types=0);
28 protected \ILIAS\Repository\LastVisited\NavigationSessionRepository
$repo;
40 $this->
user = $DIC->user();
41 $this->db =
$DIC->database();
42 $this->tree =
$DIC->repositoryTree();
43 $this->obj_definition =
$DIC[
"objDefinition"];
44 $this->items = array();
46 $this->repo = new \ILIAS\Repository\LastVisited\NavigationSessionRepository();
47 $this->items = $this->repo->getHistory();
48 $this->component_repository =
$DIC[
"component.repository"];
60 ?
int $a_sub_obj_id =
null,
61 string $a_goto_link =
""
63 $ilUser = $this->
user;
67 if ((
int) ($ilUser->getPref(
"store_last_visited") ?? 0) == 2) {
71 $a_sub_obj_id = (string) $a_sub_obj_id;
73 if ($a_title ===
"" && $a_ref_id > 0) {
80 $id = $a_ref_id .
":" . $a_sub_obj_id;
82 $new_items[
$id] = array(
"id" =>
$id,
"ref_id" => $a_ref_id,
"link" => $a_link,
"title" => $a_title,
83 "type" => $a_type,
"sub_obj_id" => $a_sub_obj_id,
"goto_link" => $a_goto_link);
86 foreach ($this->items as $key => $item) {
87 if ($item[
"id"] !=
$id && $cnt <= 10) {
88 $new_items[$item[
"id"]] = $item;
94 $this->items = $new_items;
96 $this->repo->setHistory($this->items);
99 if ((
int) ($ilUser->getPref(
"store_last_visited") ?? 0) == 1) {
104 $ilUser->updateLastVisited($this->
getItems());
114 $ilUser = $this->user;
115 $objDefinition = $this->obj_definition;
116 $component_repository = $this->component_repository;
120 foreach ($this->items as $it) {
124 !$objDefinition->isPluginTypeName($it[
"type"]) ||
127 $component_repository->
getPluginById($it[
"type"])->isActive()
131 $items[$it[
"ref_id"] .
":" . $it[
"sub_obj_id"]] = $it;
136 $db_entries = $ilUser->getLastVisited();
137 $cnt = count($items);
138 foreach ($db_entries as $rec) {
141 !isset($items[$rec[
"ref_id"] .
":" . $rec[
"sub_obj_id"]]) &&
142 $tree->
isInTree((
int) $rec[
"ref_id"]) &&
144 !$objDefinition->isPluginTypeName($rec[
"type"]) ||
146 $component_repository->
hasPluginId($rec[
"type"]) &&
147 $component_repository->
getPluginById($rec[
"type"])->isActive()
151 $link = ($rec[
"goto_link"] !=
"")
153 : ilLink::_getLink((
int) $rec[
"ref_id"]);
154 if ($rec[
"sub_obj_id"] !=
"") {
155 $title = $rec[
"title"];
156 } elseif ($rec[
"type"] ===
"sess") {
159 $title = $sess->getPresentationTitle();
166 $items[$rec[
"ref_id"] .
":" . $rec[
"sub_obj_id"]] = array(
"id" => $rec[
"ref_id"] .
":" . $rec[
"sub_obj_id"],
167 "ref_id" => $rec[
"ref_id"],
"link" => $link,
"title" => $title,
168 "type" => $rec[
"type"],
"sub_obj_id" => $rec[
"sub_obj_id"],
"goto_link" => $rec[
"goto_link"]);
178 $ilUser = $this->user;
185 "last_visited" => array(
"clob", serialize(array()))),
187 "usr_id" => array(
"integer", $ilUser->getId()))
193 $this->repo->setHistory([]);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Last visited history for repository items.
ilObjectDefinition $obj_definition
ILIAS Repository LastVisited NavigationSessionRepository $repo
ilComponentRepository $component_repository
getItems()
Get navigation item stack.
addItem(int $a_ref_id, string $a_link, string $a_type, string $a_title="", ?int $a_sub_obj_id=null, string $a_goto_link="")
Add an item to the stack.
parses the objects.xml it handles the xml-description of all ilias objects
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
isInTree(?int $a_node_id)
get all information of a node.
Readable part of repository interface to ilComponentDataDB.
getPluginById(string $id)
Get a plugin by id.
hasPluginId(string $id)
Check if a plugin exists.