ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilNavigationHistory Class Reference

Navigation History of Repository Items. More...

+ Collaboration diagram for ilNavigationHistory:

Public Member Functions

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

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

ilNavigationHistory::__construct ( )

Constructor.

Parameters
int$a_id

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

References $_SESSION, and $items.

{
$this->items = array();
$items = null;
if (isset($_SESSION["il_nav_history"]))
{
$items = unserialize($_SESSION["il_nav_history"]);
}
if (is_array($items))
{
$this->items = $items;
}
}

Member Function Documentation

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, $ilUser, $items, ilObject\_exists(), ilObject\_lookupObjId(), ilObject\_lookupTitle(), and getItems().

{
global $ilUser, $ilDB;
// never store?
if ($ilUser->prefs["store_last_visited"] == 2)
{
return;
}
$a_sub_obj_id = $a_sub_obj_id."";
if ($a_title == "" && $a_ref_id > 0)
{
$obj_id = ilObject::_lookupObjId($a_ref_id);
if (ilObject::_exists($obj_id))
{
$a_title = ilObject::_lookupTitle($obj_id);
}
}
$id = $a_ref_id.":".$a_sub_obj_id;
$new_items[$id] = array("id" => $id,"ref_id" => $a_ref_id, "link" => $a_link, "title" => $a_title,
"type" => $a_type, "sub_obj_id" => $a_sub_obj_id, "goto_link" => $a_goto_link);
$cnt = 1;
foreach($this->items as $key => $item)
{
if ($item["id"] != $id && $cnt <= 10)
{
$new_items[$item["id"]] = $item;
$cnt++;
}
}
// put items in session
$this->items = $new_items;
$items = serialize($this->items);
$_SESSION["il_nav_history"] = $items;
//var_dump($this->getItems());
// only store in session?
if ($ilUser->prefs["store_last_visited"] == 1)
{
return;
}
// update entries in db
$ilDB->update("usr_data",
array(
"last_visited" => array("clob", serialize($this->getItems()))),
array(
"usr_id" => array("integer", $ilUser->getId()))
);
}

+ Here is the call graph for this function:

ilNavigationHistory::deleteDBEntries ( )

Delete DB entries.

Parameters
@return

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

References $ilUser.

{
global $ilUser, $ilDB;
// update entries in db
$ilDB->update("usr_data",
array(
"last_visited" => array("clob", serialize(array()))),
array(
"usr_id" => array("integer", $ilUser->getId()))
);
}
ilNavigationHistory::deleteSessionEntries ( )

Delete session entries.

Parameters
@return

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

References $_SESSION.

{
$_SESSION["il_nav_history"] = serialize(array());
}
ilNavigationHistory::getItems ( )

Get navigation item stack.

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

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

Referenced by addItem().

{
global $tree, $ilDB, $ilUser, $objDefinition, $ilPluginAdmin;
$items = array();
foreach ($this->items as $it)
{
if ($tree->isInTree($it["ref_id"]) &&
(!$objDefinition->isPluginTypeName($it["type"]) ||
$ilPluginAdmin->isActive(IL_COMP_SERVICE, "Repository", "robj",
ilPlugin::lookupNameForId(IL_COMP_SERVICE, "Repository", "robj", $it["type"]))
))
{
$items[$it["ref_id"].":".$it["sub_obj_id"]] = $it;
}
}
// less than 10? -> get items from db
if (count($items) < 10 && $ilUser->getId() != ANONYMOUS_USER_ID)
{
$set = $ilDB->query("SELECT last_visited FROM usr_data ".
" WHERE usr_id = ".$ilDB->quote($ilUser->getId(), "integer")
);
$rec = $ilDB->fetchAssoc($set);
$db_entries = unserialize($rec["last_visited"]);
$cnt = count($items);
if (is_array($db_entries))
{
foreach ($db_entries as $rec)
{
include_once("./Services/Link/classes/class.ilLink.php");
if ($cnt <= 10 && ! isset($items[$rec["ref_id"].":".$rec["sub_obj_id"]]))
{
if ($tree->isInTree($rec["ref_id"]) &&
(!$objDefinition->isPluginTypeName($rec["type"]) ||
$ilPluginAdmin->isActive(IL_COMP_SERVICE, "Repository", "robj",
ilPlugin::lookupNameForId(IL_COMP_SERVICE, "Repository", "robj", $rec["type"]))
))
{
$link = ($rec["goto_link"] != "")
? $rec["goto_link"]
: ilLink::_getLink($rec["ref_id"]);
if ($rec["sub_obj_id"] != "")
{
$title = $rec["title"];
}
else
{
}
$items[$rec["ref_id"].":".$rec["sub_obj_id"]] = array("id" => $rec["ref_id"].":".$rec["sub_obj_id"],
"ref_id" => $rec["ref_id"], "link" => $link, "title" => $title,
"type" => $rec["type"], "sub_obj_id" => $rec["sub_obj_id"], "goto_link" => $rec["goto_link"]);
$cnt++;
}
}
}
}
}
//var_dump($items);
return $items;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

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: