Vereinheitliche die fachlichen Säulen auf die zentrale Säulenverwaltung
Module, Programme und Lizenzartikel verwenden wie Medien und Seiten die Tabelle pillars; die Kopie „Fachliche Säule“ in den redaktionellen Dimensionen wird nirgends mehr angeboten, geändert oder gefiltert und bleibt nur als Verlauf erhalten. - Migration (nur Ergänzungen): composition_pillar und license_article_pillar mit restrictOnDelete, pillar_id an den alten Dimensionswerten als dokumentierte Abbildung, einmalige wiederholbare Übernahme (LegacyPillarAdoption). - Übernahme nur über die gespeicherte Kennung pfeiler-<Nummer> und nur direkte Zuordnungen; mehrdeutige, abgeleitete und verwaiste Fälle werden gemeldet, nicht geraten. Medien bleiben bei ihrer Zuordnung. Alte Zeilen bleiben unverändert. Befehl: php artisan luf:saeulen-uebernehmen [--dry-run]. - Editoren von Modul, Programm und Lizenzartikel wählen Säulen aus der Säulenverwaltung; PillarService::assign gilt für alle Objektarten, Löschschutz zählt alle Objektarten. - Filter: Module und Programme, Aufbau-Picker und Mitgliederbibliothek nach der Säulenzuordnung; alte Adressen mit einem Säulenwert der Einordnung folgen der Säule. - Abgeleitete Säulen (aus enthaltenen Medien) bleiben getrennt von direkten. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d5c2b34b9d
commit
7c48a6480c
25 files changed
+1250
-44
No files matched your search
@@ -272,7 +272,7 @@ public function search(string $query, string $scope, int $exceptCompositionId):
|
||||
/**
|
||||
* @return array{items: list<array<string, string|null>>, more: bool}
|
||||
*/
|
||||
public function browse(string $query, string $kind, string $dimension, int $exceptCompositionId, bool $elementsOnly = false): array
|
||||
public function browse(string $query, string $kind, string $dimension, int $exceptCompositionId, bool $elementsOnly = false, int $pillarId = 0): array
|
||||
{
|
||||
$query = trim($query);
|
||||
$like = '%'.str_replace(['%', '_'], ['', ''], $query).'%';
|
||||
@@ -284,8 +284,8 @@ public function browse(string $query, string $kind, string $dimension, int $exce
|
||||
$latestElements = ContentElementVersion::query()
|
||||
->selectRaw('MAX(id)')
|
||||
->whereIn('status', [ContentVersionStatus::Bereit, ContentVersionStatus::Entwurf])
|
||||
->whereHas('element', function ($builder) use ($query, $like, $kind, $dimensionId): void {
|
||||
$this->constrainElement($builder, $query, $like, $kind, $dimensionId);
|
||||
->whereHas('element', function ($builder) use ($query, $like, $kind, $dimensionId, $pillarId): void {
|
||||
$this->constrainElement($builder, $query, $like, $kind, $dimensionId, $pillarId);
|
||||
})
|
||||
->groupBy('content_element_id');
|
||||
$elements = ContentElementVersion::query()
|
||||
@@ -309,7 +309,7 @@ public function browse(string $query, string $kind, string $dimension, int $exce
|
||||
->selectRaw('MAX(id)')
|
||||
->where('status', ContentVersionStatus::Bereit)
|
||||
->where('composition_id', '!=', $exceptCompositionId)
|
||||
->whereHas('composition', function ($builder) use ($query, $like, $kind, $dimensionId): void {
|
||||
->whereHas('composition', function ($builder) use ($query, $like, $kind, $dimensionId, $pillarId): void {
|
||||
if ($kind === 'modul') {
|
||||
$builder->where('kind', CompositionKind::Uebung);
|
||||
}
|
||||
@@ -318,6 +318,10 @@ public function browse(string $query, string $kind, string $dimension, int $exce
|
||||
$builder->whereIn('id', $this->dimensionSubjectIds(Composition::class, $dimensionId));
|
||||
}
|
||||
|
||||
if ($pillarId > 0) {
|
||||
$builder->whereIn('id', $this->pillarSubjectIds(Composition::class, $pillarId));
|
||||
}
|
||||
|
||||
if ($query === '') {
|
||||
return;
|
||||
}
|
||||
@@ -370,6 +374,10 @@ public function browse(string $query, string $kind, string $dimension, int $exce
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($pillarId > 0 && ! in_array($composition->id, $this->pillarSubjectIds(Composition::class, $pillarId), true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$title = $this->compositionTitle($composition);
|
||||
|
||||
if ($query !== '' && ! str_contains(mb_strtolower($title.' '.(string) ($composition->summary ?? '')), mb_strtolower($query))) {
|
||||
@@ -564,7 +572,7 @@ private function withVisibility(array $rows): array
|
||||
/**
|
||||
* @param Builder<ContentElement> $builder
|
||||
*/
|
||||
private function constrainElement($builder, string $query, string $like, string $kind, int $dimensionId): void
|
||||
private function constrainElement($builder, string $query, string $like, string $kind, int $dimensionId, int $pillarId = 0): void
|
||||
{
|
||||
$outputs = match ($kind) {
|
||||
'film' => ['film'],
|
||||
@@ -583,6 +591,10 @@ private function constrainElement($builder, string $query, string $like, string
|
||||
$builder->whereIn('id', $this->dimensionSubjectIds(ContentElement::class, $dimensionId));
|
||||
}
|
||||
|
||||
if ($pillarId > 0) {
|
||||
$builder->whereIn('id', $this->pillarSubjectIds(ContentElement::class, $pillarId));
|
||||
}
|
||||
|
||||
if ($query === '') {
|
||||
return;
|
||||
}
|
||||
@@ -597,6 +609,22 @@ private function constrainElement($builder, string $query, string $like, string
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Direkt einer Säule zugeordnete Medien oder Module und Programme (zentrale Säulenverwaltung).
|
||||
*
|
||||
* @param class-string<Model> $class
|
||||
* @return list<int>
|
||||
*/
|
||||
private function pillarSubjectIds(string $class, int $pillarId): array
|
||||
{
|
||||
[$table, $column] = $class === Composition::class
|
||||
? ['composition_pillar', 'composition_id']
|
||||
: ['content_element_pillar', 'content_element_id'];
|
||||
|
||||
return DB::table($table)->where('pillar_id', $pillarId)->pluck($column)
|
||||
->map(fn (mixed $id): int => (int) $id)->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string<Model> $class
|
||||
* @return list<int>
|
||||
|
||||
Reference in new issue
Block a user