aboutsummaryrefslogtreecommitdiff
path: root/mod/notifications/actions/save.php
blob: faee22ef627d186cbc87ce9c6c97985f8d40bf58 (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
<?php

	/**
	 * Elgg notifications plugin save action
	 * 
	 * @package ElggNotifications
	 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
	 * @author Curverider Ltd
	 * @copyright Curverider Ltd 2008-2009
	 * @link http://elgg.com/
	 */

	// Restrict to logged in users
		gatekeeper();
		
	// Get people
		$subscriptions = get_input('subscriptions');
		
	// Clear existing subscriptions
		global $SESSION;
		remove_entity_relationships($SESSION['user']->guid,'notify',false);
		
	// Add new ones
		if (is_array($subscriptions) && !empty($subscriptions)) {
			foreach($subscriptions as $subscription) {
				register_notification_interest($SESSION['user']->guid, $subscription);
			}
		}
		
		system_message(elgg_echo('notifications:subscriptions:success'));
		
		forward($_SERVER['HTTP_REFERER']);

?>