- Bilder im Text folgen dem Recht am Text; eine eigene Fähigkeit für Bilder ist nicht nötig (ADR-51, fachliche Entscheidung zur Bestätigung). - Bildadresse und PDF-Adresse des Dokuments laufen nicht ab; jeder Abruf entscheidet neu. - Die Fähigkeit text:laden ist im Rechteprofil wählbar. - Dokumentkapitel in der Medienansicht verweisen auf ihr Dokument; die Pille nennt jetzt auch Dokumentkapitel (MedienFilterDialogTest bewusst angepasst). - Abnahmeprotokoll mit Bildern unter docs/ux/verwaltung/abnahme/dokumente. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
42 lines
2.0 KiB
PHP
42 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Member;
|
|
|
|
use App\Domain\Catalog\ArticleRelease;
|
|
use App\Domain\Catalog\ContentElementVersion;
|
|
use App\Domain\Catalog\EmbeddedImages;
|
|
use App\Domain\Catalog\ExerciseGuide;
|
|
use App\Domain\Catalog\LicenseArticle;
|
|
use App\Domain\Media\DeliveryLog;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\LibraryCatalog;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
|
|
|
/**
|
|
* Ein Bild im Text eines erworbenen Stands (ADR-51). Die Adresse läuft nicht ab, weil eine Seite lange offen bleibt; dafür
|
|
* entscheidet jeder Abruf neu: Konto, Stand, Text, Recht am Text, Zugehörigkeit des Bildes zum Text und zum Stand und die
|
|
* Sperre der Bildfassung. Eine Datei liegt nie unter einem öffentlichen Pfad.
|
|
*/
|
|
class StandImageController extends Controller
|
|
{
|
|
public function __invoke(Request $request, LicenseArticle $article, ArticleRelease $release, ContentElementVersion $text, ContentElementVersion $version): StreamedResponse
|
|
{
|
|
abort_unless(app(ExerciseGuide::class)->mayOpen($request->user(), $article, $release), 403);
|
|
|
|
$served = app(EmbeddedImages::class)->serve($request->user(), $article, $release, $text, $version->id);
|
|
abort_if($served === null, 403);
|
|
|
|
$file = EmbeddedImages::file($served['version']);
|
|
abort_if($file === null, 404);
|
|
|
|
$disk = Storage::disk('media_derived');
|
|
$delivery = app(DeliveryLog::class)->write($served['grant'], $article, $release, $served['version'], 'ansehen', 'bestand', hash_file('sha256', $disk->path($file)) ?: null, 'k0');
|
|
$title = app(LibraryCatalog::class)->text($served['version']->element)['title'];
|
|
$name = ($title !== '' ? preg_replace('/[\x00-\x1F\x7F\/\\\\:*?"<>|]+/u', ' ', $title) : 'bild').'.'.strtolower(pathinfo($file, PATHINFO_EXTENSION));
|
|
|
|
return $disk->response($file, trim((string) $name), ['X-License-Copy' => $delivery->copy_id, 'Cache-Control' => 'private, max-age=300'], 'inline');
|
|
}
|
|
}
|