From 68c9e840b5c9aee941f60cb08c1f326dca7c4f13 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 25 Dec 2016 08:47:48 -0800 Subject: [PATCH] Plugin Pref import routine. --- e107_handlers/xml_class.php | 52 ++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/e107_handlers/xml_class.php b/e107_handlers/xml_class.php index 56c661a1e..e07ea0ccf 100644 --- a/e107_handlers/xml_class.php +++ b/e107_handlers/xml_class.php @@ -1023,12 +1023,16 @@ class xmlClass * Return an Array of core preferences from e107 XML Dump data * * @param array $XMLData Raw XML e107 Export Data - * @param string $prefType [optional] the type of core pref: core|emote|ipool|menu etc. + * @param string $prefType [optional] the type of core pref: core|emote|ipool|menu etc or plugin-folder name + * @param string $mode core|plugin * @return array preference array equivalent to the old $pref global; */ - public function e107ImportPrefs($XMLData, $prefType='core') + public function e107ImportPrefs($XMLData, $prefType='core', $mode='core') { - if(!vartrue($XMLData['prefs'][$prefType])) + + $key = ($mode === 'core') ? 'prefs' : 'pluginPrefs'; + + if(!vartrue($XMLData[$key][$prefType])) { return array(); } @@ -1036,7 +1040,7 @@ class xmlClass //$mes = eMessage::getInstance(); $pref = array(); - foreach($XMLData['prefs'][$prefType] as $val) + foreach($XMLData[$key][$prefType] as $val) { $name = $val['@attributes']['name']; // if(strpos($val['@value'], 'array (') === 0) @@ -1083,8 +1087,10 @@ class xmlClass } $ret = array(); - - if(vartrue($xmlArray['prefs'])) // Save Core Prefs + + // ----------------- Save Core Prefs --------------------- + + if(!empty($xmlArray['prefs'])) { foreach($xmlArray['prefs'] as $type=>$array) { @@ -1112,6 +1118,40 @@ class xmlClass } } + + // --------------- Save Plugin Prefs --------------------- + + if(!empty($xmlArray['pluginPrefs'])) + { + foreach($xmlArray['pluginPrefs'] as $type=>$array) + { + + $pArray = $this->e107ImportPrefs($xmlArray,$type, 'plugin'); + + if($mode == 'replace') // merge with existing, add new + { + e107::getPlugConfig($type)->setPref($pArray); + } + else // 'add' only new prefs + { + foreach ($pArray as $pname => $pval) + { + e107::getPlugConfig($type)->add($pname, $pval); // don't parse x/y/z + } + } + + if($debug == false) + { + e107::getPlugConfig($type) + ->setParam('nologs', $noLogs) + ->save(FALSE,TRUE); + } + } + } + + + + if(vartrue($xmlArray['database'])) { foreach($xmlArray['database']['dbTable'] as $val)