From d09df2804057e90dff97ea6ba06a811c4f61a6e4 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 26 Apr 2011 16:50:42 -0400 Subject: [PATCH] utility functions for setting config options in memory --- lib/util.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/util.php b/lib/util.php index 07a344633b..f830d9b643 100644 --- a/lib/util.php +++ b/lib/util.php @@ -1860,6 +1860,30 @@ function common_config($main, $sub) array_key_exists($sub, $config[$main])) ? $config[$main][$sub] : false; } +function common_config_set($main, $sub, $value) +{ + global $config; + if (!array_key_exists($main, $config)) { + $config[$main] = array(); + } + $config[$main][$sub] = $value; +} + +function common_config_append($main, $sub, $value) +{ + global $config; + if (!array_key_exists($main, $config)) { + $config[$main] = array(); + } + if (!array_key_exists($sub, $config[$main])) { + $config[$main][$sub] = array(); + } + if (!is_array($config[$main][$sub])) { + $config[$main][$sub] = array($config[$main][$sub]); + } + array_push($config[$main][$sub], $value); +} + /** * Pull arguments from a GET/POST/REQUEST array with first-level input checks: * strips "magic quotes" slashes if necessary, and kills invalid UTF-8 strings. -- 2.39.5