31 function _createEntry($a_obj_id, $a_action, $a_info_params =
"", $a_obj_type =
"",
32 $a_user_comment =
"", $a_update_last =
false)
36 if ($a_obj_type ==
"")
41 if (is_array($a_info_params))
43 foreach($a_info_params as $key => $param)
45 $a_info_params[$key] = str_replace(
",",
",", $param);
47 $a_info_params = implode(
",", $a_info_params);
51 $last_entry_sql =
"SELECT * FROM history WHERE ".
52 " obj_id = ".$ilDB->quote($a_obj_id,
"integer").
" AND ".
53 " obj_type = ".$ilDB->quote($a_obj_type,
"text").
" ORDER BY hdate DESC";
54 $last_entry_set = $ilDB->query($last_entry_sql);
55 $last_entry = $ilDB->fetchAssoc($last_entry_set);
61 if (($a_user_comment !=
"" && $last_entry[
"user_comment"] !=
"")
62 || !$a_update_last || $a_action != $last_entry[
"action"]
63 || $ilUser->getId() != $last_entry[
"usr_id"])
65 $id = $ilDB->nextId(
"history");
66 $ilDB->insert(
"history", array(
67 "id" => array(
"integer", $id),
68 "obj_id" => array(
"integer", $a_obj_id),
69 "obj_type" => array(
"text", $a_obj_type),
70 "action" => array(
"text", $a_action),
72 "usr_id" => array(
"integer", $ilUser->getId()),
73 "info_params" => array(
"text", $a_info_params),
74 "user_comment" => array(
"clob", $a_user_comment)
108 if ($a_user_comment !=
"")
110 $fields[
"user_comment"] = array(
"clob", $a_user_comment);
113 $ilDB->update(
"history", $fields, array(
114 "id" => array(
"integer", $id)
133 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";
143 $hist_set = $ilDB->query(
$query);
145 $hist_items = array();
146 while ($hist_rec = $ilDB->fetchAssoc($hist_set))
148 $hist_items[] = array(
"date" => $hist_rec[
"hdate"],
149 "user_id" => $hist_rec[
"usr_id"],
150 "obj_id" => $hist_rec[
"obj_id"],
151 "obj_type" => $hist_rec[
"obj_type"],
152 "action" => $hist_rec[
"action"],
153 "info_params" => $hist_rec[
"info_params"],
154 "user_comment" => $hist_rec[
"user_comment"],
155 "hist_entry_id" => $hist_rec[
"id"],
156 "title" => $hist_rec[
"title"]);
159 if ($a_obj_type ==
"lm" || $a_obj_type ==
"dbk")
161 $query =
"SELECT h.*, l.title as title FROM history h, lm_data l WHERE ".
162 " l.lm_id = ".$ilDB->quote($a_obj_id,
"integer").
" AND ".
163 " l.obj_id = h.obj_id AND ".
164 " (h.obj_type=".$ilDB->quote($a_obj_type.
":pg",
"text").
" OR h.obj_type=".$ilDB->quote($a_obj_type.
":st",
"text").
") ".
165 " ORDER BY h.hdate DESC";
167 $hist_set = $ilDB->query(
$query);
168 while ($hist_rec = $ilDB->fetchAssoc($hist_set))
170 $hist_items[] = array(
"date" => $hist_rec[
"hdate"],
171 "user_id" => $hist_rec[
"usr_id"],
172 "obj_id" => $hist_rec[
"obj_id"],
173 "obj_type" => $hist_rec[
"obj_type"],
174 "action" => $hist_rec[
"action"],
175 "info_params" => $hist_rec[
"info_params"],
176 "user_comment" => $hist_rec[
"user_comment"],
177 "hist_entry_id" => $hist_rec[
"id"],
178 "title" => $hist_rec[
"title"]);
180 usort($hist_items, array(
"ilHistory",
"_compareHistArray"));
181 $hist_items2 = array_reverse($hist_items);
190 if ($a[
"date"] == $b[
"date"])
194 return ($a[
"date"] < $b[
"date"]) ? -1 : 1;
208 $q =
"DELETE FROM history WHERE obj_id = ".
209 $ilDB->quote($a_obj_id,
"integer");
210 $r = $ilDB->manipulate($q);
226 $q =
"SELECT * FROM history WHERE obj_id = ".
227 $ilDB->quote($a_src_id,
"integer");
228 $r = $ilDB->query($q);
230 while (
$row = $ilDB->fetchObject($r))
232 $id = $ilDB->nextId(
"history");
233 $ilDB->insert(
"history", array(
234 "id" => array(
"integer", $id),
235 "obj_id" => array(
"integer", $a_dst_id),
236 "obj_type" => array(
"text",
$row->obj_type),
237 "action" => array(
"text",
$row->action),
239 "usr_id" => array(
"integer",
$row->usr_id),
240 "info_params" => array(
"text",
$row->info_params),
241 "user_comment" => array(
"clob",
$row->user_comment)
271 $q =
"SELECT * FROM history WHERE id = ".
272 $ilDB->quote($a_hist_entry_id,
"integer");
273 $r = $ilDB->query($q);
275 return $ilDB->fetchAssoc($r);