aboutsummaryrefslogtreecommitdiff
path: root/mod/notifications/start.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/notifications/start.php')
-rw-r--r--mod/notifications/start.php28
1 files changed, 26 insertions, 2 deletions
diff --git a/mod/notifications/start.php b/mod/notifications/start.php
index 873095b8b..fa36d5d69 100644
--- a/mod/notifications/start.php
+++ b/mod/notifications/start.php
@@ -23,6 +23,10 @@ function notifications_plugin_init() {
// Unset the default notification settings
unregister_plugin_hook('usersettings:save', 'user', 'notification_user_settings_save');
elgg_unextend_view('usersettings/user', 'notifications/settings/usersettings');
+
+ // update notifications based on relationships changing
+ register_elgg_event_handler('delete', 'member', 'notifications_relationship_remove');
+ register_elgg_event_handler('delete', 'friend', 'notifications_relationship_remove');
}
/**
@@ -52,7 +56,7 @@ function notifications_page_handler($page) {
}
/**
- * Notification settings page setup function
+ * Notification settings sidebar menu
*
*/
function notifications_plugin_pagesetup() {
@@ -65,9 +69,29 @@ function notifications_plugin_pagesetup() {
}
}
+/**
+ * Update notifications when a relationship is deleted
+ *
+ * @param string $event
+ * @param string $object_type
+ * @param object $relationship
+ */
+function notifications_relationship_remove($event, $object_type, $relationship) {
+ global $NOTIFICATION_HANDLERS;
+
+ $user_guid = $relationship->guid_one;
+ $object_guid = $relationship->guid_two;
+
+ // loop through all notification types
+ foreach($NOTIFICATION_HANDLERS as $method => $foo) {
+ remove_entity_relationship($user_guid, "notify{$method}", $object_guid);
+ }
+}
+
+
register_elgg_event_handler('init', 'system', 'notifications_plugin_init', 1000);
-// Register action
+
register_action("notificationsettings/save", FALSE, $CONFIG->pluginspath . "notifications/actions/save.php");
register_action("notificationsettings/groupsave", FALSE, $CONFIG->pluginspath . "notifications/actions/groupsave.php");