diff --git a/app/Audit/ConcreteFormatters/FileAuditLogFormatter.php b/app/Audit/ConcreteFormatters/FileAuditLogFormatter.php new file mode 100644 index 000000000..18983e0b1 --- /dev/null +++ b/app/Audit/ConcreteFormatters/FileAuditLogFormatter.php @@ -0,0 +1,72 @@ +getName() ?? 'Unknown File'; + $id = $subject->getId() ?? 0; + $filename = $subject->getFilename() ?? 'N/A'; + + switch ($this->event_type) { + case IAuditStrategy::EVENT_ENTITY_CREATION: + return sprintf( + "File '%s' (%s) (%d) created by user %s", + $name, + $filename, + $id, + $this->getUserInfo() + ); + + case IAuditStrategy::EVENT_ENTITY_UPDATE: + $change_details = $this->buildChangeDetails($change_set); + return sprintf( + "File '%s' (%s) (%d) updated: %s by user %s", + $name, + $filename, + $id, + $change_details, + $this->getUserInfo() + ); + + case IAuditStrategy::EVENT_ENTITY_DELETION: + return sprintf( + "File '%s' (%s) (%d) was deleted by user %s", + $name, + $filename, + $id, + $this->getUserInfo() + ); + } + } catch (\Exception $ex) { + Log::warning("FileAuditLogFormatter error: " . $ex->getMessage()); + } + + return null; + } +} diff --git a/app/Audit/ConcreteFormatters/ScheduledSummitLocationBannerAuditLogFormatter.php b/app/Audit/ConcreteFormatters/ScheduledSummitLocationBannerAuditLogFormatter.php new file mode 100644 index 000000000..0cad8a791 --- /dev/null +++ b/app/Audit/ConcreteFormatters/ScheduledSummitLocationBannerAuditLogFormatter.php @@ -0,0 +1,79 @@ +getTitle() ?? 'Unknown Banner'; + $id = $subject->getId() ?? 0; + + $location = $subject->getLocation(); + $location_name = $location ? ($location->getName() ?? 'Unknown Location') : 'Unknown Location'; + + $summit = $location ? ($location->getSummit() ? ($location->getSummit()->getName() ?? 'Unknown Summit') : 'Unknown Summit') : 'Unknown Summit'; + + switch ($this->event_type) { + case IAuditStrategy::EVENT_ENTITY_CREATION: + return sprintf( + "Scheduled Location Banner '%s' (%d) created for Location '%s' in Summit '%s' by user %s", + $title, + $id, + $location_name, + $summit, + $this->getUserInfo() + ); + + case IAuditStrategy::EVENT_ENTITY_UPDATE: + $change_details = $this->buildChangeDetails($change_set); + return sprintf( + "Scheduled Location Banner '%s' (%d) for Location '%s' in Summit '%s' updated: %s by user %s", + $title, + $id, + $location_name, + $summit, + $change_details, + $this->getUserInfo() + ); + + case IAuditStrategy::EVENT_ENTITY_DELETION: + return sprintf( + "Scheduled Location Banner '%s' (%d) for Location '%s' in Summit '%s' was deleted by user %s", + $title, + $id, + $location_name, + $summit, + $this->getUserInfo() + ); + } + } catch (\Exception $ex) { + Log::warning("ScheduledSummitLocationBannerAuditLogFormatter error: " . $ex->getMessage()); + } + + return null; + } +} diff --git a/app/Audit/ConcreteFormatters/SummitBookableVenueRoomAuditLogFormatter.php b/app/Audit/ConcreteFormatters/SummitBookableVenueRoomAuditLogFormatter.php new file mode 100644 index 000000000..a303b548c --- /dev/null +++ b/app/Audit/ConcreteFormatters/SummitBookableVenueRoomAuditLogFormatter.php @@ -0,0 +1,80 @@ +getName() ?? 'Unknown Room'; + $id = $subject->getId() ?? 0; + + $venue = $subject->getVenue(); + $venue_name = $venue ? ($venue->getName() ?? 'Unknown Venue') : 'Unknown Venue'; + + $summit = $subject->getSummit(); + $summit_name = $summit ? ($summit->getName() ?? 'Unknown Summit') : 'Unknown Summit'; + + switch ($this->event_type) { + case IAuditStrategy::EVENT_ENTITY_CREATION: + return sprintf( + "Bookable Venue Room '%s' (%d) created in Venue '%s' for Summit '%s' by user %s", + $name, + $id, + $venue_name, + $summit_name, + $this->getUserInfo() + ); + + case IAuditStrategy::EVENT_ENTITY_UPDATE: + $change_details = $this->buildChangeDetails($change_set); + return sprintf( + "Bookable Venue Room '%s' (%d) in Venue '%s' for Summit '%s' updated: %s by user %s", + $name, + $id, + $venue_name, + $summit_name, + $change_details, + $this->getUserInfo() + ); + + case IAuditStrategy::EVENT_ENTITY_DELETION: + return sprintf( + "Bookable Venue Room '%s' (%d) in Venue '%s' for Summit '%s' was deleted by user %s", + $name, + $id, + $venue_name, + $summit_name, + $this->getUserInfo() + ); + } + } catch (\Exception $ex) { + Log::warning("SummitBookableVenueRoomAuditLogFormatter error: " . $ex->getMessage()); + } + + return null; + } +} diff --git a/app/Audit/ConcreteFormatters/SummitLocationBannerAuditLogFormatter.php b/app/Audit/ConcreteFormatters/SummitLocationBannerAuditLogFormatter.php new file mode 100644 index 000000000..97992b291 --- /dev/null +++ b/app/Audit/ConcreteFormatters/SummitLocationBannerAuditLogFormatter.php @@ -0,0 +1,79 @@ +getTitle() ?? 'Unknown Banner'; + $id = $subject->getId() ?? 0; + + $location = $subject->getLocation(); + $location_name = $location ? ($location->getName() ?? 'Unknown Location') : 'Unknown Location'; + + $summit = $location ? ($location->getSummit() ? ($location->getSummit()->getName() ?? 'Unknown Summit') : 'Unknown Summit') : 'Unknown Summit'; + + switch ($this->event_type) { + case IAuditStrategy::EVENT_ENTITY_CREATION: + return sprintf( + "Location Banner '%s' (%d) created for Location '%s' in Summit '%s' by user %s", + $title, + $id, + $location_name, + $summit, + $this->getUserInfo() + ); + + case IAuditStrategy::EVENT_ENTITY_UPDATE: + $change_details = $this->buildChangeDetails($change_set); + return sprintf( + "Location Banner '%s' (%d) for Location '%s' in Summit '%s' updated: %s by user %s", + $title, + $id, + $location_name, + $summit, + $change_details, + $this->getUserInfo() + ); + + case IAuditStrategy::EVENT_ENTITY_DELETION: + return sprintf( + "Location Banner '%s' (%d) for Location '%s' in Summit '%s' was deleted by user %s", + $title, + $id, + $location_name, + $summit, + $this->getUserInfo() + ); + } + } catch (\Exception $ex) { + Log::warning("SummitLocationBannerAuditLogFormatter error: " . $ex->getMessage()); + } + + return null; + } +} diff --git a/app/Audit/ConcreteFormatters/SummitLocationImageAuditLogFormatter.php b/app/Audit/ConcreteFormatters/SummitLocationImageAuditLogFormatter.php new file mode 100644 index 000000000..63d34d581 --- /dev/null +++ b/app/Audit/ConcreteFormatters/SummitLocationImageAuditLogFormatter.php @@ -0,0 +1,79 @@ +getName() ?? 'Unknown Image'; + $id = $subject->getId() ?? 0; + + $location = $subject->getLocation(); + $location_name = $location ? ($location->getName() ?? 'Unknown Location') : 'Unknown Location'; + + $summit = $location ? ($location->getSummit() ? ($location->getSummit()->getName() ?? 'Unknown Summit') : 'Unknown Summit') : 'Unknown Summit'; + + switch ($this->event_type) { + case IAuditStrategy::EVENT_ENTITY_CREATION: + return sprintf( + "Location Image '%s' (%d) created for Location '%s' in Summit '%s' by user %s", + $name, + $id, + $location_name, + $summit, + $this->getUserInfo() + ); + + case IAuditStrategy::EVENT_ENTITY_UPDATE: + $change_details = $this->buildChangeDetails($change_set); + return sprintf( + "Location Image '%s' (%d) for Location '%s' in Summit '%s' updated: %s by user %s", + $name, + $id, + $location_name, + $summit, + $change_details, + $this->getUserInfo() + ); + + case IAuditStrategy::EVENT_ENTITY_DELETION: + return sprintf( + "Location Image '%s' (%d) for Location '%s' in Summit '%s' was deleted by user %s", + $name, + $id, + $location_name, + $summit, + $this->getUserInfo() + ); + } + } catch (\Exception $ex) { + Log::warning("SummitLocationImageAuditLogFormatter error: " . $ex->getMessage()); + } + + return null; + } +} diff --git a/app/Audit/ConcreteFormatters/SummitVenueFloorAuditLogFormatter.php b/app/Audit/ConcreteFormatters/SummitVenueFloorAuditLogFormatter.php new file mode 100644 index 000000000..31a7a90c1 --- /dev/null +++ b/app/Audit/ConcreteFormatters/SummitVenueFloorAuditLogFormatter.php @@ -0,0 +1,83 @@ +getName() ?? 'Unknown Floor'; + $number = $subject->getNumber() ?? 0; + $id = $subject->getId() ?? 0; + + $venue = $subject->getVenue(); + $venue_name = $venue ? ($venue->getName() ?? 'Unknown Venue') : 'Unknown Venue'; + + $summit = $venue ? ($venue->getSummit() ? ($venue->getSummit()->getName() ?? 'Unknown Summit') : 'Unknown Summit') : 'Unknown Summit'; + + switch ($this->event_type) { + case IAuditStrategy::EVENT_ENTITY_CREATION: + return sprintf( + "Venue Floor '%s' (Floor #%d) (%d) created in Venue '%s' for Summit '%s' by user %s", + $name, + $number, + $id, + $venue_name, + $summit, + $this->getUserInfo() + ); + + case IAuditStrategy::EVENT_ENTITY_UPDATE: + $change_details = $this->buildChangeDetails($change_set); + return sprintf( + "Venue Floor '%s' (Floor #%d) (%d) in Venue '%s' for Summit '%s' updated: %s by user %s", + $name, + $number, + $id, + $venue_name, + $summit, + $change_details, + $this->getUserInfo() + ); + + case IAuditStrategy::EVENT_ENTITY_DELETION: + return sprintf( + "Venue Floor '%s' (Floor #%d) (%d) in Venue '%s' for Summit '%s' was deleted by user %s", + $name, + $number, + $id, + $venue_name, + $summit, + $this->getUserInfo() + ); + } + } catch (\Exception $ex) { + Log::warning("SummitVenueFloorAuditLogFormatter error: " . $ex->getMessage()); + } + + return null; + } +} diff --git a/config/audit_log.php b/config/audit_log.php index 8923ec688..3c93a54ad 100644 --- a/config/audit_log.php +++ b/config/audit_log.php @@ -108,6 +108,30 @@ 'enabled' => true, 'strategy' => \App\Audit\ConcreteFormatters\SummitVenueAuditLogFormatter::class, ], + \models\summit\SummitVenueFloor::class => [ + 'enabled' => true, + 'strategy' => \App\Audit\ConcreteFormatters\SummitVenueFloorAuditLogFormatter::class, + ], + \models\main\File::class => [ + 'enabled' => true, + 'strategy' => \App\Audit\ConcreteFormatters\FileAuditLogFormatter::class, + ], + \models\summit\SummitBookableVenueRoom::class => [ + 'enabled' => true, + 'strategy' => \App\Audit\ConcreteFormatters\SummitBookableVenueRoomAuditLogFormatter::class, + ], + \models\summit\SummitLocationImage::class => [ + 'enabled' => true, + 'strategy' => \App\Audit\ConcreteFormatters\SummitLocationImageAuditLogFormatter::class, + ], + \App\Models\Foundation\Summit\Locations\Banners\SummitLocationBanner::class => [ + 'enabled' => true, + 'strategy' => \App\Audit\ConcreteFormatters\SummitLocationBannerAuditLogFormatter::class, + ], + \App\Models\Foundation\Summit\Locations\Banners\ScheduledSummitLocationBanner::class => [ + 'enabled' => true, + 'strategy' => \App\Audit\ConcreteFormatters\ScheduledSummitLocationBannerAuditLogFormatter::class, + ], \models\summit\SummitExternalLocation::class => [ 'enabled' => true, 'strategy' => \App\Audit\ConcreteFormatters\SummitExternalLocationAuditLogFormatter::class,