Zeige Kurse im Mitgliederbereich und mach hochgeladene Fassungen ansehbar.
Deploy Test / test (push) Successful in 14s
Deploy Test / deploy (push) Successful in 22s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-11-15 10:27:20 +01:00
1 parent b374335b3a
commit 4f2e5a5f3b
24 files changed
+413 -47

No files matched your search

@@ -0,0 +1,35 @@
<?php
namespace App\Http\Controllers;
use App\Domain\Catalog\ContentElementVersion;
use App\Domain\Identity\StaffRole;
use App\Models\User;
use Illuminate\Support\Facades\Storage;
use Illuminate\View\View;
use Symfony\Component\HttpFoundation\StreamedResponse;
class ContentPreviewController extends Controller
{
public function __invoke(ContentElementVersion $version): View|StreamedResponse
{
$user = auth('staff')->user();
abort_unless(
$user instanceof User && ($user->hasStaffRole(StaffRole::Redakteur) || $user->hasStaffRole(StaffRole::Katalogverwalter)),
403,
);
$version->loadMissing('element');
$file = $version->metadata['file'] ?? null;
if (is_string($file) && $file !== '' && ! str_contains($file, '..') && Storage::disk('media_derived')->exists($file)) {
return Storage::disk('media_derived')->response($file, basename($file), [
'Content-Disposition' => 'inline',
]);
}
return view('content.preview', [
'version' => $version,
]);
}
}
@@ -9,6 +9,7 @@
use App\Domain\Entitlement\Grant;
use App\Domain\Entitlement\GrantStatus;
use App\Http\Controllers\Controller;
use App\Http\CourseOutline;
use App\Http\SignedLink;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
@@ -20,7 +21,10 @@ class LibraryController extends Controller
public function index(Request $request): View
{
return view('member.library', [
'grants' => $this->grantQuery($request)->with('article.currentRelease')->get(),
'grants' => $this->grantQuery($request)->with([
'article.currentRelease.rootCompositionVersion.composition',
'article.currentRelease.rootElementVersion.element',
])->get(),
]);
}
@@ -47,14 +51,21 @@ public function show(Request $request, LicenseArticle $article): View
foreach ($release->contents as $content) {
$version = $content->elementVersion;
$class = $version->element->output_class;
$metadata = is_array($version->metadata) ? $version->metadata : [];
$action = $class === 'film' || $class === 'audio' ? 'streamen' : 'ansehen';
$decision = app(DecideAccess::class)($request->user(), $article, $release, $version, $action);
$file = $metadata['file'] ?? null;
$entries[] = [
'content' => $content,
'version' => $version,
'role' => $content->role,
'action' => $action,
'allowed' => $decision->allowed,
'reason' => $decision->reason,
'decision' => is_numeric($metadata['decision_seconds'] ?? null)
? (int) $metadata['decision_seconds']
: null,
'playable' => $decision->allowed && is_string($file) && $file !== '' && ($class === 'film' || $class === 'audio'),
'url' => $decision->allowed
? SignedLink::temporary('member.media', now()->addMinutes(10), [
'article' => $article->id,
@@ -72,6 +83,7 @@ public function show(Request $request, LicenseArticle $article): View
'article' => $article,
'release' => $release,
'entries' => $entries,
'title' => app(CourseOutline::class)->title($article),
]);
}