From c397eaafc8bc1c3e78dc062eda77e4aeedab331c Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 28 Mar 2012 12:26:11 +0200 Subject: [PATCH] Fixing bug when plugin settings are not loaded everywhere see #4559 --- main/inc/lib/plugin.lib.php | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/main/inc/lib/plugin.lib.php b/main/inc/lib/plugin.lib.php index e511ab2320..3fb51d5bc1 100644 --- a/main/inc/lib/plugin.lib.php +++ b/main/inc/lib/plugin.lib.php @@ -161,27 +161,23 @@ class AppPlugin { //Load the plugin information //The plugin_info variable is available inside the plugin index - $plugin_info = $this->get_plugin_info($plugin_name); + $plugin_info = $this->get_plugin_info($plugin_name); //We also where the plugin is $plugin_info['current_region'] = $region; // Loading the plugin/XXX/index.php file - $plugin_file = api_get_path(SYS_PLUGIN_PATH)."$plugin_name/index.php"; + $plugin_file = api_get_path(SYS_PLUGIN_PATH)."$plugin_name/index.php"; + if (file_exists($plugin_file)) { require $plugin_file; - //We set the $template variable in order to use smarty - if (isset($_template) && !empty($_template)) { - /* - foreach ($_template as $key =>$value) { - $template->assign($plugin_name[$key], $value); - } - */ + //We set the $template variable in order to use Smarty + if (isset($_template) && !empty($_template)) { $template->assign($plugin_name, $_template); } - //Loading the smarty template files if exists + //Loading the Smarty template plugin files if exists $template_list = array(); if (isset($plugin_info) && isset($plugin_info['templates'])) { $template_list = $plugin_info['templates']; @@ -205,31 +201,31 @@ class AppPlugin { * * Loads plugin info * @staticvar array $plugin_data - * @param type $plugin_name - * @param type bool + * @param string plugin name + * @param bool load from DB or from the static array * @todo filter setting_form * @return array */ function get_plugin_info($plugin_name, $forced = false) { static $plugin_data = array(); - if (isset($plugin_data[$plugin_name]) && $forced == false) { + if (isset($plugin_data[$plugin_name]) && $forced == false) { return $plugin_data[$plugin_name]; } else { - $plugin_file = api_get_path(SYS_PLUGIN_PATH)."$plugin_name/plugin.php"; + $plugin_file = api_get_path(SYS_PLUGIN_PATH)."$plugin_name/plugin.php"; $plugin_info = array(); if (file_exists($plugin_file)) { require $plugin_file; - } - $plugin_data[$plugin_name] = $plugin_info; + } //extra options $plugin_settings = api_get_settings_params(array("subkey = ? AND category = ? AND type = ? " => - array($plugin_name, 'Plugins','setting'))); + array($plugin_name, 'Plugins','setting'))); $settings_filtered = array(); foreach ($plugin_settings as $item) { $settings_filtered[$item['variable']] = $item['selected_value']; } - $plugin_info['settings'] = $settings_filtered; + $plugin_info['settings'] = $settings_filtered; + $plugin_data[$plugin_name] = $plugin_info; return $plugin_info; } }