mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2026-04-01 01:25:39 +00:00
add torrent approved moderation tools
This commit is contained in:
parent
92c2a56bbf
commit
ed6c4ea415
8 changed files with 513 additions and 207 deletions
|
|
@ -372,6 +372,60 @@ class ActivityController extends AbstractController
|
|||
|
||||
break;
|
||||
|
||||
case $activity::EVENT_TORRENT_APPROVE_ADD:
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/torrent/approve/add.html.twig',
|
||||
[
|
||||
'added' => $activity->getAdded(),
|
||||
'user' =>
|
||||
[
|
||||
'id' => $activity->getUserId(),
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->getUser(
|
||||
$activity->getUserId()
|
||||
)->getAddress()
|
||||
)
|
||||
],
|
||||
'torrent' =>
|
||||
[
|
||||
'id' => $activity->getTorrentId(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$activity->getTorrentId()
|
||||
)->getName()
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
case $activity::EVENT_TORRENT_APPROVE_DELETE:
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/torrent/approve/delete.html.twig',
|
||||
[
|
||||
'added' => $activity->getAdded(),
|
||||
'user' =>
|
||||
[
|
||||
'id' => $activity->getUserId(),
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->getUser(
|
||||
$activity->getUserId()
|
||||
)->getAddress()
|
||||
)
|
||||
],
|
||||
'torrent' =>
|
||||
[
|
||||
'id' => $activity->getTorrentId(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$activity->getTorrentId()
|
||||
)->getName()
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
// Torrent Download
|
||||
case $activity::EVENT_TORRENT_DOWNLOAD_FILE_ADD:
|
||||
|
||||
|
|
|
|||
|
|
@ -76,7 +76,13 @@ class TorrentController extends AbstractController
|
|||
$page = $request->get('page') ? (int) $request->get('page') : 1;
|
||||
|
||||
// Render template
|
||||
return $this->render('default/torrent/info.html.twig', [
|
||||
return $this->render('default/torrent/info.html.twig',
|
||||
[
|
||||
'user' =>
|
||||
[
|
||||
'id' => $user->getId(),
|
||||
'moderator' => $user->isModerator()
|
||||
],
|
||||
'torrent' =>
|
||||
[
|
||||
'id' => $torrent->getId(),
|
||||
|
|
@ -90,6 +96,7 @@ class TorrentController extends AbstractController
|
|||
],
|
||||
'locales' => $torrent->getLocales(),
|
||||
'sensitive' => $torrent->isSensitive(),
|
||||
'approved' => $torrent->isApproved(),
|
||||
'download' =>
|
||||
[
|
||||
'file' =>
|
||||
|
|
@ -564,6 +571,82 @@ class TorrentController extends AbstractController
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
#[Route(
|
||||
'/{_locale}/torrent/{torrentId}/approve/toggle',
|
||||
name: 'torrent_approve_toggle',
|
||||
requirements:
|
||||
[
|
||||
'torrentId' => '\d+',
|
||||
],
|
||||
methods:
|
||||
[
|
||||
'GET'
|
||||
]
|
||||
)]
|
||||
public function approve(
|
||||
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())
|
||||
{
|
||||
// @TODO
|
||||
throw new \Exception(
|
||||
$translator->trans('Access denied')
|
||||
);
|
||||
}
|
||||
|
||||
// Register activity event
|
||||
if (!$torrent->isApproved())
|
||||
{
|
||||
$activityService->addEventTorrentApproveAdd(
|
||||
$user->getId(),
|
||||
$torrent->getId(),
|
||||
time()
|
||||
);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$activityService->addEventTorrentApproveDelete(
|
||||
$user->getId(),
|
||||
$torrent->getId(),
|
||||
time()
|
||||
);
|
||||
}
|
||||
|
||||
// Update approved
|
||||
$torrentService->toggleTorrentApproved(
|
||||
$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}',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue