From d269215a421549e9aa04370db351a97ce4d455bf Mon Sep 17 00:00:00 2001 From: David Severwright Date: Thu, 18 Dec 2014 16:46:10 +0000 Subject: Adding support for local plugin json to override the global stuff --- graph.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'graph.php') diff --git a/graph.php b/graph.php index 8eec2ec..1771274 100644 --- a/graph.php +++ b/graph.php @@ -35,12 +35,24 @@ if ($plugin == 'aggregation') { } # plugin json -if (function_exists('json_decode') && file_exists('plugin/'.$plugin.'.json')) { - $json = file_get_contents('plugin/'.$plugin.'.json'); - $plugin_json = json_decode($json, true); +if(function_exists('json_decode')) +{ + if (file_exists('plugin/'.$plugin.'.json')) { + $json = file_get_contents('plugin/'.$plugin.'.json'); + $plugin_json = json_decode($json, true); + + if (is_null($plugin_json)) + error_log('CGP Error: invalid json in plugin/'.$plugin.'.json'); + } + if (file_exists('conf/plugin/'.$plugin.'.json')) { + $json = file_get_contents('conf/plugin/'.$plugin.'.json'); + $user_plugin_json = json_decode($json, true); + + if (is_null($user_plugin_json)) + error_log('CGP Error: invalid json in conf/plugin/'.$plugin.'.json'); - if (is_null($plugin_json)) - error_log('CGP Error: invalid json in plugin/'.$plugin.'.json'); + $plugin_json = array_replace_recursive($plugin_json, $user_plugin_json); + } } if (!isset($plugin_json[$type]['type'])) -- cgit v1.1