diff options
author | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-01-19 17:46:50 +0000 |
---|---|---|
committer | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-01-19 17:46:50 +0000 |
commit | aae8d757e4fd68c832ad7fbc45879eb96c9672ff (patch) | |
tree | 506beecae7adb48b9f5f77b37ba5708d0954cf24 | |
parent | bc962af8cc5631e1b1a3d6c79ffc1ca3696a4736 (diff) | |
download | elgg-aae8d757e4fd68c832ad7fbc45879eb96c9672ff.tar.gz elgg-aae8d757e4fd68c832ad7fbc45879eb96c9672ff.tar.bz2 |
Closes #697: Events triggered when plugin settings are updated.
git-svn-id: https://code.elgg.org/elgg/trunk@2580 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r-- | actions/plugins/settings/save.php | 2 | ||||
-rw-r--r-- | actions/plugins/usersettings/save.php | 2 | ||||
-rw-r--r-- | engine/lib/plugins.php | 30 |
3 files changed, 24 insertions, 10 deletions
diff --git a/actions/plugins/settings/save.php b/actions/plugins/settings/save.php index e21bc1122..f503c9e9f 100644 --- a/actions/plugins/settings/save.php +++ b/actions/plugins/settings/save.php @@ -35,7 +35,7 @@ } // An event to tell any interested plugins of the change is settings - trigger_elgg_event('plugin_settings_save', $plugin, find_plugin_settings($plugin)); + //trigger_elgg_event('plugin_settings_save', $plugin, find_plugin_settings($plugin)); // replaced by plugin:setting event system_message(sprintf(elgg_echo('plugins:settings:save:ok'), $plugin)); forward($_SERVER['HTTP_REFERER']); diff --git a/actions/plugins/usersettings/save.php b/actions/plugins/usersettings/save.php index 342e6c444..c30dc02ca 100644 --- a/actions/plugins/usersettings/save.php +++ b/actions/plugins/usersettings/save.php @@ -35,7 +35,7 @@ } // An event to tell any interested plugins of the change is settings - trigger_elgg_event('plugin_usersettings_save', $plugin, find_plugin_settings($plugin)); + //trigger_elgg_event('plugin_usersettings_save', $plugin, find_plugin_settings($plugin)); // replaced by plugin:usersetting event system_message(sprintf(elgg_echo('plugins:usersettings:save:ok'), $plugin)); forward($_SERVER['HTTP_REFERER']); diff --git a/engine/lib/plugins.php b/engine/lib/plugins.php index a6d10524a..639a62354 100644 --- a/engine/lib/plugins.php +++ b/engine/lib/plugins.php @@ -411,7 +411,13 @@ $prefix = "plugin:settings:$plugin_name:$name"; //$user->$prefix = $value; //$user->save(); - return set_private_setting($user->guid, $prefix, $value); + + if (trigger_elgg_event('plugin:usersetting', 'user', array( + 'plugin' => $plugin_name, + 'name' => $name, + 'value' => $value + ))) + return set_private_setting($user->guid, $prefix, $value); } return false; @@ -452,7 +458,8 @@ * @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, $plugin_name = "") - { + { + if (!$plugin_name) $plugin_name = get_plugin_name(); $plugin = find_plugin_settings($plugin_name); if (!$plugin) @@ -460,12 +467,19 @@ if ($name!='title') { - $plugin->title = $plugin_name; - $plugin->access_id = 2; - $plugin->save(); - $plugin->$name = $value; - - return $plugin->getGUID(); + if (trigger_elgg_event('plugin:setting', 'plugin', array( + 'plugin' => $plugin_name, + 'name' => $name, + 'value' => $value + ))) + { + $plugin->title = $plugin_name; + $plugin->access_id = 2; + $plugin->save(); + $plugin->$name = $value; + + return $plugin->getGUID(); + } } return false; |