summaryrefslogtreecommitdiff
path: root/app/Models/UserConfiguration.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2025-11-11 08:17:12 +0100
committerGravatar GitHub <noreply@github.com> 2025-11-11 08:17:12 +0100
commita18c35046daee15e7ac5f85db290d54541a03e3c (patch)
treeec638cf7c93537a4f81b27216097d8509252eb81 /app/Models/UserConfiguration.php
parent5e622c60fa5c40793138807280319f7e84d00cc6 (diff)
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
Diffstat (limited to 'app/Models/UserConfiguration.php')
-rw-r--r--app/Models/UserConfiguration.php28
1 files changed, 28 insertions, 0 deletions
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;
+ }
}