45         array $a_info_params = [],
    46         string $a_obj_type = 
"",
    47         string $a_user_comment = 
"",
    48         bool $a_update_last = 
false    52         $ilDB = $DIC->database();
    53         $ilUser = $DIC->user();
    55         if ($a_obj_type == 
"") {
    59         if (is_array($a_info_params)) {
    61                 $a_info_params[
$key] = str_replace(
",", 
",", 
$param);
    63             $a_info_params = implode(
",", $a_info_params);
    67         $last_entry_sql = 
"SELECT * FROM history WHERE " .
    68             " obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer") . 
" AND " .
    69             " obj_type = " . 
$ilDB->quote($a_obj_type, 
"text") . 
" ORDER BY hdate DESC";
    70         $last_entry_set = 
$ilDB->query($last_entry_sql);
    71         $last_entry = 
$ilDB->fetchAssoc($last_entry_set);
    77         if (($a_user_comment != 
"" && $last_entry[
"user_comment"] != 
"")
    78             || !$a_update_last || $a_action != $last_entry[
"action"]
    79             || $ilUser->getId() != $last_entry[
"usr_id"]) {
    81             $ilDB->insert(
"history", array(
    82                 "id" => array(
"integer", 
$id),
    83                 "obj_id" => array(
"integer", $a_obj_id),
    84                 "obj_type" => array(
"text", $a_obj_type),
    85                 "action" => array(
"text", $a_action),
    87                 "usr_id" => array(
"integer", $ilUser->getId()),
    88                 "info_params" => array(
"text", $a_info_params),
    89                 "user_comment" => array(
"clob", $a_user_comment)
    95             if ($a_user_comment != 
"") {
    96                 $fields[
"user_comment"] = array(
"clob", $a_user_comment);
    99             $ilDB->update(
"history", $fields, array(
   100                 "id" => array(
"integer", $last_entry[
"id"])
   113         string $a_obj_type = 
""   117         $ilDB = $DIC->database();
   119         if ($a_obj_type == 
"") {
   122         $query = 
"SELECT * FROM history WHERE obj_id = " .
   123             $ilDB->quote($a_obj_id, 
"integer") . 
" AND " .
   124             "obj_type = " . 
$ilDB->quote($a_obj_type, 
"text") .
   125             " ORDER BY hdate DESC";
   127         $hist_set = 
$ilDB->query($query);
   128         $hist_items = array();
   129         while ($hist_rec = 
$ilDB->fetchAssoc($hist_set)) {
   130             $hist_items[] = array(
"date" => $hist_rec[
"hdate"],
   131                 "user_id" => $hist_rec[
"usr_id"],
   132                 "obj_id" => $hist_rec[
"obj_id"],
   133                 "obj_type" => $hist_rec[
"obj_type"],
   134                 "action" => $hist_rec[
"action"],
   135                 "info_params" => $hist_rec[
"info_params"],
   136                 "user_comment" => $hist_rec[
"user_comment"],
   137                 "hist_entry_id" => $hist_rec[
"id"]);
   140         if ($a_obj_type == 
"lm") {
   141             $query = 
"SELECT h.*, l.title as title FROM history h, lm_data l WHERE " .
   142                 " l.lm_id = " . 
$ilDB->quote($a_obj_id, 
"integer") . 
" AND " .
   143                 " l.obj_id = h.obj_id AND " .
   144                 " (h.obj_type=" . 
$ilDB->quote($a_obj_type . 
":pg", 
"text") . 
" OR h.obj_type=" . 
$ilDB->quote($a_obj_type . 
":st", 
"text") . 
") " .
   145                 " ORDER BY h.hdate DESC";
   147             $hist_set = 
$ilDB->query($query);
   148             while ($hist_rec = 
$ilDB->fetchAssoc($hist_set)) {
   149                 $hist_items[] = array(
"date" => $hist_rec[
"hdate"],
   150                     "user_id" => $hist_rec[
"usr_id"],
   151                     "obj_id" => $hist_rec[
"obj_id"],
   152                     "obj_type" => $hist_rec[
"obj_type"],
   153                     "action" => $hist_rec[
"action"],
   154                     "info_params" => $hist_rec[
"info_params"],
   155                     "user_comment" => $hist_rec[
"user_comment"],
   156                     "hist_entry_id" => $hist_rec[
"id"],
   157                     "title" => $hist_rec[
"title"]);
   159             usort($hist_items, array(
"ilHistory", 
"_compareHistArray"));
   160             $hist_items2 = array_reverse($hist_items);
   169         if ($a[
"date"] == $b[
"date"]) {
   172         return ($a[
"date"] < $b[
"date"]) ? -1 : 1;
   182         $ilDB = $DIC->database();
   184         $q = 
"DELETE FROM history WHERE obj_id = " .
   185             $ilDB->quote($a_obj_id, 
"integer");
   196         $ilDB = $DIC->database();
   198         $q = 
"SELECT * FROM history WHERE obj_id = " .
   199             $ilDB->quote($a_src_id, 
"integer");
   202         while ($row = 
$ilDB->fetchObject(
$r)) {
   204             $ilDB->insert(
"history", array(
   205                 "id" => array(
"integer", 
$id),
   206                 "obj_id" => array(
"integer", $a_dst_id),
   207                 "obj_type" => array(
"text", $row->obj_type),
   208                 "action" => array(
"text", $row->action),
   210                 "usr_id" => array(
"integer", $row->usr_id),
   211                 "info_params" => array(
"text", $row->info_params),
   212                 "user_comment" => array(
"clob", $row->user_comment)
   224         $ilDB = $DIC->database();
   226         $q = 
"SELECT * FROM history WHERE id = " .
   227             $ilDB->quote($a_hist_entry_id, 
"integer");
   240         $ilDB = $DIC->database();
   242         $q = 
"DELETE FROM history WHERE id = " .
   243             $ilDB->quote($a_hist_entry_id, 
"integer");
   250     public static function _changeUserId(
int $a_hist_entry_id, 
int $new_user_id): void
   254         $ilDB = $DIC->database();
   258             array(
"usr_id" => array(
"integer", $new_user_id)),
   259             array(
"id" => array(
"integer", $a_hist_entry_id))
 static _createEntry(int $a_obj_id, string $a_action, array $a_info_params=[], string $a_obj_type="", string $a_user_comment="", bool $a_update_last=false)
Creates a new history entry for an object. 
 
static _getEntriesForObject(int $a_obj_id, string $a_obj_type="")
get all history entries for an object 
 
static _getEntryByHistoryID(int $a_hist_entry_id)
returns a single history entry 
 
static now()
Return current timestamp in Y-m-d H:i:s format. 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static _removeEntriesForObject(int $a_obj_id)
remove all history entries for an object 
 
static _removeEntryByHistoryID(int $a_hist_entry_id)
Removes a single entry from the history. 
 
static _compareHistArray(array $a, array $b)
 
static _copyEntriesForObject(int $a_src_id, int $a_dst_id)
copy all history entries for an object 
 
static _changeUserId(int $a_hist_entry_id, int $new_user_id)
Changes the user id of the specified history entry. 
 
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins 
 
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples 
 
static _lookupType(int $id, bool $reference=false)