aboutsummaryrefslogtreecommitdiff
path: root/mod/notifications/actions/groupsave.php
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-05-13 01:11:33 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-05-13 01:11:33 +0000
commit402134632f0d60e9644d0121c2a84db4a4c1a169 (patch)
treef6bf653ec6b8a955ec77ff18fd9199583b79cfc0 /mod/notifications/actions/groupsave.php
parent4ae064871ba9dca9f03e095671db48815632d070 (diff)
downloadelgg-402134632f0d60e9644d0121c2a84db4a4c1a169.tar.gz
elgg-402134632f0d60e9644d0121c2a84db4a4c1a169.tar.bz2
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
Diffstat (limited to 'mod/notifications/actions/groupsave.php')
-rw-r--r--mod/notifications/actions/groupsave.php73
1 files changed, 35 insertions, 38 deletions
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 @@
<?php
- /**
- * Elgg notifications group save
- *
- * @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-2010
- * @link http://elgg.com/
- */
+/**
+ * Elgg notifications group save
+ *
+ * @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-2010
+ * @link http://elgg.com/
+ */
- // Restrict to logged in users
- gatekeeper();
-
- // Load important global vars
- global $SESSION;
- global $NOTIFICATION_HANDLERS;
+// Load important global vars
+global $NOTIFICATION_HANDLERS;
- // 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' => $_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']);