diff --git a/.env b/.env index 95ca49a..0188510 100644 --- a/.env +++ b/.env @@ -55,6 +55,8 @@ APP_LOCALES=en|cs|eo|fr|ka|de|he|it|lv|pl|pt|ru|es|uk APP_THEME=default APP_THEMES=default +APP_SENSITIVE=0 + APP_TRACKERS=http://[201:23b4:991a:634d:8359:4521:5576:15b7]:2023/announce|http://[200:1e2f:e608:eb3a:2bf:1e62:87ba:e2f7]/announce|http://[316:c51a:62a3:8b9::5]/announce APP_PAGE_TITLE_LENGTH_MIN=10 diff --git a/config/services.yaml b/config/services.yaml index 68124cf..36a739d 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -10,6 +10,7 @@ parameters: app.locales: '%env(APP_LOCALES)%' app.theme: '%env(APP_THEME)%' app.themes: '%env(APP_THEMES)%' + app.sensitive: '%env(APP_SENSITIVE)%' app.trackers: '%env(APP_TRACKERS)%' app.page.title.length.min: '%env(APP_PAGE_TITLE_LENGTH_MIN)%' app.page.title.length.max: '%env(APP_PAGE_TITLE_LENGTH_MAX)%' diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index 37075f2..2e8c815 100644 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -142,6 +142,11 @@ class UserController extends AbstractController ); } + // Update sensitive + $user->setSensitive( + $request->get('sensitive') === 'true' + ); + // Save changes to DB $userService->save($user); @@ -164,6 +169,7 @@ class UserController extends AbstractController 'moderator' => $user->isModerator(), 'approved' => $user->isApproved(), 'status' => $user->isStatus(), + 'sensitive' => $user->isSensitive(), 'locale' => $user->getLocale(), 'locales' => $user->getLocales(), 'theme' => $user->getTheme(), @@ -223,8 +229,10 @@ class UserController extends AbstractController 'moderator' => $userTarget->isModerator(), 'approved' => $userTarget->isApproved(), 'status' => $userTarget->isStatus(), + 'sensitive' => $userTarget->isSensitive(), 'locale' => $userTarget->getLocale(), 'locales' => $userTarget->getLocales(), + 'theme' => $userTarget->getTheme(), 'added' => $userTarget->getAdded(), 'identicon' => $userService->identicon( $userTarget->getAddress(), diff --git a/src/Entity/User.php b/src/Entity/User.php index 493e61c..f727c8f 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -38,6 +38,9 @@ class User #[ORM\Column(length: 255)] private ?string $theme = null; + #[ORM\Column] + private ?bool $sensitive = null; + public function getId(): ?int { return $this->id; @@ -145,4 +148,16 @@ class User return $this; } + + public function isSensitive(): ?bool + { + return $this->sensitive; + } + + public function setSensitive(bool $sensitive): static + { + $this->sensitive = $sensitive; + + return $this; + } } diff --git a/src/Service/UserService.php b/src/Service/UserService.php index e340859..b070397 100644 --- a/src/Service/UserService.php +++ b/src/Service/UserService.php @@ -36,21 +36,42 @@ class UserService // Create new user $user = new User(); - $user->setAddress($address); - $user->setAdded(time()); - $user->setApproved(false); - $user->setModerator(false); - $user->setStatus(true); + $user->setAddress( + $address + ); + + $user->setAdded( + time() + ); + + $user->setApproved( + false + ); + + $user->setModerator( + false + ); + + $user->setStatus( + true + ); + $user->setLocale( $this->parameterBagInterface->get('app.locale') ); + $user->setLocales( explode('|', $this->parameterBagInterface->get('app.locales')) ); + $user->setTheme( $this->parameterBagInterface->get('app.theme') ); + $user->setSensitive( + $this->parameterBagInterface->get('app.sensitive') + ); + $this->save($user); // Set initial user as approved & moderator @@ -58,6 +79,7 @@ class UserService { $user->setApproved(true); $user->setModerator(true); + $user->setSensitive(false); $this->save($user); } diff --git a/templates/default/user/info.html.twig b/templates/default/user/info.html.twig index 835072c..559da1a 100644 --- a/templates/default/user/info.html.twig +++ b/templates/default/user/info.html.twig @@ -85,6 +85,20 @@ {% for i, locale in user.locales %}{% if i > 0 %},{% endif %} {{ locale|locale_name(locale)|u.title }}{% endfor %} + + {{ 'Theme'|trans }} + {{ user.theme }} + + + {{ 'Sensitive filter'|trans }} + + {% if user.sensitive %} + {{ 'yes'|trans }} + {% else %} + {{ 'no'|trans }} + {% endif %} + + diff --git a/templates/default/user/profile.html.twig b/templates/default/user/profile.html.twig index 6f2c3e3..f3bec99 100644 --- a/templates/default/user/profile.html.twig +++ b/templates/default/user/profile.html.twig @@ -85,7 +85,9 @@ - {{ 'Content filter'|trans }} + + {{ 'Content language' | trans }} + {% for locale in locales %}
@@ -102,7 +104,9 @@ - {{ 'Theme'|trans }} + + {{ 'Theme' | trans }} + + + + {{ 'Sensitive filter'|trans }} + + +
+ {% if user.sensitive %} + + {% else %} + + {% endif %} +
+ +
- +