diff --git a/classes/dml/outagedb.php b/classes/dml/outagedb.php index f5c6331..963ac3f 100644 --- a/classes/dml/outagedb.php +++ b/classes/dml/outagedb.php @@ -130,9 +130,6 @@ class outagedb { // Create calendar entry. calendar::create($outage); } else { - // Remove the createdby field so it does not get updated. - unset($outage->createdby); - $DB->update_record('auth_outage', $outage); $other = (array) $outage; $other['title'] = $outage->get_title(); @@ -140,9 +137,14 @@ class outagedb { 'objectid' => $outage->id, 'other' => $other, ]); + $event->add_record_snapshot('auth_outage', (object)(array) $outage); $event->trigger(); + // Remove the createdby field so it does not get updated. + unset($outage->createdby); + $DB->update_record('auth_outage', $outage); + // Update calendar entry. calendar::update($outage); } diff --git a/classes/local/outage.php b/classes/local/outage.php index 4a837ff..852dc56 100644 --- a/classes/local/outage.php +++ b/classes/local/outage.php @@ -281,7 +281,17 @@ class outage { */ private function adjust_field_types() { // Adjust int fields. - $fs = ['createdby', 'id', 'lastmodified', 'modifiedby', 'starttime', 'stoptime', 'warntime', 'finished']; + $fs = [ + 'id', + 'starttime', + 'stoptime', + 'warntime', + 'finished', + 'createdby', + 'lastmodified', + 'modifiedby', + ]; + foreach ($fs as $f) { $this->$f = ($this->$f === null) ? null : (int)$this->$f; }