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

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

try {
$name = $subject->getName() ?? 'Unknown Document';
$id = $subject->getId() ?? 'unknown';
$label = $subject->getLabel() ?? $name;
$summit = $subject->getSummit();
$summit_name = $summit ? ($summit->getName() ?? 'Unknown Summit') : 'Unknown Summit';

switch ($this->event_type) {
case IAuditStrategy::EVENT_ENTITY_CREATION:
return sprintf(
"Summit Document '%s' (%d) created for Summit '%s' with label '%s' by user %s",
$name,
$id,
$summit_name,
$label,
$this->getUserInfo()
);

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$change_details = $this->buildChangeDetails($change_set);
return sprintf(
"Summit Document '%s' (%d) for Summit '%s' updated: %s by user %s",
$name,
$id,
$summit_name,
$change_details,
$this->getUserInfo()
);

case IAuditStrategy::EVENT_ENTITY_DELETION:
return sprintf(
"Summit Document '%s' (%d) for Summit '%s' was deleted by user %s",
$name,
$id,
$summit_name,
$this->getUserInfo()
);
}
} catch (\Exception $ex) {
Log::warning("SummitDocumentAuditLogFormatter error: " . $ex->getMessage());
}

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

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

try {
$key = $subject->getKey() ?? 'Unknown Config';
$id = $subject->getId() ?? 'unknown';
$summit = $subject->getSummit();
$summit_name = $summit ? ($summit->getName() ?? 'Unknown Summit') : 'Unknown Summit';
$is_default = $subject->getIsDefault() ? 'default' : 'non-default';
$color_source = $subject->getColorSource() ?? 'Unknown';

switch ($this->event_type) {
case IAuditStrategy::EVENT_ENTITY_CREATION:
return sprintf(
"Schedule Config '%s' (%d) created for Summit '%s' (%s, color source: %s) by user %s",
$key,
$id,
$summit_name,
$is_default,
$color_source,
$this->getUserInfo()
);

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$change_details = $this->buildChangeDetails($change_set);
return sprintf(
"Schedule Config '%s' (%d) for Summit '%s' updated: %s by user %s",
$key,
$id,
$summit_name,
$change_details,
$this->getUserInfo()
);

case IAuditStrategy::EVENT_ENTITY_DELETION:
return sprintf(
"Schedule Config '%s' (%d) for Summit '%s' was deleted by user %s",
$key,
$id,
$summit_name,
$this->getUserInfo()
);
}
} catch (\Exception $ex) {
Log::warning("SummitScheduleConfigAuditLogFormatter error: " . $ex->getMessage());
}

return null;
}
}
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\summit\SummitSchedulePreFilterElementConfig;
use Illuminate\Support\Facades\Log;

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

try {
$id = $subject->getId() ?? 'unknown';
$type = $subject->getType() ?? 'Unknown Type';

$schedule_config = $subject->getConfig();
$config_key = $schedule_config ? ($schedule_config->getKey() ?? 'Unknown Config') : 'Unknown Config';

switch ($this->event_type) {
case IAuditStrategy::EVENT_ENTITY_CREATION:
return sprintf(
"Schedule Pre-Filter Element Config (%d) created for Config '%s' with type '%s' by user %s",
$id,
$config_key,
$type,
$this->getUserInfo()
);

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$change_details = $this->buildChangeDetails($change_set);
return sprintf(
"Schedule Pre-Filter Element Config (%d) for Config '%s' updated: %s by user %s",
$id,
$config_key,
$change_details,
$this->getUserInfo()
);

case IAuditStrategy::EVENT_ENTITY_DELETION:
return sprintf(
"Schedule Pre-Filter Element Config (%d) for Config '%s' was deleted by user %s",
$id,
$config_key,
$this->getUserInfo()
);
}
} catch (\Exception $ex) {
Log::warning("SummitSchedulePreFilterElementConfigAuditLogFormatter error: " . $ex->getMessage());
}

return null;
}
}
76 changes: 76 additions & 0 deletions app/Audit/ConcreteFormatters/SummitSignAuditLogFormatter.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 App\Models\Foundation\Summit\Signs\SummitSign;
use Illuminate\Support\Facades\Log;

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

try {
$id = $subject->getId() ?? 'unknown';
$template = $subject->getTemplate() ?? 'Unknown Template';
$location = $subject->getLocation();
$location_name = $location ? ($location->getName() ?? 'Unknown Location') : 'No Location';
$summit = $subject->getSummit();
$summit_name = $summit ? ($summit->getName() ?? 'Unknown Summit') : 'Unknown Summit';

switch ($this->event_type) {
case IAuditStrategy::EVENT_ENTITY_CREATION:
return sprintf(
"Summit Sign (%d) created for Summit '%s' at Location '%s' with template '%s' by user %s",
$id,
$summit_name,
$location_name,
$template,
$this->getUserInfo()
);

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$change_details = $this->buildChangeDetails($change_set);
return sprintf(
"Summit Sign (%d) for Summit '%s' at Location '%s' updated: %s by user %s",
$id,
$summit_name,
$location_name,
$change_details,
$this->getUserInfo()
);

case IAuditStrategy::EVENT_ENTITY_DELETION:
return sprintf(
"Summit Sign (%d) for Summit '%s' at Location '%s' was deleted by user %s",
$id,
$summit_name,
$location_name,
$this->getUserInfo()
);
}
} catch (\Exception $ex) {
Log::warning("SummitSignAuditLogFormatter error: " . $ex->getMessage());
}

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

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

try {
$name = $subject->getName() ?? 'Unknown Tag Group';
$id = $subject->getId() ?? 'unknown';
$label = $subject->getLabel() ?? $name;
$summit = $subject->getSummit();
$summit_name = $summit ? ($summit->getName() ?? 'Unknown Summit') : 'Unknown Summit';

switch ($this->event_type) {
case IAuditStrategy::EVENT_ENTITY_CREATION:
return sprintf(
"Track Tag Group '%s' (%d) created for Summit '%s' with label '%s' by user %s",
$name,
$id,
$summit_name,
$label,
$this->getUserInfo()
);

case IAuditStrategy::EVENT_ENTITY_UPDATE:
$change_details = $this->buildChangeDetails($change_set);
return sprintf(
"Track Tag Group '%s' (%d) for Summit '%s' updated: %s by user %s",
$name,
$id,
$summit_name,
$change_details,
$this->getUserInfo()
);

case IAuditStrategy::EVENT_ENTITY_DELETION:
return sprintf(
"Track Tag Group '%s' (%d) for Summit '%s' was deleted by user %s",
$name,
$id,
$summit_name,
$this->getUserInfo()
);
}
} catch (\Exception $ex) {
Log::warning("TrackTagGroupAuditLogFormatter error: " . $ex->getMessage());
}

return null;
}
}
Loading