From 108abd77ed0ee29bca4019f6a212ba1b2bdad5e7 Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Thu, 17 Mar 2022 18:06:38 +0000 Subject: Add profile default setting for admin Signed-off-by: Christopher Ng --- lib/private/Accounts/AccountManager.php | 5 ++++- lib/private/Profile/TProfileHelper.php | 15 ++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) (limited to 'lib') diff --git a/lib/private/Accounts/AccountManager.php b/lib/private/Accounts/AccountManager.php index 7f855c07d46..127adc9ef38 100644 --- a/lib/private/Accounts/AccountManager.php +++ b/lib/private/Accounts/AccountManager.php @@ -40,6 +40,7 @@ use libphonenumber\NumberParseException; use libphonenumber\PhoneNumber; use libphonenumber\PhoneNumberFormat; use libphonenumber\PhoneNumberUtil; +use OC\Profile\TProfileHelper; use OCA\Settings\BackgroundJobs\VerifyUserData; use OCP\Accounts\IAccount; use OCP\Accounts\IAccountManager; @@ -79,6 +80,8 @@ use function json_last_error; class AccountManager implements IAccountManager { use TAccountsHelper; + use TProfileHelper; + /** @var IDBConnection database connection */ private $connection; @@ -722,7 +725,7 @@ class AccountManager implements IAccountManager { [ 'name' => self::PROPERTY_PROFILE_ENABLED, - 'value' => '1', + 'value' => $this->isProfileEnabledByDefault($this->config) ? '1' : '0', ], ]; } diff --git a/lib/private/Profile/TProfileHelper.php b/lib/private/Profile/TProfileHelper.php index 0d4b5c6286e..5b57e1c9d5c 100644 --- a/lib/private/Profile/TProfileHelper.php +++ b/lib/private/Profile/TProfileHelper.php @@ -3,7 +3,7 @@ declare(strict_types=1); /** - * @copyright 2021 Christopher Ng + * @copyright 2022 Christopher Ng * * @author Christopher Ng * @@ -26,19 +26,12 @@ declare(strict_types=1); namespace OC\Profile; -use OCP\Accounts\IAccount; -use OCP\Accounts\IAccountManager; +use OCP\IConfig; trait TProfileHelper { - - /** - * Returns whether the profile is enabled for the account - * - * @since 23.0.0 - */ - protected function isProfileEnabled(IAccount $account): ?bool { + protected function isProfileEnabledByDefault(IConfig $config): ?bool { return filter_var( - $account->getProperty(IAccountManager::PROPERTY_PROFILE_ENABLED)->getValue(), + $config->getAppValue('settings', 'profile_enabled_by_default', '1'), FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE, ); -- cgit v1.2.3