mirror of
https://github.com/ceratic/MediaCollectorLibary.git
synced 2026-05-13 23:56:46 +02:00
i dont know
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user