From 94a86019bbb2142821cded619ab83bcd460ba4e5 Mon Sep 17 00:00:00 2001 From: marcus Date: Fri, 20 Jun 2008 10:17:04 +0000 Subject: Refs #61 - Added ability to find settings for plugins other than the one you are in. git-svn-id: https://code.elgg.org/elgg/trunk@1013 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/plugins.php | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'engine/lib/plugins.php') diff --git a/engine/lib/plugins.php b/engine/lib/plugins.php index 46b42f929..0d19bc049 100644 --- a/engine/lib/plugins.php +++ b/engine/lib/plugins.php @@ -154,11 +154,16 @@ /** * Shorthand function for finding the plugin settings. + * + * @param string $plugin_name Optional plugin name, if not specified then it is detected from where you + * are calling from. */ - function find_plugin_settings() + function find_plugin_settings($plugin_name = "") { $plugins = get_entities('object', 'plugin'); - $plugin_name = get_plugin_name(); + $plugin_name = sanitise_string($plugin_name); + if (!$plugin_name) + $plugin_name = get_plugin_name(); if ($plugins) { @@ -175,10 +180,11 @@ * * @param string $name The name - note, can't be "title". * @param mixed $value The value. + * @param string $plugin_name Optional plugin name, if not specified then it is detected from where you are calling from. */ - function set_plugin_setting($name, $value) + function set_plugin_setting($name, $value, $plugin_name = "") { - $plugin = find_plugin_settings(); + $plugin = find_plugin_settings($plugin_name); if (!$plugin) $plugin = new ElggPlugin(); @@ -197,10 +203,11 @@ * Get setting for a plugin. * * @param string $name The name. + * @param string $plugin_name Optional plugin name, if not specified then it is detected from where you are calling from. */ - function get_plugin_setting($name) + function get_plugin_setting($name, $plugin_name = "") { - $plugin = find_plugin_settings(); + $plugin = find_plugin_settings($plugin_name); if ($plugin) return $plugin->$name; @@ -212,10 +219,11 @@ * Clear a plugin setting. * * @param string $name The name. + * @param string $plugin_name Optional plugin name, if not specified then it is detected from where you are calling from. */ - function clear_plugin_setting($name) + function clear_plugin_setting($name, $plugin_name = "") { - $plugin = find_plugin_settings(); + $plugin = find_plugin_settings($plugin_name); if ($plugin) return $plugin->clearMetaData($name); -- cgit v1.2.3