ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f87
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...
 

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 22 of file class.ilNavigationHistory.php.

References $_SESSION, and $items.

23  {
24  $this->items = array();
25  $items = null;
26  if (isset($_SESSION["il_nav_history"]))
27  {
28  $items = unserialize($_SESSION["il_nav_history"]);
29  }
30  if (is_array($items))
31  {
32  $this->items = $items;
33  }
34  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']

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 40 of file class.ilNavigationHistory.php.

References $_SESSION, $ilDB, $ilUser, $items, ilObject\_exists(), ilObject\_lookupObjId(), ilObject\_lookupTitle(), and getItems().

42  {
43  global $ilUser, $ilDB;
44 
45  // never store?
46  if ($ilUser->prefs["store_last_visited"] == 2)
47  {
48  return;
49  }
50 
51  $a_sub_obj_id = $a_sub_obj_id."";
52 
53  if ($a_title == "" && $a_ref_id > 0)
54  {
55  $obj_id = ilObject::_lookupObjId($a_ref_id);
56  if (ilObject::_exists($obj_id))
57  {
58  $a_title = ilObject::_lookupTitle($obj_id);
59  }
60  }
61 
62  $id = $a_ref_id.":".$a_sub_obj_id;
63 
64  $new_items[$id] = array("id" => $id,"ref_id" => $a_ref_id, "link" => $a_link, "title" => $a_title,
65  "type" => $a_type, "sub_obj_id" => $a_sub_obj_id, "goto_link" => $a_goto_link);
66 
67  $cnt = 1;
68  foreach($this->items as $key => $item)
69  {
70  if ($item["id"] != $id && $cnt <= 10)
71  {
72  $new_items[$item["id"]] = $item;
73  $cnt++;
74  }
75  }
76 
77  // put items in session
78  $this->items = $new_items;
79 
80  $items = serialize($this->items);
81  $_SESSION["il_nav_history"] = $items;
82 //var_dump($this->getItems());
83 
84 
85  // only store in session?
86  if ($ilUser->prefs["store_last_visited"] == 1)
87  {
88  return;
89  }
90 
91 
92  // update entries in db
93  $ilDB->update("usr_data",
94  array(
95  "last_visited" => array("clob", serialize($this->getItems()))),
96  array(
97  "usr_id" => array("integer", $ilUser->getId()))
98  );
99  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
static _lookupTitle($a_id)
lookup object title
getItems()
Get navigation item stack.
static _lookupObjId($a_id)
global $ilUser
Definition: imgupload.php:15
global $ilDB
+ Here is the call graph for this function:

◆ deleteDBEntries()

ilNavigationHistory::deleteDBEntries ( )

Delete DB entries.

Parameters

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

References $ilDB, and $ilUser.

175  {
176  global $ilUser, $ilDB;
177 
178  // update entries in db
179  $ilDB->update("usr_data",
180  array(
181  "last_visited" => array("clob", serialize(array()))),
182  array(
183  "usr_id" => array("integer", $ilUser->getId()))
184  );
185  }
global $ilUser
Definition: imgupload.php:15
global $ilDB

◆ deleteSessionEntries()

ilNavigationHistory::deleteSessionEntries ( )

Delete session entries.

Parameters

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

References $_SESSION.

194  {
195  $_SESSION["il_nav_history"] = serialize(array());
196  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']

◆ getItems()

ilNavigationHistory::getItems ( )

Get navigation item stack.

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

References $ilDB, $ilUser, $items, ilLink\_getLink(), ilObject\_lookupObjId(), ilObject\_lookupTitle(), IL_COMP_SERVICE, and ilPlugin\lookupNameForId().

Referenced by addItem().

105  {
106  global $tree, $ilDB, $ilUser, $objDefinition, $ilPluginAdmin;
107 
108  $items = array();
109 
110  foreach ($this->items as $it)
111  {
112  if ($tree->isInTree($it["ref_id"]) &&
113  (!$objDefinition->isPluginTypeName($it["type"]) ||
114  $ilPluginAdmin->isActive(IL_COMP_SERVICE, "Repository", "robj",
115  ilPlugin::lookupNameForId(IL_COMP_SERVICE, "Repository", "robj", $it["type"]))
116  ))
117  {
118  $items[$it["ref_id"].":".$it["sub_obj_id"]] = $it;
119  }
120  }
121  // less than 10? -> get items from db
122  if (count($items) < 10 && $ilUser->getId() != ANONYMOUS_USER_ID)
123  {
124  $set = $ilDB->query("SELECT last_visited FROM usr_data ".
125  " WHERE usr_id = ".$ilDB->quote($ilUser->getId(), "integer")
126  );
127  $rec = $ilDB->fetchAssoc($set);
128  $db_entries = unserialize($rec["last_visited"]);
129  $cnt = count($items);
130  if (is_array($db_entries))
131  {
132  foreach ($db_entries as $rec)
133  {
134  include_once("./Services/Link/classes/class.ilLink.php");
135 
136  if ($cnt <= 10 && ! isset($items[$rec["ref_id"].":".$rec["sub_obj_id"]]))
137  {
138  if ($tree->isInTree($rec["ref_id"]) &&
139  (!$objDefinition->isPluginTypeName($rec["type"]) ||
140  $ilPluginAdmin->isActive(IL_COMP_SERVICE, "Repository", "robj",
141  ilPlugin::lookupNameForId(IL_COMP_SERVICE, "Repository", "robj", $rec["type"]))
142  ))
143  {
144  $link = ($rec["goto_link"] != "")
145  ? $rec["goto_link"]
146  : ilLink::_getLink($rec["ref_id"]);
147  if ($rec["sub_obj_id"] != "")
148  {
149  $title = $rec["title"];
150  }
151  else
152  {
153  $title = ilObject::_lookupTitle(ilObject::_lookupObjId($rec["ref_id"]));
154  }
155  $items[$rec["ref_id"].":".$rec["sub_obj_id"]] = array("id" => $rec["ref_id"].":".$rec["sub_obj_id"],
156  "ref_id" => $rec["ref_id"], "link" => $link, "title" => $title,
157  "type" => $rec["type"], "sub_obj_id" => $rec["sub_obj_id"], "goto_link" => $rec["goto_link"]);
158  $cnt++;
159  }
160  }
161  }
162  }
163  }
164 //var_dump($items);
165  return $items;
166  }
static _lookupTitle($a_id)
lookup object title
lookupNameForId($a_ctype, $a_cname, $a_slot_id, $a_plugin_id)
Lookup name for id.
static _lookupObjId($a_id)
global $ilUser
Definition: imgupload.php:15
global $ilDB
const IL_COMP_SERVICE
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $items

ilNavigationHistory::$items
private

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

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


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