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

62
src/Controller/UserController.php

@ -44,46 +44,10 @@ class UserController extends AbstractController @@ -44,46 +44,10 @@ class UserController extends AbstractController
UserService $userService
): 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(
'default/user/dashboard.html.twig',
[
'activities' => $activities
'activities' => $activityService->findLastActivities()
]
);
}
@ -271,7 +235,8 @@ class UserController extends AbstractController @@ -271,7 +235,8 @@ class UserController extends AbstractController
public function toggleStar(
Request $request,
TranslatorInterface $translator,
UserService $userService
UserService $userService,
ActivityService $activityService,
): Response
{
// Init user
@ -294,12 +259,31 @@ class UserController extends AbstractController @@ -294,12 +259,31 @@ class UserController extends AbstractController
}
// Update
$userService->toggleUserStar(
$value = $userService->toggleUserStar(
$user->getId(),
$userTarget->getId(),
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
return $this->redirectToRoute(
'user_info',

103
src/Entity/Activity.php

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
namespace App\Entity;
use App\Repository\ActivityRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ActivityRepository::class)]
@ -13,18 +14,62 @@ class Activity @@ -13,18 +14,62 @@ class Activity
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $event = null;
#[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;
#[ORM\Column(nullable: true)]
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
{
return $this->id;
@ -37,63 +82,75 @@ class Activity @@ -37,63 +82,75 @@ class Activity
return $this;
}
public function getEvent(): ?string
public function getEvent(): ?int
{
return $this->event;
}
public function setEvent(string $event): static
public function setEvent(int $event): static
{
$this->event = $event;
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;
}
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;
}
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;
}
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;
}
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 @@ -20,28 +20,4 @@ class ActivityRepository extends ServiceEntityRepository
{
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; @@ -6,49 +6,416 @@ use App\Entity\Activity;
use App\Repository\ActivityRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class ActivityService
{
private EntityManagerInterface $entityManager;
private ActivityRepository $activityRepository;
private ParameterBagInterface $parameterBagInterface;
private EntityManagerInterface $entityManagerInterface;
public function __construct(
EntityManagerInterface $entityManager,
ParameterBagInterface $parameterBagInterface
EntityManagerInterface $entityManagerInterface
)
{
$this->entityManager = $entityManager;
$this->activityRepository = $entityManager->getRepository(Activity::class);
$this->parameterBagInterface = $parameterBagInterface;
$this->entityManagerInterface = $entityManagerInterface;
}
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->setEvent($event);
$activity->setUserId($userId);
$activity->setApproved($approved);
$activity->setAdded(time());
$activity->setEvent(
Activity::EVENT_USER_ADD
);
$this->entityManager->persist($activity);
$this->entityManager->flush();
$activity->setUserId(
$userId
);
$activity->setAdded(
$added
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
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 @@ -84,6 +84,7 @@ class UserService
$user->setApproved(true);
$user->setModerator(true);
$user->setSensitive(false);
$this->save($user);
}
@ -151,12 +152,14 @@ class UserService @@ -151,12 +152,14 @@ class UserService
int $userId,
int $userIdTarget,
int $added
): void
): bool
{
if ($userStar = $this->findUserStar($userId, $userIdTarget))
{
$this->entityManagerInterface->remove($userStar);
$this->entityManagerInterface->flush();
return false;
}
else
@ -169,6 +172,8 @@ class UserService @@ -169,6 +172,8 @@ class UserService
$this->entityManagerInterface->persist($userStar);
$this->entityManagerInterface->flush();
return true;
}
}

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

@ -0,0 +1,12 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -1,23 +1,12 @@
{% extends 'default/layout.html.twig' %}
{% block title %}{{ 'Last activity'|trans }} - {{ name }}{% endblock %}
{% block title %}{{ 'Activity' | trans }} - {{ name }}{% endblock %}
{% block main_content %}
{% for activity in activities %}
<div class="padding-16-px margin-y-8-px border-radius-3-px background-color-night">
<div class="row">
<div class="column width-80">
<a href="{{ path('user_info', { userId : activity.user.id }) }}">
<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>
{{ render(controller(
'App\\Controller\\ActivityController::template',
{ activity : activity }
)) }}
</div>
{% endfor %}
{% endblock %}
Loading…
Cancel
Save