From ff31226fdeb972aac2f37f0098240cb366a9bb26 Mon Sep 17 00:00:00 2001 From: brettp Date: Wed, 5 May 2010 19:14:48 +0000 Subject: Merged 18_new_admin branch to trunk. git-svn-id: http://code.elgg.org/elgg/trunk@5977 36083f99-b078-4883-b0ff-0f9b5a30f544 --- actions/plugins/settings/save.php | 50 +++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 10 deletions(-) (limited to 'actions/plugins') diff --git a/actions/plugins/settings/save.php b/actions/plugins/settings/save.php index bbbb6a367..6aa47b60e 100644 --- a/actions/plugins/settings/save.php +++ b/actions/plugins/settings/save.php @@ -10,22 +10,52 @@ $params = get_input('params'); $plugin = get_input('plugin'); +if (!$plugin_info = load_plugin_manifest($plugin)) { + register_error(sprintf(elgg_echo('plugins:settings:save:fail'), $plugin)); + forward($_SERVER['HTTP_REFERER']); +} + +$plugin_name = $plugin_info['name']; -gatekeeper(); +admin_gatekeeper(); $result = false; -foreach ($params as $k => $v) { - // Save - $result = set_plugin_setting($k, $v, $plugin); +$options = array( + 'plugin' => $plugin, + 'manifest' => $plugin_info, + 'settings' => $params +); - // Error? - if (!$result) { - register_error(sprintf(elgg_echo('plugins:settings:save:fail'), $plugin)); - forward($_SERVER['HTTP_REFERER']); - exit; +// allow a plugin to override the save action for their settings +if (elgg_action_exist("settings/$plugin/save")) { + action("settings/$plugin/save"); +} else { + foreach ($params as $k => $v) { + if (!$result = set_plugin_setting($k, $v, $plugin)) { + register_error(sprintf(elgg_echo('plugins:settings:save:fail'), $plugin_name)); + forward($_SERVER['HTTP_REFERER']); + exit; + } } } -system_message(sprintf(elgg_echo('plugins:settings:save:ok'), $plugin)); +system_message(sprintf(elgg_echo('plugins:settings:save:ok'), $plugin_name)); forward($_SERVER['HTTP_REFERER']); +// +//$trigger = trigger_plugin_hook('plugin:save_settings', $plugin, $options, NULL); +//if ($trigger === NULL) { +// foreach ($params as $k => $v) { +// if (!$result = set_plugin_setting($k, $v, $plugin)) { +// register_error(sprintf(elgg_echo('plugins:settings:save:fail'), $plugin_name)); +// forward($_SERVER['HTTP_REFERER']); +// exit; +// } +// } +//} elseif ($trigger === FALSE) { +// register_error(sprintf(elgg_echo('plugins:settings:save:fail'), $plugin_name)); +// forward($_SERVER['HTTP_REFERER']); +//} +// +//system_message(sprintf(elgg_echo('plugins:settings:save:ok'), $plugin_name)); +//forward($_SERVER['HTTP_REFERER']); \ No newline at end of file -- cgit v1.2.3