diff --git a/.env b/.env index 8687566d..2b0260c6 100644 --- a/.env +++ b/.env @@ -37,16 +37,11 @@ DEFAULT_LANG="en" DEFAULT_TIMEZONE="Europe/Berlin" # The currency that is used inside the DB (and is assumed when no currency is set). This can not be changed later, so be sure to set it the currency used in your country BASE_CURRENCY="EUR" -# Use gravatars for user avatars, when user has no own avatar defined -USE_GRAVATAR=0 # The public reachable URL of this Part-DB installation. This is used for generating links in SAML and email templates # This must end with a slash! DEFAULT_URI="https://partdb.changeme.invalid/" -# Disable that if you do not want that Part-DB connects to GitHub to check for available updates, or if your server can not connect to the internet -CHECK_FOR_UPDATES=1 - ################################################################################### # Email settings ################################################################################### diff --git a/config/parameters.yaml b/config/parameters.yaml index 7ff1b68e..a3d66202 100644 --- a/config/parameters.yaml +++ b/config/parameters.yaml @@ -21,11 +21,8 @@ parameters: # Users and Privacy ###################################################################################################################### partdb.gdpr_compliance: true # If this option is activated, IP addresses are anonymized to be GDPR compliant - partdb.users.use_gravatar: '%env(bool:USE_GRAVATAR)%' # Set to false, if no Gravatar images should be used for user profiles. partdb.users.email_pw_reset: '%env(bool:ALLOW_EMAIL_PW_RESET)%' # Config if users are able, to reset their password by email. By default this enabled, when a mail server is configured. - partdb.check_for_updates: '%env(bool:CHECK_FOR_UPDATES)' # Set to false, if Part-DB should not contact the GitHub API to check for updates - ###################################################################################################################### # Mail settings ###################################################################################################################### @@ -110,7 +107,6 @@ parameters: env(DEFAULT_TIMEZONE): 'Europe/Berlin' env(INSTANCE_NAME): 'Part-DB' env(BASE_CURRENCY): 'EUR' - env(USE_GRAVATAR): '0' env(REDIRECT_TO_HTTPS): 0 diff --git a/config/services.yaml b/config/services.yaml index 695deb11..2f4f08e9 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -184,10 +184,6 @@ services: tags: - { name: 'translation.extractor', alias: 'permissionExtractor'} - App\Services\UserSystem\UserAvatarHelper: - arguments: - $use_gravatar: '%partdb.users.use_gravatar%' - App\Form\Type\ThemeChoiceType: arguments: $available_themes: '%partdb.available_themes%' @@ -313,10 +309,6 @@ services: arguments: $project_dir: '%kernel.project_dir%' - App\Services\System\UpdateAvailableManager: - arguments: - $check_for_updates: '%partdb.check_for_updates%' - App\Doctrine\Middleware\MySQLSSLConnectionMiddlewareWrapper: arguments: diff --git a/src/Controller/ToolsController.php b/src/Controller/ToolsController.php index 97df8d15..7ffc3ee9 100644 --- a/src/Controller/ToolsController.php +++ b/src/Controller/ToolsController.php @@ -63,7 +63,7 @@ class ToolsController extends AbstractController 'enabled_locales' => $this->getParameter('partdb.locale_menu'), 'demo_mode' => $this->getParameter('partdb.demo_mode'), 'gpdr_compliance' => $this->getParameter('partdb.gdpr_compliance'), - 'use_gravatar' => $this->getParameter('partdb.users.use_gravatar'), + 'use_gravatar' => $settings->system->privacy->useGravatar, 'email_password_reset' => $this->getParameter('partdb.users.email_pw_reset'), 'enviroment' => $this->getParameter('kernel.environment'), 'is_debug' => $this->getParameter('kernel.debug'), diff --git a/src/Services/System/UpdateAvailableManager.php b/src/Services/System/UpdateAvailableManager.php index 31cb3266..82cfb84e 100644 --- a/src/Services/System/UpdateAvailableManager.php +++ b/src/Services/System/UpdateAvailableManager.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace App\Services\System; +use App\Settings\SystemSettings\PrivacySettings; use Psr\Log\LoggerInterface; use Shivas\VersioningBundle\Service\VersionManagerInterface; use Symfony\Component\DependencyInjection\Attribute\Autowire; @@ -43,7 +44,7 @@ class UpdateAvailableManager public function __construct(private readonly HttpClientInterface $httpClient, private readonly CacheInterface $updateCache, private readonly VersionManagerInterface $versionManager, - private readonly bool $check_for_updates, private readonly LoggerInterface $logger, + private readonly PrivacySettings $privacySettings, private readonly LoggerInterface $logger, #[Autowire(param: 'kernel.debug')] private readonly bool $is_dev_mode) { @@ -83,7 +84,7 @@ class UpdateAvailableManager public function isUpdateAvailable(): bool { //If we don't want to check for updates, we can return false - if (!$this->check_for_updates) { + if (!$this->privacySettings->checkForUpdates) { return false; } @@ -101,7 +102,7 @@ class UpdateAvailableManager private function getLatestVersionInfo(): array { //If we don't want to check for updates, we can return dummy data - if (!$this->check_for_updates) { + if (!$this->privacySettings->checkForUpdates) { return [ 'version' => '0.0.1', 'url' => 'update-checking-disabled' diff --git a/src/Services/UserSystem/UserAvatarHelper.php b/src/Services/UserSystem/UserAvatarHelper.php index a694fa77..9dbe9c12 100644 --- a/src/Services/UserSystem/UserAvatarHelper.php +++ b/src/Services/UserSystem/UserAvatarHelper.php @@ -30,6 +30,7 @@ use App\Entity\Attachments\UserAttachment; use App\Entity\UserSystem\User; use App\Services\Attachments\AttachmentSubmitHandler; use App\Services\Attachments\AttachmentURLGenerator; +use App\Settings\SystemSettings\PrivacySettings; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\Asset\Packages; use Symfony\Component\HttpFoundation\File\UploadedFile; @@ -42,7 +43,7 @@ class UserAvatarHelper public const IMG_DEFAULT_AVATAR_PATH = 'img/default_avatar.svg'; public function __construct( - private readonly bool $use_gravatar, + private readonly PrivacySettings $privacySettings, private readonly Packages $packages, private readonly AttachmentURLGenerator $attachmentURLGenerator, private readonly EntityManagerInterface $entityManager, @@ -65,7 +66,7 @@ class UserAvatarHelper } //If not check if gravatar is enabled (then use gravatar URL) - if ($this->use_gravatar) { + if ($this->privacySettings->useGravatar) { return $this->getGravatar($user, 200); //200px wide picture } @@ -82,7 +83,7 @@ class UserAvatarHelper } //If not check if gravatar is enabled (then use gravatar URL) - if ($this->use_gravatar) { + if ($this->privacySettings->useGravatar) { return $this->getGravatar($user, 50); //50px wide picture } @@ -99,7 +100,7 @@ class UserAvatarHelper } //If not check if gravatar is enabled (then use gravatar URL) - if ($this->use_gravatar) { + if ($this->privacySettings->useGravatar) { return $this->getGravatar($user, 150); } diff --git a/src/Settings/SystemSettings.php b/src/Settings/SystemSettings.php index 8c3bfb0e..38dce049 100644 --- a/src/Settings/SystemSettings.php +++ b/src/Settings/SystemSettings.php @@ -26,6 +26,7 @@ namespace App\Settings; use App\Settings\SystemSettings\AttachmentsSettings; use App\Settings\SystemSettings\CustomizationSettings; use App\Settings\SystemSettings\HistorySettings; +use App\Settings\SystemSettings\PrivacySettings; use Jbtronics\SettingsBundle\Settings\EmbeddedSettings; use Jbtronics\SettingsBundle\Settings\Settings; @@ -35,6 +36,9 @@ class SystemSettings #[EmbeddedSettings()] public ?CustomizationSettings $customization = null; + #[EmbeddedSettings()] + public ?PrivacySettings $privacy = null; + #[EmbeddedSettings()] public ?AttachmentsSettings $attachments = null; diff --git a/src/Settings/SystemSettings/PrivacySettings.php b/src/Settings/SystemSettings/PrivacySettings.php new file mode 100644 index 00000000..3bdb7489 --- /dev/null +++ b/src/Settings/SystemSettings/PrivacySettings.php @@ -0,0 +1,52 @@ +. + */ + +declare(strict_types=1); + + +namespace App\Settings\SystemSettings; + +use Jbtronics\SettingsBundle\Metadata\EnvVarMode; +use Jbtronics\SettingsBundle\Settings\Settings; +use Jbtronics\SettingsBundle\Settings\SettingsParameter; +use Jbtronics\SettingsBundle\Settings\SettingsTrait; +use Symfony\Component\Translation\TranslatableMessage as TM; + +#[Settings] +class PrivacySettings +{ + use SettingsTrait; + + #[SettingsParameter( + label: new TM("settings.system.privacy.checkForUpdates"), + description: new TM("settings.system.privacy.checkForUpdates.description"), + envVar: 'bool:CHECK_FOR_UPDATES', envVarMode: EnvVarMode::OVERWRITE)] + public bool $checkForUpdates = true; + + /** + * @var bool Use gravatars for user avatars, when user has no own avatar defined + */ + #[SettingsParameter( + label: new TM("settings.system.privacy.useGravatar"), + description: new TM("settings.system.privacy.useGravatar.description"), + envVar: 'bool:USE_GRAVATAR', envVarMode: EnvVarMode::OVERWRITE)] + public bool $useGravatar = false; + +} \ No newline at end of file diff --git a/translations/messages.en.xlf b/translations/messages.en.xlf index fc055205..32c2d7e5 100644 --- a/translations/messages.en.xlf +++ b/translations/messages.en.xlf @@ -12527,5 +12527,29 @@ Please note, that you can not impersonate a disabled user. If you try you will g Data structure deletion + + + settings.system.privacy.useGravatar + Use Gravatar avatars + + + + + settings.system.privacy.useGravatar.description + If a user does not have an avatar image specified, use the avatar from Gravatar based on the user email. This causes the browser to load pictures from a third-party! + + + + + settings.system.privacy.checkForUpdates + Check for Part-DB updates + + + + + settings.system.privacy.checkForUpdates.description + Part-DB regularly checks if a new version is available on GitHub. Disable this here, if you do not want this or if your server can not connect to the internet. + +