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
72 changes: 72 additions & 0 deletions app/Audit/ConcreteFormatters/FileAuditLogFormatter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

namespace App\Audit\ConcreteFormatters;

/**
* Copyright 2026 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

use App\Audit\AbstractAuditLogFormatter;
use App\Audit\Interfaces\IAuditStrategy;
use models\main\File;
use Illuminate\Support\Facades\Log;

class FileAuditLogFormatter extends AbstractAuditLogFormatter
{
public function format($subject, array $change_set): ?string
{
if (!$subject instanceof File) {
return null;
}

try {
$name = $subject->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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php

namespace App\Audit\ConcreteFormatters;

/**
* Copyright 2026 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

use App\Audit\AbstractAuditLogFormatter;
use App\Audit\Interfaces\IAuditStrategy;
use App\Models\Foundation\Summit\Locations\Banners\ScheduledSummitLocationBanner;
use Illuminate\Support\Facades\Log;

class ScheduledSummitLocationBannerAuditLogFormatter extends AbstractAuditLogFormatter
{
public function format($subject, array $change_set): ?string
{
if (!$subject instanceof ScheduledSummitLocationBanner) {
return null;
}

try {
$title = $subject->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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php

namespace App\Audit\ConcreteFormatters;

/**
* Copyright 2026 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

use App\Audit\AbstractAuditLogFormatter;
use App\Audit\Interfaces\IAuditStrategy;
use models\summit\SummitBookableVenueRoom;
use Illuminate\Support\Facades\Log;

class SummitBookableVenueRoomAuditLogFormatter extends AbstractAuditLogFormatter
{
public function format($subject, array $change_set): ?string
{
if (!$subject instanceof SummitBookableVenueRoom) {
return null;
}

try {
$name = $subject->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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php

namespace App\Audit\ConcreteFormatters;

/**
* Copyright 2026 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

use App\Audit\AbstractAuditLogFormatter;
use App\Audit\Interfaces\IAuditStrategy;
use App\Models\Foundation\Summit\Locations\Banners\SummitLocationBanner;
use Illuminate\Support\Facades\Log;

class SummitLocationBannerAuditLogFormatter extends AbstractAuditLogFormatter
{
public function format($subject, array $change_set): ?string
{
if (!$subject instanceof SummitLocationBanner) {
return null;
}

try {
$title = $subject->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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php

namespace App\Audit\ConcreteFormatters;

/**
* Copyright 2026 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

use App\Audit\AbstractAuditLogFormatter;
use App\Audit\Interfaces\IAuditStrategy;
use models\summit\SummitLocationImage;
use Illuminate\Support\Facades\Log;

class SummitLocationImageAuditLogFormatter extends AbstractAuditLogFormatter
{
public function format($subject, array $change_set): ?string
{
if (!$subject instanceof SummitLocationImage) {
return null;
}

try {
$name = $subject->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;
}
}
Loading
Loading