From a18c35046daee15e7ac5f85db290d54541a03e3c Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 11 Nov 2025 08:17:12 +0100 Subject: Housekeeping lib_rss.php (#8193) * Housekeeping lib_rss.php `lib_rss.php` had become much too large, especially after https://github.com/FreshRSS/FreshRSS/pull/7924 Moved most functions to other places. Mostly no change of code otherwise (see comments). * Extension: composer run-script phpstan-third-party --- app/Models/UserConfiguration.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'app/Models/UserConfiguration.php') diff --git a/app/Models/UserConfiguration.php b/app/Models/UserConfiguration.php index eaa08d92d..d98d85fe3 100644 --- a/app/Models/UserConfiguration.php +++ b/app/Models/UserConfiguration.php @@ -108,4 +108,32 @@ final class FreshRSS_UserConfiguration extends Minz_Configuration { } return $default_user_conf; } + + /** + * Register and return the configuration for a given user. + * + * Note this function has been created to generate temporary configuration + * objects. If you need a long-time configuration, please don't use this function. + * + * @param string $username the name of the user of which we want the configuration. + * @return FreshRSS_UserConfiguration|null object, or null if the configuration cannot be loaded. + * @throws Minz_ConfigurationNamespaceException + */ + public static function getForUser(string $username): ?FreshRSS_UserConfiguration { + if (!FreshRSS_user_Controller::checkUsername($username)) { + return null; + } + $namespace = 'user_' . $username; + try { + FreshRSS_UserConfiguration::register($namespace, + USERS_PATH . '/' . $username . '/config.php', + FRESHRSS_PATH . '/config-user.default.php'); + } catch (Minz_FileNotExistException $e) { + Minz_Log::warning($e->getMessage(), ADMIN_LOG); + return null; + } + + $user_conf = FreshRSS_UserConfiguration::get($namespace); + return $user_conf; + } } -- cgit v1.2.3