diff --git a/lib/Settings/Admin.php b/lib/Settings/Admin.php index f7cc9045b..14107fe7e 100644 --- a/lib/Settings/Admin.php +++ b/lib/Settings/Admin.php @@ -98,8 +98,8 @@ public function getForm() { $activityGroups[$groupIdentifier]['activities'][$identifier] = [ 'desc' => $setting->getName(), - IExtension::METHOD_MAIL => $this->userSettings->getConfigSetting('email', $identifier), - IExtension::METHOD_NOTIFICATION => $this->userSettings->getConfigSetting('notification', $identifier), + IExtension::METHOD_MAIL => $this->userSettings->getAdminSetting('email', $identifier), + IExtension::METHOD_NOTIFICATION => $this->userSettings->getAdminSetting('notification', $identifier), 'methods' => $methods, ]; } @@ -111,7 +111,7 @@ public function getForm() { } $settingBatchTime = UserSettings::EMAIL_SEND_HOURLY; - $currentSetting = (int) $this->userSettings->getConfigSetting('setting', 'batchtime'); + $currentSetting = (int) $this->userSettings->getAdminSetting('setting', 'batchtime'); if ($currentSetting === 3600 * 24 * 7) { $settingBatchTime = UserSettings::EMAIL_SEND_WEEKLY; } elseif ($currentSetting === 3600 * 24) { diff --git a/lib/UserSettings.php b/lib/UserSettings.php index 3ba6cfbb6..2928e0d8e 100644 --- a/lib/UserSettings.php +++ b/lib/UserSettings.php @@ -56,7 +56,8 @@ public function __construct(IManager $manager, IConfig $config) { } /** - * Get a setting for a user + * Get the user setting + * Falling back to the admin default if not set for the user * * Falls back to some good default values if the user does not have a preference * @@ -70,7 +71,7 @@ public function getUserSetting($user, $method, $type) { return false; } - $defaultSetting = $this->getDefaultFromSetting($method, $type); + $defaultSetting = $this->getAdminSetting($method, $type); if (!$this->canModifySetting($method, $type)) { return $defaultSetting; } @@ -93,12 +94,15 @@ public function getUserSetting($user, $method, $type) { } /** + * Get the admin configured default for the setting + * Falling back to the implementation default if not set by the admin + * * @param string $method * @param string $type * @return bool|int */ - public function getConfigSetting($method, $type) { - $defaultSetting = $this->getDefaultFromSetting($method, $type); + public function getAdminSetting($method, $type) { + $defaultSetting = $this->getDefaultSetting($method, $type); if (is_bool($defaultSetting)) { return (bool) $this->config->getAppValue( 'activity', @@ -115,13 +119,13 @@ public function getConfigSetting($method, $type) { } /** - * Get a good default setting for a preference + * Get default setting for a preference from the implementation * * @param string $method Should be one of 'stream', 'email' or 'setting' * @param string $type One of the activity types, 'batchtime', 'self' or 'selfemail' * @return bool|int */ - protected function getDefaultFromSetting($method, $type) { + protected function getDefaultSetting($method, $type) { if ($method === 'setting') { if ($type === 'batchtime') { return 3600; @@ -236,12 +240,12 @@ public function filterUsersBySetting($users, $method, $type) { // If the setting is enabled by default, // we add all users that didn't set the preference yet. - if ($this->getDefaultFromSetting($method, $type)) { + if ($this->getDefaultSetting($method, $type)) { foreach ($users as $user) { if ($method === 'notification') { $filteredUsers[$user] = true; } else { - $filteredUsers[$user] = $this->getDefaultFromSetting('setting', 'batchtime'); + $filteredUsers[$user] = $this->getDefaultSetting('setting', 'batchtime'); } } } diff --git a/templates/settings/admin.php b/templates/settings/admin.php index 4829cd378..c69e6670f 100644 --- a/templates/settings/admin.php +++ b/templates/settings/admin.php @@ -41,7 +41,7 @@
- t('Configure the default notification settings for new users.')); ?> + t('Configure the default notification settings.')); ?>
inc('settings/form')); ?> diff --git a/tests/UserSettingsTest.php b/tests/UserSettingsTest.php index 5d4c5c748..37f8dc9db 100644 --- a/tests/UserSettingsTest.php +++ b/tests/UserSettingsTest.php @@ -77,6 +77,6 @@ public function testGetDefaultSetting(string $method, string $type, $expected): ->willReturn($s); } } - $this->assertEquals($expected, self::invokePrivate($this->userSettings, 'getDefaultFromSetting', [$method, $type])); + $this->assertEquals($expected, self::invokePrivate($this->userSettings, 'getDefaultSetting', [$method, $type])); } }