37 $a_update_last =
false 41 $ilDB = $DIC->database();
44 if ($a_obj_type ==
"") {
48 if (is_array($a_info_params)) {
49 foreach ($a_info_params as
$key => $param) {
50 $a_info_params[
$key] = str_replace(
",",
",", $param);
52 $a_info_params = implode(
",", $a_info_params);
56 $last_entry_sql =
"SELECT * FROM history WHERE " .
57 " obj_id = " .
$ilDB->quote($a_obj_id,
"integer") .
" AND " .
58 " obj_type = " .
$ilDB->quote($a_obj_type,
"text") .
" ORDER BY hdate DESC";
59 $last_entry_set =
$ilDB->query($last_entry_sql);
60 $last_entry =
$ilDB->fetchAssoc($last_entry_set);
66 if (($a_user_comment !=
"" && $last_entry[
"user_comment"] !=
"")
67 || !$a_update_last || $a_action != $last_entry[
"action"]
68 ||
$ilUser->getId() != $last_entry[
"usr_id"]) {
70 $ilDB->insert(
"history", array(
71 "id" => array(
"integer",
$id),
72 "obj_id" => array(
"integer", $a_obj_id),
73 "obj_type" => array(
"text", $a_obj_type),
74 "action" => array(
"text", $a_action),
76 "usr_id" => array(
"integer",
$ilUser->getId()),
77 "info_params" => array(
"text", $a_info_params),
78 "user_comment" => array(
"clob", $a_user_comment)
110 if ($a_user_comment !=
"") {
111 $fields[
"user_comment"] = array(
"clob", $a_user_comment);
114 $ilDB->update(
"history", $fields, array(
115 "id" => array(
"integer",
$id)
132 $ilDB = $DIC->database();
134 if ($a_obj_type ==
"") {
138 $query =
"SELECT * FROM history WHERE obj_id = " .
139 $ilDB->quote($a_obj_id,
"integer") .
" AND " .
140 "obj_type = " .
$ilDB->quote($a_obj_type,
"text") .
141 " ORDER BY hdate DESC";
145 $hist_items = array();
146 while ($hist_rec =
$ilDB->fetchAssoc($hist_set)) {
147 $hist_items[] = array(
"date" => $hist_rec[
"hdate"],
148 "user_id" => $hist_rec[
"usr_id"],
149 "obj_id" => $hist_rec[
"obj_id"],
150 "obj_type" => $hist_rec[
"obj_type"],
151 "action" => $hist_rec[
"action"],
152 "info_params" => $hist_rec[
"info_params"],
153 "user_comment" => $hist_rec[
"user_comment"],
154 "hist_entry_id" => $hist_rec[
"id"],
155 "title" => $hist_rec[
"title"]);
158 if ($a_obj_type ==
"lm") {
159 $query =
"SELECT h.*, l.title as title FROM history h, lm_data l WHERE " .
160 " l.lm_id = " .
$ilDB->quote($a_obj_id,
"integer") .
" AND " .
161 " l.obj_id = h.obj_id AND " .
162 " (h.obj_type=" .
$ilDB->quote($a_obj_type .
":pg",
"text") .
" OR h.obj_type=" .
$ilDB->quote($a_obj_type .
":st",
"text") .
") " .
163 " ORDER BY h.hdate DESC";
166 while ($hist_rec =
$ilDB->fetchAssoc($hist_set)) {
167 $hist_items[] = array(
"date" => $hist_rec[
"hdate"],
168 "user_id" => $hist_rec[
"usr_id"],
169 "obj_id" => $hist_rec[
"obj_id"],
170 "obj_type" => $hist_rec[
"obj_type"],
171 "action" => $hist_rec[
"action"],
172 "info_params" => $hist_rec[
"info_params"],
173 "user_comment" => $hist_rec[
"user_comment"],
174 "hist_entry_id" => $hist_rec[
"id"],
175 "title" => $hist_rec[
"title"]);
177 usort($hist_items, array(
"ilHistory",
"_compareHistArray"));
178 $hist_items2 = array_reverse($hist_items);
187 if ($a[
"date"] == $b[
"date"]) {
190 return ($a[
"date"] < $b[
"date"]) ? -1 : 1;
204 $ilDB = $DIC->database();
206 $q =
"DELETE FROM history WHERE obj_id = " .
207 $ilDB->quote($a_obj_id,
"integer");
224 $ilDB = $DIC->database();
226 $q =
"SELECT * FROM history WHERE obj_id = " .
227 $ilDB->quote($a_src_id,
"integer");
232 $ilDB->insert(
"history", array(
233 "id" => array(
"integer",
$id),
234 "obj_id" => array(
"integer", $a_dst_id),
235 "obj_type" => array(
"text",
$row->obj_type),
236 "action" => array(
"text",
$row->action),
238 "usr_id" => array(
"integer",
$row->usr_id),
239 "info_params" => array(
"text",
$row->info_params),
240 "user_comment" => array(
"clob",
$row->user_comment)
270 $ilDB = $DIC->database();
272 $q =
"SELECT * FROM history WHERE id = " .
273 $ilDB->quote($a_hist_entry_id,
"integer");
288 $ilDB = $DIC->database();
290 $q =
"DELETE FROM history WHERE id = " .
291 $ilDB->quote($a_hist_entry_id,
"integer");
292 $ilDB->manipulate($q);
305 $ilDB = $DIC->database();
309 array(
"usr_id" => array(
"integer", $new_user_id)),
310 array(
"id" => array(
"integer", $a_hist_entry_id))
static _removeEntryByHistoryID($a_hist_entry_id)
Removes a single entry from the history.
static _changeUserId($a_hist_entry_id, $new_user_id)
Changes the user id of the specified history entry.
if(!array_key_exists('StateId', $_REQUEST)) $id
static _compareHistArray($a, $b)
static now()
Return current timestamp in Y-m-d H:i:s format.
static _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.
static _getEntryByHistoryID($a_hist_entry_id)
returns a single history entry
This class methods for maintain history enties for objects.
static _copyEntriesForObject($a_src_id, $a_dst_id)
copy all history entries for an object
static _getEntriesForObject($a_obj_id, $a_obj_type="")
get all history entries for an object
static _lookupType($a_id, $a_reference=false)
lookup object type
static _removeEntriesForObject($a_obj_id)
remove all history entries for an object