31 function _createEntry($a_obj_id, $a_action, $a_info_params =
"", $a_obj_type =
"",
32 $a_user_comment =
"", $a_update_last =
false)
34 global
$ilDB, $ilUser;
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 ".
164 " ORDER BY h.hdate DESC";
166 $hist_set = $ilDB->query(
$query);
167 while ($hist_rec = $ilDB->fetchAssoc($hist_set))
169 $hist_items[] = array(
"date" => $hist_rec[
"hdate"],
170 "user_id" => $hist_rec[
"usr_id"],
171 "obj_id" => $hist_rec[
"obj_id"],
172 "obj_type" => $hist_rec[
"obj_type"],
173 "action" => $hist_rec[
"action"],
174 "info_params" => $hist_rec[
"info_params"],
175 "user_comment" => $hist_rec[
"user_comment"],
176 "hist_entry_id" => $hist_rec[
"id"],
177 "title" => $hist_rec[
"title"]);
179 usort($hist_items, array(
"ilHistory",
"_compareHistArray"));
180 $hist_items2 = array_reverse($hist_items);
189 if ($a[
"date"] == $b[
"date"])
193 return ($a[
"date"] < $b[
"date"]) ? -1 : 1;
207 $q =
"DELETE FROM history WHERE obj_id = ".
208 $ilDB->quote($a_obj_id,
"integer");
209 $r = $ilDB->manipulate($q);
225 $q =
"SELECT * FROM history WHERE obj_id = ".
226 $ilDB->quote($a_src_id,
"integer");
227 $r = $ilDB->query($q);
229 while (
$row = $ilDB->fetchObject($r))
231 $id = $ilDB->nextId(
"history");
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 $q =
"SELECT * FROM history WHERE id = ".
271 $ilDB->quote($a_hist_entry_id,
"integer");
272 $r = $ilDB->query($q);
274 return $ilDB->fetchAssoc($r);