aboutsummaryrefslogtreecommitdiff
path: root/mod/notifications/actions
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
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')
-rw-r--r--mod/notifications/actions/groupsave.php73
-rw-r--r--mod/notifications/actions/save.php70
2 files changed, 68 insertions, 75 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']);
diff --git a/mod/notifications/actions/save.php b/mod/notifications/actions/save.php
index a4a5903f9..f8b533d23 100644
--- a/mod/notifications/actions/save.php
+++ b/mod/notifications/actions/save.php
@@ -1,42 +1,38 @@
<?php
- /**
- * Elgg notifications
- *
- * @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
+ *
+ * @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();
-
- global $SESSION;
-
- global $NOTIFICATION_HANDLERS;
- foreach($NOTIFICATION_HANDLERS as $method => $foo) {
- $subscriptions[$method] = get_input($method.'subscriptions');
- $personal[$method] = get_input($method.'personal');
- $collections[$method] = get_input($method.'collections');
-
- $metaname = 'collections_notifications_preferences_' . $method;
- $_SESSION['user']->$metaname = $collections[$method];
- set_user_notification_setting($_SESSION['user']->guid, $method, ($personal[$method] == '1') ? true : false);
- remove_entity_relationships($SESSION['user']->guid,'notify' . $method, false, 'user');
- }
-
- // Add new ones
- foreach($subscriptions as $key => $subscription)
- if (is_array($subscription) && !empty($subscription)) {
- foreach($subscription as $subscriptionperson) {
- add_entity_relationship($_SESSION['user']->guid, 'notify' . $key, $subscriptionperson);
- }
+$user = get_loggedin_user();
+
+global $NOTIFICATION_HANDLERS;
+foreach($NOTIFICATION_HANDLERS as $method => $foo) {
+ $subscriptions[$method] = get_input($method.'subscriptions');
+ $personal[$method] = get_input($method.'personal');
+ $collections[$method] = get_input($method.'collections');
+
+ $metaname = 'collections_notifications_preferences_' . $method;
+ $user->$metaname = $collections[$method];
+ set_user_notification_setting($user->guid, $method, ($personal[$method] == '1') ? true : false);
+ remove_entity_relationships($user->guid, 'notify' . $method, false, 'user');
+}
+
+// Add new ones
+foreach($subscriptions as $key => $subscription) {
+ if (is_array($subscription) && !empty($subscription)) {
+ foreach($subscription as $subscriptionperson) {
+ add_entity_relationship($user->guid, 'notify' . $key, $subscriptionperson);
}
-
- 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']);