Browse Source

init activity features #4

main
ghost 1 year ago
parent
commit
ef84fefca3
  1. 620
      src/Controller/ActivityController.php
  2. 97
      src/Controller/TorrentController.php
  3. 62
      src/Controller/UserController.php
  4. 103
      src/Entity/Activity.php
  5. 24
      src/Repository/ActivityRepository.php
  6. 411
      src/Service/ActivityService.php
  7. 7
      src/Service/UserService.php
  8. 12
      templates/default/activity/event/torrent/add.html.twig
  9. 18
      templates/default/activity/event/torrent/locales/add.html.twig
  10. 18
      templates/default/activity/event/torrent/locales/approve/add.html.twig
  11. 18
      templates/default/activity/event/torrent/locales/approve/delete.html.twig
  12. 18
      templates/default/activity/event/torrent/locales/delete.html.twig
  13. 18
      templates/default/activity/event/torrent/sensitive/add.html.twig
  14. 18
      templates/default/activity/event/torrent/sensitive/approve/add.html.twig
  15. 18
      templates/default/activity/event/torrent/sensitive/approve/delete.html.twig
  16. 18
      templates/default/activity/event/torrent/sensitive/delete.html.twig
  17. 9
      templates/default/activity/event/undefined.html.twig
  18. 9
      templates/default/activity/event/user/add.html.twig
  19. 12
      templates/default/activity/event/user/approve/add.html.twig
  20. 12
      templates/default/activity/event/user/approve/delete.html.twig
  21. 12
      templates/default/activity/event/user/moderator/add.html.twig
  22. 12
      templates/default/activity/event/user/moderator/delete.html.twig
  23. 12
      templates/default/activity/event/user/star/add.html.twig
  24. 12
      templates/default/activity/event/user/star/delete.html.twig
  25. 12
      templates/default/activity/event/user/status/add.html.twig
  26. 12
      templates/default/activity/event/user/status/delete.html.twig
  27. 21
      templates/default/user/dashboard.html.twig

620
src/Controller/ActivityController.php

@ -0,0 +1,620 @@
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use App\Service\ActivityService;
use App\Service\UserService;
use App\Service\ArticleService;
use App\Service\TorrentService;
class ActivityController extends AbstractController
{
public function template(
$activity,
ActivityService $activityService,
UserService $userService,
ArticleService $articleService,
TorrentService $torrentService,
): Response
{
switch ($activity->getEvent())
{
// User
case $activity::EVENT_USER_ADD:
return $this->render(
'default/activity/event/user/add.html.twig',
[
'added' => $activity->getAdded(),
'user' =>
[
'id' => $activity->getUserId(),
'identicon' => $userService->identicon(
$userService->getUser(
$activity->getUserId()
)->getAddress()
)
]
]
);
break;
case $activity::EVENT_USER_APPROVE_ADD:
return $this->render(
'default/activity/event/user/approve/add.html.twig',
[
'added' => $activity->getAdded(),
'user' =>
[
'id' => $activity->getUserId(),
'identicon' => $userService->identicon(
$userService->getUser(
$activity->getUserId()
)->getAddress()
)
],
'by' =>
[
'user' =>
[
'id' => $activity->getData()['userId'],
'identicon' => $userService->identicon(
$userService->getUser(
$activity->getData()['userId']
)->getAddress()
)
]
]
]
);
break;
case $activity::EVENT_USER_APPROVE_DELETE:
return $this->render(
'default/activity/event/user/approve/delete.html.twig',
[
'added' => $activity->getAdded(),
'user' =>
[
'id' => $activity->getUserId(),
'identicon' => $userService->identicon(
$userService->getUser(
$activity->getUserId()
)->getAddress()
)
],
'by' =>
[
'user' =>
[
'id' => $activity->getData()['userId'],
'identicon' => $userService->identicon(
$userService->getUser(
$activity->getData()['userId']
)->getAddress()
)
]
]
]
);
break;
case $activity::EVENT_USER_MODERATOR_ADD:
return $this->render(
'default/activity/event/user/moderator/add.html.twig',
[
'added' => $activity->getAdded(),
'user' =>
[
'id' => $activity->getUserId(),
'identicon' => $userService->identicon(
$userService->getUser(
$activity->getUserId()
)->getAddress()
)
],
'by' =>
[
'user' =>
[
'id' => $activity->getData()['userId'],
'identicon' => $userService->identicon(
$userService->getUser(
$activity->getData()['userId']
)->getAddress()
)
]
]
]
);
break;
case $activity::EVENT_USER_MODERATOR_DELETE:
return $this->render(
'default/activity/event/user/moderator/delete.html.twig',
[
'added' => $activity->getAdded(),
'user' =>
[
'id' => $activity->getUserId(),
'identicon' => $userService->identicon(
$userService->getUser(
$activity->getUserId()
)->getAddress()
)
],
'by' =>
[
'user' =>
[
'id' => $activity->getData()['userId'],
'identicon' => $userService->identicon(
$userService->getUser(
$activity->getData()['userId']
)->getAddress()
)
]
]
]
);
break;
case $activity::EVENT_USER_STATUS_ADD:
return $this->render(
'default/activity/event/user/status/add.html.twig',
[
'added' => $activity->getAdded(),
'user' =>
[
'id' => $activity->getUserId(),
'identicon' => $userService->identicon(
$userService->getUser(
$activity->getUserId()
)->getAddress()
)
],
'by' =>
[
'user' =>
[
'id' => $activity->getData()['userId'],
'identicon' => $userService->identicon(
$userService->getUser(
$activity->getData()['userId']
)->getAddress()
)
]
]
]
);
break;
case $activity::EVENT_USER_STATUS_DELETE:
return $this->render(
'default/activity/event/user/status/delete.html.twig',
[
'added' => $activity->getAdded(),
'user' =>
[
'id' => $activity->getUserId(),
'identicon' => $userService->identicon(
$userService->getUser(
$activity->getUserId()
)->getAddress()
)
],
'by' =>
[
'user' =>
[
'id' => $activity->getData()['userId'],
'identicon' => $userService->identicon(
$userService->getUser(
$activity->getData()['userId']
)->getAddress()
)
]
]
]
);
break;
case $activity::EVENT_USER_STAR_ADD:
return $this->render(
'default/activity/event/user/star/add.html.twig',
[
'added' => $activity->getAdded(),
'user' =>
[
'id' => $activity->getUserId(),
'identicon' => $userService->identicon(
$userService->getUser(
$activity->getUserId()
)->getAddress()
)
],
'by' =>
[
'user' =>
[
'id' => $activity->getData()['userId'],
'identicon' => $userService->identicon(
$userService->getUser(
$activity->getData()['userId']
)->getAddress()
)
]
]
]
);
break;
case $activity::EVENT_USER_STAR_DELETE:
return $this->render(
'default/activity/event/user/star/delete.html.twig',
[
'added' => $activity->getAdded(),
'user' =>
[
'id' => $activity->getUserId(),
'identicon' => $userService->identicon(
$userService->getUser(
$activity->getUserId()
)->getAddress()
)
],
'by' =>
[
'user' =>
[
'id' => $activity->getData()['userId'],
'identicon' => $userService->identicon(
$userService->getUser(
$activity->getData()['userId']
)->getAddress()
)
]
]
]
);
break;
// Torrent
case $activity::EVENT_TORRENT_ADD:
return $this->render(
'default/activity/event/torrent/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;
/// Torrent Locales
case $activity::EVENT_TORRENT_LOCALES_ADD:
return $this->render(
'default/activity/event/torrent/locales/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(),
'locales' => [
'id' => $activity->getData()['torrentLocalesId'],
'exist' => $torrentService->getTorrentLocales(
$activity->getData()['torrentLocalesId'] // could be deleted by moderator, remove links
)
]
]
]
);
break;
case $activity::EVENT_TORRENT_LOCALES_DELETE:
return $this->render(
'default/activity/event/torrent/locales/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(),
'locales' => [
'id' => $activity->getData()['torrentLocalesId'],
'exist' => $torrentService->getTorrentLocales(
$activity->getData()['torrentLocalesId'] // could be deleted by moderator, remove links
)
]
]
]
);
break;
case $activity::EVENT_TORRENT_LOCALES_APPROVE_ADD:
return $this->render(
'default/activity/event/torrent/locales/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(),
'locales' => [
'id' => $activity->getData()['torrentLocalesId'],
'exist' => $torrentService->getTorrentLocales(
$activity->getData()['torrentLocalesId'] // could be deleted by moderator, remove links
)
]
]
]
);
break;
case $activity::EVENT_TORRENT_LOCALES_APPROVE_DELETE:
return $this->render(
'default/activity/event/torrent/locales/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(),
'locales' => [
'id' => $activity->getData()['torrentLocalesId'],
'exist' => $torrentService->getTorrentLocales(
$activity->getData()['torrentLocalesId'] // could be deleted by moderator, remove links
)
]
]
]
);
break;
/// Torrent Sensitive
case $activity::EVENT_TORRENT_SENSITIVE_ADD:
return $this->render(
'default/activity/event/torrent/sensitive/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(),
'sensitive' => [
'id' => $activity->getData()['torrentSensitiveId'],
'exist' => $torrentService->getTorrentSensitive(
$activity->getData()['torrentSensitiveId'] // could be deleted by moderator, remove links
)
]
]
]
);
break;
case $activity::EVENT_TORRENT_SENSITIVE_DELETE:
return $this->render(
'default/activity/event/torrent/sensitive/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(),
'sensitive' => [
'id' => $activity->getData()['torrentSensitiveId'],
'exist' => $torrentService->getTorrentSensitive(
$activity->getData()['torrentSensitiveId'] // could be deleted by moderator, remove links
)
]
]
]
);
break;
case $activity::EVENT_TORRENT_SENSITIVE_APPROVE_ADD:
return $this->render(
'default/activity/event/torrent/sensitive/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(),
'sensitive' => [
'id' => $activity->getData()['torrentSensitiveId'],
'exist' => $torrentService->getTorrentSensitive(
$activity->getData()['torrentSensitiveId'] // could be deleted by moderator, remove links
)
]
]
]
);
break;
case $activity::EVENT_TORRENT_SENSITIVE_APPROVE_DELETE:
return $this->render(
'default/activity/event/torrent/sensitive/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(),
'sensitive' => [
'id' => $activity->getData()['torrentSensitiveId'],
'exist' => $torrentService->getTorrentSensitive(
$activity->getData()['torrentSensitiveId'] // could be deleted by moderator, remove links
)
]
]
]
);
break;
// Page
default:
return $this->render(
'default/activity/event/undefined.html.twig',
[
'added' => $activity->getAdded(),
'user' =>
[
'id' => $activity->getUserId(),
'identicon' => $userService->identicon(
$userService->getUser(
$activity->getUserId()
)->getAddress()
)
]
]
);
}
}
}

97
src/Controller/TorrentController.php

@ -11,6 +11,7 @@ use Symfony\Component\HttpFoundation\Request;
use App\Service\UserService; use App\Service\UserService;
use App\Service\TorrentService; use App\Service\TorrentService;
use App\Service\ActivityService;
class TorrentController extends AbstractController class TorrentController extends AbstractController
{ {
@ -332,7 +333,8 @@ class TorrentController extends AbstractController
Request $request, Request $request,
TranslatorInterface $translator, TranslatorInterface $translator,
UserService $userService, UserService $userService,
TorrentService $torrentService TorrentService $torrentService,
ActivityService $activityService
): Response ): Response
{ {
// Init user // Init user
@ -463,7 +465,7 @@ class TorrentController extends AbstractController
if (empty($form['locales']['error'])) if (empty($form['locales']['error']))
{ {
// Save data // Save data
$torrentService->addTorrentLocales( $torrentLocales = $torrentService->addTorrentLocales(
$torrent->getId(), $torrent->getId(),
$user->getId(), $user->getId(),
time(), time(),
@ -471,6 +473,14 @@ class TorrentController extends AbstractController
$user->isApproved() $user->isApproved()
); );
// Register activity event
$activityService->addEventTorrentLocalesAdd(
$user->getId(),
$torrent->getId(),
time(),
$torrentLocales->getId()
);
// Redirect to info article created // Redirect to info article created
return $this->redirectToRoute( return $this->redirectToRoute(
'torrent_info', 'torrent_info',
@ -516,7 +526,8 @@ class TorrentController extends AbstractController
Request $request, Request $request,
TranslatorInterface $translator, TranslatorInterface $translator,
UserService $userService, UserService $userService,
TorrentService $torrentService TorrentService $torrentService,
ActivityService $activityService,
): Response ): Response
{ {
// Init user // Init user
@ -545,6 +556,27 @@ class TorrentController extends AbstractController
); );
} }
// Register activity event
if (!$torrentLocales->isApproved())
{
$activityService->addEventTorrentLocalesApproveAdd(
$user->getId(),
$torrent->getId(),
time(),
$torrentLocales->getId()
);
}
else
{
$activityService->addEventTorrentLocalesApproveDelete(
$user->getId(),
$torrent->getId(),
time(),
$torrentLocales->getId()
);
}
// Update approved // Update approved
$torrentService->toggleTorrentLocalesApproved( $torrentService->toggleTorrentLocalesApproved(
$torrentLocales->getId() $torrentLocales->getId()
@ -578,7 +610,8 @@ class TorrentController extends AbstractController
Request $request, Request $request,
TranslatorInterface $translator, TranslatorInterface $translator,
UserService $userService, UserService $userService,
TorrentService $torrentService TorrentService $torrentService,
ActivityService $activityService
): Response ): Response
{ {
// Init user // Init user
@ -607,6 +640,14 @@ class TorrentController extends AbstractController
); );
} }
// Add activity event
$activityService->addEventTorrentLocalesDelete(
$user->getId(),
$torrent->getId(),
time(),
$torrentLocales->getId()
);
// Update approved // Update approved
$torrentService->deleteTorrentLocales( $torrentService->deleteTorrentLocales(
$torrentLocales->getId() $torrentLocales->getId()
@ -646,7 +687,8 @@ class TorrentController extends AbstractController
Request $request, Request $request,
TranslatorInterface $translator, TranslatorInterface $translator,
UserService $userService, UserService $userService,
TorrentService $torrentService TorrentService $torrentService,
ActivityService $activityService
): Response ): Response
{ {
// Init user // Init user
@ -749,7 +791,7 @@ class TorrentController extends AbstractController
if ($request->isMethod('post')) if ($request->isMethod('post'))
{ {
// Save data // Save data
$torrentService->addTorrentSensitive( $torrentSensitive = $torrentService->addTorrentSensitive(
$torrent->getId(), $torrent->getId(),
$user->getId(), $user->getId(),
time(), time(),
@ -757,6 +799,14 @@ class TorrentController extends AbstractController
$user->isApproved() $user->isApproved()
); );
// Add activity event
$activityService->addEventTorrentSensitiveAdd(
$user->getId(),
$torrent->getId(),
time(),
$torrentSensitive->getId()
);
// Redirect to info article created // Redirect to info article created
return $this->redirectToRoute( return $this->redirectToRoute(
'torrent_info', 'torrent_info',
@ -800,7 +850,8 @@ class TorrentController extends AbstractController
Request $request, Request $request,
TranslatorInterface $translator, TranslatorInterface $translator,
UserService $userService, UserService $userService,
TorrentService $torrentService TorrentService $torrentService,
ActivityService $activityService
): Response ): Response
{ {
// Init user // Init user
@ -829,6 +880,27 @@ class TorrentController extends AbstractController
); );
} }
// Add activity event
if (!$torrentSensitive->isApproved())
{
$activityService->addEventTorrentSensitiveApproveAdd(
$user->getId(),
$torrent->getId(),
time(),
$torrentSensitive->getId()
);
}
else
{
$activityService->addEventTorrentSensitiveApproveDelete(
$user->getId(),
$torrent->getId(),
time(),
$torrentSensitive->getId()
);
}
// Update approved // Update approved
$torrentService->toggleTorrentSensitiveApproved( $torrentService->toggleTorrentSensitiveApproved(
$torrentSensitive->getId() $torrentSensitive->getId()
@ -862,7 +934,8 @@ class TorrentController extends AbstractController
Request $request, Request $request,
TranslatorInterface $translator, TranslatorInterface $translator,
UserService $userService, UserService $userService,
TorrentService $torrentService TorrentService $torrentService,
ActivityService $activityService
): Response ): Response
{ {
// Init user // Init user
@ -891,6 +964,14 @@ class TorrentController extends AbstractController
); );
} }
// Add activity event
$activityService->addEventTorrentSensitiveDelete(
$user->getId(),
$torrent->getId(),
time(),
$torrentSensitive->getId()
);
// Update approved // Update approved
$torrentService->deleteTorrentSensitive( $torrentService->deleteTorrentSensitive(
$torrentSensitive->getId() $torrentSensitive->getId()

62
src/Controller/UserController.php

@ -44,46 +44,10 @@ class UserController extends AbstractController
UserService $userService UserService $userService
): Response ): Response
{ {
// Init user session
$user = $userService->init(
$request->getClientIp()
);
// Build activity history
$activities = [];
/*
foreach ($activityService->findLast($user->isModerator()) as $activity)
{
if (!$activity->getUserId())
{
continue;
}
$activityUser = $userService->getUser(
$activity->getUserId()
);
$activities[] =
[
'user' =>
[
'id' => $activityUser->getId(),
'identicon' => $userService->identicon(
$activityUser->getAddress(),
24
)
],
'type' => 'join',
'added' => $activity->getAdded()
];
}
*/
return $this->render( return $this->render(
'default/user/dashboard.html.twig', 'default/user/dashboard.html.twig',
[ [
'activities' => $activities 'activities' => $activityService->findLastActivities()
] ]
); );
} }
@ -271,7 +235,8 @@ class UserController extends AbstractController
public function toggleStar( public function toggleStar(
Request $request, Request $request,
TranslatorInterface $translator, TranslatorInterface $translator,
UserService $userService UserService $userService,
ActivityService $activityService,
): Response ): Response
{ {
// Init user // Init user
@ -294,12 +259,31 @@ class UserController extends AbstractController
} }
// Update // Update
$userService->toggleUserStar( $value = $userService->toggleUserStar(
$user->getId(), $user->getId(),
$userTarget->getId(), $userTarget->getId(),
time() time()
); );
// Add activity event
if ($value)
{
$activityService->addEventUserStarAdd(
$user->getId(),
time(),
$userTarget->getId()
);
}
else
{
$activityService->addEventUserStarDelete(
$user->getId(),
time(),
$userTarget->getId()
);
}
// Redirect to info article created // Redirect to info article created
return $this->redirectToRoute( return $this->redirectToRoute(
'user_info', 'user_info',

103
src/Entity/Activity.php

@ -3,6 +3,7 @@
namespace App\Entity; namespace App\Entity;
use App\Repository\ActivityRepository; use App\Repository\ActivityRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ActivityRepository::class)] #[ORM\Entity(repositoryClass: ActivityRepository::class)]
@ -13,18 +14,62 @@ class Activity
#[ORM\Column] #[ORM\Column]
private ?int $id = null; private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $event = null;
#[ORM\Column] #[ORM\Column]
private ?int $added = null; private ?int $event = null;
#[ORM\Column(nullable: true)] // Event codes
/// User
public const EVENT_USER_ADD = 10000;
public const EVENT_USER_APPROVE_ADD = 10200;
public const EVENT_USER_APPROVE_DELETE = 10210;
public const EVENT_USER_MODERATOR_ADD = 10300;
public const EVENT_USER_MODERATOR_DELETE = 10310;
public const EVENT_USER_STATUS_ADD = 10400;
public const EVENT_USER_STATUS_DELETE = 10410;
public const EVENT_USER_STAR_ADD = 10500;
public const EVENT_USER_STAR_DELETE = 10510;
/// Torrent
public const EVENT_TORRENT_ADD = 20000;
public const EVENT_TORRENT_LOCALES_ADD = 20100;
public const EVENT_TORRENT_LOCALES_DELETE = 20101;
public const EVENT_TORRENT_LOCALES_APPROVE_ADD = 20110;
public const EVENT_TORRENT_LOCALES_APPROVE_DELETE = 20111;
public const EVENT_TORRENT_SENSITIVE_ADD = 20200;
public const EVENT_TORRENT_SENSITIVE_DELETE = 20201;
public const EVENT_TORRENT_SENSITIVE_APPROVE_ADD = 20210;
public const EVENT_TORRENT_SENSITIVE_APPROVE_DELETE = 20211;
public const EVENT_TORRENT_DOWNLOAD_FILE_ADD = 20300;
public const EVENT_TORRENT_DOWNLOAD_MAGNET_ADD = 20400;
/// Article
public const EVENT_ARTICLE_ADD = 30000;
// ...
#[ORM\Column]
private ?int $userId = null; private ?int $userId = null;
#[ORM\Column(nullable: true)] #[ORM\Column(nullable: true)]
private ?int $articleId = null; private ?int $articleId = null;
#[ORM\Column(nullable: true)]
private ?int $torrentId = null;
#[ORM\Column]
private ?int $added = null;
#[ORM\Column(type: Types::ARRAY)]
private array $data = [];
public function getId(): ?int public function getId(): ?int
{ {
return $this->id; return $this->id;
@ -37,63 +82,75 @@ class Activity
return $this; return $this;
} }
public function getEvent(): ?string public function getEvent(): ?int
{ {
return $this->event; return $this->event;
} }
public function setEvent(string $event): static public function setEvent(int $event): static
{ {
$this->event = $event; $this->event = $event;
return $this; return $this;
} }
public function getAdded(): ?int public function getUserId(): ?int
{ {
return $this->added; return $this->userId;
} }
public function setAdded(int $added): static public function setUserId(?int $userId): static
{ {
$this->added = $added; $this->userId = $userId;
return $this; return $this;
} }
public function setApproved(bool $approved): static public function getArticleId(): ?int
{ {
$this->approved = $approved; return $this->articleId;
}
public function setArticleId(int $articleId): static
{
$this->articleId = $articleId;
return $this; return $this;
} }
public function getUserId(): ?int public function getTorrentId(): ?int
{ {
return $this->userId; return $this->torrentId;
} }
public function setUserId(?int $userId): static public function setTorrentId(?int $torrentId): static
{ {
$this->userId = $userId; $this->torrentId = $torrentId;
return $this; return $this;
} }
public function getArticleId(): ?int public function getAdded(): ?int
{ {
return $this->articleId; return $this->added;
} }
public function setArticleId(?int $articleId): static public function setAdded(int $added): static
{ {
$this->articleId = $articleId; $this->added = $added;
return $this; return $this;
} }
public function isApproved(): ?bool public function getData(): array
{
return $this->data;
}
public function setData(array $data): static
{ {
return $this->approved; $this->data = $data;
return $this;
} }
} }

24
src/Repository/ActivityRepository.php

@ -20,28 +20,4 @@ class ActivityRepository extends ServiceEntityRepository
{ {
parent::__construct($registry, Activity::class); parent::__construct($registry, Activity::class);
} }
public function findLast(int $start = 0, int $limit = 10): array
{
return $this->createQueryBuilder('a')
->orderBy('a.id', 'DESC') // same to a.added
->setFirstResult($start)
->setMaxResults($limit)
->getQuery()
->getResult()
;
}
public function findLastByApprovedField(bool $approved, int $start = 0, int $limit = 10): array
{
return $this->createQueryBuilder('a')
->orderBy('a.id', 'DESC') // same to a.added
->where('a.approved = :approved')
->setParameter('approved', $approved)
->setFirstResult($start)
->setMaxResults($limit)
->getQuery()
->getResult()
;
}
} }

411
src/Service/ActivityService.php

@ -6,49 +6,416 @@ use App\Entity\Activity;
use App\Repository\ActivityRepository; use App\Repository\ActivityRepository;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class ActivityService class ActivityService
{ {
private EntityManagerInterface $entityManager; private EntityManagerInterface $entityManagerInterface;
private ActivityRepository $activityRepository;
private ParameterBagInterface $parameterBagInterface;
public function __construct( public function __construct(
EntityManagerInterface $entityManager, EntityManagerInterface $entityManagerInterface
ParameterBagInterface $parameterBagInterface
) )
{ {
$this->entityManager = $entityManager; $this->entityManagerInterface = $entityManagerInterface;
$this->activityRepository = $entityManager->getRepository(Activity::class); }
$this->parameterBagInterface = $parameterBagInterface;
public function findLastActivities(): array
{
return $this->entityManagerInterface
->getRepository(Activity::class)
->findBy(
[],
[
'id' => 'DESC'
]
);
} }
public function addEvent(int $userId, string $event, array $data): ?Activity // User
public function addEventUserJoin(
int $userId,
int $added
): ?Activity
{ {
$activity = new Activity(); $activity = new Activity();
$activity->setEvent($event); $activity->setEvent(
$activity->setUserId($userId); Activity::EVENT_USER_ADD
$activity->setApproved($approved); );
$activity->setAdded(time());
$this->entityManager->persist($activity); $activity->setUserId(
$this->entityManager->flush(); $userId
);
$activity->setAdded(
$added
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity; return $activity;
} }
public function findLast(bool $moderator): ?array public function addEventUserStarAdd(
int $userId,
int $added,
int $userIdTarget
): ?Activity
{ {
if ($moderator) $activity = new Activity();
$activity->setEvent(
Activity::EVENT_USER_STAR_DELETE
);
$activity->setUserId(
$userId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'userId' => $userIdTarget
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
public function addEventUserStarDelete(
int $userId,
int $added,
int $userIdTarget
): ?Activity
{ {
return $this->activityRepository->findLast(); $activity = new Activity();
$activity->setEvent(
Activity::EVENT_USER_STAR_DELETE
);
$activity->setUserId(
$userId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'userId' => $userIdTarget
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
} }
else // Torrent
/// Torrent locales
public function addEventTorrentLocalesAdd(
int $userId,
int $torrentId,
int $added,
int $torrentLocalesId,
): ?Activity
{ {
return $this->activityRepository->findLastByApprovedField(true); $activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_LOCALES_ADD
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'torrentLocalesId' => $torrentLocalesId
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
} }
public function addEventTorrentLocalesDelete(
int $userId,
int $torrentId,
int $added,
int $torrentLocalesId,
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_LOCALES_DELETE
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'torrentLocalesId' => $torrentLocalesId
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
public function addEventTorrentLocalesApproveAdd(
int $userId,
int $torrentId,
int $added,
int $torrentLocalesId,
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_LOCALES_APPROVE_ADD
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'torrentLocalesId' => $torrentLocalesId
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
public function addEventTorrentLocalesApproveDelete(
int $userId,
int $torrentId,
int $added,
int $torrentLocalesId,
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_LOCALES_APPROVE_DELETE
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'torrentLocalesId' => $torrentLocalesId
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
/// Torrent sensitive
public function addEventTorrentSensitiveAdd(
int $userId,
int $torrentId,
int $added,
int $torrentSensitiveId,
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_SENSITIVE_ADD
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'torrentSensitiveId' => $torrentSensitiveId
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
public function addEventTorrentSensitiveDelete(
int $userId,
int $torrentId,
int $added,
int $torrentSensitiveId,
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_SENSITIVE_DELETE
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'torrentSensitiveId' => $torrentSensitiveId
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
public function addEventTorrentSensitiveApproveAdd(
int $userId,
int $torrentId,
int $added,
int $torrentSensitiveId,
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_SENSITIVE_APPROVE_ADD
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'torrentSensitiveId' => $torrentSensitiveId
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
public function addEventTorrentSensitiveApproveDelete(
int $userId,
int $torrentId,
int $added,
int $torrentSensitiveId,
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_SENSITIVE_APPROVE_DELETE
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'torrentSensitiveId' => $torrentSensitiveId
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
} }
} }

7
src/Service/UserService.php

@ -84,6 +84,7 @@ class UserService
$user->setApproved(true); $user->setApproved(true);
$user->setModerator(true); $user->setModerator(true);
$user->setSensitive(false); $user->setSensitive(false);
$this->save($user); $this->save($user);
} }
@ -151,12 +152,14 @@ class UserService
int $userId, int $userId,
int $userIdTarget, int $userIdTarget,
int $added int $added
): void ): bool
{ {
if ($userStar = $this->findUserStar($userId, $userIdTarget)) if ($userStar = $this->findUserStar($userId, $userIdTarget))
{ {
$this->entityManagerInterface->remove($userStar); $this->entityManagerInterface->remove($userStar);
$this->entityManagerInterface->flush(); $this->entityManagerInterface->flush();
return false;
} }
else else
@ -169,6 +172,8 @@ class UserService
$this->entityManagerInterface->persist($userStar); $this->entityManagerInterface->persist($userStar);
$this->entityManagerInterface->flush(); $this->entityManagerInterface->flush();
return true;
} }
} }

12
templates/default/activity/event/torrent/add.html.twig

@ -0,0 +1,12 @@
<a href="{{ path('user_info', { userId : user.id }) }}">
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ user.identicon }}" alt="{{ 'identicon' | trans }}" />
</a>
<span class="margin-x-4-px">
{{ 'added torrent' | trans }}
</span>
<a href="{{ path('torrent_info', { torrentId : torrent.id }) }}">
{{ torrent.name }}
</a>
<div class="float-right">
{{ added | format_ago }}
</div>

18
templates/default/activity/event/torrent/locales/add.html.twig

@ -0,0 +1,18 @@
<a href="{{ path('user_info', { userId : user.id }) }}">
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ user.identicon }}" alt="{{ 'identicon' | trans }}" />
</a>
{{ 'added locales edition' | trans }}
{% if torrent.locales.exist %}
<a href="{{ path('torrent_locales_edit', { torrentId : torrent.id, torrentLocalesId : torrent.locales.id }) }}">
#{{ torrent.locales.id }}
</a>
{% else %}
#{{ torrent.locales.id }}
{% endif %}
{{ 'for torrent' | trans }}
<a href="{{ path('torrent_info', { torrentId : torrent.id }) }}">
{{ torrent.name }}
</a>
<div class="float-right">
{{ added | format_ago }}
</div>

18
templates/default/activity/event/torrent/locales/approve/add.html.twig

@ -0,0 +1,18 @@
<a href="{{ path('user_info', { userId : user.id }) }}">
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ user.identicon }}" alt="{{ 'identicon' | trans }}" />
</a>
{{ 'approved locales edition' | trans }}
{% if torrent.locales.exist %}
<a href="{{ path('torrent_locales_edit', { torrentId : torrent.id, torrentLocalesId : torrent.locales.id }) }}">
#{{ torrent.locales.id }}
</a>
{% else %}
#{{ torrent.locales.id }}
{% endif %}
{{ 'for torrent' | trans }}
<a href="{{ path('torrent_info', { torrentId : torrent.id }) }}">
{{ torrent.name }}
</a>
<div class="float-right">
{{ added | format_ago }}
</div>

18
templates/default/activity/event/torrent/locales/approve/delete.html.twig

@ -0,0 +1,18 @@
<a href="{{ path('user_info', { userId : user.id }) }}">
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ user.identicon }}" alt="{{ 'identicon' | trans }}" />
</a>
{{ 'disapproved locales edition' | trans }}
{% if torrent.locales.exist %}
<a href="{{ path('torrent_locales_edit', { torrentId : torrent.id, torrentLocalesId : torrent.locales.id }) }}">
#{{ torrent.locales.id }}
</a>
{% else %}
#{{ torrent.locales.id }}
{% endif %}
{{ 'for torrent' | trans }}
<a href="{{ path('torrent_info', { torrentId : torrent.id }) }}">
{{ torrent.name }}
</a>
<div class="float-right">
{{ added | format_ago }}
</div>

18
templates/default/activity/event/torrent/locales/delete.html.twig

@ -0,0 +1,18 @@
<a href="{{ path('user_info', { userId : user.id }) }}">
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ user.identicon }}" alt="{{ 'identicon' | trans }}" />
</a>
{{ 'deleted locales edition' | trans }}
{% if torrent.locales.exist %}
<a href="{{ path('torrent_locales_edit', { torrentId : torrent.id, torrentLocalesId : torrent.locales.id }) }}">
#{{ torrent.locales.id }}
</a>
{% else %}
#{{ torrent.locales.id }}
{% endif %}
{{ 'for torrent' | trans }}
<a href="{{ path('torrent_info', { torrentId : torrent.id }) }}">
{{ torrent.name }}
</a>
<div class="float-right">
{{ added | format_ago }}
</div>

18
templates/default/activity/event/torrent/sensitive/add.html.twig

@ -0,0 +1,18 @@
<a href="{{ path('user_info', { userId : user.id }) }}">
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ user.identicon }}" alt="{{ 'identicon' | trans }}" />
</a>
{{ 'added sensitive edition' | trans }}
{% if torrent.sensitive.exist %}
<a href="{{ path('torrent_sensitive_edit', { torrentId : torrent.id, torrentSensitiveId : torrent.sensitive.id }) }}">
#{{ torrent.sensitive.id }}
</a>
{% else %}
#{{ torrent.sensitive.id }}
{% endif %}
{{ 'for torrent' | trans }}
<a href="{{ path('torrent_info', { torrentId : torrent.id }) }}">
{{ torrent.name }}
</a>
<div class="float-right">
{{ added | format_ago }}
</div>

18
templates/default/activity/event/torrent/sensitive/approve/add.html.twig

@ -0,0 +1,18 @@
<a href="{{ path('user_info', { userId : user.id }) }}">
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ user.identicon }}" alt="{{ 'identicon' | trans }}" />
</a>
{{ 'approved sensitive edition' | trans }}
{% if torrent.sensitive.exist %}
<a href="{{ path('torrent_sensitive_edit', { torrentId : torrent.id, torrentSensitiveId : torrent.sensitive.id }) }}">
#{{ torrent.sensitive.id }}
</a>
{% else %}
#{{ torrent.sensitive.id }}
{% endif %}
{{ 'for torrent' | trans }}
<a href="{{ path('torrent_info', { torrentId : torrent.id }) }}">
{{ torrent.name }}
</a>
<div class="float-right">
{{ added | format_ago }}
</div>

18
templates/default/activity/event/torrent/sensitive/approve/delete.html.twig

@ -0,0 +1,18 @@
<a href="{{ path('user_info', { userId : user.id }) }}">
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ user.identicon }}" alt="{{ 'identicon' | trans }}" />
</a>
{{ 'disapproved sensitive edition' | trans }}
{% if torrent.sensitive.exist %}
<a href="{{ path('torrent_sensitive_edit', { torrentId : torrent.id, torrentSensitiveId : torrent.sensitive.id }) }}">
#{{ torrent.sensitive.id }}
</a>
{% else %}
#{{ torrent.sensitive.id }}
{% endif %}
{{ 'for torrent' | trans }}
<a href="{{ path('torrent_info', { torrentId : torrent.id }) }}">
{{ torrent.name }}
</a>
<div class="float-right">
{{ added | format_ago }}
</div>

18
templates/default/activity/event/torrent/sensitive/delete.html.twig

@ -0,0 +1,18 @@
<a href="{{ path('user_info', { userId : user.id }) }}">
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ user.identicon }}" alt="{{ 'identicon' | trans }}" />
</a>
{{ 'deleted sensitive edition' | trans }}
{% if torrent.sensitive.exist %}
<a href="{{ path('torrent_sensitive_edit', { torrentId : torrent.id, torrentSensitiveId : torrent.sensitive.id }) }}">
#{{ torrent.sensitive.id }}
</a>
{% else %}
#{{ torrent.sensitive.id }}
{% endif %}
{{ 'for torrent' | trans }}
<a href="{{ path('torrent_info', { torrentId : torrent.id }) }}">
{{ torrent.name }}
</a>
<div class="float-right">
{{ added | format_ago }}
</div>

9
templates/default/activity/event/undefined.html.twig

@ -0,0 +1,9 @@
<a href="{{ path('user_info', { userId : user.id }) }}">
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ user.identicon }}" alt="{{ 'identicon' | trans }}" />
</a>
<span class="margin-x-4-px">
{{ 'undefined event' | trans }}
</span>
<div class="float-right">
{{ added | format_ago }}
</div>

9
templates/default/activity/event/user/add.html.twig

@ -0,0 +1,9 @@
<a href="{{ path('user_info', { userId : user.id }) }}">
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ user.identicon }}" alt="{{ 'identicon' | trans }}" />
</a>
<span class="margin-x-4-px">
{{ 'joined' | trans }} {{ name }}
</span>
<div class="float-right">
{{ added | format_ago }}
</div>

12
templates/default/activity/event/user/approve/add.html.twig

@ -0,0 +1,12 @@
<a href="{{ path('user_info', { userId : user.id }) }}">
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ user.identicon }}" alt="{{ 'identicon' | trans }}" />
</a>
<span class="margin-x-4-px">
{{ 'approved by' | trans }}
</span>
<a href="{{ path('user_info', { userId : by.user.id }) }}">
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ by.user.identicon }}" alt="{{ 'identicon' | trans }}" />
</a>
<div class="float-right">
{{ added | format_ago }}
</div>

12
templates/default/activity/event/user/approve/delete.html.twig

@ -0,0 +1,12 @@
<a href="{{ path('user_info', { userId : user.id }) }}">
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ user.identicon }}" alt="{{ 'identicon' | trans }}" />
</a>
<span class="margin-x-4-px">
{{ 'disapproved by' | trans }}
</span>
<a href="{{ path('user_info', { userId : by.user.id }) }}">
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ by.user.identicon }}" alt="{{ 'identicon' | trans }}" />
</a>
<div class="float-right">
{{ added | format_ago }}
</div>

12
templates/default/activity/event/user/moderator/add.html.twig

@ -0,0 +1,12 @@
<a href="{{ path('user_info', { userId : by.user.id }) }}">
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ by.user.identicon }}" alt="{{ 'identicon' | trans }}" />
</a>
<span class="margin-x-4-px">
{{ 'grant moderator permissions to' | trans }}
</span>
<a href="{{ path('user_info', { userId : user.id }) }}">
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ user.identicon }}" alt="{{ 'identicon' | trans }}" />
</a>
<div class="float-right">
{{ added | format_ago }}
</div>

12
templates/default/activity/event/user/moderator/delete.html.twig

@ -0,0 +1,12 @@
<a href="{{ path('user_info', { userId : by.user.id }) }}">
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ by.user.identicon }}" alt="{{ 'identicon' | trans }}" />
</a>
<span class="margin-x-4-px">
{{ 'remove moderator permissions from' | trans }}
</span>
<a href="{{ path('user_info', { userId : user.id }) }}">
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ user.identicon }}" alt="{{ 'identicon' | trans }}" />
</a>
<div class="float-right">
{{ added | format_ago }}
</div>

12
templates/default/activity/event/user/star/add.html.twig

@ -0,0 +1,12 @@
<a href="{{ path('user_info', { userId : user.id }) }}">
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ user.identicon }}" alt="{{ 'identicon' | trans }}" />
</a>
<span class="margin-x-4-px">
{{ 'add star to' | trans }}
</span>
<a href="{{ path('user_info', { userId : by.user.id }) }}">
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ by.user.identicon }}" alt="{{ 'identicon' | trans }}" />
</a>
<div class="float-right">
{{ added | format_ago }}
</div>

12
templates/default/activity/event/user/star/delete.html.twig

@ -0,0 +1,12 @@
<a href="{{ path('user_info', { userId : user.id }) }}">
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ user.identicon }}" alt="{{ 'identicon' | trans }}" />
</a>
<span class="margin-x-4-px">
{{ 'removed star from' | trans }}
</span>
<a href="{{ path('user_info', { userId : by.user.id }) }}">
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ by.user.identicon }}" alt="{{ 'identicon' | trans }}" />
</a>
<div class="float-right">
{{ added | format_ago }}
</div>

12
templates/default/activity/event/user/status/add.html.twig

@ -0,0 +1,12 @@
<a href="{{ path('user_info', { userId : by.user.id }) }}">
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ by.user.identicon }}" alt="{{ 'identicon' | trans }}" />
</a>
<span class="margin-x-4-px">
{{ 'enable user' | trans }}
</span>
<a href="{{ path('user_info', { userId : user.id }) }}">
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ user.identicon }}" alt="{{ 'identicon' | trans }}" />
</a>
<div class="float-right">
{{ added | format_ago }}
</div>

12
templates/default/activity/event/user/status/delete.html.twig

@ -0,0 +1,12 @@
<a href="{{ path('user_info', { userId : by.user.id }) }}">
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ by.user.identicon }}" alt="{{ 'identicon' | trans }}" />
</a>
<span class="margin-x-4-px">
{{ 'diable user' | trans }}
</span>
<a href="{{ path('user_info', { userId : user.id }) }}">
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ user.identicon }}" alt="{{ 'identicon' | trans }}" />
</a>
<div class="float-right">
{{ added | format_ago }}
</div>

21
templates/default/user/dashboard.html.twig

@ -1,23 +1,12 @@
{% extends 'default/layout.html.twig' %} {% extends 'default/layout.html.twig' %}
{% block title %}{{ 'Last activity'|trans }} - {{ name }}{% endblock %} {% block title %}{{ 'Activity' | trans }} - {{ name }}{% endblock %}
{% block main_content %} {% block main_content %}
{% for activity in activities %} {% for activity in activities %}
<div class="padding-16-px margin-y-8-px border-radius-3-px background-color-night"> <div class="padding-16-px margin-y-8-px border-radius-3-px background-color-night">
<div class="row"> {{ render(controller(
<div class="column width-80"> 'App\\Controller\\ActivityController::template',
<a href="{{ path('user_info', { userId : activity.user.id }) }}"> { activity : activity }
<img class="vertical-align-middle border-radius-50 border-color-default border-width-2-px margin-r-8-px" )) }}
src="{{ activity.user.identicon }}"
alt="{{ 'identicon'|trans }}" />
</a>
{% if activity.type == 'join' %}
{{ 'joined'|trans }} {{ name }}
{% endif %}
</div>
<div class="column width-20 text-right padding-y-4-px">
{{ activity.added }}
</div>
</div>
</div> </div>
{% endfor %} {% endfor %}
{% endblock %} {% endblock %}
Loading…
Cancel
Save