ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilHistory Class Reference

This class methods for maintain history enties for objects. More...

+ Collaboration diagram for ilHistory:

Public Member Functions

 _createEntry ($a_obj_id, $a_action, $a_info_params="", $a_obj_type="", $a_user_comment="", $a_update_last=false)
 Creates a new history entry for an object.
 _getEntriesForObject ($a_obj_id, $a_obj_type="")
 get all history entries for an object
 _compareHistArray ($a, $b)
 _removeEntriesForObject ($a_obj_id)
 remove all history entries for an object
 _copyEntriesForObject ($a_src_id, $a_dst_id)
 copy all history entries for an object
 _getEntryByHistoryID ($a_hist_entry_id)
 returns a single history entry

Detailed Description

This class methods for maintain history enties for objects.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
Id:
class.ilHistory.php 20150 2009-06-08 18:02:33Z akill

Definition at line 10 of file class.ilHistory.php.

Member Function Documentation

ilHistory::_compareHistArray (   $a,
  $b 
)

Definition at line 187 of file class.ilHistory.php.

{
if ($a["date"] == $b["date"])
{
return 0;
}
return ($a["date"] < $b["date"]) ? -1 : 1;
}
ilHistory::_copyEntriesForObject (   $a_src_id,
  $a_dst_id 
)

copy all history entries for an object

Parameters
integer$a_src_idsource object id
integer$a_dst_iddestination object id
Returns
boolean

Definition at line 221 of file class.ilHistory.php.

References $ilDB, $q, $row, and ilUtil\now().

Referenced by ilObjFile\cloneObject().

{
global $ilDB;
$q = "SELECT * FROM history WHERE obj_id = ".
$ilDB->quote($a_src_id, "integer");
$r = $ilDB->query($q);
while ($row = $ilDB->fetchObject($r))
{
$id = $ilDB->nextId("history");
$ilDB->insert("history", array(
"id" => array("integer", $id),
"obj_id" => array("integer", $a_dst_id),
"obj_type" => array("text", $row->obj_type),
"action" => array("text", $row->action),
"hdate" => array("timestamp", ilUtil::now()),
"usr_id" => array("integer", $row->usr_id),
"info_params" => array("text", $row->info_params),
"user_comment" => array("clob", $row->user_comment)
));
/*
$q = "INSERT INTO history (obj_id, obj_type, action, hdate, usr_id, info_params, user_comment) VALUES ".
"(".
$ilDB->quote($a_dst_id).", ".
$ilDB->quote($row->obj_type).", ".
$ilDB->quote($row->action).", ".
$ilDB->quote($row->hdate).", ".
$ilDB->quote($row->usr_id).", ".
$ilDB->quote($row->info_params).", ".
$ilDB->quote($row->user_comment).
")";
$ilDB->query($q);*/
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilHistory::_createEntry (   $a_obj_id,
  $a_action,
  $a_info_params = "",
  $a_obj_type = "",
  $a_user_comment = "",
  $a_update_last = false 
)

Creates a new history entry for an object.

The information text parameters have to be separated by comma. The information text has to be stored in a langage variable "hist_<object_type>_<action>". This text can contain placeholders %1, %2, ... for each parameter. The placehoders are replaced by the parameters in ilHistoryGUI->getHistoryTable().

Please note that the object type must be specified, if the object is not derived from ilObject.

Parameters
int$a_obj_idobject id
string$a_actionaction
string$a_info_paramsinformation text parameters, separated by comma or as an array
string$a_obj_typeobject type (must only be set, if object is not in object_data table)
string$a_user_commentuser comment

Definition at line 31 of file class.ilHistory.php.

References $ilDB, $key, $param, ilObject\_lookupType(), and ilUtil\now().

Referenced by ilLinkResourceItems\add(), ilPageEditorGUI\addChangeComment(), ilObjFile\addFileVersion(), ilObjContentObjectGUI\confirmedDelete(), ilLMObject\create(), ilObjFileDAV\createNewVersion(), ilObjFile\createProperties(), ilStructureObjectGUI\cutPage(), ilLinkResourceItems\delete(), ilObjContentObject\executeDragDrop(), ilStructureObjectGUI\pastePage(), ilObjFile\replaceFile(), ilLinkResourceItems\update(), ilFileXMLParser\updateFileContents(), and ilLMPageObjectGUI\updateHistory().

{
global $ilDB, $ilUser;
if ($a_obj_type == "")
{
$a_obj_type = ilObject::_lookupType($a_obj_id);
}
if (is_array($a_info_params))
{
foreach($a_info_params as $key => $param)
{
$a_info_params[$key] = str_replace(",", "&#044;", $param);
}
$a_info_params = implode(",", $a_info_params);
}
// get last entry of object
$last_entry_sql = "SELECT * FROM history WHERE ".
" obj_id = ".$ilDB->quote($a_obj_id, "integer")." AND ".
" obj_type = ".$ilDB->quote($a_obj_type, "text")." ORDER BY hdate DESC";
$last_entry_set = $ilDB->query($last_entry_sql);
$last_entry = $ilDB->fetchAssoc($last_entry_set);
// note: insert is forced if last entry already has a comment and a
// new comment is given too OR
// if entry should not be updated OR
// if current action or user id are not equal with last entry
if (($a_user_comment != "" && $last_entry["user_comment"] != "")
|| !$a_update_last || $a_action != $last_entry["action"]
|| $ilUser->getId() != $last_entry["usr_id"])
{
$id = $ilDB->nextId("history");
$ilDB->insert("history", array(
"id" => array("integer", $id),
"obj_id" => array("integer", $a_obj_id),
"obj_type" => array("text", $a_obj_type),
"action" => array("text", $a_action),
"hdate" => array("timestamp", ilUtil::now()),
"usr_id" => array("integer", $ilUser->getId()),
"info_params" => array("text", $a_info_params),
"user_comment" => array("clob", $a_user_comment)
));
/*$query = "INSERT INTO history (id, obj_id, obj_type, action, hdate, usr_id, info_params, user_comment) VALUES ".
"(".
$ilDB->quote($id).", ".
$ilDB->quote($a_obj_id).", ".
$ilDB->quote($a_obj_type).", ".
$ilDB->quote($a_action).", ".
"now(), ".
$ilDB->quote($ilUser->getId()).", ".
$ilDB->quote($a_info_params).", ".
$ilDB->quote($a_user_comment).
")";
$ilDB->query($query);*/
}
else
{
// if entry should be updated, update user comment only
// if it is set (this means, user comment has been empty
// because if old and new comment are given, an INSERT is forced
// see if statement above)
//$uc_str = ($a_user_comment != "")
// ? ", user_comment = ".$ilDB->quote($a_user_comment)
// : "";
/*$query = "UPDATE history SET ".
" hdate = now() ".
$uc_str.
" WHERE id = ".$ilDB->quote($last_entry["id"]);
$ilDB->query($query);*/
$fields = array(
"hdate" => array("timestamp", ilUtil::now())
);
if ($a_user_comment != "")
{
$fields["user_comment"] = array("clob", $a_user_comment);
}
$ilDB->update("history", $fields, array(
"id" => array("integer", $id)
));
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilHistory::_getEntriesForObject (   $a_obj_id,
  $a_obj_type = "" 
)

get all history entries for an object

Parameters
int$a_obj_idobject id
Returns
array array of history entries (arrays with keys "date", "user_id", "obj_id", "action", "info_params")

Definition at line 129 of file class.ilHistory.php.

References $ilDB, $query, and ilObject\_lookupType().

Referenced by ilHistoryGUI\getHistoryTable(), ilHistoryGUI\getVersionsTable(), and ilFileXMLWriter\start().

{
global $ilDB;
if ($a_obj_type == "")
{
$a_obj_type = ilObject::_lookupType($a_obj_id);
}
$query = "SELECT * FROM history WHERE obj_id = ".
$ilDB->quote($a_obj_id, "integer")." AND ".
"obj_type = ".$ilDB->quote($a_obj_type, "text").
" ORDER BY hdate DESC";
$hist_set = $ilDB->query($query);
$hist_items = array();
while ($hist_rec = $ilDB->fetchAssoc($hist_set))
{
$hist_items[] = array("date" => $hist_rec["hdate"],
"user_id" => $hist_rec["usr_id"],
"obj_id" => $hist_rec["obj_id"],
"obj_type" => $hist_rec["obj_type"],
"action" => $hist_rec["action"],
"info_params" => $hist_rec["info_params"],
"user_comment" => $hist_rec["user_comment"],
"hist_entry_id" => $hist_rec["id"],
"title" => $hist_rec["title"]);
}
if ($a_obj_type == "lm" || $a_obj_type == "dbk")
{
$query = "SELECT h.*, l.title as title FROM history h, lm_data l WHERE ".
" l.lm_id = ".$ilDB->quote($a_obj_id, "integer")." AND ".
" l.obj_id = h.obj_id ".
" ORDER BY h.hdate DESC";
$hist_set = $ilDB->query($query);
while ($hist_rec = $ilDB->fetchAssoc($hist_set))
{
$hist_items[] = array("date" => $hist_rec["hdate"],
"user_id" => $hist_rec["usr_id"],
"obj_id" => $hist_rec["obj_id"],
"obj_type" => $hist_rec["obj_type"],
"action" => $hist_rec["action"],
"info_params" => $hist_rec["info_params"],
"user_comment" => $hist_rec["user_comment"],
"hist_entry_id" => $hist_rec["id"],
"title" => $hist_rec["title"]);
}
usort($hist_items, array("ilHistory", "_compareHistArray"));
$hist_items2 = array_reverse($hist_items);
return $hist_items2;
}
return $hist_items;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilHistory::_getEntryByHistoryID (   $a_hist_entry_id)

returns a single history entry

Definition at line 266 of file class.ilHistory.php.

References $ilDB, and $q.

Referenced by ilObjFile\determineFileSize(), ilObjFile\getFile(), and ilObjFile\sendFile().

{
global $ilDB;
$q = "SELECT * FROM history WHERE id = ".
$ilDB->quote($a_hist_entry_id, "integer");
$r = $ilDB->query($q);
return $ilDB->fetchAssoc($r);
}

+ Here is the caller graph for this function:

ilHistory::_removeEntriesForObject (   $a_obj_id)

remove all history entries for an object

Parameters
int$a_obj_idobject id
Returns
boolean

Definition at line 203 of file class.ilHistory.php.

References $ilDB, and $q.

Referenced by ilObjFile\delete(), and ilObjFile\deleteVersions().

{
global $ilDB;
$q = "DELETE FROM history WHERE obj_id = ".
$ilDB->quote($a_obj_id, "integer");
$r = $ilDB->manipulate($q);
return true;
}

+ Here is the caller graph for this function:


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