From 402134632f0d60e9644d0121c2a84db4a4c1a169 Mon Sep 17 00:00:00 2001 From: cash Date: Thu, 13 May 2010 01:11:33 +0000 Subject: merged in notifications plugin cleanup from 1.7 branch: [5962], [5978] - [5980], [6000] git-svn-id: http://code.elgg.org/elgg/trunk@6020 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/notifications/actions/groupsave.php | 73 ++++++++++++++++----------------- 1 file changed, 35 insertions(+), 38 deletions(-) (limited to 'mod/notifications/actions/groupsave.php') diff --git a/mod/notifications/actions/groupsave.php b/mod/notifications/actions/groupsave.php index ca250c7fd..84154930e 100644 --- a/mod/notifications/actions/groupsave.php +++ b/mod/notifications/actions/groupsave.php @@ -1,44 +1,41 @@ 'member', 'relationship_guid' => $_SESSION['user']->guid, 'types' => 'group', 'limit' => 9999))) { - foreach($groupmemberships as $groupmembership) - $groups[] = $groupmembership->guid; - } - - foreach($NOTIFICATION_HANDLERS as $method => $foo) { - $subscriptions[$method] = get_input($method.'subscriptions'); - $personal[$method] = get_input($method.'personal'); - $collections[$method] = get_input($method.'collections'); - if (!empty($groups)) - foreach($groups as $group) - if (in_array($group,$subscriptions[$method])) { - add_entity_relationship($SESSION['user']->guid,'notify'.$method,$group); - } else { - remove_entity_relationship($SESSION['user']->guid,'notify'.$method,$group); - } +// Get group memberships and condense them down to an array of guids +$groups = array(); +if ($groupmemberships = elgg_get_entities_from_relationship(array('relationship' => 'member', 'relationship_guid' => get_loggedin_userid(), 'types' => 'group', 'limit' => 9999))) { + foreach($groupmemberships as $groupmembership) { + $groups[] = $groupmembership->guid; + } +} + +foreach($NOTIFICATION_HANDLERS as $method => $foo) { + $subscriptions[$method] = get_input($method.'subscriptions'); + $personal[$method] = get_input($method.'personal'); + $collections[$method] = get_input($method.'collections'); + if (!empty($groups)) { + foreach($groups as $group) { + if (in_array($group,$subscriptions[$method])) { + add_entity_relationship(get_loggedin_userid(), 'notify'.$method, $group); + } else { + remove_entity_relationship(get_loggedin_userid(), 'notify'.$method, $group); + } } - - system_message(elgg_echo('notifications:subscriptions:success')); - - forward($_SERVER['HTTP_REFERER']); + } +} + +system_message(elgg_echo('notifications:subscriptions:success')); -?> \ No newline at end of file +forward($_SERVER['HTTP_REFERER']); -- cgit v1.2.3