Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions app/Audit/AbstractAuditLogFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ protected function formatChangeValue($value): string
}


protected function buildChangeDetails(array $change_set): string
protected function buildChangeDetails(array $change_set): ?string
{
$changed_fields = [];
$ignored_fields = $this->getIgnoredFields();
Expand All @@ -178,21 +178,51 @@ protected function buildChangeDetails(array $change_set): string
}

if (empty($changed_fields)) {
return 'properties without changes registered';
return null;
}

$fields_summary = count($changed_fields) . ' field(s) modified: ';
return $fields_summary . implode(' | ', $changed_fields);
}


protected function formatFieldChange(string $prop_name, $old_value, $new_value): ?string
{
if ($this->valuesAreEffectivelyEqual($old_value, $new_value)) {
return null;
}

$old_display = $this->formatChangeValue($old_value);
$new_display = $this->formatChangeValue($new_value);

return sprintf("Property \"%s\" has changed from \"%s\" to \"%s\"", $prop_name, $old_display, $new_display);
}

protected function valuesAreEffectivelyEqual($old_value, $new_value): bool
{
if ($old_value === $new_value) {
return true;
}

if ($old_value instanceof \DateTimeInterface && $new_value instanceof \DateTimeInterface) {
if ($old_value->getTimestamp() === $new_value->getTimestamp()) {
return true;
}

try {
return $old_value->format('U.u') === $new_value->format('U.u');
} catch (\Throwable $e) {
return false;
}
}

if ((is_scalar($old_value) || is_null($old_value)) && (is_scalar($new_value) || is_null($new_value))) {
return $this->formatChangeValue($old_value) === $this->formatChangeValue($new_value);
}

return false;
}

/**
* Format detailed message for many-to-many collection changes
*/
Expand Down
4 changes: 2 additions & 2 deletions app/Audit/AuditLogOtlpStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function audit($subject, array $change_set, string $event_type, AuditCon
return;
}
Log::debug("AuditLogOtlpStrategy::audit", ['subject' => $subject, 'change_set' => $change_set, 'event_type' => $event_type]);
try {
try {
$entity = $this->resolveAuditableEntity($subject);
if (is_null($entity)) {
Log::warning("AuditLogOtlpStrategy::audit subject not found");
Expand All @@ -76,7 +76,7 @@ public function audit($subject, array $change_set, string $event_type, AuditCon
job: $job,
);
Log::debug("AuditLogOtlpStrategy::audit entry sent to OTEL", ["user_id" => $ctx->userId, "user_email" => $ctx->userEmail]);

} catch (\Exception $ex) {
Log::error('OTEL audit logging error: ' . $ex->getMessage(), [
'exception' => $ex,
Expand Down
3 changes: 3 additions & 0 deletions app/Audit/ConcreteFormatters/AffiliationAuditLogFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public function format($subject, array $change_set): ?string

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$details = $this->buildChangeDetails($change_set);
if ($details === null) {
return null;
}
return sprintf("Affiliation (%s) for '%s' (%s) updated: %s by user %s", $id, $owner_name, $job_title, $details, $this->getUserInfo());

case IAuditStrategy::EVENT_ENTITY_DELETION:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public function format($subject, array $change_set): ?string
$question_type = $subject->getQuestionType();
$question_label = $question_type ? ($question_type->getLabel() ?? 'Unknown Question') : 'Unknown Question';
$change_details = $this->buildChangeDetails($change_set);
if ($change_details === null) {
return null;
}
return sprintf(
"Assigned Selection Plan Extra Question (%s) '%s' updated: %s by user %s",
$id,
Expand Down
3 changes: 3 additions & 0 deletions app/Audit/ConcreteFormatters/CompanyAuditLogFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public function format($subject, array $change_set): ?string

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$change_details = $this->buildChangeDetails($change_set);
if ($change_details === null) {
return null;
}
return sprintf(
"Company '%s' (%d) updated: %s by user %s",
$name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function format($subject, array $change_set): ?string
return sprintf("Extra Question Value '%s' (%s) for Question '%s' created by user %s", $label, $id, $question_label, $this->getUserInfo());
case IAuditStrategy::EVENT_ENTITY_UPDATE:
$details = $this->buildChangeDetails($change_set);
if ($details === null) return null;
return sprintf("Extra Question Value '%s' (%s) for Question '%s' updated: %s by user %s", $label, $id, $question_label, $details, $this->getUserInfo());
case IAuditStrategy::EVENT_ENTITY_DELETION:
return sprintf("Extra Question Value '%s' (%s) for Question '%s' deleted by user %s", $label, $id, $question_label, $this->getUserInfo());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public function format($subject, array $change_set): ?string

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$change_details = $this->buildChangeDetails($change_set);
if ($change_details === null) {
return null;
}
return sprintf(
"Featured speaker '%s' (%s) updated: %s by user %s",
$speaker_name,
Expand Down
3 changes: 3 additions & 0 deletions app/Audit/ConcreteFormatters/FileAuditLogFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public function format($subject, array $change_set): ?string

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$change_details = $this->buildChangeDetails($change_set);
if ($change_details === null) {
return null;
}
return sprintf(
"File '%s' (%s) (%d) updated: %s by user %s",
$name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ public function format($subject, array $change_set): ?string

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$change_details = $this->buildChangeDetails($change_set);
if ($change_details === null) {
return null;
}
return sprintf(
"Pre-Paid Discount Code '%s' (%d) for Summit '%s' updated: %s (current: %s) by user %s",
$code,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public function format($subject, array $change_set): ?string
return sprintf("Presentation Attendee Vote (%s) for '%s' created by user %s", $id, $title, $this->getUserInfo());
case IAuditStrategy::EVENT_ENTITY_UPDATE:
$details = $this->buildChangeDetails($change_set);
if ($details === null) {
return null;
}
return sprintf("Presentation Attendee Vote (%s) for '%s' updated: %s by user %s", $id, $title, $details, $this->getUserInfo());
case IAuditStrategy::EVENT_ENTITY_DELETION:
return sprintf("Presentation Attendee Vote (%s) for '%s' deleted by user %s", $id, $title, $this->getUserInfo());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public function format($subject, array $change_set): ?string

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$change_details = $this->buildChangeDetails($change_set);
if ($change_details === null) {
return null;
}
return sprintf(
"Presentation Category '%s' (%s) (%d) for Summit '%s' updated: %s by user %s",
$title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public function format($subject, array $change_set): ?string

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$change_details = $this->buildChangeDetails($change_set);
if ($change_details === null) {
return null;
}
return sprintf(
"Track Group (PresentationCategoryGroup) '%s' (%s) for Summit '%s' updated: %s by user %s",
$name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function format(mixed $subject, array $change_set): ?string

abstract protected function formatCreation(array $data): string;

abstract protected function formatUpdate(array $data, array $change_set): string;
abstract protected function formatUpdate(array $data, array $change_set): ?string;

abstract protected function formatDeletion(array $data): string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public function format($subject, array $change_set): ?string

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$change_details = $this->buildChangeDetails($change_set);
if ($change_details === null) {
return null;
}
return sprintf(
"Presentation Action Type '%s' (%d) for Summit '%s' updated: %s by user %s",
$label,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ protected function formatCreation(array $data): string
);
}

protected function formatUpdate(array $data, array $change_set): string
protected function formatUpdate(array $data, array $change_set): ?string
{
$change_details = $this->buildChangeDetails($change_set);
if ($change_details === null) {
return null;
}
return sprintf(
"Presentation '%s' (%s) updated: %s by user %s",
$data['title'],
$data['id'],
$this->buildChangeDetails($change_set),
$change_details,
$this->getUserInfo()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public function format($subject, array $change_set): ?string

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$change_details = $this->buildChangeDetails($change_set);
if ($change_details === null) {
return null;
}
return sprintf(
"Presentation Link '%s' (%d) for presentation '%s' updated: %s by user %s",
$title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public function format($subject, array $change_set): ?string

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$change_details = $this->buildChangeDetails($change_set);
if ($change_details === null) {
return null;
}
return sprintf(
"Presentation Media Upload '%s' (%d) for presentation '%s' updated: %s by user %s",
$title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public function format($subject, array $change_set): ?string

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$change_details = $this->buildChangeDetails($change_set);
if ($change_details === null) {
return null;
}
return sprintf(
"Presentation Slide '%s' (%d) for presentation '%s' updated: %s by user %s",
$title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public function format($subject, array $change_set): ?string

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$change_details = $this->buildChangeDetails($change_set);
if ($change_details === null) {
return null;
}
return sprintf(
"Speaker '%s' (%s) updated: %s by user %s",
$full_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public function format($subject, array $change_set): ?string

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$change_details = $this->buildChangeDetails($change_set);
if ($change_details === null) {
return null;
}
return sprintf(
"Speaker Assistance Confirmation (%d) for '%s' on Summit '%s' updated: %s by user %s",
$id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ protected function formatCreation(array $data): string
);
}

protected function formatUpdate(array $data, array $change_set): string
protected function formatUpdate(array $data, array $change_set): ?string
{
$change_details = $this->buildChangeDetails($change_set);
if ($change_details === null) {
return null;
}
return sprintf(
"Presentation '%s' (%s) updated: %s by user %s",
$data['title'],
$data['id'],
$this->buildChangeDetails($change_set),
$change_details,
$this->getUserInfo()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public function format($subject, array $change_set): ?string

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$change_details = $this->buildChangeDetails($change_set);
if ($change_details === null) {
return null;
}
return sprintf(
"Track Chair Rating Type '%s' updated: %s by user %s",
$name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public function format($subject, array $change_set): ?string

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$change_details = $this->buildChangeDetails($change_set);
if ($change_details === null) {
return null;
}
return sprintf(
"Score Type '%s' updated: %s by user %s",
$label,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public function format($subject, array $change_set): ?string

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$change_details = $this->buildChangeDetails($change_set);
if ($change_details === null) {
return null;
}
return sprintf(
"Presentation '%s' (%d) updated: %s by user %s",
$title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public function format($subject, array $change_set): ?string

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$change_details = $this->buildChangeDetails($change_set);
if ($change_details === null) {
return null;
}
return sprintf(
"Presentation Video '%s' (%d) for presentation '%s' updated: %s by user %s",
$title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public function format($subject, array $change_set): ?string

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$change_details = $this->buildChangeDetails($change_set);
if ($change_details === null) {
return null;
}
return sprintf(
"Presentation Type '%s' (%d) for Summit '%s' updated: %s by user %s",
$type_name,
Expand Down
3 changes: 3 additions & 0 deletions app/Audit/ConcreteFormatters/RSVPAuditLogFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public function format($subject, array $change_set): ?string

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$change_details = $this->buildChangeDetails($change_set);
if ($change_details === null) {
return null;
}
return sprintf(
"RSVP (ID: %s) for event '%s' updated: %s by user %s",
$id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public function format($subject, array $change_set): ?string

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$change_details = $this->buildChangeDetails($change_set);
if ($change_details === null) {
return null;
}
return sprintf(
"RSVP invitation (ID: %s) for attendee '%s' to event '%s' updated: %s by user %s",
$id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public function format($subject, array $change_set): ?string

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$change_details = $this->buildChangeDetails($change_set);
if ($change_details === null) {
return null;
}
return sprintf(
"%s question '%s' (ID: %s) in RSVP template (ID: %s) updated: %s by user %s",
$className,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public function format($subject, array $change_set): ?string

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$change_details = $this->buildChangeDetails($change_set);
if ($change_details === null) {
return null;
}
return sprintf(
"RSVP Template '%s' (%d) for Summit '%s' updated: %s by user %s",
$title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public function format($subject, array $change_set): ?string

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$change_details = $this->buildChangeDetails($change_set);
if ($change_details === null) {
return null;
}
return sprintf(
"Scheduled Location Banner '%s' (%d) for Location '%s' in Summit '%s' updated: %s by user %s",
$title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public function format($subject, array $change_set): ?string

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$change_details = $this->buildChangeDetails($change_set);
if ($change_details === null) {
return null;
}
return sprintf(
"Selection Plan Allowed Editable Presentation Question (%s) type '%s' updated: %s by user %s",
$id,
Expand Down
Loading
Loading