]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Corrected clear_plugin_setting() to only remove a single plugin setting instead of...
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Thu, 28 Jan 2010 23:40:14 +0000 (23:40 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Thu, 28 Jan 2010 23:40:14 +0000 (23:40 +0000)
Added clear_all_plugin_settings() to remove all settings for a plugin.

git-svn-id: http://code.elgg.org/elgg/trunk@3853 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/plugins.php

index 76692b4474d33645bf09230595948650da160459..d7c154b5f2492f552d3add2a4f0e089b82dca6b8 100644 (file)
@@ -53,10 +53,10 @@ class ElggPlugin extends ElggObject {
                $meta = get_private_setting($this->guid, $name);
 
                if ($meta === false) {
-                       // Can't find it, so return null 
+                       // Can't find it, so return null
                        return NULL;
                }
-                       
+
                return $meta;
        }
 
@@ -230,10 +230,10 @@ function load_plugins() {
                                                if (!include($CONFIG->pluginspath . $mod . "/start.php")) {
                                                        // automatically disable the bad plugin
                                                        disable_plugin($mod);
-                                                       
+
                                                        // register error rather than rendering the site unusable with exception
                                                        register_error(sprintf(elgg_echo('PluginException:MisconfiguredPlugin'), $mod));
-                                                       
+
                                                        // continue loading remaining plugins
                                                        continue;
                                                }
@@ -554,11 +554,25 @@ function clear_plugin_setting($name, $plugin_name = "") {
        $plugin = find_plugin_settings($plugin_name);
 
        if ($plugin) {
-               //$plugin->clearMetaData($name);
+               return remove_private_setting($plugin->guid, $name);
+       }
+
+       return FALSE;
+}
+
+/**
+ * Clear all plugin settings.
+ *
+ * @param string $plugin_name Optional plugin name, if not specified then it is detected from where you are calling from.
+ */
+function clear_all_plugin_settings($plugin_name = "") {
+       $plugin = find_plugin_settings($plugin_name);
+
+       if ($plugin) {
                return remove_all_private_settings($plugin->guid);
        }
 
-       return false;
+       return FALSE;
 }
 
 /**