mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2026-03-31 17:15:38 +00:00
implement approved/sensitive access behavior
This commit is contained in:
parent
130add0904
commit
60a5593446
22 changed files with 681 additions and 122 deletions
|
|
@ -43,6 +43,9 @@ class ActivityController extends AbstractController
|
|||
return $this->render(
|
||||
'default/activity/list.html.twig',
|
||||
[
|
||||
'session' => [
|
||||
'user' => $user
|
||||
],
|
||||
'activities' => $activityService->findLastActivities( // @TODO locale/sensitive filters
|
||||
$user->getEvents(),
|
||||
$this->getParameter('app.pagination'),
|
||||
|
|
@ -59,7 +62,8 @@ class ActivityController extends AbstractController
|
|||
}
|
||||
|
||||
public function event(
|
||||
$activity,
|
||||
\App\Entity\User $user,
|
||||
\App\Entity\Activity $activity,
|
||||
ActivityService $activityService,
|
||||
UserService $userService,
|
||||
TorrentService $torrentService,
|
||||
|
|
@ -347,6 +351,12 @@ class ActivityController extends AbstractController
|
|||
// Torrent
|
||||
case $activity::EVENT_TORRENT_ADD:
|
||||
|
||||
// Init torrent
|
||||
if (!$torrent = $torrentService->getTorrent($activity->getTorrentId()))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/torrent/add.html.twig',
|
||||
[
|
||||
|
|
@ -362,10 +372,22 @@ class ActivityController extends AbstractController
|
|||
],
|
||||
'torrent' =>
|
||||
[
|
||||
'id' => $activity->getTorrentId(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$activity->getTorrentId()
|
||||
'id' => $torrent->getId(),
|
||||
'sensitive' => $torrent->isSensitive(),
|
||||
'approved' => $torrent->isApproved(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$torrent->getId()
|
||||
)->getName()
|
||||
],
|
||||
'session' =>
|
||||
[
|
||||
'user' =>
|
||||
[
|
||||
'id' => $user->getId(),
|
||||
'sensitive' => $user->isSensitive(),
|
||||
'moderator' => $user->isModerator(),
|
||||
'owner' => $user->getId() === $torrent->getUserId(),
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
|
@ -374,6 +396,12 @@ class ActivityController extends AbstractController
|
|||
|
||||
case $activity::EVENT_TORRENT_APPROVE_ADD:
|
||||
|
||||
// Init torrent
|
||||
if (!$torrent = $torrentService->getTorrent($activity->getTorrentId()))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/torrent/approve/add.html.twig',
|
||||
[
|
||||
|
|
@ -389,10 +417,22 @@ class ActivityController extends AbstractController
|
|||
],
|
||||
'torrent' =>
|
||||
[
|
||||
'id' => $activity->getTorrentId(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$activity->getTorrentId()
|
||||
'id' => $torrent->getId(),
|
||||
'sensitive' => $torrent->isSensitive(),
|
||||
'approved' => $torrent->isApproved(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$torrent->getId()
|
||||
)->getName()
|
||||
],
|
||||
'session' =>
|
||||
[
|
||||
'user' =>
|
||||
[
|
||||
'id' => $user->getId(),
|
||||
'sensitive' => $user->isSensitive(),
|
||||
'moderator' => $user->isModerator(),
|
||||
'owner' => $user->getId() === $torrent->getUserId(),
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
|
@ -401,6 +441,12 @@ class ActivityController extends AbstractController
|
|||
|
||||
case $activity::EVENT_TORRENT_APPROVE_DELETE:
|
||||
|
||||
// Init torrent
|
||||
if (!$torrent = $torrentService->getTorrent($activity->getTorrentId()))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/torrent/approve/delete.html.twig',
|
||||
[
|
||||
|
|
@ -416,10 +462,22 @@ class ActivityController extends AbstractController
|
|||
],
|
||||
'torrent' =>
|
||||
[
|
||||
'id' => $activity->getTorrentId(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$activity->getTorrentId()
|
||||
'id' => $torrent->getId(),
|
||||
'sensitive' => $torrent->isSensitive(),
|
||||
'approved' => $torrent->isApproved(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$torrent->getId()
|
||||
)->getName()
|
||||
],
|
||||
'session' =>
|
||||
[
|
||||
'user' =>
|
||||
[
|
||||
'id' => $user->getId(),
|
||||
'sensitive' => $user->isSensitive(),
|
||||
'moderator' => $user->isModerator(),
|
||||
'owner' => $user->getId() === $torrent->getUserId(),
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
|
@ -429,6 +487,12 @@ class ActivityController extends AbstractController
|
|||
// Torrent Download
|
||||
case $activity::EVENT_TORRENT_DOWNLOAD_FILE_ADD:
|
||||
|
||||
// Init torrent
|
||||
if (!$torrent = $torrentService->getTorrent($activity->getTorrentId()))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/torrent/download/file/add.html.twig',
|
||||
[
|
||||
|
|
@ -444,10 +508,22 @@ class ActivityController extends AbstractController
|
|||
],
|
||||
'torrent' =>
|
||||
[
|
||||
'id' => $activity->getTorrentId(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$activity->getTorrentId()
|
||||
'id' => $torrent->getId(),
|
||||
'sensitive' => $torrent->isSensitive(),
|
||||
'approved' => $torrent->isApproved(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$torrent->getId()
|
||||
)->getName()
|
||||
],
|
||||
'session' =>
|
||||
[
|
||||
'user' =>
|
||||
[
|
||||
'id' => $user->getId(),
|
||||
'sensitive' => $user->isSensitive(),
|
||||
'moderator' => $user->isModerator(),
|
||||
'owner' => $user->getId() === $torrent->getUserId(),
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
|
@ -456,6 +532,12 @@ class ActivityController extends AbstractController
|
|||
|
||||
case $activity::EVENT_TORRENT_DOWNLOAD_MAGNET_ADD:
|
||||
|
||||
// Init torrent
|
||||
if (!$torrent = $torrentService->getTorrent($activity->getTorrentId()))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/torrent/download/magnet/add.html.twig',
|
||||
[
|
||||
|
|
@ -471,10 +553,22 @@ class ActivityController extends AbstractController
|
|||
],
|
||||
'torrent' =>
|
||||
[
|
||||
'id' => $activity->getTorrentId(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$activity->getTorrentId()
|
||||
'id' => $torrent->getId(),
|
||||
'sensitive' => $torrent->isSensitive(),
|
||||
'approved' => $torrent->isApproved(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$torrent->getId()
|
||||
)->getName()
|
||||
],
|
||||
'session' =>
|
||||
[
|
||||
'user' =>
|
||||
[
|
||||
'id' => $user->getId(),
|
||||
'sensitive' => $user->isSensitive(),
|
||||
'moderator' => $user->isModerator(),
|
||||
'owner' => $user->getId() === $torrent->getUserId(),
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
|
@ -484,6 +578,12 @@ class ActivityController extends AbstractController
|
|||
/// Torrent Locales
|
||||
case $activity::EVENT_TORRENT_LOCALES_ADD:
|
||||
|
||||
// Init torrent
|
||||
if (!$torrent = $torrentService->getTorrent($activity->getTorrentId()))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/torrent/locales/add.html.twig',
|
||||
[
|
||||
|
|
@ -499,16 +599,28 @@ class ActivityController extends AbstractController
|
|||
],
|
||||
'torrent' =>
|
||||
[
|
||||
'id' => $activity->getTorrentId(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$activity->getTorrentId()
|
||||
'id' => $torrent->getId(),
|
||||
'sensitive' => $torrent->isSensitive(),
|
||||
'approved' => $torrent->isApproved(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$torrent->getId()
|
||||
)->getName(),
|
||||
'locales' => [
|
||||
'locales' => [
|
||||
'id' => $activity->getData()['torrentLocalesId'],
|
||||
'exist' => $torrentService->getTorrentLocales(
|
||||
'exist' => $torrentService->getTorrentLocales(
|
||||
$activity->getData()['torrentLocalesId'] // could be deleted by moderator, remove links
|
||||
)
|
||||
]
|
||||
],
|
||||
'session' =>
|
||||
[
|
||||
'user' =>
|
||||
[
|
||||
'id' => $user->getId(),
|
||||
'sensitive' => $user->isSensitive(),
|
||||
'moderator' => $user->isModerator(),
|
||||
'owner' => $user->getId() === $torrent->getUserId(),
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
|
@ -517,6 +629,12 @@ class ActivityController extends AbstractController
|
|||
|
||||
case $activity::EVENT_TORRENT_LOCALES_DELETE:
|
||||
|
||||
// Init torrent
|
||||
if (!$torrent = $torrentService->getTorrent($activity->getTorrentId()))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/torrent/locales/delete.html.twig',
|
||||
[
|
||||
|
|
@ -532,16 +650,28 @@ class ActivityController extends AbstractController
|
|||
],
|
||||
'torrent' =>
|
||||
[
|
||||
'id' => $activity->getTorrentId(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$activity->getTorrentId()
|
||||
'id' => $torrent->getId(),
|
||||
'sensitive' => $torrent->isSensitive(),
|
||||
'approved' => $torrent->isApproved(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$torrent->getId()
|
||||
)->getName(),
|
||||
'locales' => [
|
||||
'id' => $activity->getData()['torrentLocalesId'],
|
||||
'locales' => [
|
||||
'id' => $activity->getData()['torrentLocalesId'],
|
||||
'exist' => $torrentService->getTorrentLocales(
|
||||
$activity->getData()['torrentLocalesId'] // could be deleted by moderator, remove links
|
||||
)
|
||||
]
|
||||
],
|
||||
'session' =>
|
||||
[
|
||||
'user' =>
|
||||
[
|
||||
'id' => $user->getId(),
|
||||
'sensitive' => $user->isSensitive(),
|
||||
'moderator' => $user->isModerator(),
|
||||
'owner' => $user->getId() === $torrent->getUserId(),
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
|
@ -550,6 +680,12 @@ class ActivityController extends AbstractController
|
|||
|
||||
case $activity::EVENT_TORRENT_LOCALES_APPROVE_ADD:
|
||||
|
||||
// Init torrent
|
||||
if (!$torrent = $torrentService->getTorrent($activity->getTorrentId()))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/torrent/locales/approve/add.html.twig',
|
||||
[
|
||||
|
|
@ -565,16 +701,28 @@ class ActivityController extends AbstractController
|
|||
],
|
||||
'torrent' =>
|
||||
[
|
||||
'id' => $activity->getTorrentId(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$activity->getTorrentId()
|
||||
'id' => $torrent->getId(),
|
||||
'sensitive' => $torrent->isSensitive(),
|
||||
'approved' => $torrent->isApproved(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$torrent->getId()
|
||||
)->getName(),
|
||||
'locales' => [
|
||||
'id' => $activity->getData()['torrentLocalesId'],
|
||||
'locales' => [
|
||||
'id' => $activity->getData()['torrentLocalesId'],
|
||||
'exist' => $torrentService->getTorrentLocales(
|
||||
$activity->getData()['torrentLocalesId'] // could be deleted by moderator, remove links
|
||||
)
|
||||
]
|
||||
],
|
||||
'session' =>
|
||||
[
|
||||
'user' =>
|
||||
[
|
||||
'id' => $user->getId(),
|
||||
'sensitive' => $user->isSensitive(),
|
||||
'moderator' => $user->isModerator(),
|
||||
'owner' => $user->getId() === $torrent->getUserId(),
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
|
@ -583,6 +731,12 @@ class ActivityController extends AbstractController
|
|||
|
||||
case $activity::EVENT_TORRENT_LOCALES_APPROVE_DELETE:
|
||||
|
||||
// Init torrent
|
||||
if (!$torrent = $torrentService->getTorrent($activity->getTorrentId()))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/torrent/locales/approve/delete.html.twig',
|
||||
[
|
||||
|
|
@ -598,16 +752,28 @@ class ActivityController extends AbstractController
|
|||
],
|
||||
'torrent' =>
|
||||
[
|
||||
'id' => $activity->getTorrentId(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$activity->getTorrentId()
|
||||
'id' => $torrent->getId(),
|
||||
'sensitive' => $torrent->isSensitive(),
|
||||
'approved' => $torrent->isApproved(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$torrent->getId()
|
||||
)->getName(),
|
||||
'locales' => [
|
||||
'id' => $activity->getData()['torrentLocalesId'],
|
||||
'locales' => [
|
||||
'id' => $activity->getData()['torrentLocalesId'],
|
||||
'exist' => $torrentService->getTorrentLocales(
|
||||
$activity->getData()['torrentLocalesId'] // could be deleted by moderator, remove links
|
||||
)
|
||||
]
|
||||
],
|
||||
'session' =>
|
||||
[
|
||||
'user' =>
|
||||
[
|
||||
'id' => $user->getId(),
|
||||
'sensitive' => $user->isSensitive(),
|
||||
'moderator' => $user->isModerator(),
|
||||
'owner' => $user->getId() === $torrent->getUserId(),
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
|
@ -617,6 +783,12 @@ class ActivityController extends AbstractController
|
|||
/// Torrent Sensitive
|
||||
case $activity::EVENT_TORRENT_SENSITIVE_ADD:
|
||||
|
||||
// Init torrent
|
||||
if (!$torrent = $torrentService->getTorrent($activity->getTorrentId()))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/torrent/sensitive/add.html.twig',
|
||||
[
|
||||
|
|
@ -632,16 +804,28 @@ class ActivityController extends AbstractController
|
|||
],
|
||||
'torrent' =>
|
||||
[
|
||||
'id' => $activity->getTorrentId(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$activity->getTorrentId()
|
||||
'id' => $torrent->getId(),
|
||||
'sensitive' => $torrent->isSensitive(),
|
||||
'approved' => $torrent->isApproved(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$torrent->getId()
|
||||
)->getName(),
|
||||
'sensitive' => [
|
||||
'id' => $activity->getData()['torrentSensitiveId'],
|
||||
'id' => $activity->getData()['torrentSensitiveId'],
|
||||
'exist' => $torrentService->getTorrentSensitive(
|
||||
$activity->getData()['torrentSensitiveId'] // could be deleted by moderator, remove links
|
||||
)
|
||||
]
|
||||
],
|
||||
'session' =>
|
||||
[
|
||||
'user' =>
|
||||
[
|
||||
'id' => $user->getId(),
|
||||
'sensitive' => $user->isSensitive(),
|
||||
'moderator' => $user->isModerator(),
|
||||
'owner' => $user->getId() === $torrent->getUserId(),
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
|
@ -650,6 +834,12 @@ class ActivityController extends AbstractController
|
|||
|
||||
case $activity::EVENT_TORRENT_SENSITIVE_DELETE:
|
||||
|
||||
// Init torrent
|
||||
if (!$torrent = $torrentService->getTorrent($activity->getTorrentId()))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/torrent/sensitive/delete.html.twig',
|
||||
[
|
||||
|
|
@ -665,16 +855,28 @@ class ActivityController extends AbstractController
|
|||
],
|
||||
'torrent' =>
|
||||
[
|
||||
'id' => $activity->getTorrentId(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$activity->getTorrentId()
|
||||
'id' => $torrent->getId(),
|
||||
'sensitive' => $torrent->isSensitive(),
|
||||
'approved' => $torrent->isApproved(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$torrent->getId()
|
||||
)->getName(),
|
||||
'sensitive' => [
|
||||
'id' => $activity->getData()['torrentSensitiveId'],
|
||||
'id' => $activity->getData()['torrentSensitiveId'],
|
||||
'exist' => $torrentService->getTorrentSensitive(
|
||||
$activity->getData()['torrentSensitiveId'] // could be deleted by moderator, remove links
|
||||
)
|
||||
]
|
||||
],
|
||||
'session' =>
|
||||
[
|
||||
'user' =>
|
||||
[
|
||||
'id' => $user->getId(),
|
||||
'sensitive' => $user->isSensitive(),
|
||||
'moderator' => $user->isModerator(),
|
||||
'owner' => $user->getId() === $torrent->getUserId(),
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
|
@ -683,6 +885,12 @@ class ActivityController extends AbstractController
|
|||
|
||||
case $activity::EVENT_TORRENT_SENSITIVE_APPROVE_ADD:
|
||||
|
||||
// Init torrent
|
||||
if (!$torrent = $torrentService->getTorrent($activity->getTorrentId()))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/torrent/sensitive/approve/add.html.twig',
|
||||
[
|
||||
|
|
@ -698,16 +906,28 @@ class ActivityController extends AbstractController
|
|||
],
|
||||
'torrent' =>
|
||||
[
|
||||
'id' => $activity->getTorrentId(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$activity->getTorrentId()
|
||||
'id' => $torrent->getId(),
|
||||
'sensitive' => $torrent->isSensitive(),
|
||||
'approved' => $torrent->isApproved(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$torrent->getId()
|
||||
)->getName(),
|
||||
'sensitive' => [
|
||||
'id' => $activity->getData()['torrentSensitiveId'],
|
||||
'id' => $activity->getData()['torrentSensitiveId'],
|
||||
'exist' => $torrentService->getTorrentSensitive(
|
||||
$activity->getData()['torrentSensitiveId'] // could be deleted by moderator, remove links
|
||||
)
|
||||
]
|
||||
],
|
||||
'session' =>
|
||||
[
|
||||
'user' =>
|
||||
[
|
||||
'id' => $user->getId(),
|
||||
'sensitive' => $user->isSensitive(),
|
||||
'moderator' => $user->isModerator(),
|
||||
'owner' => $user->getId() === $torrent->getUserId(),
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
|
@ -716,6 +936,12 @@ class ActivityController extends AbstractController
|
|||
|
||||
case $activity::EVENT_TORRENT_SENSITIVE_APPROVE_DELETE:
|
||||
|
||||
// Init torrent
|
||||
if (!$torrent = $torrentService->getTorrent($activity->getTorrentId()))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/torrent/sensitive/approve/delete.html.twig',
|
||||
[
|
||||
|
|
@ -731,16 +957,28 @@ class ActivityController extends AbstractController
|
|||
],
|
||||
'torrent' =>
|
||||
[
|
||||
'id' => $activity->getTorrentId(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$activity->getTorrentId()
|
||||
'id' => $torrent->getId(),
|
||||
'sensitive' => $torrent->isSensitive(),
|
||||
'approved' => $torrent->isApproved(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$torrent->getId()
|
||||
)->getName(),
|
||||
'sensitive' => [
|
||||
'id' => $activity->getData()['torrentSensitiveId'],
|
||||
'id' => $activity->getData()['torrentSensitiveId'],
|
||||
'exist' => $torrentService->getTorrentSensitive(
|
||||
$activity->getData()['torrentSensitiveId'] // could be deleted by moderator, remove links
|
||||
)
|
||||
]
|
||||
],
|
||||
'session' =>
|
||||
[
|
||||
'user' =>
|
||||
[
|
||||
'id' => $user->getId(),
|
||||
'sensitive' => $user->isSensitive(),
|
||||
'moderator' => $user->isModerator(),
|
||||
'owner' => $user->getId() === $torrent->getUserId(),
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
|
@ -750,6 +988,12 @@ class ActivityController extends AbstractController
|
|||
/// Torrent star
|
||||
case $activity::EVENT_TORRENT_STAR_ADD:
|
||||
|
||||
// Init torrent
|
||||
if (!$torrent = $torrentService->getTorrent($activity->getTorrentId()))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/torrent/star/add.html.twig',
|
||||
[
|
||||
|
|
@ -765,10 +1009,22 @@ class ActivityController extends AbstractController
|
|||
],
|
||||
'torrent' =>
|
||||
[
|
||||
'id' => $activity->getTorrentId(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$activity->getTorrentId()
|
||||
'id' => $torrent->getId(),
|
||||
'sensitive' => $torrent->isSensitive(),
|
||||
'approved' => $torrent->isApproved(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$torrent->getId()
|
||||
)->getName()
|
||||
],
|
||||
'session' =>
|
||||
[
|
||||
'user' =>
|
||||
[
|
||||
'id' => $user->getId(),
|
||||
'sensitive' => $user->isSensitive(),
|
||||
'moderator' => $user->isModerator(),
|
||||
'owner' => $user->getId() === $torrent->getUserId(),
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
|
@ -777,6 +1033,12 @@ class ActivityController extends AbstractController
|
|||
|
||||
case $activity::EVENT_TORRENT_STAR_DELETE:
|
||||
|
||||
// Init torrent
|
||||
if (!$torrent = $torrentService->getTorrent($activity->getTorrentId()))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/torrent/star/delete.html.twig',
|
||||
[
|
||||
|
|
@ -792,18 +1054,28 @@ class ActivityController extends AbstractController
|
|||
],
|
||||
'torrent' =>
|
||||
[
|
||||
'id' => $activity->getTorrentId(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$activity->getTorrentId()
|
||||
'id' => $torrent->getId(),
|
||||
'sensitive' => $torrent->isSensitive(),
|
||||
'approved' => $torrent->isApproved(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$torrent->getId()
|
||||
)->getName()
|
||||
],
|
||||
'session' =>
|
||||
[
|
||||
'user' =>
|
||||
[
|
||||
'id' => $user->getId(),
|
||||
'sensitive' => $user->isSensitive(),
|
||||
'moderator' => $user->isModerator(),
|
||||
'owner' => $user->getId() === $torrent->getUserId(),
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
// @TODO Page
|
||||
|
||||
default:
|
||||
|
||||
return $this->render(
|
||||
|
|
|
|||
|
|
@ -55,6 +55,18 @@ class TorrentController extends AbstractController
|
|||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
// Sensitive filter
|
||||
if (!$user->isModerator() && $user->getId() != $torrent->getUserId() && $user->isSensitive())
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
// Approved filter
|
||||
if (!$user->isModerator() && $user->getId() != $torrent->getUserId() && !$torrent->isApproved())
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
// Get contributors
|
||||
$contributors = [];
|
||||
foreach ($torrentService->getTorrentContributors($torrent) as $userId)
|
||||
|
|
@ -95,6 +107,10 @@ class TorrentController extends AbstractController
|
|||
// Render template
|
||||
return $this->render('default/torrent/info.html.twig',
|
||||
[
|
||||
'session' =>
|
||||
[
|
||||
'user' => $user
|
||||
],
|
||||
'user' =>
|
||||
[
|
||||
'id' => $user->getId(),
|
||||
|
|
@ -215,16 +231,16 @@ class TorrentController extends AbstractController
|
|||
$total = $torrentService->findTorrentsTotal(
|
||||
$query,
|
||||
$user->getLocales(),
|
||||
$user->isSensitive() ? false : null, // hide on sensitive mode enabled or show all
|
||||
$user->isModerator() ? null : true, // show approved content only for regular users
|
||||
!$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
|
||||
);
|
||||
|
||||
$torrents = [];
|
||||
foreach ($torrentService->findTorrents(
|
||||
$query,
|
||||
$user->getLocales(),
|
||||
$user->isSensitive() ? false : null, // hide on sensitive mode enabled or show all
|
||||
$user->isModerator() ? null : true, // show approved content only for regular users
|
||||
!$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
|
||||
$this->getParameter('app.pagination'),
|
||||
($page - 1) * $this->getParameter('app.pagination')
|
||||
) as $torrent)
|
||||
|
|
@ -247,8 +263,10 @@ class TorrentController extends AbstractController
|
|||
|
||||
$torrents[] =
|
||||
[
|
||||
'id' => $torrent->getId(),
|
||||
'added' => $torrent->getAdded(),
|
||||
'id' => $torrent->getId(),
|
||||
'added' => $torrent->getAdded(),
|
||||
'approved' => $torrent->isApproved(),
|
||||
'sensitive' => $torrent->isSensitive(),
|
||||
'file' =>
|
||||
[
|
||||
'name' => $file->getName(),
|
||||
|
|
@ -341,8 +359,8 @@ class TorrentController extends AbstractController
|
|||
$total = $torrentService->findTorrentsTotal(
|
||||
[],
|
||||
$user->getLocales(),
|
||||
$user->isSensitive() ? false : null, // hide on sensitive mode enabled or show all
|
||||
$user->isModerator() ? null : true, // show approved content only for regular users
|
||||
!$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
|
||||
);
|
||||
|
||||
// Create torrents list
|
||||
|
|
@ -350,8 +368,8 @@ class TorrentController extends AbstractController
|
|||
foreach ($torrentService->findTorrents(
|
||||
[],
|
||||
$user->getLocales(),
|
||||
$user->isSensitive() ? false : null, // hide on sensitive mode enabled or show all
|
||||
$user->isModerator() ? null : true, // show approved content only for regular users
|
||||
!$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
|
||||
$this->getParameter('app.pagination'),
|
||||
($page - 1) * $this->getParameter('app.pagination')
|
||||
) as $torrent)
|
||||
|
|
@ -375,8 +393,10 @@ class TorrentController extends AbstractController
|
|||
|
||||
$torrents[] =
|
||||
[
|
||||
'id' => $torrent->getId(),
|
||||
'added' => $torrent->getAdded(),
|
||||
'id' => $torrent->getId(),
|
||||
'added' => $torrent->getAdded(),
|
||||
'approved' => $torrent->isApproved(),
|
||||
'sensitive' => $torrent->isSensitive(),
|
||||
'file' =>
|
||||
[
|
||||
'name' => $file->getName(),
|
||||
|
|
@ -1480,6 +1500,18 @@ class TorrentController extends AbstractController
|
|||
);
|
||||
}
|
||||
|
||||
// Sensitive filter
|
||||
if (!$user->isModerator() && $user->getId() != $torrent->getUserId() && $user->isSensitive())
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
// Approved filter
|
||||
if (!$user->isModerator() && $user->getId() != $torrent->getUserId() && !$torrent->isApproved())
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
// Register download
|
||||
$torrentService->addTorrentDownloadFile(
|
||||
$torrent->getId(),
|
||||
|
|
@ -1588,6 +1620,18 @@ class TorrentController extends AbstractController
|
|||
);
|
||||
}
|
||||
|
||||
// Sensitive filter
|
||||
if (!$user->isModerator() && $user->getId() != $torrent->getUserId() && $user->isSensitive())
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
// Approved filter
|
||||
if (!$user->isModerator() && $user->getId() != $torrent->getUserId() && !$torrent->isApproved())
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
// Register download
|
||||
$torrentService->addTorrentDownloadMagnet(
|
||||
$torrent->getId(),
|
||||
|
|
|
|||
|
|
@ -208,6 +208,10 @@ class UserController extends AbstractController
|
|||
return $this->render(
|
||||
'default/user/info.html.twig',
|
||||
[
|
||||
'session' =>
|
||||
[
|
||||
'user' => $user
|
||||
],
|
||||
'user' => [
|
||||
'id' => $userTarget->getId(),
|
||||
'address' => $userTarget->getId() === $user->getId() ? $userTarget->getAddress() : false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue