diff options
Diffstat (limited to 'actions/plugins/settings')
-rw-r--r-- | actions/plugins/settings/save.php | 50 |
1 files changed, 40 insertions, 10 deletions
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 |