mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2026-04-01 01:25:39 +00:00
add category edition events support #26
This commit is contained in:
parent
2e9b119733
commit
31aad63399
28 changed files with 1514 additions and 37 deletions
|
|
@ -1116,6 +1116,219 @@ class ActivityController extends AbstractController
|
|||
|
||||
break;
|
||||
|
||||
/// Torrent Categories
|
||||
case $activity::EVENT_TORRENT_CATEGORIES_ADD:
|
||||
|
||||
// Init torrent
|
||||
if (!$torrent = $torrentService->getTorrent($activity->getTorrentId()))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/torrent/categories/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(),
|
||||
'categories' => [
|
||||
'id' => $activity->getData()['torrentCategoriesId'],
|
||||
'exist' => $torrentService->getTorrentCategories(
|
||||
$activity->getData()['torrentCategoriesId'] // could be deleted by moderator, remove links
|
||||
)
|
||||
]
|
||||
],
|
||||
'session' =>
|
||||
[
|
||||
'user' =>
|
||||
[
|
||||
'id' => $user->getId(),
|
||||
'sensitive' => $user->isSensitive(),
|
||||
'moderator' => $user->isModerator(),
|
||||
'owner' => $user->getId() === $torrent->getUserId(),
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
case $activity::EVENT_TORRENT_CATEGORIES_DELETE:
|
||||
|
||||
// Init torrent
|
||||
if (!$torrent = $torrentService->getTorrent($activity->getTorrentId()))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/torrent/categories/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(),
|
||||
'categories' => [
|
||||
'id' => $activity->getData()['torrentCategoriesId'],
|
||||
'exist' => $torrentService->getTorrentCategories(
|
||||
$activity->getData()['torrentCategoriesId'] // could be deleted by moderator, remove links
|
||||
)
|
||||
]
|
||||
],
|
||||
'session' =>
|
||||
[
|
||||
'user' =>
|
||||
[
|
||||
'id' => $user->getId(),
|
||||
'sensitive' => $user->isSensitive(),
|
||||
'moderator' => $user->isModerator(),
|
||||
'owner' => $user->getId() === $torrent->getUserId(),
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
case $activity::EVENT_TORRENT_CATEGORIES_APPROVE_ADD:
|
||||
|
||||
// Init torrent
|
||||
if (!$torrent = $torrentService->getTorrent($activity->getTorrentId()))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/torrent/categories/approve/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(),
|
||||
'categories' => [
|
||||
'id' => $activity->getData()['torrentCategoriesId'],
|
||||
'exist' => $torrentService->getTorrentCategories(
|
||||
$activity->getData()['torrentCategoriesId'] // could be deleted by moderator, remove links
|
||||
)
|
||||
]
|
||||
],
|
||||
'session' =>
|
||||
[
|
||||
'user' =>
|
||||
[
|
||||
'id' => $user->getId(),
|
||||
'sensitive' => $user->isSensitive(),
|
||||
'moderator' => $user->isModerator(),
|
||||
'owner' => $user->getId() === $torrent->getUserId(),
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
case $activity::EVENT_TORRENT_CATEGORIES_APPROVE_DELETE:
|
||||
|
||||
// Init torrent
|
||||
if (!$torrent = $torrentService->getTorrent($activity->getTorrentId()))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/torrent/categories/approve/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(),
|
||||
'categories' => [
|
||||
'id' => $activity->getData()['torrentCategoriesId'],
|
||||
'exist' => $torrentService->getTorrentCategories(
|
||||
$activity->getData()['torrentCategoriesId'] // could be deleted by moderator, remove links
|
||||
)
|
||||
]
|
||||
],
|
||||
'session' =>
|
||||
[
|
||||
'user' =>
|
||||
[
|
||||
'id' => $user->getId(),
|
||||
'sensitive' => $user->isSensitive(),
|
||||
'moderator' => $user->isModerator(),
|
||||
'owner' => $user->getId() === $torrent->getUserId(),
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
/// Torrent Sensitive
|
||||
case $activity::EVENT_TORRENT_SENSITIVE_ADD:
|
||||
|
||||
|
|
|
|||
|
|
@ -1704,14 +1704,12 @@ class TorrentController extends AbstractController
|
|||
);
|
||||
|
||||
// Register activity event
|
||||
/* @TODO
|
||||
$activityService->addEventTorrentCategoriesAdd(
|
||||
$user->getId(),
|
||||
$torrent->getId(),
|
||||
time(),
|
||||
$torrentCategories->getId()
|
||||
);
|
||||
*/
|
||||
|
||||
// Redirect to info page
|
||||
return $this->redirectToRoute(
|
||||
|
|
@ -1792,7 +1790,6 @@ class TorrentController extends AbstractController
|
|||
}
|
||||
|
||||
// Register activity event
|
||||
/* @TODO
|
||||
if (!$torrentCategories->isApproved())
|
||||
{
|
||||
$activityService->addEventTorrentCategoriesApproveAdd(
|
||||
|
|
@ -1812,7 +1809,6 @@ class TorrentController extends AbstractController
|
|||
$torrentCategories->getId()
|
||||
);
|
||||
}
|
||||
*/
|
||||
|
||||
// Update approved
|
||||
$torrentService->toggleTorrentCategoriesApproved(
|
||||
|
|
@ -1881,14 +1877,12 @@ class TorrentController extends AbstractController
|
|||
}
|
||||
|
||||
// Add activity event
|
||||
/* @TODO
|
||||
$activityService->addEventTorrentCategoriesDelete(
|
||||
$user->getId(),
|
||||
$torrent->getId(),
|
||||
time(),
|
||||
$torrentCategories->getId()
|
||||
);
|
||||
*/
|
||||
|
||||
// Update approved
|
||||
$torrentService->deleteTorrentCategories(
|
||||
|
|
|
|||
|
|
@ -20,52 +20,57 @@ class Activity
|
|||
// Event codes
|
||||
|
||||
/// User
|
||||
public const EVENT_USER_ADD = 1000;
|
||||
public const EVENT_USER_ADD = 1000;
|
||||
|
||||
public const EVENT_USER_APPROVE_ADD = 1200;
|
||||
public const EVENT_USER_APPROVE_DELETE = 1201;
|
||||
public const EVENT_USER_APPROVE_ADD = 1200;
|
||||
public const EVENT_USER_APPROVE_DELETE = 1201;
|
||||
|
||||
public const EVENT_USER_MODERATOR_ADD = 1300;
|
||||
public const EVENT_USER_MODERATOR_DELETE = 1301;
|
||||
public const EVENT_USER_MODERATOR_ADD = 1300;
|
||||
public const EVENT_USER_MODERATOR_DELETE = 1301;
|
||||
|
||||
public const EVENT_USER_STATUS_ADD = 1400;
|
||||
public const EVENT_USER_STATUS_DELETE = 1401;
|
||||
public const EVENT_USER_STATUS_ADD = 1400;
|
||||
public const EVENT_USER_STATUS_DELETE = 1401;
|
||||
|
||||
public const EVENT_USER_STAR_ADD = 1500;
|
||||
public const EVENT_USER_STAR_DELETE = 1501;
|
||||
public const EVENT_USER_STAR_ADD = 1500;
|
||||
public const EVENT_USER_STAR_DELETE = 1501;
|
||||
|
||||
/// Torrent
|
||||
public const EVENT_TORRENT_ADD = 2000;
|
||||
public const EVENT_TORRENT_ADD = 2000;
|
||||
|
||||
public const EVENT_TORRENT_APPROVE_ADD = 1100;
|
||||
public const EVENT_TORRENT_APPROVE_DELETE = 1101;
|
||||
public const EVENT_TORRENT_APPROVE_ADD = 1100;
|
||||
public const EVENT_TORRENT_APPROVE_DELETE = 1101;
|
||||
|
||||
public const EVENT_TORRENT_LOCALES_ADD = 2200;
|
||||
public const EVENT_TORRENT_LOCALES_DELETE = 2201;
|
||||
public const EVENT_TORRENT_LOCALES_APPROVE_ADD = 2210;
|
||||
public const EVENT_TORRENT_LOCALES_APPROVE_DELETE = 2211;
|
||||
public const EVENT_TORRENT_LOCALES_ADD = 2200;
|
||||
public const EVENT_TORRENT_LOCALES_DELETE = 2201;
|
||||
public const EVENT_TORRENT_LOCALES_APPROVE_ADD = 2210;
|
||||
public const EVENT_TORRENT_LOCALES_APPROVE_DELETE = 2211;
|
||||
|
||||
public const EVENT_TORRENT_SENSITIVE_ADD = 2300;
|
||||
public const EVENT_TORRENT_SENSITIVE_DELETE = 2301;
|
||||
public const EVENT_TORRENT_SENSITIVE_APPROVE_ADD = 2310;
|
||||
public const EVENT_TORRENT_SENSITIVE_APPROVE_DELETE = 2311;
|
||||
public const EVENT_TORRENT_SENSITIVE_ADD = 2300;
|
||||
public const EVENT_TORRENT_SENSITIVE_DELETE = 2301;
|
||||
public const EVENT_TORRENT_SENSITIVE_APPROVE_ADD = 2310;
|
||||
public const EVENT_TORRENT_SENSITIVE_APPROVE_DELETE = 2311;
|
||||
|
||||
public const EVENT_TORRENT_STAR_ADD = 2400;
|
||||
public const EVENT_TORRENT_STAR_DELETE = 2401;
|
||||
public const EVENT_TORRENT_STAR_ADD = 2400;
|
||||
public const EVENT_TORRENT_STAR_DELETE = 2401;
|
||||
|
||||
public const EVENT_TORRENT_DOWNLOAD_FILE_ADD = 2500;
|
||||
public const EVENT_TORRENT_DOWNLOAD_FILE_ADD = 2500;
|
||||
|
||||
public const EVENT_TORRENT_DOWNLOAD_MAGNET_ADD = 2600;
|
||||
public const EVENT_TORRENT_DOWNLOAD_MAGNET_ADD = 2600;
|
||||
|
||||
public const EVENT_TORRENT_WANTED_ADD = 2700;
|
||||
public const EVENT_TORRENT_WANTED_ADD = 2700;
|
||||
|
||||
public const EVENT_TORRENT_STATUS_ADD = 1800;
|
||||
public const EVENT_TORRENT_STATUS_DELETE = 1801;
|
||||
public const EVENT_TORRENT_STATUS_ADD = 1800;
|
||||
public const EVENT_TORRENT_STATUS_DELETE = 1801;
|
||||
|
||||
public const EVENT_TORRENT_POSTER_ADD = 2800;
|
||||
public const EVENT_TORRENT_POSTER_DELETE = 2801;
|
||||
public const EVENT_TORRENT_POSTER_APPROVE_ADD = 2810;
|
||||
public const EVENT_TORRENT_POSTER_APPROVE_DELETE = 2811;
|
||||
public const EVENT_TORRENT_POSTER_ADD = 2800;
|
||||
public const EVENT_TORRENT_POSTER_DELETE = 2801;
|
||||
public const EVENT_TORRENT_POSTER_APPROVE_ADD = 2810;
|
||||
public const EVENT_TORRENT_POSTER_APPROVE_DELETE = 2811;
|
||||
|
||||
public const EVENT_TORRENT_CATEGORIES_ADD = 2900;
|
||||
public const EVENT_TORRENT_CATEGORIES_DELETE = 2901;
|
||||
public const EVENT_TORRENT_CATEGORIES_APPROVE_ADD = 2910;
|
||||
public const EVENT_TORRENT_CATEGORIES_APPROVE_DELETE = 2911;
|
||||
|
||||
// ...
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,11 @@ class ActivityService
|
|||
Activity::EVENT_TORRENT_LOCALES_APPROVE_ADD,
|
||||
Activity::EVENT_TORRENT_LOCALES_APPROVE_DELETE,
|
||||
|
||||
Activity::EVENT_TORRENT_CATEGORIES_ADD,
|
||||
Activity::EVENT_TORRENT_CATEGORIES_DELETE,
|
||||
Activity::EVENT_TORRENT_CATEGORIES_APPROVE_ADD,
|
||||
Activity::EVENT_TORRENT_CATEGORIES_APPROVE_DELETE,
|
||||
|
||||
Activity::EVENT_TORRENT_SENSITIVE_ADD,
|
||||
Activity::EVENT_TORRENT_SENSITIVE_DELETE,
|
||||
Activity::EVENT_TORRENT_SENSITIVE_APPROVE_ADD,
|
||||
|
|
@ -277,6 +282,55 @@ class ActivityService
|
|||
|
||||
break;
|
||||
|
||||
/// Torrent categories
|
||||
case Activity::EVENT_TORRENT_CATEGORIES_ADD:
|
||||
|
||||
$events
|
||||
[
|
||||
$this->translatorInterface->trans('Torrent categories')
|
||||
]
|
||||
[
|
||||
$this->translatorInterface->trans('Added')
|
||||
] = $code;
|
||||
|
||||
break;
|
||||
|
||||
case Activity::EVENT_TORRENT_CATEGORIES_DELETE:
|
||||
|
||||
$events
|
||||
[
|
||||
$this->translatorInterface->trans('Torrent categories')
|
||||
]
|
||||
[
|
||||
$this->translatorInterface->trans('Deleted')
|
||||
] = $code;
|
||||
|
||||
break;
|
||||
|
||||
case Activity::EVENT_TORRENT_CATEGORIES_APPROVE_ADD:
|
||||
|
||||
$events
|
||||
[
|
||||
$this->translatorInterface->trans('Torrent categories')
|
||||
]
|
||||
[
|
||||
$this->translatorInterface->trans('Approved')
|
||||
] = $code;
|
||||
|
||||
break;
|
||||
|
||||
case Activity::EVENT_TORRENT_CATEGORIES_APPROVE_DELETE:
|
||||
|
||||
$events
|
||||
[
|
||||
$this->translatorInterface->trans('Torrent categories')
|
||||
]
|
||||
[
|
||||
$this->translatorInterface->trans('Disapproved')
|
||||
] = $code;
|
||||
|
||||
break;
|
||||
|
||||
/// Torrent sensitive
|
||||
case Activity::EVENT_TORRENT_SENSITIVE_ADD:
|
||||
|
||||
|
|
@ -1303,6 +1357,155 @@ class ActivityService
|
|||
return $activity;
|
||||
}
|
||||
|
||||
/// Torrent categories
|
||||
public function addEventTorrentCategoriesAdd(
|
||||
int $userId,
|
||||
int $torrentId,
|
||||
int $added,
|
||||
int $torrentCategoriesId,
|
||||
): ?Activity
|
||||
{
|
||||
$activity = new Activity();
|
||||
|
||||
$activity->setEvent(
|
||||
Activity::EVENT_TORRENT_CATEGORIES_ADD
|
||||
);
|
||||
|
||||
$activity->setUserId(
|
||||
$userId
|
||||
);
|
||||
|
||||
$activity->setTorrentId(
|
||||
$torrentId
|
||||
);
|
||||
|
||||
$activity->setAdded(
|
||||
$added
|
||||
);
|
||||
|
||||
$activity->setData(
|
||||
[
|
||||
'torrentCategoriesId' => $torrentCategoriesId
|
||||
]
|
||||
);
|
||||
|
||||
$this->entityManagerInterface->persist($activity);
|
||||
$this->entityManagerInterface->flush();
|
||||
|
||||
return $activity;
|
||||
}
|
||||
|
||||
public function addEventTorrentCategoriesDelete(
|
||||
int $userId,
|
||||
int $torrentId,
|
||||
int $added,
|
||||
int $torrentCategoriesId,
|
||||
): ?Activity
|
||||
{
|
||||
$activity = new Activity();
|
||||
|
||||
$activity->setEvent(
|
||||
Activity::EVENT_TORRENT_CATEGORIES_DELETE
|
||||
);
|
||||
|
||||
$activity->setUserId(
|
||||
$userId
|
||||
);
|
||||
|
||||
$activity->setTorrentId(
|
||||
$torrentId
|
||||
);
|
||||
|
||||
$activity->setAdded(
|
||||
$added
|
||||
);
|
||||
|
||||
$activity->setData(
|
||||
[
|
||||
'torrentCategoriesId' => $torrentCategoriesId
|
||||
]
|
||||
);
|
||||
|
||||
$this->entityManagerInterface->persist($activity);
|
||||
$this->entityManagerInterface->flush();
|
||||
|
||||
return $activity;
|
||||
}
|
||||
|
||||
public function addEventTorrentCategoriesApproveAdd(
|
||||
int $userId,
|
||||
int $torrentId,
|
||||
int $added,
|
||||
int $torrentCategoriesId,
|
||||
): ?Activity
|
||||
{
|
||||
$activity = new Activity();
|
||||
|
||||
$activity->setEvent(
|
||||
Activity::EVENT_TORRENT_CATEGORIES_APPROVE_ADD
|
||||
);
|
||||
|
||||
$activity->setUserId(
|
||||
$userId
|
||||
);
|
||||
|
||||
$activity->setTorrentId(
|
||||
$torrentId
|
||||
);
|
||||
|
||||
$activity->setAdded(
|
||||
$added
|
||||
);
|
||||
|
||||
$activity->setData(
|
||||
[
|
||||
'torrentCategoriesId' => $torrentCategoriesId
|
||||
]
|
||||
);
|
||||
|
||||
$this->entityManagerInterface->persist($activity);
|
||||
$this->entityManagerInterface->flush();
|
||||
|
||||
return $activity;
|
||||
}
|
||||
|
||||
public function addEventTorrentCategoriesApproveDelete(
|
||||
int $userId,
|
||||
int $torrentId,
|
||||
int $added,
|
||||
int $torrentCategoriesId,
|
||||
): ?Activity
|
||||
{
|
||||
$activity = new Activity();
|
||||
|
||||
$activity->setEvent(
|
||||
Activity::EVENT_TORRENT_CATEGORIES_APPROVE_DELETE
|
||||
);
|
||||
|
||||
$activity->setUserId(
|
||||
$userId
|
||||
);
|
||||
|
||||
$activity->setTorrentId(
|
||||
$torrentId
|
||||
);
|
||||
|
||||
$activity->setAdded(
|
||||
$added
|
||||
);
|
||||
|
||||
$activity->setData(
|
||||
[
|
||||
'torrentCategoriesId' => $torrentCategoriesId
|
||||
]
|
||||
);
|
||||
|
||||
$this->entityManagerInterface->persist($activity);
|
||||
$this->entityManagerInterface->flush();
|
||||
|
||||
return $activity;
|
||||
}
|
||||
|
||||
/// Torrent sensitive
|
||||
public function addEventTorrentSensitiveAdd(
|
||||
int $userId,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue