|
|
@ -63,8 +63,8 @@ class UserController extends AbstractController |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[Route( |
|
|
|
#[Route( |
|
|
|
'/{_locale}/profile', |
|
|
|
'/{_locale}/settings', |
|
|
|
name: 'user_profile', |
|
|
|
name: 'user_settings', |
|
|
|
defaults: [ |
|
|
|
defaults: [ |
|
|
|
'_locale' => '%app.locale%' |
|
|
|
'_locale' => '%app.locale%' |
|
|
|
], |
|
|
|
], |
|
|
@ -72,7 +72,7 @@ class UserController extends AbstractController |
|
|
|
'_locale' => '%app.locales%', |
|
|
|
'_locale' => '%app.locales%', |
|
|
|
], |
|
|
|
], |
|
|
|
)] |
|
|
|
)] |
|
|
|
public function profile( |
|
|
|
public function settings( |
|
|
|
Request $request, |
|
|
|
Request $request, |
|
|
|
UserService $userService, |
|
|
|
UserService $userService, |
|
|
|
ActivityService $activityService |
|
|
|
ActivityService $activityService |
|
|
@ -121,17 +121,36 @@ class UserController extends AbstractController |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Update events |
|
|
|
|
|
|
|
$events = []; |
|
|
|
|
|
|
|
foreach ((array) $request->get('events') as $event) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (in_array($event, $activityService->getEventCodes())) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$events[] = $event; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$user->setEvents( |
|
|
|
|
|
|
|
$events |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// Update sensitive |
|
|
|
// Update sensitive |
|
|
|
$user->setSensitive( |
|
|
|
$user->setSensitive( |
|
|
|
$request->get('sensitive') === 'true' |
|
|
|
$request->get('sensitive') === 'true' |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Update yggdrasil |
|
|
|
|
|
|
|
$user->setYggdrasil( |
|
|
|
|
|
|
|
$request->get('yggdrasil') === 'true' |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// Save changes to DB |
|
|
|
// Save changes to DB |
|
|
|
$userService->save($user); |
|
|
|
$userService->save($user); |
|
|
|
|
|
|
|
|
|
|
|
// Redirect user to new locale |
|
|
|
// Redirect user to new locale |
|
|
|
return $this->redirectToRoute( |
|
|
|
return $this->redirectToRoute( |
|
|
|
'user_profile', |
|
|
|
'user_settings', |
|
|
|
[ |
|
|
|
[ |
|
|
|
'_locale' => $user->getLocale() |
|
|
|
'_locale' => $user->getLocale() |
|
|
|
] |
|
|
|
] |
|
|
@ -140,38 +159,35 @@ class UserController extends AbstractController |
|
|
|
|
|
|
|
|
|
|
|
// Render template |
|
|
|
// Render template |
|
|
|
return $this->render( |
|
|
|
return $this->render( |
|
|
|
'default/user/profile.html.twig', |
|
|
|
'default/user/settings.html.twig', |
|
|
|
[ |
|
|
|
[ |
|
|
|
'user' => [ |
|
|
|
'user' => [ |
|
|
|
'id' => $user->getId(), |
|
|
|
'id' => $user->getId(), |
|
|
|
'address' => $request->getClientIp() == $user->getAddress() ? $user->getAddress() : false, |
|
|
|
|
|
|
|
'moderator' => $user->isModerator(), |
|
|
|
|
|
|
|
'approved' => $user->isApproved(), |
|
|
|
|
|
|
|
'status' => $user->isStatus(), |
|
|
|
|
|
|
|
'sensitive' => $user->isSensitive(), |
|
|
|
'sensitive' => $user->isSensitive(), |
|
|
|
|
|
|
|
'yggdrasil' => $user->isYggdrasil(), |
|
|
|
'locale' => $user->getLocale(), |
|
|
|
'locale' => $user->getLocale(), |
|
|
|
'locales' => $user->getLocales(), |
|
|
|
'locales' => $user->getLocales(), |
|
|
|
|
|
|
|
'events' => $user->getEvents(), |
|
|
|
'theme' => $user->getTheme(), |
|
|
|
'theme' => $user->getTheme(), |
|
|
|
'added' => $user->getAdded(), |
|
|
|
'added' => $user->getAdded() |
|
|
|
'identicon' => $userService->identicon( |
|
|
|
|
|
|
|
$user->getAddress(), |
|
|
|
|
|
|
|
48 |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
], |
|
|
|
'locales' => explode('|', $this->getParameter('app.locales')), |
|
|
|
'locales' => explode('|', $this->getParameter('app.locales')), |
|
|
|
'themes' => explode('|', $this->getParameter('app.themes')) |
|
|
|
'themes' => explode('|', $this->getParameter('app.themes')), |
|
|
|
|
|
|
|
'events' => $activityService->getEventsTree() |
|
|
|
] |
|
|
|
] |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[Route( |
|
|
|
#[Route( |
|
|
|
'/{_locale}/user/{userId}', |
|
|
|
'/{_locale}/profile/{userId}', |
|
|
|
name: 'user_info', |
|
|
|
name: 'user_info', |
|
|
|
defaults: [ |
|
|
|
defaults: [ |
|
|
|
'_locale' => '%app.locale%' |
|
|
|
'_locale' => '%app.locale%', |
|
|
|
|
|
|
|
'userId' => null |
|
|
|
], |
|
|
|
], |
|
|
|
requirements: [ |
|
|
|
requirements: [ |
|
|
|
'_locale' => '%app.locales%', |
|
|
|
'_locale' => '%app.locales%', |
|
|
|
|
|
|
|
'userId' => '\d+', |
|
|
|
], |
|
|
|
], |
|
|
|
)] |
|
|
|
)] |
|
|
|
public function info( |
|
|
|
public function info( |
|
|
@ -197,7 +213,9 @@ class UserController extends AbstractController |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Init target user |
|
|
|
// Init target user |
|
|
|
if (!$userTarget = $userService->getUser($request->get('userId'))) |
|
|
|
if (!$userTarget = $userService->getUser( |
|
|
|
|
|
|
|
$request->get('userId') ? $request->get('userId') : $user->getId() |
|
|
|
|
|
|
|
)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
throw $this->createNotFoundException(); |
|
|
|
throw $this->createNotFoundException(); |
|
|
|
} |
|
|
|
} |
|
|
@ -208,13 +226,15 @@ class UserController extends AbstractController |
|
|
|
[ |
|
|
|
[ |
|
|
|
'user' => [ |
|
|
|
'user' => [ |
|
|
|
'id' => $userTarget->getId(), |
|
|
|
'id' => $userTarget->getId(), |
|
|
|
'address' => $request->getClientIp() == $userTarget->getAddress() ? $userTarget->getAddress() : false, |
|
|
|
'address' => $userTarget->getId() === $user->getId() ? $userTarget->getAddress() : false, |
|
|
|
'moderator' => $userTarget->isModerator(), |
|
|
|
'moderator' => $userTarget->isModerator(), |
|
|
|
'approved' => $userTarget->isApproved(), |
|
|
|
'approved' => $userTarget->isApproved(), |
|
|
|
'status' => $userTarget->isStatus(), |
|
|
|
'status' => $userTarget->isStatus(), |
|
|
|
'sensitive' => $userTarget->isSensitive(), |
|
|
|
'sensitive' => $userTarget->isSensitive(), |
|
|
|
|
|
|
|
'yggdrasil' => $userTarget->isYggdrasil(), |
|
|
|
'locale' => $userTarget->getLocale(), |
|
|
|
'locale' => $userTarget->getLocale(), |
|
|
|
'locales' => $userTarget->getLocales(), |
|
|
|
'locales' => $userTarget->getLocales(), |
|
|
|
|
|
|
|
'events' => $userTarget->getEvents(), |
|
|
|
'theme' => $userTarget->getTheme(), |
|
|
|
'theme' => $userTarget->getTheme(), |
|
|
|
'added' => $userTarget->getAdded(), |
|
|
|
'added' => $userTarget->getAdded(), |
|
|
|
'identicon' => $userService->identicon( |
|
|
|
'identicon' => $userService->identicon( |
|
|
@ -232,7 +252,8 @@ class UserController extends AbstractController |
|
|
|
$userTarget->getId() |
|
|
|
$userTarget->getId() |
|
|
|
) |
|
|
|
) |
|
|
|
], |
|
|
|
], |
|
|
|
] |
|
|
|
], |
|
|
|
|
|
|
|
'events' => $activityService->getEventsTree() |
|
|
|
] |
|
|
|
] |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
@ -587,7 +608,11 @@ class UserController extends AbstractController |
|
|
|
time(), |
|
|
|
time(), |
|
|
|
$this->getParameter('app.locale'), |
|
|
|
$this->getParameter('app.locale'), |
|
|
|
explode('|', $this->getParameter('app.locales')), |
|
|
|
explode('|', $this->getParameter('app.locales')), |
|
|
|
$this->getParameter('app.theme') |
|
|
|
$activityService->getEventCodes(), |
|
|
|
|
|
|
|
$this->getParameter('app.theme'), |
|
|
|
|
|
|
|
$this->getParameter('app.sensitive'), |
|
|
|
|
|
|
|
$this->getParameter('app.yggdrasil'), |
|
|
|
|
|
|
|
$this->getParameter('app.approved') |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// Add user join event |
|
|
|
// Add user join event |
|
|
|