aboutsummaryrefslogtreecommitdiffstats
path: root/include/config.php
diff options
context:
space:
mode:
authorFabio Comuni <fabrix.xm@gmail.com>2011-12-19 18:01:38 +0100
committerFabio Comuni <fabrix.xm@gmail.com>2011-12-19 18:01:38 +0100
commita6f3b582939022fae0834e4f62b435f18551c968 (patch)
treebdc5bf647629d762c64113cbc812d1c8fe07fac8 /include/config.php
parent84bbf5d3bd90eb6feb131c753ccb5c8e75fbaea3 (diff)
downloadvolse-hubzilla-a6f3b582939022fae0834e4f62b435f18551c968.tar.gz
volse-hubzilla-a6f3b582939022fae0834e4f62b435f18551c968.tar.bz2
volse-hubzilla-a6f3b582939022fae0834e4f62b435f18551c968.zip
config: set/get arrays with pconfig
Diffstat (limited to 'include/config.php')
-rw-r--r--include/config.php12
1 files changed, 8 insertions, 4 deletions
diff --git a/include/config.php b/include/config.php
index f565ab117..92694f519 100644
--- a/include/config.php
+++ b/include/config.php
@@ -145,8 +145,9 @@ function get_pconfig($uid,$family, $key, $instore = false) {
);
if(count($ret)) {
- $a->config[$uid][$family][$key] = $ret[0]['v'];
- return $ret[0]['v'];
+ $val = (preg_match("|^a:[0-9]+:{.*}$|", $ret[0]['v'])?unserialize( $ret[0]['v']):$ret[0]['v']);
+ $a->config[$uid][$family][$key] = $val;
+ return $val;
}
else {
$a->config[$uid][$family][$key] = '!<unset>!';
@@ -177,20 +178,23 @@ function set_pconfig($uid,$family,$key,$value) {
global $a;
+ // manage array value
+ $dbvalue = (is_array($value)?serialize($value):$value);
+
if(get_pconfig($uid,$family,$key,true) === false) {
$a->config[$uid][$family][$key] = $value;
$ret = q("INSERT INTO `pconfig` ( `uid`, `cat`, `k`, `v` ) VALUES ( %d, '%s', '%s', '%s' ) ",
intval($uid),
dbesc($family),
dbesc($key),
- dbesc($value)
+ dbesc($dbvalue)
);
if($ret)
return $value;
return $ret;
}
$ret = q("UPDATE `pconfig` SET `v` = '%s' WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s' LIMIT 1",
- dbesc($value),
+ dbesc($dbvalue),
intval($uid),
dbesc($family),
dbesc($key)