add composer-unused, comprehensive docs, and project restructure
- Add icanhazstring/composer-unused as dev dependency for dependency hygiene checks
- Add German documentation (docs/) covering architecture, conventions, workflows, and developer checklists
- Add API layer (ApiAuth, ApiBootstrap, ApiResponse), audit, scheduler, custom fields, and SSO services
- Add Microsoft OIDC SSO, API token management, and user lifecycle features
- Add swagger-ui vendor integration and OpenAPI spec
- Add production Docker setup and bin/ scripts
- Update composer dependencies, config, templates, and frontend assets throughout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 15:27:35 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace MintyPHP\Repository\CustomField;
|
|
|
|
|
|
|
|
|
|
use MintyPHP\DB;
|
|
|
|
|
|
2026-03-13 21:58:51 +01:00
|
|
|
/** Manages selected option links for user custom field values (atomic replace). */
|
2026-04-22 19:32:14 +02:00
|
|
|
class UserCustomFieldValueOptionRepository implements UserCustomFieldValueOptionRepositoryInterface
|
add composer-unused, comprehensive docs, and project restructure
- Add icanhazstring/composer-unused as dev dependency for dependency hygiene checks
- Add German documentation (docs/) covering architecture, conventions, workflows, and developer checklists
- Add API layer (ApiAuth, ApiBootstrap, ApiResponse), audit, scheduler, custom fields, and SSO services
- Add Microsoft OIDC SSO, API token management, and user lifecycle features
- Add swagger-ui vendor integration and OpenAPI spec
- Add production Docker setup and bin/ scripts
- Update composer dependencies, config, templates, and frontend assets throughout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 15:27:35 +01:00
|
|
|
{
|
2026-04-22 19:32:14 +02:00
|
|
|
public function replaceForValueId(int $valueId, array $optionIds): bool
|
add composer-unused, comprehensive docs, and project restructure
- Add icanhazstring/composer-unused as dev dependency for dependency hygiene checks
- Add German documentation (docs/) covering architecture, conventions, workflows, and developer checklists
- Add API layer (ApiAuth, ApiBootstrap, ApiResponse), audit, scheduler, custom fields, and SSO services
- Add Microsoft OIDC SSO, API token management, and user lifecycle features
- Add swagger-ui vendor integration and OpenAPI spec
- Add production Docker setup and bin/ scripts
- Update composer dependencies, config, templates, and frontend assets throughout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 15:27:35 +01:00
|
|
|
{
|
|
|
|
|
if ($valueId <= 0) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$deleted = DB::delete('delete from user_custom_field_value_options where value_id = ?', (string) $valueId);
|
|
|
|
|
if ($deleted === false) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$optionIds = array_values(array_unique(array_map('intval', $optionIds)));
|
|
|
|
|
$optionIds = array_values(array_filter($optionIds, static fn ($id) => $id > 0));
|
|
|
|
|
if (!$optionIds) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach ($optionIds as $optionId) {
|
|
|
|
|
$inserted = DB::insert(
|
|
|
|
|
'insert into user_custom_field_value_options (value_id, option_id, created) values (?,?,NOW())',
|
|
|
|
|
(string) $valueId,
|
|
|
|
|
(string) $optionId
|
|
|
|
|
);
|
|
|
|
|
if ($inserted === false) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-22 19:32:14 +02:00
|
|
|
public function listOptionIdsByValueIds(array $valueIds): array
|
add composer-unused, comprehensive docs, and project restructure
- Add icanhazstring/composer-unused as dev dependency for dependency hygiene checks
- Add German documentation (docs/) covering architecture, conventions, workflows, and developer checklists
- Add API layer (ApiAuth, ApiBootstrap, ApiResponse), audit, scheduler, custom fields, and SSO services
- Add Microsoft OIDC SSO, API token management, and user lifecycle features
- Add swagger-ui vendor integration and OpenAPI spec
- Add production Docker setup and bin/ scripts
- Update composer dependencies, config, templates, and frontend assets throughout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 15:27:35 +01:00
|
|
|
{
|
|
|
|
|
$valueIds = array_values(array_unique(array_map('intval', $valueIds)));
|
|
|
|
|
$valueIds = array_values(array_filter($valueIds, static fn ($id) => $id > 0));
|
|
|
|
|
if (!$valueIds) {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$rows = DB::select(
|
|
|
|
|
'select value_id, option_id from user_custom_field_value_options where value_id in (???)',
|
|
|
|
|
$valueIds
|
|
|
|
|
);
|
|
|
|
|
if (!is_array($rows)) {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$map = [];
|
|
|
|
|
foreach ($rows as $row) {
|
|
|
|
|
$data = $row['user_custom_field_value_options'] ?? $row;
|
|
|
|
|
if (!is_array($data)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
$valueId = (int) ($data['value_id'] ?? 0);
|
|
|
|
|
$optionId = (int) ($data['option_id'] ?? 0);
|
|
|
|
|
if ($valueId <= 0 || $optionId <= 0) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
$map[$valueId] ??= [];
|
|
|
|
|
$map[$valueId][] = $optionId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach ($map as &$ids) {
|
|
|
|
|
$ids = array_values(array_unique(array_map('intval', $ids)));
|
|
|
|
|
sort($ids, SORT_NUMERIC);
|
|
|
|
|
}
|
|
|
|
|
unset($ids);
|
|
|
|
|
|
|
|
|
|
return $map;
|
|
|
|
|
}
|
|
|
|
|
}
|