$prefix = true; } } $collection = elgg_get_plugin_setting('default_collection_methods', 'notification_tools'); // Set methods for notifications about friends' activity if ($collection) { $collection_methods = explode(',', $collection); // Here we just mark the default methods. The core notification plugin // will take care of creating the actual 'notify' relationships // between user and each friends. foreach ($collection_methods as $method) { $setting_name = "collections_notifications_preferences_{$method}"; // The -1 seems like a weird value but that's what the core // is using for whatever reason. $user->$setting_name = '-1'; } } $user->save(); return true; } /** * Enable default notification methods when user joins a group * * @param string $event 'join' * @param string $type 'group' * @param array $params Array containing ElggUser and ElggGroup */ function notification_tools_enable_for_new_group_member($event, $type, $params) { $group = $params['group']; $user = $params['user']; $methods = elgg_get_plugin_setting('default_group_methods', 'notification_tools'); if (empty($methods)) { return true; } if (!$group instanceof ElggGroup) { return true; } if (!$user instanceof ElggUser) { return true; } $methods = explode(',', $methods); foreach ($methods as $method) { add_entity_relationship($user->guid, "notify{$method}", $group->guid); } return true; }