aboutsummaryrefslogtreecommitdiff
path: root/actions/settings.php
blob: 29a77577fa64d282a613d99de3a7415c3bf53731 (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
<?php
	/**
	 * Save settings of Tidypics
	 * 
	 */

	global $CONFIG;

	gatekeeper();
	action_gatekeeper();


	// Params array (text boxes and drop downs)
	$params = get_input('params');
	$result = false;
	foreach ($params as $k => $v) {
		if (!set_plugin_setting($k, $v, 'tidypics')) {
			register_error(sprintf(elgg_echo('plugins:settings:save:fail'), 'tidypics'));
			forward($_SERVER['HTTP_REFERER']);
		}
	}

	// check boxes
	if (is_array(get_input('download_link'))) // this can be done due to way Elgg uses checkboxes
		set_plugin_setting('download_link', 'enabled', 'tidypics');
	else
		set_plugin_setting('download_link', 'disabled', 'tidypics');
	
	if (is_array(get_input('tagging')))
		set_plugin_setting('tagging', 'enabled', 'tidypics');
	else
		set_plugin_setting('tagging', 'disabled', 'tidypics');


	// image sizes
	$image_sizes = array();
	$image_sizes['large_image_width'] = get_input('large_thumb_width');
	$image_sizes['large_image_height'] = get_input('large_thumb_height');
	$image_sizes['small_image_width'] = get_input('small_thumb_width');
	$image_sizes['small_image_height'] = get_input('small_thumb_height');
	$image_sizes['thumb_image_width'] = get_input('thumb_width');
	$image_sizes['thumb_image_height'] = get_input('thumb_height');
	set_plugin_setting('image_sizes', serialize($image_sizes), 'tidypics');


	
	system_message(elgg_echo('tidypics:settings:save:ok'));
	
	forward($_SERVER['HTTP_REFERER']);
?>