From 580fb9fc3a9da6e4c567276152bdef6885644eb4 Mon Sep 17 00:00:00 2001 From: kmorimatsu Date: Fri, 6 Apr 2007 19:37:07 +0000 Subject: [PATCH] Fix bug, getOption() values are not reflected after changing them by using admin page. git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/nucleus-jp/trunk@249 1ca29b6e-896d-4ea0-84a5-967f57386b96 --- euc/nucleus/libs/MANAGER.php | 22 ++++++++++++++++++++-- euc/nucleus/libs/PLUGIN.php | 18 +++++++++++++++--- utf8/nucleus/libs/MANAGER.php | 22 ++++++++++++++++++++-- utf8/nucleus/libs/PLUGIN.php | 18 +++++++++++++++--- 4 files changed, 70 insertions(+), 10 deletions(-) diff --git a/euc/nucleus/libs/MANAGER.php b/euc/nucleus/libs/MANAGER.php index 5a0312c..5cf440d 100755 --- a/euc/nucleus/libs/MANAGER.php +++ b/euc/nucleus/libs/MANAGER.php @@ -20,8 +20,8 @@ * * @license http://nucleuscms.org/license.txt GNU General Public License * @copyright Copyright (C) 2002-2007 The Nucleus Group - * @version $Id: MANAGER.php,v 1.4 2007-03-27 12:13:56 kimitake Exp $ - * $NucleusJP: MANAGER.php,v 1.7 2007/02/04 06:28:46 kimitake Exp $ + * @version $Id: MANAGER.php,v 1.5 2007-04-06 19:37:07 kmorimatsu Exp $ + * $NucleusJP: MANAGER.php,v 1.4 2007/03/27 12:13:56 kimitake Exp $ */ class MANAGER { @@ -275,6 +275,24 @@ class MANAGER { } /** + * checks if the given plugin IS loaded or not + */ + function &pluginLoaded($name) { + $plugin =& $this->plugins[$name]; + return $plugin; + } + function &pidLoaded($pid) { + $plugin=false; + reset($this->plugins); + while (list($name) = each($this->plugins)) { + if ($pid!=$this->plugins[$name]->getId()) continue; + $plugin= & $this->plugins[$name]; + break; + } + return $plugin; + } + + /** * checks if the given plugin IS installed or not */ function pluginInstalled($name) { diff --git a/euc/nucleus/libs/PLUGIN.php b/euc/nucleus/libs/PLUGIN.php index 6251c3c..069a719 100755 --- a/euc/nucleus/libs/PLUGIN.php +++ b/euc/nucleus/libs/PLUGIN.php @@ -17,8 +17,8 @@ * * @license http://nucleuscms.org/license.txt GNU General Public License * @copyright Copyright (C) 2002-2007 The Nucleus Group - * @version $Id: PLUGIN.php,v 1.6 2007-03-30 22:18:54 kmorimatsu Exp $ - * $NucleusJP: PLUGIN.php,v 1.5 2007/03/27 12:13:56 kimitake Exp $ + * @version $Id: PLUGIN.php,v 1.7 2007-04-06 19:37:07 kmorimatsu Exp $ + * $NucleusJP: PLUGIN.php,v 1.6 2007/03/30 22:18:54 kmorimatsu Exp $ */ class NucleusPlugin { @@ -292,6 +292,10 @@ $this->plugin_options = 0; } + function clearOptionValueCache(){ + $this->_aOptionValues = array(); + } + // private function _createOption($context, $name, $desc, $type, $defValue, $typeExtras = '') { // create in plugin_option_desc @@ -563,7 +567,10 @@ $res = sql_query($query); if ($o = mysql_fetch_object($res)) { - foreach ($values as $contextid => $value) { + foreach ($values as $key => $value) { + // avoid overriding the key used by foreach statement + $contextid=$key; + // retreive any metadata $meta = NucleusPlugin::getOptionMeta($o->oextra); @@ -603,6 +610,11 @@ } } } + // clear option value cache if the plugin object is already loaded + if (is_object($o)) { + $plugin=& $manager->pidLoaded($o->opid); + if ($plugin) $plugin->clearOptionValueCache(); + } } } diff --git a/utf8/nucleus/libs/MANAGER.php b/utf8/nucleus/libs/MANAGER.php index da48584..055e6a6 100755 --- a/utf8/nucleus/libs/MANAGER.php +++ b/utf8/nucleus/libs/MANAGER.php @@ -20,8 +20,8 @@ * * @license http://nucleuscms.org/license.txt GNU General Public License * @copyright Copyright (C) 2002-2007 The Nucleus Group - * @version $Id: MANAGER.php,v 1.7 2007-02-04 06:28:46 kimitake Exp $ - * $NucleusJP: MANAGER.php,v 1.6 2006/07/20 08:01:52 kimitake Exp $ + * @version $Id: MANAGER.php,v 1.8 2007-04-06 19:36:29 kmorimatsu Exp $ + * $NucleusJP: MANAGER.php,v 1.7 2007/02/04 06:28:46 kimitake Exp $ */ class MANAGER { @@ -275,6 +275,24 @@ class MANAGER { } /** + * checks if the given plugin IS loaded or not + */ + function &pluginLoaded($name) { + $plugin =& $this->plugins[$name]; + return $plugin; + } + function &pidLoaded($pid) { + $plugin=false; + reset($this->plugins); + while (list($name) = each($this->plugins)) { + if ($pid!=$this->plugins[$name]->getId()) continue; + $plugin= & $this->plugins[$name]; + break; + } + return $plugin; + } + + /** * checks if the given plugin IS installed or not */ function pluginInstalled($name) { diff --git a/utf8/nucleus/libs/PLUGIN.php b/utf8/nucleus/libs/PLUGIN.php index ddd33ef..060c254 100755 --- a/utf8/nucleus/libs/PLUGIN.php +++ b/utf8/nucleus/libs/PLUGIN.php @@ -17,8 +17,8 @@ * * @license http://nucleuscms.org/license.txt GNU General Public License * @copyright Copyright (C) 2002-2007 The Nucleus Group - * @version $Id: PLUGIN.php,v 1.10 2007-03-30 22:18:28 kmorimatsu Exp $ - * $NucleusJP: PLUGIN.php,v 1.9 2007/03/13 05:03:23 shizuki Exp $ + * @version $Id: PLUGIN.php,v 1.11 2007-04-06 19:36:29 kmorimatsu Exp $ + * $NucleusJP: PLUGIN.php,v 1.10 2007/03/30 22:18:28 kmorimatsu Exp $ */ class NucleusPlugin { @@ -292,6 +292,10 @@ $this->plugin_options = 0; } + function clearOptionValueCache(){ + $this->_aOptionValues = array(); + } + // private function _createOption($context, $name, $desc, $type, $defValue, $typeExtras = '') { // create in plugin_option_desc @@ -563,7 +567,10 @@ $res = sql_query($query); if ($o = mysql_fetch_object($res)) { - foreach ($values as $contextid => $value) { + foreach ($values as $key => $value) { + // avoid overriding the key used by foreach statement + $contextid=$key; + // retreive any metadata $meta = NucleusPlugin::getOptionMeta($o->oextra); @@ -603,6 +610,11 @@ } } } + // clear option value cache if the plugin object is already loaded + if (is_object($o)) { + $plugin=& $manager->pidLoaded($o->opid); + if ($plugin) $plugin->clearOptionValueCache(); + } } } -- 2.11.0