diff --git a/.env b/.env
index 0a58587..f2013ac 100644
--- a/.env
+++ b/.env
@@ -48,7 +48,7 @@ MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
# YGGtracker
# Application version, used for API and media cache
-APP_VERSION='2.2.0'
+APP_VERSION='2.2.1'
# Application name
APP_NAME=YGGtracker
diff --git a/migrations/Version20231026163131.php b/migrations/Version20231026163131.php
new file mode 100644
index 0000000..51c0288
--- /dev/null
+++ b/migrations/Version20231026163131.php
@@ -0,0 +1,37 @@
+addSql('ALTER TABLE torrent ADD COLUMN status BOOLEAN DEFAULT 1');
+ }
+
+ public function down(Schema $schema): void
+ {
+ // this down() migration is auto-generated, please modify it to your needs
+ $this->addSql('CREATE TEMPORARY TABLE __temp__torrent AS SELECT id, user_id, added, scraped, locales, sensitive, approved, md5file, keywords, seeders, peers, leechers FROM torrent');
+ $this->addSql('DROP TABLE torrent');
+ $this->addSql('CREATE TABLE torrent (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, user_id INTEGER NOT NULL, added INTEGER NOT NULL, scraped INTEGER DEFAULT NULL, locales CLOB NOT NULL --(DC2Type:simple_array)
+ , sensitive BOOLEAN NOT NULL, approved BOOLEAN NOT NULL, md5file VARCHAR(32) NOT NULL, keywords CLOB DEFAULT NULL --(DC2Type:simple_array)
+ , seeders INTEGER DEFAULT NULL, peers INTEGER DEFAULT NULL, leechers INTEGER DEFAULT NULL)');
+ $this->addSql('INSERT INTO torrent (id, user_id, added, scraped, locales, sensitive, approved, md5file, keywords, seeders, peers, leechers) SELECT id, user_id, added, scraped, locales, sensitive, approved, md5file, keywords, seeders, peers, leechers FROM __temp__torrent');
+ $this->addSql('DROP TABLE __temp__torrent');
+ }
+}
diff --git a/public/asset/default/css/framework.css b/public/asset/default/css/framework.css
index 3c632be..7fb4b66 100644
--- a/public/asset/default/css/framework.css
+++ b/public/asset/default/css/framework.css
@@ -208,6 +208,14 @@ a.button-green:hover {
border-top: 1px #5d627d solid;
}
+.border-bottom-dashed {
+ border-bottom: 1px #5d627d dashed;
+}
+
+.border-top-dashed {
+ border-top: 1px #5d627d dashed;
+}
+
.border-width-2-px {
border-width: 2px;
}
@@ -367,6 +375,10 @@ a:visited.background-color-hover-night-light:hover {
padding-bottom: 24px;
}
+.margin-t-4-px {
+ margin-top: 4px;
+}
+
.margin-l-4-px {
margin-left: 4px;
}
diff --git a/src/Controller/ActivityController.php b/src/Controller/ActivityController.php
index 4ac57f1..c4e147d 100644
--- a/src/Controller/ActivityController.php
+++ b/src/Controller/ActivityController.php
@@ -560,6 +560,7 @@ class ActivityController extends AbstractController
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
+ 'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName()
@@ -606,6 +607,7 @@ class ActivityController extends AbstractController
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
+ 'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName()
@@ -652,6 +654,7 @@ class ActivityController extends AbstractController
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
+ 'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName()
@@ -699,6 +702,7 @@ class ActivityController extends AbstractController
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
+ 'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName()
@@ -745,6 +749,7 @@ class ActivityController extends AbstractController
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
+ 'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName()
@@ -783,6 +788,102 @@ class ActivityController extends AbstractController
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
+ 'status' => $torrent->isStatus(),
+ 'name' => $torrentService->readTorrentFileByTorrentId(
+ $torrent->getId()
+ )->getName()
+ ],
+ 'session' =>
+ [
+ 'user' =>
+ [
+ 'id' => $user->getId(),
+ 'sensitive' => $user->isSensitive(),
+ 'moderator' => $user->isModerator(),
+ 'owner' => $user->getId() === $torrent->getUserId(),
+ ]
+ ]
+ ]
+ );
+
+ break;
+
+ // Torrent Status
+ case $activity::EVENT_TORRENT_STATUS_ADD:
+
+ // Init torrent
+ if (!$torrent = $torrentService->getTorrent($activity->getTorrentId()))
+ {
+ throw $this->createNotFoundException();
+ }
+
+ return $this->render(
+ 'default/activity/event/torrent/status/add' . $extension,
+ [
+ 'id' => $activity->getId(),
+ 'added' => $activity->getAdded(),
+ 'user' =>
+ [
+ 'id' => $activity->getUserId(),
+ 'identicon' => $userService->identicon(
+ $userService->getUser(
+ $activity->getUserId()
+ )->getAddress()
+ )
+ ],
+ 'torrent' =>
+ [
+ 'id' => $torrent->getId(),
+ 'sensitive' => $torrent->isSensitive(),
+ 'approved' => $torrent->isApproved(),
+ 'status' => $torrent->isStatus(),
+ 'name' => $torrentService->readTorrentFileByTorrentId(
+ $torrent->getId()
+ )->getName()
+ ],
+ 'session' =>
+ [
+ 'user' =>
+ [
+ 'id' => $user->getId(),
+ 'sensitive' => $user->isSensitive(),
+ 'moderator' => $user->isModerator(),
+ 'owner' => $user->getId() === $torrent->getUserId(),
+ ]
+ ]
+ ]
+ );
+
+ break;
+
+ case $activity::EVENT_TORRENT_STATUS_DELETE:
+
+ // Init torrent
+ if (!$torrent = $torrentService->getTorrent($activity->getTorrentId()))
+ {
+ throw $this->createNotFoundException();
+ }
+
+ return $this->render(
+ 'default/activity/event/torrent/status/delete' . $extension,
+ [
+ 'id' => $activity->getId(),
+ 'added' => $activity->getAdded(),
+ 'user' =>
+ [
+ 'id' => $activity->getUserId(),
+ 'identicon' => $userService->identicon(
+ $userService->getUser(
+ $activity->getUserId()
+ )->getAddress()
+ )
+ ],
+ 'torrent' =>
+ [
+ 'id' => $torrent->getId(),
+ 'sensitive' => $torrent->isSensitive(),
+ 'approved' => $torrent->isApproved(),
+ 'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName()
@@ -830,6 +931,7 @@ class ActivityController extends AbstractController
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
+ 'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName(),
@@ -882,6 +984,7 @@ class ActivityController extends AbstractController
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
+ 'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName(),
@@ -934,6 +1037,7 @@ class ActivityController extends AbstractController
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
+ 'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName(),
@@ -986,6 +1090,7 @@ class ActivityController extends AbstractController
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
+ 'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName(),
@@ -1039,6 +1144,7 @@ class ActivityController extends AbstractController
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
+ 'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName(),
@@ -1091,6 +1197,7 @@ class ActivityController extends AbstractController
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
+ 'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName(),
@@ -1143,6 +1250,7 @@ class ActivityController extends AbstractController
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
+ 'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName(),
@@ -1195,6 +1303,7 @@ class ActivityController extends AbstractController
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
+ 'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName(),
@@ -1248,6 +1357,7 @@ class ActivityController extends AbstractController
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
+ 'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName()
@@ -1294,6 +1404,7 @@ class ActivityController extends AbstractController
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
+ 'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName()
diff --git a/src/Controller/TorrentController.php b/src/Controller/TorrentController.php
index a95ae77..a775048 100644
--- a/src/Controller/TorrentController.php
+++ b/src/Controller/TorrentController.php
@@ -62,8 +62,9 @@ class TorrentController extends AbstractController
throw $this->createNotFoundException();
}
- // Approved filter
- if (!$user->isModerator() && $user->getId() != $torrent->getUserId() && !$torrent->isApproved())
+ // Access filter
+ if (!$user->isModerator() && $user->getId() != $torrent->getUserId() &&
+ (!$torrent->isStatus() || !$torrent->isApproved()))
{
throw $this->createNotFoundException();
}
@@ -110,9 +111,10 @@ class TorrentController extends AbstractController
[
'session' =>
[
- 'user' => $user,
+ 'user' => $user,
'id' => $user->getId(),
- 'moderator' => $user->isModerator()
+ 'moderator' => $user->isModerator(),
+ 'owner' => $user->getId() === $torrent->getUserId(),
],
'torrent' =>
[
@@ -129,6 +131,7 @@ class TorrentController extends AbstractController
'locales' => $torrent->getLocales(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
+ 'status' => $torrent->isStatus(),
'download' =>
[
'file' =>
@@ -226,24 +229,30 @@ class TorrentController extends AbstractController
$activityService
);
+ //
+
// Init request
$query = $request->get('query') ? explode(' ', urldecode($request->get('query'))) : [];
$page = $request->get('page') ? (int) $request->get('page') : 1;
// Get total torrents
$total = $torrentService->findTorrentsTotal(
+ $user->getId(),
$query,
$user->getLocales(),
- !$user->isModerator() && $user->isSensitive() ? false : null, // hide on sensitive mode enabled or show all
- !$user->isModerator() ? true : null, // show approved content only for regular users
+ !$user->isModerator() && $user->isSensitive() ? false : null,
+ !$user->isModerator() ? true : null,
+ !$user->isModerator() ? true : null,
);
$torrents = [];
foreach ($torrentService->findTorrents(
+ $user->getId(),
$query,
$user->getLocales(),
- !$user->isModerator() && $user->isSensitive() ? false : null, // hide on sensitive mode enabled or show all
- !$user->isModerator() ? true : null, // show approved content only for regular users
+ !$user->isModerator() && $user->isSensitive() ? false : null,
+ !$user->isModerator() ? true : null,
+ !$user->isModerator() ? true : null,
$this->getParameter('app.pagination'),
($page - 1) * $this->getParameter('app.pagination')
) as $torrent)
@@ -254,18 +263,6 @@ class TorrentController extends AbstractController
throw $this->createNotFoundException(); // @TODO exception
}
- // Generate keywords
- /* @TODO deprecated, based on active search result
- $keywords = [];
- foreach ($torrent->getKeywords() as $keyword)
- {
- if (in_array($keyword, $query))
- {
- $keywords[] = $keyword;
- }
- }
- */
-
// Generate keywords by extension
$keywords = [];
@@ -296,6 +293,7 @@ class TorrentController extends AbstractController
'added' => $torrent->getAdded(),
'approved' => $torrent->isApproved(),
'sensitive' => $torrent->isSensitive(),
+ 'status' => $torrent->isStatus(),
'file' =>
[
'name' => $file->getName(),
@@ -401,19 +399,23 @@ class TorrentController extends AbstractController
// Get total torrents
$total = $torrentService->findTorrentsTotal(
+ $user->getId(),
[],
$user->getLocales(),
- !$user->isModerator() && $user->isSensitive() ? false : null, // hide on sensitive mode enabled or show all
- !$user->isModerator() ? true : null, // show approved content only for regular users
+ !$user->isModerator() && $user->isSensitive() ? false : null,
+ !$user->isModerator() ? true : null,
+ !$user->isModerator() ? true : null,
);
// Create torrents list
$torrents = [];
foreach ($torrentService->findTorrents(
+ $user->getId(),
[],
$user->getLocales(),
- !$user->isModerator() && $user->isSensitive() ? false : null, // hide on sensitive mode enabled or show all
- !$user->isModerator() ? true : null, // show approved content only for regular users
+ !$user->isModerator() && $user->isSensitive() ? false : null,
+ !$user->isModerator() ? true : null,
+ !$user->isModerator() ? true : null,
$this->getParameter('app.pagination'),
($page - 1) * $this->getParameter('app.pagination')
) as $torrent)
@@ -454,6 +456,7 @@ class TorrentController extends AbstractController
'added' => $torrent->getAdded(),
'approved' => $torrent->isApproved(),
'sensitive' => $torrent->isSensitive(),
+ 'status' => $torrent->isStatus(),
'file' =>
[
'name' => $file->getName(),
@@ -558,19 +561,23 @@ class TorrentController extends AbstractController
// Get total torrents
$total = $torrentService->findTorrentsTotal(
+ $user->getId(),
$query,
$user->getLocales(),
- !$user->isModerator() && $user->isSensitive() ? false : null, // hide on sensitive mode enabled or show all
- !$user->isModerator() ? true : null // show approved content only for regular users
+ !$user->isModerator() && $user->isSensitive() ? false : null,
+ !$user->isModerator() ? true : null,
+ !$user->isModerator() ? true : null,
);
// Create torrents list
$torrents = [];
foreach ($torrentService->findTorrents(
+ $user->getId(),
$query,
$user->getLocales(),
- !$user->isModerator() && $user->isSensitive() ? false : null, // hide on sensitive mode enabled or show all
- !$user->isModerator() ? true : null, // show approved content only for regular users
+ !$user->isModerator() && $user->isSensitive() ? false : null,
+ !$user->isModerator() ? true : null,
+ !$user->isModerator() ? true : null,
$this->getParameter('app.pagination'),
($page - 1) * $this->getParameter('app.pagination')
) as $torrent)
@@ -583,9 +590,9 @@ class TorrentController extends AbstractController
$torrents[] =
[
- 'id' => $torrent->getId(),
- 'added' => $torrent->getAdded(),
- 'file' =>
+ 'id' => $torrent->getId(),
+ 'added' => $torrent->getAdded(),
+ 'file' =>
[
'name' => $file->getName(),
],
@@ -624,6 +631,13 @@ class TorrentController extends AbstractController
ActivityService $activityService
): Response
{
+ // Init user
+ $user = $this->initUser(
+ $request,
+ $userService,
+ $activityService
+ );
+
// Init request
$query = $request->get('query') ? explode(' ', urldecode($request->get('query'))) : [];
$page = $request->get('page') ? (int) $request->get('page') : 1;
@@ -638,19 +652,23 @@ class TorrentController extends AbstractController
// Get total torrents
$total = $torrentService->findTorrentsTotal(
+ $user->getId(),
$query,
$locales,
- $sensitive,
- true, // approved only
+ !$user->isModerator() ? $sensitive : null,
+ !$user->isModerator() ? true : null,
+ !$user->isModerator() ? true : null,
);
// Create torrents list
$torrents = [];
foreach ($torrentService->findTorrents(
+ $user->getId(),
$query,
$locales,
- $sensitive,
- true, // approved only
+ !$user->isModerator() ? $sensitive : null,
+ !$user->isModerator() ? true : null,
+ !$user->isModerator() ? true : null,
$this->getParameter('app.pagination'),
($page - 1) * $this->getParameter('app.pagination')
) as $torrent)
@@ -867,7 +885,8 @@ class TorrentController extends AbstractController
time(),
(array) $locales,
(bool) $request->get('sensitive'),
- $user->isApproved()
+ $user->isApproved(),
+ $user->isStatus()
);
// Add activity event
@@ -898,7 +917,7 @@ class TorrentController extends AbstractController
);
}
-
+ // Torrent moderation
#[Route(
'/{_locale}/torrent/{torrentId}/approve/toggle',
name: 'torrent_approve_toggle',
@@ -975,6 +994,82 @@ class TorrentController extends AbstractController
);
}
+ #[Route(
+ '/{_locale}/torrent/{torrentId}/status/toggle',
+ name: 'torrent_status_toggle',
+ requirements:
+ [
+ '_locale' => '%app.locales%',
+ 'torrentId' => '\d+',
+ ],
+ methods:
+ [
+ 'GET'
+ ]
+ )]
+ public function status(
+ Request $request,
+ UserService $userService,
+ TorrentService $torrentService,
+ ActivityService $activityService
+ ): Response
+ {
+ // Init user
+ $user = $this->initUser(
+ $request,
+ $userService,
+ $activityService
+ );
+
+ // Init torrent
+ if (!$torrent = $torrentService->getTorrent($request->get('torrentId')))
+ {
+ throw $this->createNotFoundException();
+ }
+
+ // Check permissions
+ if (!($user->isModerator() || $user->getId() == $torrent->getUserId()))
+ {
+ // @TODO
+ throw new \Exception(
+ $translator->trans('Access denied')
+ );
+ }
+
+ // Register activity event
+ if (!$torrent->isStatus())
+ {
+ $activityService->addEventTorrentStatusAdd(
+ $user->getId(),
+ $torrent->getId(),
+ time()
+ );
+ }
+
+ else
+ {
+ $activityService->addEventTorrentStatusDelete(
+ $user->getId(),
+ $torrent->getId(),
+ time()
+ );
+ }
+
+ // Update status
+ $torrentService->toggleTorrentStatus(
+ $torrent->getId()
+ );
+
+ // Redirect back to form
+ return $this->redirectToRoute(
+ 'torrent_info',
+ [
+ '_locale' => $request->get('_locale'),
+ 'torrentId' => $torrent->getId()
+ ]
+ );
+ }
+
// Torrent locales
#[Route(
'/{_locale}/torrent/{torrentId}/edit/locales/{torrentLocalesId}',
@@ -1807,14 +1902,9 @@ class TorrentController extends AbstractController
throw $this->createNotFoundException();
}
- // Sensitive filter
- if (!$user->isModerator() && $user->isSensitive())
- {
- throw $this->createNotFoundException();
- }
-
- // Approved filter
- if (!$user->isModerator() && $user->getId() != $torrent->getUserId() && !$torrent->isApproved())
+ // Access filter
+ if (!$user->isModerator() && $user->getId() != $torrent->getUserId() &&
+ (!$torrent->isStatus() || !$torrent->isApproved()))
{
throw $this->createNotFoundException();
}
@@ -1934,14 +2024,9 @@ class TorrentController extends AbstractController
throw $this->createNotFoundException();
}
- // Sensitive filter
- if (!$user->isModerator() && $user->isSensitive())
- {
- throw $this->createNotFoundException();
- }
-
- // Approved filter
- if (!$user->isModerator() && $user->getId() != $torrent->getUserId() && !$torrent->isApproved())
+ // Access filter
+ if (!$user->isModerator() && $user->getId() != $torrent->getUserId() &&
+ (!$torrent->isStatus() || !$torrent->isApproved()))
{
throw $this->createNotFoundException();
}
@@ -2058,14 +2143,9 @@ class TorrentController extends AbstractController
throw $this->createNotFoundException();
}
- // Sensitive filter
- if (!$user->isModerator() && $user->isSensitive())
- {
- throw $this->createNotFoundException();
- }
-
- // Approved filter
- if (!$user->isModerator() && $user->getId() != $torrent->getUserId() && !$torrent->isApproved())
+ // Access filter
+ if (!$user->isModerator() && $user->getId() != $torrent->getUserId() &&
+ (!$torrent->isStatus() || !$torrent->isApproved()))
{
throw $this->createNotFoundException();
}
@@ -2389,10 +2469,12 @@ class TorrentController extends AbstractController
'locale' => $locale,
'locales' => $locales,
'torrents' => $torrentService->findTorrents(
+ 0, // no user session init, pass 0
[], // without keywords filter
$locales, // all system locales
null, // all sensitive levels
true, // approved only
+ true, // enabled only
1000, // @TODO limit
0 // offset
)
diff --git a/src/Entity/Activity.php b/src/Entity/Activity.php
index 3b208b9..233ab46 100644
--- a/src/Entity/Activity.php
+++ b/src/Entity/Activity.php
@@ -59,6 +59,9 @@ class Activity
public const EVENT_TORRENT_WANTED_ADD = 2700;
+ public const EVENT_TORRENT_STATUS_ADD = 1800;
+ public const EVENT_TORRENT_STATUS_DELETE = 1801;
+
// ...
#[ORM\Column]
diff --git a/src/Entity/Torrent.php b/src/Entity/Torrent.php
index 876bd1e..ef34679 100644
--- a/src/Entity/Torrent.php
+++ b/src/Entity/Torrent.php
@@ -33,6 +33,9 @@ class Torrent
#[ORM\Column]
private ?bool $approved = null;
+ #[ORM\Column]
+ private ?bool $status = null;
+
#[ORM\Column(length: 32)]
private ?string $md5file = null;
@@ -156,6 +159,18 @@ class Torrent
return $this;
}
+ public function isStatus(): ?bool
+ {
+ return $this->status;
+ }
+
+ public function setStatus(bool $status): static
+ {
+ $this->status = $status;
+
+ return $this;
+ }
+
public function getSeeders(): ?int
{
return $this->seeders;
diff --git a/src/Repository/TorrentRepository.php b/src/Repository/TorrentRepository.php
index 01a10ec..f960e90 100644
--- a/src/Repository/TorrentRepository.php
+++ b/src/Repository/TorrentRepository.php
@@ -22,38 +22,46 @@ class TorrentRepository extends ServiceEntityRepository
}
public function findTorrentsTotal(
+ int $userId,
array $keywords,
array $locales,
?bool $sensitive = null,
- ?bool $approved = null,
- int $limit = 10,
- int $offset = 0
+ ?bool $approved = null,
+ ?bool $status = null,
+ int $limit = 10,
+ int $offset = 0
): int
{
return $this->getTorrentsQueryByFilter(
+ $userId,
$keywords,
$locales,
$sensitive,
$approved,
+ $status,
)->select('count(t.id)')
->getQuery()
->getSingleScalarResult();
}
public function findTorrents(
+ int $userId,
array $keywords,
array $locales,
?bool $sensitive = null,
- ?bool $approved = null,
+ ?bool $approved = null,
+ ?bool $status = null,
int $limit = 10,
int $offset = 0
): array
{
return $this->getTorrentsQueryByFilter(
+ $userId,
$keywords,
$locales,
$sensitive,
$approved,
+ $status,
)->setMaxResults($limit)
->setFirstResult($offset)
->orderBy('t.id', 'DESC') // same as t.added
@@ -62,54 +70,85 @@ class TorrentRepository extends ServiceEntityRepository
}
private function getTorrentsQueryByFilter(
+ int $userId,
array $keywords,
array $locales,
?bool $sensitive = null,
- ?bool $approved = null,
+ ?bool $approved = null,
+ ?bool $status = null,
): \Doctrine\ORM\QueryBuilder
{
$query = $this->createQueryBuilder('t');
- if ($keywords) // @TODO ANY or DTS
+ if ($keywords)
{
- $andX = $query->expr()->andX();
+ $andKeywords = $query->expr()->andX();
foreach ($keywords as $i => $keyword)
{
$keyword = mb_strtolower($keyword); // all keywords stored in lowercase
- $andX->add("t.keywords LIKE :keyword{$i}");
+ $andKeywords->add("t.keywords LIKE :keyword{$i}");
+
$query->setParameter(":keyword{$i}", "%{$keyword}%");
}
- $query->andWhere($andX);
+ $query->andWhere($andKeywords);
}
- if ($locales) // @TODO ANY or DTS
+ if ($locales)
{
- //$orX = $query->expr()->orX();
- $orX = $query->expr()->orX();
+ $orLocales = $query->expr()->orX();
foreach ($locales as $i => $locale)
{
- $orX->add("t.locales LIKE :locale{$i}");
+ $orLocales->add("t.locales LIKE :locale{$i}");
+ $orLocales->add("t.userId = :userId");
$query->setParameter(":locale{$i}", "%{$locale}%");
+ $query->setParameter('userId', $userId);
}
- $query->andWhere($orX);
+ $query->andWhere($orLocales);
}
if (is_bool($sensitive))
{
- $query->andWhere('t.sensitive = :sensitive')
- ->setParameter('sensitive', $sensitive);
+ $orSensitive = $query->expr()->orX();
+
+ $orSensitive->add("t.sensitive = :sensitive");
+ $orSensitive->add("t.userId = :userId");
+
+ $query->setParameter('sensitive', $sensitive);
+ $query->setParameter('userId', $userId);
+
+ $query->andWhere($orSensitive);
}
if (is_bool($approved))
{
- $query->andWhere('t.approved = :approved')
- ->setParameter('approved', $approved);
+ $orApproved = $query->expr()->orX();
+
+ $orApproved->add("t.approved = :approved");
+ $orApproved->add("t.userId = :userId");
+
+ $query->setParameter('approved', $approved);
+ $query->setParameter('userId', $userId);
+
+ $query->andWhere($orApproved);
+ }
+
+ if (is_bool($status))
+ {
+ $orStatus = $query->expr()->orX();
+
+ $orStatus->add("t.status = :status");
+ $orStatus->add("t.userId = :userId");
+
+ $query->setParameter('status', $status);
+ $query->setParameter('userId', $userId);
+
+ $query->andWhere($orStatus);
}
return $query;
diff --git a/src/Service/ActivityService.php b/src/Service/ActivityService.php
index 4dbbb74..d7dfb5a 100644
--- a/src/Service/ActivityService.php
+++ b/src/Service/ActivityService.php
@@ -62,6 +62,9 @@ class ActivityService
Activity::EVENT_TORRENT_DOWNLOAD_FILE_ADD,
Activity::EVENT_TORRENT_DOWNLOAD_MAGNET_ADD,
+ Activity::EVENT_TORRENT_STATUS_ADD,
+ Activity::EVENT_TORRENT_STATUS_DELETE,
+
Activity::EVENT_TORRENT_WANTED_ADD,
];
}
@@ -379,6 +382,30 @@ class ActivityService
] = $code;
break;
+
+ case Activity::EVENT_TORRENT_STATUS_ADD:
+
+ $events
+ [
+ $this->translatorInterface->trans('Torrents')
+ ]
+ [
+ $this->translatorInterface->trans('Enabled')
+ ] = $code;
+
+ break;
+
+ case Activity::EVENT_TORRENT_STATUS_DELETE:
+
+ $events
+ [
+ $this->translatorInterface->trans('Torrents')
+ ]
+ [
+ $this->translatorInterface->trans('Disabled')
+ ] = $code;
+
+ break;
}
}
@@ -861,6 +888,65 @@ class ActivityService
return $activity;
}
+ public function addEventTorrentStatusAdd(
+ int $userId,
+ int $torrentId,
+ int $added
+ ): ?Activity
+ {
+ $activity = new Activity();
+
+ $activity->setEvent(
+ Activity::EVENT_TORRENT_STATUS_ADD
+ );
+
+ $activity->setUserId(
+ $userId
+ );
+
+ $activity->setTorrentId(
+ $torrentId
+ );
+
+ $activity->setAdded(
+ $added
+ );
+
+ $this->entityManagerInterface->persist($activity);
+ $this->entityManagerInterface->flush();
+
+ return $activity;
+ }
+
+ public function addEventTorrentStatusDelete(
+ int $userId,
+ int $torrentId,
+ int $added
+ ): ?Activity
+ {
+ $activity = new Activity();
+
+ $activity->setEvent(
+ Activity::EVENT_TORRENT_STATUS_DELETE
+ );
+
+ $activity->setUserId(
+ $userId
+ );
+
+ $activity->setTorrentId(
+ $torrentId
+ );
+
+ $activity->setAdded(
+ $added
+ );
+
+ $this->entityManagerInterface->persist($activity);
+ $this->entityManagerInterface->flush();
+
+ return $activity;
+ }
public function addEventTorrentWantedAdd(
int $userId,
diff --git a/src/Service/TorrentService.php b/src/Service/TorrentService.php
index 00986a3..b7129fe 100644
--- a/src/Service/TorrentService.php
+++ b/src/Service/TorrentService.php
@@ -192,7 +192,8 @@ class TorrentService
int $added,
array $locales,
bool $sensitive,
- bool $approved
+ bool $approved,
+ bool $status
): ?Torrent
{
$torrent = $this->addTorrent(
@@ -204,7 +205,8 @@ class TorrentService
),
$locales,
$sensitive,
- $approved
+ $approved,
+ $status
);
$filesystem = new Filesystem();
@@ -249,7 +251,8 @@ class TorrentService
array $keywords,
array $locales,
bool $sensitive,
- bool $approved
+ bool $approved,
+ bool $status
): ?Torrent
{
$torrent = new Torrent();
@@ -261,6 +264,7 @@ class TorrentService
$torrent->setLocales($locales);
$torrent->setSensitive($sensitive);
$torrent->setApproved($approved);
+ $torrent->setStatus($status);
$this->entityManagerInterface->persist($torrent);
$this->entityManagerInterface->flush();
@@ -292,6 +296,30 @@ class TorrentService
return $torrent;
}
+ public function toggleTorrentStatus(
+ int $torrentId
+ ): ?Torrent
+ {
+ $torrent = $this->getTorrent($torrentId);
+
+ $torrent->setStatus(
+ !$torrent->isStatus() // toggle current value
+ );
+
+ $this->entityManagerInterface->persist($torrent);
+ $this->entityManagerInterface->flush();
+
+ $this->updateTorrentLocales(
+ $torrent->getId()
+ );
+
+ $this->updateTorrentSensitive(
+ $torrent->getId()
+ );
+
+ return $torrent;
+ }
+
public function getTorrentScrapeQueue(): ?Torrent
{
return $this->entityManagerInterface
@@ -305,40 +333,48 @@ class TorrentService
}
public function findTorrents(
+ int $userId,
array $keywords,
array $locales,
?bool $sensitive,
?bool $approved,
- int $limit,
- int $offset
+ ?bool $status,
+ int $limit,
+ int $offset
) : array
{
return $this->entityManagerInterface
->getRepository(Torrent::class)
->findTorrents(
+ $userId,
$keywords,
$locales,
$sensitive,
$approved,
+ $status,
$limit,
$offset
);
}
public function findTorrentsTotal(
+ int $userId,
array $keywords,
array $locales,
?bool $sensitive,
- ?bool $approved
+ ?bool $approved,
+ ?bool $status
) : int
{
return $this->entityManagerInterface
->getRepository(Torrent::class)
->findTorrentsTotal(
+ $userId,
$keywords,
$locales,
$sensitive,
- $approved
+ $approved,
+ $status
);
}
diff --git a/templates/default/activity/event/torrent/add.html.twig b/templates/default/activity/event/torrent/add.html.twig
index 11712a2..b7e2610 100644
--- a/templates/default/activity/event/torrent/add.html.twig
+++ b/templates/default/activity/event/torrent/add.html.twig
@@ -9,9 +9,11 @@
{{ torrent.name }}
{% else %}
- {% if torrent.approved == false %}
+ {% if torrent.status == false %}
+ #{{ torrent.id }} ({{ 'disabled' | trans }})
+ {% elseif torrent.approved == false %}
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
- {% elseif torrent.sensitive == true %}
+ {% elseif torrent.sensitive == true and session.user.sensitive == true %}
#{{ torrent.id }} ({{ 'sensitive' | trans }})
{% else %}
diff --git a/templates/default/activity/event/torrent/add.rss.twig b/templates/default/activity/event/torrent/add.rss.twig
index 174c82c..db55c4c 100644
--- a/templates/default/activity/event/torrent/add.rss.twig
+++ b/templates/default/activity/event/torrent/add.rss.twig
@@ -6,9 +6,11 @@
{% if session.user.moderator or session.user.owner %}
{{ torrent.name }}
{% else %}
- {% if torrent.approved == false %}
+ {% if torrent.status == false %}
+ #{{ torrent.id }} ({{ 'disabled' | trans }})
+ {% elseif torrent.approved == false %}
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
- {% elseif torrent.sensitive == true %}
+ {% elseif torrent.sensitive == true and session.user.sensitive == true %}
#{{ torrent.id }} ({{ 'sensitive' | trans }})
{% else %}
{{ torrent.name }}
diff --git a/templates/default/activity/event/torrent/approve/add.html.twig b/templates/default/activity/event/torrent/approve/add.html.twig
index ab2350c..e394ecb 100644
--- a/templates/default/activity/event/torrent/approve/add.html.twig
+++ b/templates/default/activity/event/torrent/approve/add.html.twig
@@ -11,7 +11,11 @@
{{ torrent.name }}
{% else %}
- {% if torrent.sensitive == true %}
+ {% if torrent.status == false %}
+ #{{ torrent.id }} ({{ 'disabled' | trans }})
+ {% elseif torrent.approved == false %}
+ #{{ torrent.id }} ({{ 'waiting for approve' | trans }})
+ {% elseif torrent.sensitive == true and session.user.sensitive == true %}
#{{ torrent.id }} ({{ 'sensitive' | trans }})
{% else %}
diff --git a/templates/default/activity/event/torrent/approve/add.rss.twig b/templates/default/activity/event/torrent/approve/add.rss.twig
index 7287540..e378199 100644
--- a/templates/default/activity/event/torrent/approve/add.rss.twig
+++ b/templates/default/activity/event/torrent/approve/add.rss.twig
@@ -6,7 +6,11 @@
{% if session.user.moderator or session.user.owner %}
{{ torrent.name }}
{% else %}
- {% if torrent.sensitive == true %}
+ {% if torrent.status == false %}
+ #{{ torrent.id }} ({{ 'disabled' | trans }})
+ {% elseif torrent.approved == false %}
+ #{{ torrent.id }} ({{ 'waiting for approve' | trans }})
+ {% elseif torrent.sensitive == true and session.user.sensitive == true %}
#{{ torrent.id }} ({{ 'sensitive' | trans }})
{% else %}
{{ torrent.name }}
diff --git a/templates/default/activity/event/torrent/approve/delete.html.twig b/templates/default/activity/event/torrent/approve/delete.html.twig
index 3033a95..50d6079 100644
--- a/templates/default/activity/event/torrent/approve/delete.html.twig
+++ b/templates/default/activity/event/torrent/approve/delete.html.twig
@@ -11,9 +11,11 @@
{{ torrent.name }}
{% else %}
- {% if torrent.approved == false %}
+ {% if torrent.status == false %}
+ #{{ torrent.id }} ({{ 'disabled' | trans }})
+ {% elseif torrent.approved == false %}
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
- {% elseif torrent.sensitive == true %}
+ {% elseif torrent.sensitive == true and session.user.sensitive == true %}
#{{ torrent.id }} ({{ 'sensitive' | trans }})
{% else %}
diff --git a/templates/default/activity/event/torrent/approve/delete.rss.twig b/templates/default/activity/event/torrent/approve/delete.rss.twig
index d358829..7252d9f 100644
--- a/templates/default/activity/event/torrent/approve/delete.rss.twig
+++ b/templates/default/activity/event/torrent/approve/delete.rss.twig
@@ -6,7 +6,11 @@
{% if session.user.moderator or session.user.owner %}
{{ torrent.name }}
{% else %}
- {% if torrent.sensitive == true %}
+ {% if torrent.status == false %}
+ #{{ torrent.id }} ({{ 'disabled' | trans }})
+ {% elseif torrent.approved == false %}
+ #{{ torrent.id }} ({{ 'waiting for approve' | trans }})
+ {% elseif torrent.sensitive == true and session.user.sensitive == true %}
#{{ torrent.id }} ({{ 'sensitive' | trans }})
{% else %}
{{ torrent.name }}
diff --git a/templates/default/activity/event/torrent/download/file/add.html.twig b/templates/default/activity/event/torrent/download/file/add.html.twig
index 7959ff7..f71609a 100644
--- a/templates/default/activity/event/torrent/download/file/add.html.twig
+++ b/templates/default/activity/event/torrent/download/file/add.html.twig
@@ -14,9 +14,11 @@
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
{% endif %}
{% else %}
- {% if torrent.approved == false %}
+ {% if torrent.status == false %}
+ #{{ torrent.id }} ({{ 'disabled' | trans }})
+ {% elseif torrent.approved == false %}
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
- {% elseif torrent.sensitive == true %}
+ {% elseif torrent.sensitive == true and session.user.sensitive == true %}
#{{ torrent.id }} ({{ 'sensitive' | trans }})
{% else %}
diff --git a/templates/default/activity/event/torrent/download/file/add.rss.twig b/templates/default/activity/event/torrent/download/file/add.rss.twig
index ebeaf7c..d9bee5b 100644
--- a/templates/default/activity/event/torrent/download/file/add.rss.twig
+++ b/templates/default/activity/event/torrent/download/file/add.rss.twig
@@ -6,9 +6,11 @@
{% if session.user.moderator or session.user.owner %}
{{ torrent.name }}
{% else %}
- {% if torrent.approved == false %}
+ {% if torrent.status == false %}
+ #{{ torrent.id }} ({{ 'disabled' | trans }})
+ {% elseif torrent.approved == false %}
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
- {% elseif torrent.sensitive == true %}
+ {% elseif torrent.sensitive == true and session.user.sensitive == true %}
#{{ torrent.id }} ({{ 'sensitive' | trans }})
{% else %}
{{ torrent.name }}
diff --git a/templates/default/activity/event/torrent/download/magnet/add.html.twig b/templates/default/activity/event/torrent/download/magnet/add.html.twig
index a3aa52a..1545e69 100644
--- a/templates/default/activity/event/torrent/download/magnet/add.html.twig
+++ b/templates/default/activity/event/torrent/download/magnet/add.html.twig
@@ -14,9 +14,11 @@
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
{% endif %}
{% else %}
- {% if torrent.approved == false %}
+ {% if torrent.status == false %}
+ #{{ torrent.id }} ({{ 'disabled' | trans }})
+ {% elseif torrent.approved == false %}
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
- {% elseif torrent.sensitive == true %}
+ {% elseif torrent.sensitive == true and session.user.sensitive == true %}
#{{ torrent.id }} ({{ 'sensitive' | trans }})
{% else %}
diff --git a/templates/default/activity/event/torrent/download/magnet/add.rss.twig b/templates/default/activity/event/torrent/download/magnet/add.rss.twig
index 6afad66..e29157f 100644
--- a/templates/default/activity/event/torrent/download/magnet/add.rss.twig
+++ b/templates/default/activity/event/torrent/download/magnet/add.rss.twig
@@ -6,9 +6,11 @@
{% if session.user.moderator or session.user.owner %}
{{ torrent.name }}
{% else %}
- {% if torrent.approved == false %}
+ {% if torrent.status == false %}
+ #{{ torrent.id }} ({{ 'disabled' | trans }})
+ {% elseif torrent.approved == false %}
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
- {% elseif torrent.sensitive == true %}
+ {% elseif torrent.sensitive == true and session.user.sensitive == true %}
#{{ torrent.id }} ({{ 'sensitive' | trans }})
{% else %}
{{ torrent.name }}
diff --git a/templates/default/activity/event/torrent/locales/add.html.twig b/templates/default/activity/event/torrent/locales/add.html.twig
index a5f8c37..facd581 100644
--- a/templates/default/activity/event/torrent/locales/add.html.twig
+++ b/templates/default/activity/event/torrent/locales/add.html.twig
@@ -20,9 +20,11 @@
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
{% endif %}
{% else %}
- {% if torrent.approved == false %}
+ {% if torrent.status == false %}
+ #{{ torrent.id }} ({{ 'disabled' | trans }})
+ {% elseif torrent.approved == false %}
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
- {% elseif torrent.sensitive == true %}
+ {% elseif torrent.sensitive == true and session.user.sensitive == true %}
#{{ torrent.id }} ({{ 'sensitive' | trans }})
{% else %}
diff --git a/templates/default/activity/event/torrent/locales/add.rss.twig b/templates/default/activity/event/torrent/locales/add.rss.twig
index 20a65f5..81ec578 100644
--- a/templates/default/activity/event/torrent/locales/add.rss.twig
+++ b/templates/default/activity/event/torrent/locales/add.rss.twig
@@ -8,9 +8,11 @@
{% if session.user.moderator or session.user.owner %}
{{ torrent.name }}
{% else %}
- {% if torrent.approved == false %}
+ {% if torrent.status == false %}
+ #{{ torrent.id }} ({{ 'disabled' | trans }})
+ {% elseif torrent.approved == false %}
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
- {% elseif torrent.sensitive == true %}
+ {% elseif torrent.sensitive == true and session.user.sensitive == true %}
#{{ torrent.id }} ({{ 'sensitive' | trans }})
{% else %}
{{ torrent.name }}
diff --git a/templates/default/activity/event/torrent/locales/approve/add.html.twig b/templates/default/activity/event/torrent/locales/approve/add.html.twig
index 254e24b..27ed85b 100644
--- a/templates/default/activity/event/torrent/locales/approve/add.html.twig
+++ b/templates/default/activity/event/torrent/locales/approve/add.html.twig
@@ -20,9 +20,11 @@
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
{% endif %}
{% else %}
- {% if torrent.approved == false %}
+ {% if torrent.status == false %}
+ #{{ torrent.id }} ({{ 'disabled' | trans }})
+ {% elseif torrent.approved == false %}
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
- {% elseif torrent.sensitive == true %}
+ {% elseif torrent.sensitive == true and session.user.sensitive == true %}
#{{ torrent.id }} ({{ 'sensitive' | trans }})
{% else %}
diff --git a/templates/default/activity/event/torrent/locales/approve/add.rss.twig b/templates/default/activity/event/torrent/locales/approve/add.rss.twig
index fc86232..64dbcdd 100644
--- a/templates/default/activity/event/torrent/locales/approve/add.rss.twig
+++ b/templates/default/activity/event/torrent/locales/approve/add.rss.twig
@@ -8,9 +8,11 @@
{% if session.user.moderator or session.user.owner %}
{{ torrent.name }}
{% else %}
- {% if torrent.approved == false %}
+ {% if torrent.status == false %}
+ #{{ torrent.id }} ({{ 'disabled' | trans }})
+ {% elseif torrent.approved == false %}
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
- {% elseif torrent.sensitive == true %}
+ {% elseif torrent.sensitive == true and session.user.sensitive == true %}
#{{ torrent.id }} ({{ 'sensitive' | trans }})
{% else %}
{{ torrent.name }}
diff --git a/templates/default/activity/event/torrent/locales/approve/delete.html.twig b/templates/default/activity/event/torrent/locales/approve/delete.html.twig
index 020216c..d49dcb1 100644
--- a/templates/default/activity/event/torrent/locales/approve/delete.html.twig
+++ b/templates/default/activity/event/torrent/locales/approve/delete.html.twig
@@ -22,9 +22,11 @@
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
{% endif %}
{% else %}
- {% if torrent.approved == false %}
+ {% if torrent.status == false %}
+ #{{ torrent.id }} ({{ 'disabled' | trans }})
+ {% elseif torrent.approved == false %}
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
- {% elseif torrent.sensitive == true %}
+ {% elseif torrent.sensitive == true and session.user.sensitive == true %}
#{{ torrent.id }} ({{ 'sensitive' | trans }})
{% else %}
diff --git a/templates/default/activity/event/torrent/locales/approve/delete.rss.twig b/templates/default/activity/event/torrent/locales/approve/delete.rss.twig
index de936f1..b0cbada 100644
--- a/templates/default/activity/event/torrent/locales/approve/delete.rss.twig
+++ b/templates/default/activity/event/torrent/locales/approve/delete.rss.twig
@@ -8,9 +8,11 @@
{% if session.user.moderator or session.user.owner %}
{{ torrent.name }}
{% else %}
- {% if torrent.approved == false %}
+ {% if torrent.status == false %}
+ #{{ torrent.id }} ({{ 'disabled' | trans }})
+ {% elseif torrent.approved == false %}
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
- {% elseif torrent.sensitive == true %}
+ {% elseif torrent.sensitive == true and session.user.sensitive == true %}
#{{ torrent.id }} ({{ 'sensitive' | trans }})
{% else %}
{{ torrent.name }}
diff --git a/templates/default/activity/event/torrent/locales/delete.html.twig b/templates/default/activity/event/torrent/locales/delete.html.twig
index 3794dc8..4327e41 100644
--- a/templates/default/activity/event/torrent/locales/delete.html.twig
+++ b/templates/default/activity/event/torrent/locales/delete.html.twig
@@ -20,9 +20,11 @@
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
{% endif %}
{% else %}
- {% if torrent.approved == false %}
+ {% if torrent.status == false %}
+ #{{ torrent.id }} ({{ 'disabled' | trans }})
+ {% elseif torrent.approved == false %}
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
- {% elseif torrent.sensitive == true %}
+ {% elseif torrent.sensitive == true and session.user.sensitive == true %}
#{{ torrent.id }} ({{ 'sensitive' | trans }})
{% else %}
diff --git a/templates/default/activity/event/torrent/locales/delete.rss.twig b/templates/default/activity/event/torrent/locales/delete.rss.twig
index 2c26702..1bb311d 100644
--- a/templates/default/activity/event/torrent/locales/delete.rss.twig
+++ b/templates/default/activity/event/torrent/locales/delete.rss.twig
@@ -8,9 +8,11 @@
{% if session.user.moderator or session.user.owner %}
{{ torrent.name }}
{% else %}
- {% if torrent.approved == false %}
+ {% if torrent.status == false %}
+ #{{ torrent.id }} ({{ 'disabled' | trans }})
+ {% elseif torrent.approved == false %}
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
- {% elseif torrent.sensitive == true %}
+ {% elseif torrent.sensitive == true and session.user.sensitive == true %}
#{{ torrent.id }} ({{ 'sensitive' | trans }})
{% else %}
{{ torrent.name }}
diff --git a/templates/default/activity/event/torrent/sensitive/add.html.twig b/templates/default/activity/event/torrent/sensitive/add.html.twig
index 6165658..e21705a 100644
--- a/templates/default/activity/event/torrent/sensitive/add.html.twig
+++ b/templates/default/activity/event/torrent/sensitive/add.html.twig
@@ -20,10 +20,12 @@
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
{% endif %}
{% else %}
- {% if torrent.approved == false %}
+ {% if torrent.status == false %}
+ #{{ torrent.id }} ({{ 'disabled' | trans }})
+ {% elseif torrent.approved == false %}
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
- {% elseif torrent.sensitive == true %}
- #{{ torrent.id }} ({{ 'sensitive' | trans }})
+ {% elseif torrent.sensitive == true and session.user.sensitive == true %}
+ #{{ torrent.id }}
{% else %}
{{ torrent.name }}
diff --git a/templates/default/activity/event/torrent/sensitive/add.rss.twig b/templates/default/activity/event/torrent/sensitive/add.rss.twig
index 4280165..e1036bb 100644
--- a/templates/default/activity/event/torrent/sensitive/add.rss.twig
+++ b/templates/default/activity/event/torrent/sensitive/add.rss.twig
@@ -8,10 +8,12 @@
{% if session.user.moderator or session.user.owner %}
{{ torrent.name }}
{% else %}
- {% if torrent.approved == false %}
+ {% if torrent.status == false %}
+ #{{ torrent.id }} ({{ 'disabled' | trans }})
+ {% elseif torrent.approved == false %}
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
- {% elseif torrent.sensitive == true %}
- #{{ torrent.id }} ({{ 'sensitive' | trans }})
+ {% elseif torrent.sensitive == true and session.user.sensitive == true %}
+ #{{ torrent.id }}
{% else %}
{{ torrent.name }}
{% endif %}
diff --git a/templates/default/activity/event/torrent/sensitive/approve/add.html.twig b/templates/default/activity/event/torrent/sensitive/approve/add.html.twig
index 464bd9b..4bad7b0 100644
--- a/templates/default/activity/event/torrent/sensitive/approve/add.html.twig
+++ b/templates/default/activity/event/torrent/sensitive/approve/add.html.twig
@@ -20,10 +20,12 @@
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
{% endif %}
{% else %}
- {% if torrent.approved == false %}
+ {% if torrent.status == false %}
+ #{{ torrent.id }} ({{ 'disabled' | trans }})
+ {% elseif torrent.approved == false %}
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
- {% elseif torrent.sensitive == true %}
- #{{ torrent.id }} ({{ 'sensitive' | trans }})
+ {% elseif torrent.sensitive == true and session.user.sensitive == true %}
+ #{{ torrent.id }}
{% else %}
{{ torrent.name }}
diff --git a/templates/default/activity/event/torrent/sensitive/approve/add.rss.twig b/templates/default/activity/event/torrent/sensitive/approve/add.rss.twig
index f8d029e..583a42f 100644
--- a/templates/default/activity/event/torrent/sensitive/approve/add.rss.twig
+++ b/templates/default/activity/event/torrent/sensitive/approve/add.rss.twig
@@ -8,10 +8,12 @@
{% if session.user.moderator or session.user.owner %}
{{ torrent.name }}
{% else %}
- {% if torrent.approved == false %}
+ {% if torrent.status == false %}
+ #{{ torrent.id }} ({{ 'disabled' | trans }})
+ {% elseif torrent.approved == false %}
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
- {% elseif torrent.sensitive == true %}
- #{{ torrent.id }} ({{ 'sensitive' | trans }})
+ {% elseif torrent.sensitive == true and session.user.sensitive == true %}
+ #{{ torrent.id }}
{% else %}
{{ torrent.name }}
{% endif %}
diff --git a/templates/default/activity/event/torrent/sensitive/approve/delete.html.twig b/templates/default/activity/event/torrent/sensitive/approve/delete.html.twig
index 9134a0f..c02a804 100644
--- a/templates/default/activity/event/torrent/sensitive/approve/delete.html.twig
+++ b/templates/default/activity/event/torrent/sensitive/approve/delete.html.twig
@@ -20,10 +20,12 @@
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
{% endif %}
{% else %}
- {% if torrent.approved == false %}
+ {% if torrent.status == false %}
+ #{{ torrent.id }} ({{ 'disabled' | trans }})
+ {% elseif torrent.approved == false %}
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
- {% elseif torrent.sensitive == true %}
- #{{ torrent.id }} ({{ 'sensitive' | trans }})
+ {% elseif torrent.sensitive == true and session.user.sensitive == true %}
+ #{{ torrent.id }}
{% else %}
{{ torrent.name }}
diff --git a/templates/default/activity/event/torrent/sensitive/approve/delete.rss.twig b/templates/default/activity/event/torrent/sensitive/approve/delete.rss.twig
index da8ea11..f1a697f 100644
--- a/templates/default/activity/event/torrent/sensitive/approve/delete.rss.twig
+++ b/templates/default/activity/event/torrent/sensitive/approve/delete.rss.twig
@@ -8,10 +8,12 @@
{% if session.user.moderator or session.user.owner %}
{{ torrent.name }}
{% else %}
- {% if torrent.approved == false %}
+ {% if torrent.status == false %}
+ #{{ torrent.id }} ({{ 'disabled' | trans }})
+ {% elseif torrent.approved == false %}
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
- {% elseif torrent.sensitive == true %}
- #{{ torrent.id }} ({{ 'sensitive' | trans }})
+ {% elseif torrent.sensitive == true and session.user.sensitive == true %}
+ #{{ torrent.id }}
{% else %}
{{ torrent.name }}
{% endif %}
diff --git a/templates/default/activity/event/torrent/sensitive/delete.html.twig b/templates/default/activity/event/torrent/sensitive/delete.html.twig
index 9912cf3..a2640dc 100644
--- a/templates/default/activity/event/torrent/sensitive/delete.html.twig
+++ b/templates/default/activity/event/torrent/sensitive/delete.html.twig
@@ -20,10 +20,12 @@
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
{% endif %}
{% else %}
- {% if torrent.approved == false %}
+ {% if torrent.status == false %}
+ #{{ torrent.id }} ({{ 'disabled' | trans }})
+ {% elseif torrent.approved == false %}
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
- {% elseif torrent.sensitive == true %}
- #{{ torrent.id }} ({{ 'sensitive' | trans }})
+ {% elseif torrent.sensitive == true and session.user.sensitive == true %}
+ #{{ torrent.id }}
{% else %}
{{ torrent.name }}
diff --git a/templates/default/activity/event/torrent/sensitive/delete.rss.twig b/templates/default/activity/event/torrent/sensitive/delete.rss.twig
index d2254e8..3c13424 100644
--- a/templates/default/activity/event/torrent/sensitive/delete.rss.twig
+++ b/templates/default/activity/event/torrent/sensitive/delete.rss.twig
@@ -8,10 +8,12 @@
{% if session.user.moderator or session.user.owner %}
{{ torrent.name }}
{% else %}
- {% if torrent.approved == false %}
+ {% if torrent.status == false %}
+ #{{ torrent.id }} ({{ 'disabled' | trans }})
+ {% elseif torrent.approved == false %}
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
- {% elseif torrent.sensitive == true %}
- #{{ torrent.id }} ({{ 'sensitive' | trans }})
+ {% elseif torrent.sensitive == true and session.user.sensitive == true %}
+ #{{ torrent.id }}
{% else %}
{{ torrent.name }}
{% endif %}
diff --git a/templates/default/activity/event/torrent/star/add.html.twig b/templates/default/activity/event/torrent/star/add.html.twig
index 16095fe..9d27547 100644
--- a/templates/default/activity/event/torrent/star/add.html.twig
+++ b/templates/default/activity/event/torrent/star/add.html.twig
@@ -12,9 +12,11 @@
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
{% endif %}
{% else %}
- {% if torrent.approved == false %}
+ {% if torrent.status == false %}
+ #{{ torrent.id }} ({{ 'disabled' | trans }})
+ {% elseif torrent.approved == false %}
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
- {% elseif torrent.sensitive == true %}
+ {% elseif torrent.sensitive == true and session.user.sensitive == true %}
#{{ torrent.id }} ({{ 'sensitive' | trans }})
{% else %}
diff --git a/templates/default/activity/event/torrent/star/add.rss.twig b/templates/default/activity/event/torrent/star/add.rss.twig
index d56a7b5..a5fb324 100644
--- a/templates/default/activity/event/torrent/star/add.rss.twig
+++ b/templates/default/activity/event/torrent/star/add.rss.twig
@@ -6,9 +6,11 @@
{% if session.user.moderator or session.user.owner %}
{{ torrent.name }}
{% else %}
- {% if torrent.approved == false %}
+ {% if torrent.status == false %}
+ #{{ torrent.id }} ({{ 'disabled' | trans }})
+ {% elseif torrent.approved == false %}
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
- {% elseif torrent.sensitive == true %}
+ {% elseif torrent.sensitive == true and session.user.sensitive == true %}
#{{ torrent.id }} ({{ 'sensitive' | trans }})
{% else %}
{{ torrent.name }}
diff --git a/templates/default/activity/event/torrent/star/delete.html.twig b/templates/default/activity/event/torrent/star/delete.html.twig
index fd8f6f7..a160792 100644
--- a/templates/default/activity/event/torrent/star/delete.html.twig
+++ b/templates/default/activity/event/torrent/star/delete.html.twig
@@ -13,9 +13,11 @@
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
{% endif %}
{% else %}
- {% if torrent.approved == false %}
+ {% if torrent.status == false %}
+ #{{ torrent.id }} ({{ 'disabled' | trans }})
+ {% elseif torrent.approved == false %}
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
- {% elseif torrent.sensitive == true %}
+ {% elseif torrent.sensitive == true and session.user.sensitive == true %}
#{{ torrent.id }} ({{ 'sensitive' | trans }})
{% else %}
diff --git a/templates/default/activity/event/torrent/star/delete.rss.twig b/templates/default/activity/event/torrent/star/delete.rss.twig
index e24ff3a..6c4c02c 100644
--- a/templates/default/activity/event/torrent/star/delete.rss.twig
+++ b/templates/default/activity/event/torrent/star/delete.rss.twig
@@ -6,9 +6,11 @@
{% if session.user.moderator or session.user.owner %}
{{ torrent.name }}
{% else %}
- {% if torrent.approved == false %}
+ {% if torrent.status == false %}
+ #{{ torrent.id }} ({{ 'disabled' | trans }})
+ {% elseif torrent.approved == false %}
#{{ torrent.id }} ({{ 'waiting for approve' | trans }})
- {% elseif torrent.sensitive == true %}
+ {% elseif torrent.sensitive == true and session.user.sensitive == true %}
#{{ torrent.id }} ({{ 'sensitive' | trans }})
{% else %}
{{ torrent.name }}
diff --git a/templates/default/activity/event/torrent/status/add.html.twig b/templates/default/activity/event/torrent/status/add.html.twig
new file mode 100644
index 0000000..0466adc
--- /dev/null
+++ b/templates/default/activity/event/torrent/status/add.html.twig
@@ -0,0 +1,30 @@
+
@@ -90,19 +90,19 @@
| ||||
- {{ 'Approved' | trans }} + {{ 'Enabled' | trans }} | - {% if torrent.approved %} + {% if torrent.status %} {{ 'Yes' | trans }} - + {% else %} {{ 'No' | trans }} - + @@ -110,6 +110,30 @@ {% endif %} | |||
+ {{ 'Approved' | trans }} + | ++ {% if torrent.approved %} + {{ 'Yes' | trans }} + + + + {% else %} + {{ 'No' | trans }} + + + + {% endif %} + | +|||
diff --git a/templates/default/torrent/list.html.twig b/templates/default/torrent/list.html.twig index 12cfcdc..c0824d8 100644 --- a/templates/default/torrent/list.html.twig +++ b/templates/default/torrent/list.html.twig @@ -39,6 +39,14 @@ {{ 'wanted' | trans }} {% endif %} + {% if torrent.status == false %} + + + + {% endif %} {% if torrent.approved == false %} {% endif %} {% if torrent.sensitive == true %} - + diff --git a/templates/default/user/settings.html.twig b/templates/default/user/settings.html.twig index ad7fb65..857c555 100644 --- a/templates/default/user/settings.html.twig +++ b/templates/default/user/settings.html.twig @@ -65,34 +65,39 @@ | ||||
- {{ 'Locales' | trans }}
+
+ {{ 'Locales' | trans }}
+
|
- + |
{% for locale in locales %}
-
+
{% if locale in user.locales %}
{% else %}
{% endif %}
-
{% endfor %}
|
||
- {{ 'Hide sensitive' | trans }} + | + {{ 'Sensitive' | trans }} | -
-
+
+ |
{% if user.sensitive %}
-
+
{% else %}
-
+
{% endif %}
+
| |
+ | {{ group }} | -+ |
{% for key, value in event %}
-
+
{% if value in user.events %}
{% else %}
{% endif %}
- |
{% if user.yggdrasil %}
-
+
{% else %}
-
+
{% endif %}
+ |