aboutsummaryrefslogtreecommitdiff
path: root/mod/opendd/actions/opendd/feed/subscribe.php
blob: d96c93218996101dfec097be0d61605008d475ec (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
<?php
	/**
	 * Elgg OpenDD aggregator
	 * 
	 * @package ElggOpenDD
	 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
	 * @author Marcus Povey
	 * @copyright Curverider Ltd 2008
	 * @link http://elgg.com/
	 */	

	// Load configuration
	global $CONFIG;
	
	gatekeeper();
	
	$input = array();
	foreach($CONFIG->opendd as $shortname => $valuetype) {
		$input[$shortname] = get_input($shortname);
		if ($valuetype == 'tags')
			$input[$shortname] = string_to_tag_array($input[$shortname]);
	}
	
	$feed_guid = get_input('feed_guid');
	$feed = NULL;
	if ($feed_guid)
		$feed = get_entity($feed_guid);
	else
	{
		$feed = new ElggObject();
		$feed->subtype = 'oddfeed';
	}
	
	if (!($feed instanceof ElggObject))
	{
		register_error(elgg_echo("opendd:notobject"));
		
		forward($_SERVER['HTTP_REFERER']);
		exit;
	}
	
	// Assume we can edit or this is a new group
	if (sizeof($input) > 0)
	{
		foreach($input as $shortname => $value) {
			$feed->$shortname = $value;
		}
	}
	
	
	if ($feed->save())
		system_message(elgg_echo("opendd:feedok"));
	else
		register_error(elgg_echo("opendd:feednotok"));
	
	forward($_SERVER['HTTP_REFERER']);
	exit;
?>