61 lines
1.9 KiB
PHP
61 lines
1.9 KiB
PHP
<?php
|
|
class ModuleService {
|
|
private static $modules = [
|
|
'dinos' => [
|
|
'slug' => 'dinos',
|
|
'name' => 'Dino Generator',
|
|
'badge' => 'AI Art',
|
|
'description' => 'KI Dino-Bilderstellung & Google Photos Sync',
|
|
'path' => '/dinos',
|
|
'adminOnly' => false
|
|
],
|
|
'plants' => [
|
|
'slug' => 'plants',
|
|
'name' => 'Plant Tracker',
|
|
'badge' => 'AI Vision',
|
|
'description' => 'Pflanzen-Tracking, Pflege & KI-Erkennung',
|
|
'path' => '/plants',
|
|
'adminOnly' => false
|
|
],
|
|
'storymachine' => [
|
|
'slug' => 'storymachine',
|
|
'name' => 'Story Machine',
|
|
'badge' => 'Creative',
|
|
'description' => 'Interaktive Kinder-Geschichtenmaschine',
|
|
'path' => '/storymachine',
|
|
'adminOnly' => false
|
|
],
|
|
'test' => [
|
|
'slug' => 'test',
|
|
'name' => 'Test',
|
|
'badge' => 'Test',
|
|
'description' => 'Interaktive Web Audio API Synthese & Soundtest',
|
|
'path' => '/test',
|
|
'adminOnly' => false
|
|
]
|
|
];
|
|
|
|
public static function getAll(): array {
|
|
return self::$modules;
|
|
}
|
|
|
|
public static function getBySlug(string $slug): ?array {
|
|
return self::$modules[$slug] ?? null;
|
|
}
|
|
|
|
public static function getAccessibleForUser(array $userProjects, bool $isAdmin = false): array {
|
|
$accessible = [];
|
|
foreach (self::$modules as $slug => $module) {
|
|
if ($isAdmin) {
|
|
$accessible[$slug] = $module;
|
|
} elseif (in_array($slug, $userProjects, true) && !$module['adminOnly']) {
|
|
$accessible[$slug] = $module;
|
|
}
|
|
}
|
|
return $accessible;
|
|
}
|
|
|
|
public static function isValidModule(string $slug): bool {
|
|
return isset(self::$modules[$slug]);
|
|
}
|
|
}
|