ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilNavigationHistory Class Reference

Navigation History of Repository Items. More...

+ Collaboration diagram for ilNavigationHistory:

Public Member Functions

 __construct ()
 Constructor. More...
 
 addItem ( $a_ref_id, $a_link, $a_type, $a_title="", $a_sub_obj_id="", $a_goto_link="")
 Add an item to the stack. More...
 
 getItems ()
 Get navigation item stack. More...
 
 deleteDBEntries ()
 Delete DB entries. More...
 
 deleteSessionEntries ()
 Delete session entries. More...
 

Protected Attributes

 $user
 
 $db
 
 $tree
 
 $obj_definition
 
 $plugin_admin
 

Private Attributes

 $items
 

Detailed Description

Navigation History of Repository Items.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 12 of file class.ilNavigationHistory.php.

Constructor & Destructor Documentation

◆ __construct()

ilNavigationHistory::__construct ( )

Constructor.

Parameters
int$a_id

Definition at line 47 of file class.ilNavigationHistory.php.

48 {
49 global $DIC;
50
51 $this->user = $DIC->user();
52 $this->db = $DIC->database();
53 $this->tree = $DIC->repositoryTree();
54 $this->obj_definition = $DIC["objDefinition"];
55 $this->plugin_admin = $DIC["ilPluginAdmin"];
56 $this->items = array();
57 $items = null;
58 if (isset($_SESSION["il_nav_history"])) {
59 $items = unserialize($_SESSION["il_nav_history"]);
60 }
61 if (is_array($items)) {
62 $this->items = $items;
63 }
64 }
user()
Definition: user.php:4
$_SESSION["AccountId"]
global $DIC
Definition: saml.php:7

References $_SESSION, $DIC, $items, and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ addItem()

ilNavigationHistory::addItem (   $a_ref_id,
  $a_link,
  $a_type,
  $a_title = "",
  $a_sub_obj_id = "",
  $a_goto_link = "" 
)

Add an item to the stack.

If ref_id is already used, the item is moved to the top.

Definition at line 70 of file class.ilNavigationHistory.php.

77 {
80
81 // never store?
82 if ($ilUser->prefs["store_last_visited"] == 2) {
83 return;
84 }
85
86 $a_sub_obj_id = $a_sub_obj_id . "";
87
88 if ($a_title == "" && $a_ref_id > 0) {
89 $obj_id = ilObject::_lookupObjId($a_ref_id);
90 if (ilObject::_exists($obj_id)) {
91 $a_title = ilObject::_lookupTitle($obj_id);
92 }
93 }
94
95 $id = $a_ref_id . ":" . $a_sub_obj_id;
96
97 $new_items[$id] = array("id" => $id,"ref_id" => $a_ref_id, "link" => $a_link, "title" => $a_title,
98 "type" => $a_type, "sub_obj_id" => $a_sub_obj_id, "goto_link" => $a_goto_link);
99
100 $cnt = 1;
101 foreach ($this->items as $key => $item) {
102 if ($item["id"] != $id && $cnt <= 10) {
103 $new_items[$item["id"]] = $item;
104 $cnt++;
105 }
106 }
107
108 // put items in session
109 $this->items = $new_items;
110
111 $items = serialize($this->items);
112 $_SESSION["il_nav_history"] = $items;
113 //var_dump($this->getItems());
114
115
116 // only store in session?
117 if ($ilUser->prefs["store_last_visited"] == 1) {
118 return;
119 }
120
121
122 // update entries in db
123 $ilDB->update(
124 "usr_data",
125 array(
126 "last_visited" => array("clob", serialize($this->getItems()))),
127 array(
128 "usr_id" => array("integer", $ilUser->getId()))
129 );
130 }
getItems()
Get navigation item stack.
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public
$key
Definition: croninfo.php:18
if(!array_key_exists('StateId', $_REQUEST)) $id
global $ilDB
$ilUser
Definition: imgupload.php:18
$a_type
Definition: workflow.php:92

References $_SESSION, $a_type, $db, $id, $ilDB, $ilUser, $items, $key, $user, ilObject\_exists(), ilObject\_lookupObjId(), ilObject\_lookupTitle(), and getItems().

Referenced by ilObjIndividualAssessmentGUI\addToNavigationHistory(), and ilObjForumGUI\executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteDBEntries()

ilNavigationHistory::deleteDBEntries ( )

Delete DB entries.

Parameters

return

Definition at line 210 of file class.ilNavigationHistory.php.

211 {
214
215 // update entries in db
216 $ilDB->update(
217 "usr_data",
218 array(
219 "last_visited" => array("clob", serialize(array()))),
220 array(
221 "usr_id" => array("integer", $ilUser->getId()))
222 );
223 }

References $db, $ilDB, $ilUser, and $user.

◆ deleteSessionEntries()

ilNavigationHistory::deleteSessionEntries ( )

Delete session entries.

Parameters

return

Definition at line 231 of file class.ilNavigationHistory.php.

232 {
233 $_SESSION["il_nav_history"] = serialize(array());
234 }

References $_SESSION.

◆ getItems()

ilNavigationHistory::getItems ( )

Get navigation item stack.

Definition at line 135 of file class.ilNavigationHistory.php.

136 {
140 $objDefinition = $this->obj_definition;
141 $ilPluginAdmin = $this->plugin_admin;
142
143 $items = array();
144
145 foreach ($this->items as $it) {
146 if ($tree->isInTree($it["ref_id"]) &&
147 (
148 !$objDefinition->isPluginTypeName($it["type"]) ||
149 $ilPluginAdmin->isActive(
151 "Repository",
152 "robj",
153 ilPlugin::lookupNameForId(IL_COMP_SERVICE, "Repository", "robj", $it["type"])
154 )
155 )) {
156 $items[$it["ref_id"] . ":" . $it["sub_obj_id"]] = $it;
157 }
158 }
159 // less than 10? -> get items from db
160 if (count($items) < 10 && $ilUser->getId() != ANONYMOUS_USER_ID) {
161 $set = $ilDB->query(
162 "SELECT last_visited FROM usr_data " .
163 " WHERE usr_id = " . $ilDB->quote($ilUser->getId(), "integer")
164 );
165 $rec = $ilDB->fetchAssoc($set);
166 $db_entries = unserialize($rec["last_visited"]);
167 $cnt = count($items);
168 if (is_array($db_entries)) {
169 foreach ($db_entries as $rec) {
170 include_once("./Services/Link/classes/class.ilLink.php");
171
172 if ($cnt <= 10 && !isset($items[$rec["ref_id"] . ":" . $rec["sub_obj_id"]])) {
173 if ($tree->isInTree($rec["ref_id"]) &&
174 (
175 !$objDefinition->isPluginTypeName($rec["type"]) ||
176 $ilPluginAdmin->isActive(
178 "Repository",
179 "robj",
180 ilPlugin::lookupNameForId(IL_COMP_SERVICE, "Repository", "robj", $rec["type"])
181 )
182 )) {
183 $link = ($rec["goto_link"] != "")
184 ? $rec["goto_link"]
185 : ilLink::_getLink($rec["ref_id"]);
186 if ($rec["sub_obj_id"] != "") {
187 $title = $rec["title"];
188 } else {
190 }
191 $items[$rec["ref_id"] . ":" . $rec["sub_obj_id"]] = array("id" => $rec["ref_id"] . ":" . $rec["sub_obj_id"],
192 "ref_id" => $rec["ref_id"], "link" => $link, "title" => $title,
193 "type" => $rec["type"], "sub_obj_id" => $rec["sub_obj_id"], "goto_link" => $rec["goto_link"]);
194 $cnt++;
195 }
196 }
197 }
198 }
199 }
200 //var_dump($items);
201 return $items;
202 }
const IL_COMP_SERVICE
static lookupNameForId(string $a_ctype, string $a_cname, string $a_slot_id, string $a_plugin_id)

References $db, $ilDB, $ilUser, $items, $obj_definition, $plugin_admin, $title, $tree, $user, ilLink\_getLink(), ilObject\_lookupObjId(), ilObject\_lookupTitle(), IL_COMP_SERVICE, and ilPlugin\lookupNameForId().

Referenced by addItem().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilNavigationHistory::$db
protected

Definition at line 22 of file class.ilNavigationHistory.php.

Referenced by addItem(), deleteDBEntries(), and getItems().

◆ $items

ilNavigationHistory::$items
private

Definition at line 40 of file class.ilNavigationHistory.php.

Referenced by __construct(), addItem(), and getItems().

◆ $obj_definition

ilNavigationHistory::$obj_definition
protected

Definition at line 32 of file class.ilNavigationHistory.php.

Referenced by getItems().

◆ $plugin_admin

ilNavigationHistory::$plugin_admin
protected

Definition at line 37 of file class.ilNavigationHistory.php.

Referenced by getItems().

◆ $tree

ilNavigationHistory::$tree
protected

Definition at line 27 of file class.ilNavigationHistory.php.

Referenced by getItems().

◆ $user

ilNavigationHistory::$user
protected

Definition at line 17 of file class.ilNavigationHistory.php.

Referenced by addItem(), deleteDBEntries(), and getItems().


The documentation for this class was generated from the following file: