Files
ops-Gazelle/sections/bookmarks/add.php
2025-08-27 16:44:44 +02:00

26 lines
651 B
PHP

<?php
/** @phpstan-var \Gazelle\User $Viewer */
declare(strict_types=1);
namespace Gazelle;
authorize();
$id = (int)($_GET['id'] ?? 0);
if ($id === 0) {
json_error('bad id');
}
$object = match ($_GET['type'] ?? '') {
'artist' => new Manager\Artist()->findById($id),
'collage' => new Manager\Collage()->findById($id),
'request' => new Manager\Request()->findById($id),
'torrent' => new Manager\TGroup()->findById($id),
default => json_error('bad type'),
};
if ($object instanceof Intf\Bookmarked && new User\Bookmark($Viewer)->create($object)) {
print(json_encode('OK'));
} else {
json_error('not bookmarked');
}