mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2026-04-01 01:25:39 +00:00
add user moderation events #4
This commit is contained in:
parent
6ea0024b94
commit
0339ee9f23
4 changed files with 278 additions and 15 deletions
|
|
@ -55,6 +55,201 @@ class ActivityService
|
|||
return $activity;
|
||||
}
|
||||
|
||||
/// User approved
|
||||
public function addEventUserApproveAdd(
|
||||
int $userId,
|
||||
int $added,
|
||||
int $userIdTarget,
|
||||
): ?Activity
|
||||
{
|
||||
$activity = new Activity();
|
||||
|
||||
$activity->setEvent(
|
||||
Activity::EVENT_USER_APPROVE_ADD
|
||||
);
|
||||
|
||||
$activity->setUserId(
|
||||
$userId
|
||||
);
|
||||
|
||||
$activity->setAdded(
|
||||
$added
|
||||
);
|
||||
|
||||
$activity->setData(
|
||||
[
|
||||
'userId' => $userIdTarget
|
||||
]
|
||||
);
|
||||
|
||||
$this->entityManagerInterface->persist($activity);
|
||||
$this->entityManagerInterface->flush();
|
||||
|
||||
return $activity;
|
||||
}
|
||||
|
||||
public function addEventUserApproveDelete(
|
||||
int $userId,
|
||||
int $added,
|
||||
int $userIdTarget,
|
||||
): ?Activity
|
||||
{
|
||||
$activity = new Activity();
|
||||
|
||||
$activity->setEvent(
|
||||
Activity::EVENT_USER_APPROVE_DELETE
|
||||
);
|
||||
|
||||
$activity->setUserId(
|
||||
$userId
|
||||
);
|
||||
|
||||
$activity->setAdded(
|
||||
$added
|
||||
);
|
||||
|
||||
$activity->setData(
|
||||
[
|
||||
'userId' => $userIdTarget
|
||||
]
|
||||
);
|
||||
|
||||
$this->entityManagerInterface->persist($activity);
|
||||
$this->entityManagerInterface->flush();
|
||||
|
||||
return $activity;
|
||||
}
|
||||
|
||||
/// User status
|
||||
public function addEventUserStatusAdd(
|
||||
int $userId,
|
||||
int $added,
|
||||
int $userIdTarget,
|
||||
): ?Activity
|
||||
{
|
||||
$activity = new Activity();
|
||||
|
||||
$activity->setEvent(
|
||||
Activity::EVENT_USER_STATUS_ADD
|
||||
);
|
||||
|
||||
$activity->setUserId(
|
||||
$userId
|
||||
);
|
||||
|
||||
$activity->setAdded(
|
||||
$added
|
||||
);
|
||||
|
||||
$activity->setData(
|
||||
[
|
||||
'userId' => $userIdTarget
|
||||
]
|
||||
);
|
||||
|
||||
$this->entityManagerInterface->persist($activity);
|
||||
$this->entityManagerInterface->flush();
|
||||
|
||||
return $activity;
|
||||
}
|
||||
|
||||
public function addEventUserStatusDelete(
|
||||
int $userId,
|
||||
int $added,
|
||||
int $userIdTarget,
|
||||
): ?Activity
|
||||
{
|
||||
$activity = new Activity();
|
||||
|
||||
$activity->setEvent(
|
||||
Activity::EVENT_USER_STATUS_DELETE
|
||||
);
|
||||
|
||||
$activity->setUserId(
|
||||
$userId
|
||||
);
|
||||
|
||||
$activity->setAdded(
|
||||
$added
|
||||
);
|
||||
|
||||
$activity->setData(
|
||||
[
|
||||
'userId' => $userIdTarget
|
||||
]
|
||||
);
|
||||
|
||||
$this->entityManagerInterface->persist($activity);
|
||||
$this->entityManagerInterface->flush();
|
||||
|
||||
return $activity;
|
||||
}
|
||||
|
||||
/// User moderator
|
||||
public function addEventUserModeratorAdd(
|
||||
int $userId,
|
||||
int $added,
|
||||
int $userIdTarget,
|
||||
): ?Activity
|
||||
{
|
||||
$activity = new Activity();
|
||||
|
||||
$activity->setEvent(
|
||||
Activity::EVENT_USER_MODERATOR_ADD
|
||||
);
|
||||
|
||||
$activity->setUserId(
|
||||
$userId
|
||||
);
|
||||
|
||||
$activity->setAdded(
|
||||
$added
|
||||
);
|
||||
|
||||
$activity->setData(
|
||||
[
|
||||
'userId' => $userIdTarget
|
||||
]
|
||||
);
|
||||
|
||||
$this->entityManagerInterface->persist($activity);
|
||||
$this->entityManagerInterface->flush();
|
||||
|
||||
return $activity;
|
||||
}
|
||||
|
||||
public function addEventUserModeratorDelete(
|
||||
int $userId,
|
||||
int $added,
|
||||
int $userIdTarget,
|
||||
): ?Activity
|
||||
{
|
||||
$activity = new Activity();
|
||||
|
||||
$activity->setEvent(
|
||||
Activity::EVENT_USER_MODERATOR_DELETE
|
||||
);
|
||||
|
||||
$activity->setUserId(
|
||||
$userId
|
||||
);
|
||||
|
||||
$activity->setAdded(
|
||||
$added
|
||||
);
|
||||
|
||||
$activity->setData(
|
||||
[
|
||||
'userId' => $userIdTarget
|
||||
]
|
||||
);
|
||||
|
||||
$this->entityManagerInterface->persist($activity);
|
||||
$this->entityManagerInterface->flush();
|
||||
|
||||
return $activity;
|
||||
}
|
||||
|
||||
/// User star
|
||||
public function addEventUserStarAdd(
|
||||
int $userId,
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ class UserService
|
|||
|
||||
public function toggleUserModerator(
|
||||
int $userId
|
||||
): void
|
||||
): ?User
|
||||
{
|
||||
if ($user = $this->getUser($userId))
|
||||
{
|
||||
|
|
@ -190,11 +190,13 @@ class UserService
|
|||
$this->entityManagerInterface->persist($user);
|
||||
$this->entityManagerInterface->flush();
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
public function toggleUserStatus(
|
||||
int $userId
|
||||
): void
|
||||
): ?User
|
||||
{
|
||||
if ($user = $this->getUser($userId))
|
||||
{
|
||||
|
|
@ -205,11 +207,13 @@ class UserService
|
|||
$this->entityManagerInterface->persist($user);
|
||||
$this->entityManagerInterface->flush();
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
public function toggleUserApproved(
|
||||
int $userId
|
||||
): void
|
||||
): ?User
|
||||
{
|
||||
if ($user = $this->getUser($userId))
|
||||
{
|
||||
|
|
@ -220,5 +224,7 @@ class UserService
|
|||
$this->entityManagerInterface->persist($user);
|
||||
$this->entityManagerInterface->flush();
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue