diff options
author | Mario <mario@mariovavti.com> | 2018-01-09 09:00:20 +0100 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2018-01-09 09:00:20 +0100 |
commit | 4f4d0e416eac87121898b8a27b1afa6065ff17a2 (patch) | |
tree | aae7f2582b2b9c6596dcbf87c06a836434140830 /Zotlabs/Lib/Config.php | |
parent | 22c89b6c660e185d5c5c6362acf23b145d932d15 (diff) | |
parent | 8fde0f01b8472082158b38386046ed606bcfbc49 (diff) | |
download | volse-hubzilla-4f4d0e416eac87121898b8a27b1afa6065ff17a2.tar.gz volse-hubzilla-4f4d0e416eac87121898b8a27b1afa6065ff17a2.tar.bz2 volse-hubzilla-4f4d0e416eac87121898b8a27b1afa6065ff17a2.zip |
Merge branch '3.0RC'3.0
Diffstat (limited to 'Zotlabs/Lib/Config.php')
-rw-r--r-- | Zotlabs/Lib/Config.php | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/Zotlabs/Lib/Config.php b/Zotlabs/Lib/Config.php index 6e042feba..f9f22ba3a 100644 --- a/Zotlabs/Lib/Config.php +++ b/Zotlabs/Lib/Config.php @@ -1,4 +1,4 @@ -<?php /** @file */ +<?php namespace Zotlabs\Lib; @@ -14,7 +14,6 @@ class Config { * @param string $family * The category of the configuration value */ - static public function Load($family) { if(! array_key_exists($family, \App::$config)) \App::$config[$family] = array(); @@ -30,7 +29,7 @@ class Config { } \App::$config[$family]['config_loaded'] = true; } - } + } } /** @@ -47,8 +46,7 @@ class Config { * @return mixed * Return the set value, or false if the database update failed */ - - static public function Set($family,$key,$value) { + static public function Set($family, $key, $value) { // manage array value $dbvalue = ((is_array($value)) ? serialize($value) : $value); $dbvalue = ((is_bool($dbvalue)) ? intval($dbvalue) : $dbvalue); @@ -76,8 +74,8 @@ class Config { \App::$config[$family][$key] = $value; $ret = $value; } - return $ret; + return $ret; } /** @@ -88,25 +86,25 @@ class Config { * $key from a cached storage in App::$config[$family]. If a key is found in the * DB but does not exist in local config cache, pull it into the cache so we * do not have to hit the DB again for this item. - * + * * Returns false if not set. * * @param string $family * The category of the configuration value * @param string $key * The configuration key to query + * @param string $default (optional) default false * @return mixed Return value or false on error or if not set */ - - static public function Get($family,$key,$default = false) { + static public function Get($family, $key, $default = false) { if((! array_key_exists($family, \App::$config)) || (! array_key_exists('config_loaded', \App::$config[$family]))) self::Load($family); if(array_key_exists('config_loaded', \App::$config[$family])) { if(! array_key_exists($key, \App::$config[$family])) { - return $default; + return $default; } - return ((! is_array(\App::$config[$family][$key])) && (preg_match('|^a:[0-9]+:{.*}$|s', \App::$config[$family][$key])) + return ((! is_array(\App::$config[$family][$key])) && (preg_match('|^a:[0-9]+:{.*}$|s', \App::$config[$family][$key])) ? unserialize(\App::$config[$family][$key]) : \App::$config[$family][$key] ); @@ -127,17 +125,18 @@ class Config { * The configuration key to delete * @return mixed */ - - static public function Delete($family,$key) { + static public function Delete($family, $key) { $ret = false; if(array_key_exists($family, \App::$config) && array_key_exists($key, \App::$config[$family])) unset(\App::$config[$family][$key]); - $ret = q("DELETE FROM config WHERE cat = '%s' AND k = '%s'", + + $ret = q("DELETE FROM config WHERE cat = '%s' AND k = '%s'", dbesc($family), dbesc($key) ); + return $ret; } @@ -154,12 +153,12 @@ class Config { * The configuration key to query * @return mixed */ - static private function get_from_storage($family,$key) { $ret = q("SELECT * FROM config WHERE cat = '%s' AND k = '%s' LIMIT 1", dbesc($family), dbesc($key) ); + return $ret; } |