aboutsummaryrefslogtreecommitdiffstats
path: root/boot.php
diff options
context:
space:
mode:
authorfabrixxm <fabrix.xm@gmail.com>2011-06-19 15:10:31 +0200
committerfabrixxm <fabrix.xm@gmail.com>2011-06-19 15:10:31 +0200
commit10eb79a629278e11a0ed56193adef9895ff73638 (patch)
tree77386f2a26444dbf1007119c05162d464508e0fd /boot.php
parentfba2056b1ffb77c087feb05035f68736539e20ad (diff)
downloadvolse-hubzilla-10eb79a629278e11a0ed56193adef9895ff73638.tar.gz
volse-hubzilla-10eb79a629278e11a0ed56193adef9895ff73638.tar.bz2
volse-hubzilla-10eb79a629278e11a0ed56193adef9895ff73638.zip
add array support to set_config and get_config
Diffstat (limited to 'boot.php')
-rw-r--r--boot.php15
1 files changed, 10 insertions, 5 deletions
diff --git a/boot.php b/boot.php
index 5165dc990..3f69fd084 100644
--- a/boot.php
+++ b/boot.php
@@ -1243,8 +1243,10 @@ function get_config($family, $key, $instore = false) {
dbesc($key)
);
if(count($ret)) {
- $a->config[$family][$key] = $ret[0]['v'];
- return $ret[0]['v'];
+ // manage array value
+ $val = (preg_match("|^a:[0-9]+:{.*}$|", $ret[0]['v'])?unserialize( $ret[0]['v']):$ret[0]['v']);
+ $a->config[$family][$key] = $val;
+ return $val;
}
else {
$a->config[$family][$key] = '!<unset>!';
@@ -1258,22 +1260,25 @@ function get_config($family, $key, $instore = false) {
if(! function_exists('set_config')) {
function set_config($family,$key,$value) {
-
global $a;
+
+ // manage array value
+ $dbvalue = (is_array($value)?serialize($value):$value);
if(get_config($family,$key,true) === false) {
$a->config[$family][$key] = $value;
$ret = q("INSERT INTO `config` ( `cat`, `k`, `v` ) VALUES ( '%s', '%s', '%s' ) ",
dbesc($family),
dbesc($key),
- dbesc($value)
+ dbesc($dbvalue)
);
if($ret)
return $value;
return $ret;
}
+
$ret = q("UPDATE `config` SET `v` = '%s' WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
- dbesc($value),
+ dbesc($dbvalue),
dbesc($family),
dbesc($key)
);