* The category of the configuration value
* @param string $key
* The configuration key to query
- * @param boolean $refresh
- * If true the config is loaded from the db and not from the cache
+ * @param mixed $default_value optional
+ * The value to return if key is not set (default: null)
+ * @param boolean $refresh optional
+ * If true the config is loaded from the db and not from the cache (default: false)
* @return mixed Stored value or null if it does not exist
*/
- public static function get($family, $key, $refresh = false) {
+ public static function get($family, $key, $default_value=null, $refresh = false) {
global $a;
// Looking if the whole family isn't set
if(isset($a->config[$family])) {
if($a->config[$family] === '!<unset>!') {
- return null;
+ return $default_value;
}
}
if(isset($a->config[$family][$key])) {
if($a->config[$family][$key] === '!<unset>!') {
- return null;
+ return $default_value;
}
return $a->config[$family][$key];
}
elseif (function_exists("xcache_set"))
xcache_set($family."|".$key, '!<unset>!', 600);*/
}
- return null;
+ return $default_value;
}
/**
* The category of the configuration value
* @param string $key
* The configuration key to query
- * @param boolean $refresh
- * If true the config is loaded from the db and not from the cache
+ * @param mixed $default_value optional
+ * The value to return if key is not set (default: null)
+ * @param boolean $refresh optional
+ * If true the config is loaded from the db and not from the cache (default: false)
* @return mixed Stored value or null if it does not exist
*/
- public static function get($uid, $family, $key, $refresh = false) {
+ public static function get($uid, $family, $key, $default_value = null, $refresh = false) {
global $a;
// Looking if the whole family isn't set
if(isset($a->config[$uid][$family])) {
if($a->config[$uid][$family] === '!<unset>!') {
- return null;
+ return $default_value;
}
}
if(isset($a->config[$uid][$family][$key])) {
if($a->config[$uid][$family][$key] === '!<unset>!') {
- return null;
+ return $default_value;
}
return $a->config[$uid][$family][$key];
}
elseif (function_exists("xcache_set"))
xcache_set($uid."|".$family."|".$key, '!<unset>!', 600);*/
}
- return null;
+ return $default_value;
}
/**
* @return mixed Stored value or false if it does not exist
*/
function get_config($family, $key, $refresh = false) {
- $v = Config::get($family, $key, $refresh);
- if(is_null($v))
- $v = false;
-
+ $v = Config::get($family, $key, false, $refresh);
return $v;
}
* @return mixed Stored value or false if it does not exist
*/
function get_pconfig($uid, $family, $key, $refresh = false) {
- $v = PConfig::get($uid, $family, $key, $refresh);
- if(is_null($v))
- $v = false;
-
+ $v = PConfig::get($uid, $family, $key, false, $refresh);
return $v;
}