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
71 changes: 71 additions & 0 deletions app/Audit/ConcreteFormatters/SponsorAdAuditLogFormatter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?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\SponsorAd;
use Illuminate\Support\Facades\Log;

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

try {
$text = $subject->getText() ?? 'No Text';
$sponsor = $subject->getSponsor();
$sponsor_id = $sponsor ? ($sponsor->getId() ?? 'unknown') : 'unknown';
$sponsor_company = $sponsor && $sponsor->getCompany() ? ($sponsor->getCompany()->getName() ?? 'Unknown Company') : 'Unknown Company';

switch ($this->event_type) {
case IAuditStrategy::EVENT_ENTITY_CREATION:
return sprintf(
"Sponsor Ad '%s' for Sponsor %s ('%s') created by user %s",
$text,
$sponsor_id,
$sponsor_company,
$this->getUserInfo()
);

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$details = $this->buildChangeDetails($change_set);
return sprintf(
"Sponsor Ad '%s' for Sponsor %s updated: %s by user %s",
$text,
$sponsor_id,
$details,
$this->getUserInfo()
);

case IAuditStrategy::EVENT_ENTITY_DELETION:
return sprintf(
"Sponsor Ad '%s' for Sponsor %s deleted by user %s",
$text,
$sponsor_id,
$this->getUserInfo()
);
}
} catch (\Exception $ex) {
Log::warning("SponsorAdAuditLogFormatter error: " . $ex->getMessage());
}

return null;
}
}
76 changes: 76 additions & 0 deletions app/Audit/ConcreteFormatters/SponsorBadgeScanAuditLogFormatter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?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\SponsorBadgeScan;
use Illuminate\Support\Facades\Log;

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

try {
$id = $subject->getId() ?? 'unknown';
$scan_date = $subject->getScanDate();
$scan_date_str = $scan_date ? $scan_date->format('Y-m-d H:i:s') : 'Unknown Date';
$user = $subject->getUser();
$user_email = $user ? ($user->getEmail() ?? 'Unknown User') : 'Unknown User';
$sponsor = $subject->getSponsor();
$sponsor_id = $sponsor ? ($sponsor->getId() ?? 'unknown') : 'unknown';

switch ($this->event_type) {
case IAuditStrategy::EVENT_ENTITY_CREATION:
return sprintf(
"Sponsor Badge Scan (ID: %s) for user '%s' scanned on '%s' by Sponsor %s created by user %s",
$id,
$user_email,
$scan_date_str,
$sponsor_id,
$this->getUserInfo()
);

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$details = $this->buildChangeDetails($change_set);
return sprintf(
"Sponsor Badge Scan (ID: %s) for Sponsor %s updated: %s by user %s",
$id,
$sponsor_id,
$details,
$this->getUserInfo()
);

case IAuditStrategy::EVENT_ENTITY_DELETION:
return sprintf(
"Sponsor Badge Scan (ID: %s) for user '%s' by Sponsor %s deleted by user %s",
$id,
$user_email,
$sponsor_id,
$this->getUserInfo()
);
}
} catch (\Exception $ex) {
Log::warning("SponsorBadgeScanAuditLogFormatter error: " . $ex->getMessage());
}

return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?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\SponsorBadgeScanExtraQuestionAnswer;
use Illuminate\Support\Facades\Log;

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

try {
$id = $subject->getId() ?? 'unknown';
$value = $subject->getValue() ?? 'No Value';
$question = $subject->getQuestion();
$question_label = $question ? ($question->getLabel() ?? 'Unknown Question') : 'Unknown Question';
$badge_scan = $subject->getBadgeScan();
$sponsor_id = $badge_scan && $badge_scan->getSponsor() ? ($badge_scan->getSponsor()->getId() ?? 'unknown') : 'unknown';

switch ($this->event_type) {
case IAuditStrategy::EVENT_ENTITY_CREATION:
return sprintf(
"Sponsor Badge Scan Extra Question Answer (ID: %s) for question '%s' with value '%s' created for Sponsor %s by user %s",
$id,
$question_label,
$value,
$sponsor_id,
$this->getUserInfo()
);

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$details = $this->buildChangeDetails($change_set);
return sprintf(
"Sponsor Badge Scan Extra Question Answer (ID: %s) for question '%s' updated: %s by user %s",
$id,
$question_label,
$details,
$this->getUserInfo()
);

case IAuditStrategy::EVENT_ENTITY_DELETION:
return sprintf(
"Sponsor Badge Scan Extra Question Answer (ID: %s) for question '%s' deleted by user %s",
$id,
$question_label,
$this->getUserInfo()
);
}
} catch (\Exception $ex) {
Log::warning("SponsorBadgeScanExtraQuestionAnswerAuditLogFormatter error: " . $ex->getMessage());
}

return null;
}
}
78 changes: 78 additions & 0 deletions app/Audit/ConcreteFormatters/SponsorMaterialAuditLogFormatter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?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\SponsorMaterial;
use Illuminate\Support\Facades\Log;

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

try {
$id = $subject->getId() ?? 'unknown';
$name = $subject->getName() ?? 'No Name';
$type = $subject->getType() ?? 'Unknown Type';
$order = $subject->getOrder() ? (string)$subject->getOrder() : 'unknown';
$sponsor = $subject->getSponsor();
$sponsor_id = $sponsor ? ($sponsor->getId() ?? 'unknown') : 'unknown';

switch ($this->event_type) {
case IAuditStrategy::EVENT_ENTITY_CREATION:
return sprintf(
"Sponsor Material (ID: %s) '%s' type '%s' (Order: %s) for Sponsor %s created by user %s",
$id,
$name,
$type,
$order,
$sponsor_id,
$this->getUserInfo()
);

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$details = $this->buildChangeDetails($change_set);
return sprintf(
"Sponsor Material (ID: %s) '%s' for Sponsor %s updated: %s by user %s",
$id,
$name,
$sponsor_id,
$details,
$this->getUserInfo()
);

case IAuditStrategy::EVENT_ENTITY_DELETION:
return sprintf(
"Sponsor Material (ID: %s) '%s' type '%s' for Sponsor %s deleted by user %s",
$id,
$name,
$type,
$sponsor_id,
$this->getUserInfo()
);
}
} catch (\Exception $ex) {
Log::warning("SponsorMaterialAuditLogFormatter error: " . $ex->getMessage());
}

return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?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\SponsorSocialNetwork;
use Illuminate\Support\Facades\Log;

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

try {
$id = $subject->getId() ?? 'unknown';
$link = $subject->getLink() ?? 'No Link';
$icon = $subject->getIconCSSClass() ?? 'No Icon';
$sponsor = $subject->getSponsor();
$sponsor_id = $sponsor ? ($sponsor->getId() ?? 'unknown') : 'unknown';

switch ($this->event_type) {
case IAuditStrategy::EVENT_ENTITY_CREATION:
return sprintf(
"Sponsor Social Network (ID: %s) '%s' with icon '%s' for Sponsor %s created by user %s",
$id,
$link,
$icon,
$sponsor_id,
$this->getUserInfo()
);

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$details = $this->buildChangeDetails($change_set);
return sprintf(
"Sponsor Social Network (ID: %s) for Sponsor %s updated: %s by user %s",
$id,
$sponsor_id,
$details,
$this->getUserInfo()
);

case IAuditStrategy::EVENT_ENTITY_DELETION:
return sprintf(
"Sponsor Social Network (ID: %s) '%s' for Sponsor %s deleted by user %s",
$id,
$link,
$sponsor_id,
$this->getUserInfo()
);
}
} catch (\Exception $ex) {
Log::warning("SponsorSocialNetworkAuditLogFormatter error: " . $ex->getMessage());
}

return null;
}
}
Loading