aboutsummaryrefslogtreecommitdiff
path: root/actions/plugins/settings/save.php
blob: 2edf58e5b881c78c87d7c381c01fc93934b9cf11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/**
 * Elgg plugin settings save action.
 *
 * @package Elgg
 * @subpackage Core
 */

$params = get_input('params');
$plugin = get_input('plugin');
if (!$plugin_info = load_plugin_manifest($plugin)) {
	register_error(elgg_echo('plugins:settings:save:fail', array($plugin)));
	forward(REFERER);
}

$plugin_name = $plugin_info['name'];

admin_gatekeeper();

$result = false;

$options = array(
	'plugin' => $plugin,
	'manifest' => $plugin_info,
	'settings' => $params
);

// 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(elgg_echo('plugins:settings:save:fail', array($plugin_name)));
			forward(REFERER);
			exit;
		}
	}
}

system_message(elgg_echo('plugins:settings:save:ok', array($plugin_name)));
forward(REFERER);
//
//$trigger = elgg_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(elgg_echo('plugins:settings:save:fail', array($plugin_name)));
//			forward(REFERER);
//			exit;
//		}
//	}
//} elseif ($trigger === FALSE) {
//	register_error(elgg_echo('plugins:settings:save:fail', array($plugin_name)));
//	forward(REFERER);
//}
//
//system_message(elgg_echo('plugins:settings:save:ok', array($plugin_name)));
//forward(REFERER);