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 %} +
+