This class methods for maintain history enties for objects. More...
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 | |
This class methods for maintain history enties for objects.
Definition at line 30 of file class.ilHistory.php.
| ilHistory::_compareHistArray | ( | $ | a, | |
| $ | b | |||
| ) |
Definition at line 181 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
| integer | $a_src_id source object id | |
| integer | $a_dst_id destination object id |
Definition at line 214 of file class.ilHistory.php.
Referenced by ilObjFile::cloneObject().
{
global $ilDB;
$q = "SELECT * FROM history WHERE obj_id = ".$ilDB->quote($a_src_id);
$r = $ilDB->query($q);
while ($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
{
$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 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.
| int | $a_obj_id object id | |
| string | $a_action action | |
| string | $a_info_params information text parameters, separated by comma or as an array | |
| string | $a_obj_type object type (must only be set, if object is not in object_data table) | |
| string | $a_user_comment user comment |
Definition at line 51 of file class.ilHistory.php.
References ilObject::_lookupType().
Referenced by ilLinkResourceItems::add(), ilPageEditorGUI::addChangeComment(), ilObjContentObjectGUI::confirmedDelete(), ilLMObject::create(), ilObjFile::create(), ilStructureObjectGUI::cutPage(), ilLinkResourceItems::delete(), ilStructureObjectGUI::pastePage(), ilObjContentObjectGUI::proceedDragDrop(), 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(",", ",", $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)." AND ".
" obj_type = ".$ilDB->quote($a_obj_type)." ORDER BY hdate DESC limit 1";
$last_entry_set = $ilDB->query($last_entry_sql);
$last_entry = $last_entry_set->fetchRow(DB_FETCHMODE_ASSOC);
// 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"])
{
$query = "INSERT INTO history (obj_id, obj_type, action, hdate, usr_id, info_params, user_comment) VALUES ".
"(".
$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);
}
}
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
| int | $a_obj_id object id |
Definition at line 123 of file class.ilHistory.php.
References 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)." AND ".
"obj_type = ".$ilDB->quote($a_obj_type).
" ORDER BY hdate DESC";
$hist_set = $ilDB->query($query);
$hist_items = array();
while ($hist_rec = $hist_set->fetchRow(DB_FETCHMODE_ASSOC))
{
$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 as h, lm_data as l WHERE ".
" l.lm_id = ".$ilDB->quote($a_obj_id)." AND ".
" l.obj_id = h.obj_id ".
" ORDER BY h.hdate DESC";
$hist_set = $ilDB->query($query);
while ($hist_rec = $hist_set->fetchRow(DB_FETCHMODE_ASSOC))
{
$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 245 of file class.ilHistory.php.
Referenced by ilObjFile::sendFile().
{
global $ilDB;
$q = "SELECT * FROM history WHERE id = ".$ilDB->quote($a_hist_entry_id);
$r = $ilDB->query($q);
return $r->fetchRow(DB_FETCHMODE_ASSOC);
}
Here is the caller graph for this function:| ilHistory::_removeEntriesForObject | ( | $ | a_obj_id | ) |
remove all history entries for an object
| int | $a_obj_id object id |
Definition at line 197 of file class.ilHistory.php.
Referenced by ilObjFile::delete().
{
global $ilDB;
$q = "DELETE FROM history WHERE obj_id = ".$ilDB->quote($a_obj_id);
$r = $ilDB->query($q);
return true;
}
Here is the caller graph for this function:
1.7.1