3 * User Configuration Class
5 * @file include/Core/PConfig.php
7 * @brief Contains the class with methods for user configuration
9 namespace Friendica\Core;
12 * @brief Management of user configuration storage
14 * Please do not store booleans - convert to 0/1 integer values
15 * The PConfig::get() functions return boolean false for keys that are unset,
16 * and this could lead to subtle bugs.
21 * @var Config\PConfiguration
23 private static $config;
26 * Initialize the config with only the cache
28 * @param Config\PConfiguration $config The configuration cache
30 public static function init(Config\PConfiguration $config)
32 self::$config = $config;
36 * @brief Loads all configuration values of a user's config family into a cached storage.
38 * @param string $uid The user_id
39 * @param string $cat The category of the configuration value
43 public static function load($uid, $cat)
45 self::$config->load($uid, $cat);
49 * @brief Get a particular user's config variable given the category name
52 * @param string $uid The user_id
53 * @param string $cat The category of the configuration value
54 * @param string $key The configuration key to query
55 * @param mixed $default_value optional, The value to return if key is not set (default: null)
56 * @param boolean $refresh optional, If true the config is loaded from the db and not from the cache (default: false)
58 * @return mixed Stored value or null if it does not exist
60 public static function get($uid, $cat, $key, $default_value = null, $refresh = false)
62 return self::$config->get($uid, $cat, $key, $default_value, $refresh);
66 * @brief Sets a configuration value for a user
68 * @param string $uid The user_id
69 * @param string $cat The category of the configuration value
70 * @param string $key The configuration key to set
71 * @param mixed $value The value to store
73 * @return bool Operation success
75 public static function set($uid, $cat, $key, $value)
77 return self::$config->set($uid, $cat, $key, $value);
81 * @brief Deletes the given key from the users's configuration.
83 * @param string $uid The user_id
84 * @param string $cat The category of the configuration value
85 * @param string $key The configuration key to delete
89 public static function delete($uid, $cat, $key)
91 return self::$config->delete($uid, $cat, $key);