From 5aa20e6a2290c4984156d1d6ad58094b3d60f0db Mon Sep 17 00:00:00 2001 From: ghost Date: Sun, 8 Oct 2023 03:30:57 +0300 Subject: [PATCH] draft torrent sensitive features --- src/Repository/TorrentSensitiveRepository.php | 33 +++++++++++++++++++ templates/default/torrent/info.html.twig | 16 +++++++++ 2 files changed, 49 insertions(+) diff --git a/src/Repository/TorrentSensitiveRepository.php b/src/Repository/TorrentSensitiveRepository.php index e21c7e6..4829843 100644 --- a/src/Repository/TorrentSensitiveRepository.php +++ b/src/Repository/TorrentSensitiveRepository.php @@ -20,4 +20,37 @@ class TorrentSensitiveRepository extends ServiceEntityRepository { parent::__construct($registry, TorrentSensitive::class); } + + public function getTorrentSensitive(int $id): ?TorrentSensitive + { + return $this->createQueryBuilder('ts') + ->where('ts.id = :id') + ->setParameter('id', $id) + ->getQuery() + ->getOneOrNullResult() + ; + } + + public function findLastTorrentSensitive(int $torrentId): ?TorrentSensitive + { + return $this->createQueryBuilder('ts') + ->where('ts.torrentId = :torrentId') + ->setParameter('torrentId', $torrentId) + ->orderBy('ts.id', 'DESC') // same to ts.added + ->setMaxResults(1) + ->getQuery() + ->getOneOrNullResult() + ; + } + + public function findTorrentSensitive(int $torrentId): array + { + return $this->createQueryBuilder('ts') + ->where('ts.torrentId = :torrentId') + ->setParameter('torrentId', $torrentId) + ->orderBy('ts.id', 'DESC') // same to ts.added + ->getQuery() + ->getResult() + ; + } } diff --git a/templates/default/torrent/info.html.twig b/templates/default/torrent/info.html.twig index d249e63..fea1b45 100644 --- a/templates/default/torrent/info.html.twig +++ b/templates/default/torrent/info.html.twig @@ -193,6 +193,22 @@ {% endif %} +
+ + + + + + {{ 'Sensitive'|trans }} +
+
+ {% if torrent.sensitive %} + {{ 'yes'|trans }} + {% else %} + {{ 'no'|trans }} + {% endif %} +
+