i dont know

This commit is contained in:
Lars Behrends
2025-10-20 23:40:55 +02:00
parent 552bb72370
commit 73d8441787
33 changed files with 3079 additions and 69 deletions

View File

@@ -164,9 +164,29 @@ function array_to_object(array $array): object
}
/**
* Convert object to array recursively
* Check if a media type is visible to the current user
*/
function object_to_array(object $object): array
function is_media_type_visible(string $mediaType): bool
{
return json_decode(json_encode($object), true);
// Get database connection
$pdo = \App\Database\Database::getInstance();
// Get media visibility setting
$stmt = $pdo->prepare("SELECT setting_value FROM settings WHERE setting_key = :key LIMIT 1");
$stmt->execute(['key' => "media_visibility_{$mediaType}"]);
$visibility = $stmt->fetchColumn() ?: 'authenticated'; // Default to authenticated only
// Check user authentication status
$isLoggedIn = is_logged_in();
switch ($visibility) {
case 'public':
return true; // Visible to everyone
case 'authenticated':
return $isLoggedIn; // Visible only to authenticated users
case 'hidden':
return false; // Hidden from all users
default:
return $isLoggedIn; // Default to authenticated only
}
}