There is a critical bug in og_notifications_add_form_submit() - the form used to create group subscriptions.
The module calls for a variable that is never set anywhere. A foreach is used to iterate the variable, but since it doesn't exist, nothing happens, and you're still given a success message that the subscription was saved.
function og_notifications_add_form_submit($form, &$form_state) {
$form_values = $form_state['values'];
$subscription = new stdClass;
$subscription->type = 'grouptype';
$subscription->uid = $form_values['account']->uid;
$subscription->send_interval = $form_values['subscription']['send_interval'][0];
$subscription->send_method = isset($form_values['send_method']) ? $form_values['send_method'] :
$form_values['subscription']['send_method'][0];
// String cast due to notifications requiring it as the value field is
// a varchar.
$subscription->fields = array('group' => (string) $form_values['subscription']['group'][0], 'type' =>
$form_values['subscription']['node_type'][0]);
if ($form_values['subscription']['node_type'][0] == 'all') {
/** THE PROBLEM IS RIGHT BELOW HERE **/
$types = array_filter(variable_get('og_notifications_content_types', array()));
foreach ($types as $type) {
$subscription->fields['type'] = $type;
notifications_save_subscription($subscription);
unset($subscription->sid);
}
}
else {
notifications_save_subscription($subscription);
}
drupal_set_message(t('Subscription saved.'));
}
| Comment | File | Size | Author |
|---|---|---|---|
| #25 | og_notifications-subscriptions-not-saving-835030.patch | 4.47 KB | tbenice |
| #14 | og_notifications-subscriptions-not-saving-835030.patch | 6.73 KB | mstef |
Comments
Comment #1
ensemble commentedI'm having this problem too. I just came here to find out if anyone else had the same problem, although I hadn't looked into the code yet to try to figure out what was happening. Subscribing.
Comment #2
ensemble commentedFrom what I can tell by puttering around on my site, the "og_notifications_content_types" is, in fact set. In my case, it's set to:
Array
(
[blog] => 0
[og_user_roles_subgroup] => 0
[articulation] => 0
[blogpost] => 0
[story] => 0
)
when I was testing. However, since they're all set to 0, the array_filter gets rid of them all. I'm too new at this to know what that means - I don't know where that particular list came from (it doesn't correspond to the content types that are in use in my groups) or why they're set to 0.
Comment #3
mstef commentedGrep the entire og module. The only time they're set is by the .install file in an update hook.
Open atrium purposely ships with the variable strongarmed because thats the only way it works.
Comment #4
ensemble commentedJust checking back. Has anyone looked into this? Does anyone know if there are any plans to fix it? It's a pretty important bug that's keeping me from upgrading OG to the newest version.
Comment #5
mstef commentedThere's a very large amount of bugs in the current OG version. I will be digging in to this one within a few weeks.
Comment #7
crifi commented+1 subscribe
Comment #8
amitaibu> I will be digging in to this one within a few weeks.
Great, any help will be appreciated, as I'm dealing most of the time with getting OG7 ready.
Comment #9
jgoodwill01 commented+1 Subscribe
Comment #10
tbenice commentedlooking for resolution. I'm going to try and find a solution.
Comment #11
tbenice commentedline 90 of og_notifications.module
found by find/replace. This is version 6.21 of OG.
/admin/messaging/notifications/subscriptions/content allows you to pick from content types that are group posts.
The subscriptions show up in the account page. However none of my notifications are sending now. Going to try and troubleshoot.
Comment #12
mstef commentedFound the problem(s) -- patching now
Comment #13
tbenice commentedthats fantastick, thanks so much!
Comment #14
mstef commentedAttached is a patch that seems to clear up all the necessary issues..
Subscriptions will save now properly.
Just make sure that at least some nodes have the Content type in group subscription enabled, as well as the UI options. I removed the admin settings for per-node choices for group subscriptions, but it's really just a duplication of the per-node options that notifications offers itself.
Please test and get back to me.
Feedback and suggestions welcome.
Comment #15
mstef commentedIt's worth noting, that this patch is not necessarily required to get og_notifications working. You just have to set a number of variables before anything actually works, and there is no indication that these settings are missing. The patch is most helpful in that it eliminates the duplicate admin setting, as described in the previous post.
This is also helpful when you're dealing with a site that contains a number of features, each which contains a content type (like Drupal Commons, for instance). With the way this module works, prior to my patch, there is only one variable used to determine which group node types should be available for subscriptions - and it shouldn't be like that, because then you can only export that variable to one feature.
Comment #16
mstef commentedThere still are some problems..
1) Notifications allows you to duplicate group/content-type subscriptions
2) If you're subscribed to content type X (globally), you're allowed to subscribe to content type X inside group A
Comment #17
tbenice commentedNot seeing any content types to choose in user/uid/notifications/add/grouptype and selecting 'all content types' (only option) does not save any subscriptions.
and yes, the redundancy is odd. in theory it will be a problem because it will send 2 notifications (one for thread and one for group)?
Comment #18
mstef commented@tbenice: read #14. you need to turn on the og notifications.
Comment #19
tbenice commented@mikesteff-
The og notifications fieldset in /admin/messaging/notifications/subscriptions/content is no longer there with the patch, so I cant select them. Sorry!
Comment #20
mstef commented@tbenice: You skipped over everything I wrote, right?
(loc: /admin/messaging/notifications/content)
Global options:
Content type in group. Subscribe to specific content within a group.
Thread. Subscribe to all changes and comments for a thread.
Content type. Subscribe to all content of a given type.
Author. Subscribe to all content submitted by a user.
Content type and Author. Subscribe to all content of a given type submitted by a user.
If you're using per-nodetype options, you need to edit each node type and turn that on for it.
Please re-read what I wrote about removing the duplicate node-type options on this admin page.
Comment #21
tbenice commentedThanks, I did read what you wrote, and doing that makes sense. However, with global settings and with the og notifications selected there are no post type options in user/#/notifications/add/og. I don't know how to explain the problem more clearly.
of course og notifications must be selected, I did that. It still doesn't work, sorry.
Comment #22
mstef commentedCheck permissions?
Comment #23
tbenice commentedusing user 1. I'll try again fresh and let you know.
Comment #24
tbenice commentedI think that I know what the problem is, let me test and then get back.
Comment #25
tbenice commentedHere is what I've found:
1) i stuck a dprint_r under line 50 of og_notifications.pages.inc to print out $node_types and it gives an empty array
2) since $node_types is filled by og_notifications_node_types() I did the same in that function to print out $group_types and $allowed. og_notifications_node_types() returns the array based on logic between these 2 arrays. $group_types was an array with the expected data (types that are posted into groups), but $allowed was an empty array.
3) $allowed is filled by notifications_content_types('names', 'grouptype'). However, that function takes only 1 argument ($subs_type). So I think that the correct call is notifications_content_types('grouptype'). However, that call simply returns all content types not those that are 'grouptype'.
I'm not sure when or where the 'grouptype' option is saved.
I think that this fixes it, updated patch for og_notifications.module (only) attached.
Comment #26
tbenice commentedone other problem I've found:
selecting 'all content types' in /user/#/notifications/add/grouptype seems to only save the topmost content type in the list...not all. I think that was there before the patch though, and might be a separate issue.
Comment #27
mstef commented1) The only time it will give an empty array is if you haven't enabled grouptype subscriptions via the admin UI.
2) See 1.
3) It takes two arguments, the latter being the subtype, which is 'grouptype'.
Not really sure how you're having these issues as it works perfectly for me. Maybe try with a fresh install..
Ps: dsm() (from devel.module) is the best for printing arrays/objects.
Comment #28
tbenice commentedmikesteff, I don't know what to say here. Did you look at the code?
EDIT: Maybe we're using different versions of notifications? I'm using 4.0 Beta 7. I wonder if og_notifications is written for an earlier version? I don't remember reading anything about that though...
I see only 1 argument.
I seem to have this part fixed to my satisfaction thanks to your work and my fix. Whether you agree that it is a fix or just suspect that I don't know anything is of no consequence to me. I'll go with what I have.
btw, same problem on a fresh install. good idea though!
Thanks!
Comment #29
tbenice commentedIndeed I see that this is my issue most likely. The 6.x-dev patches for notifications/messaging 4x have not been in a stable release yet.
I'll try the -dev version of og and see how that works. Thanks for the patience.
-Ted
Comment #30
mstef commentedOh..that makes sense then.. og 6.x-2.1 supports notifications 2.x. og 6.x-dev supports notifications 4.x...
Comment #31
thepanz commentedmikesteff: I'm fighting with your same issue (you can find my new code here: https://github.com/thePanz/og/tree/DRUPAL-6--2).
it works with notifications 4.x (you can find my patches in my GitHub too).
Few works need to be done for:
1. per-group subscription settings
2. remove subscription duplication for grouptype and nodetype
3. if I enable "all post in group" i MUST also enable "post-type in group", in such case the user, when he/she subscribes to a "all group content" will see also the grouptype subscriptions..
Comments and suggestions are welcome..
Comment #32
mstef commentedI'm using Notifications 2.x.
Comment #33
thepanz commentedok, I missed the OG version your patch was against.
Maybe my code can help others (using Notifications 4.x)
Comment #34
Grayside commentedOG6 is now on Notifications 2.x for releases and dev. Skimming the issue, looks like we are in Needs Review.
Comment #36
greggles#14: og_notifications-subscriptions-not-saving-835030.patch queued for re-testing.
Comment #37
hankvanzile commentedI am experiencing this issue with 6.x-2.2 with Commons 6.x.2.4. Old subscriptions remain in place and notifications based on node type, etc. are working, so I know it's related to OG. How can I help test this? Should I apply the patch in comment 25?
Comment #38
greggles@RightSizedView - yes, that's the next step. Thanks for helping!
Comment #39
hankvanzile commentedWell, this is embarrassing, but @mikestefff's comment made me check my og_contenttype settings. They were, in fact, all turned off. I'm wondering if something in upgrading OG to 6.x-2.2 turned them off? Ah well.
I can report that this is working as expected in Organic Groups Notifications 6.x-2.2 using Drupal Commons 6.x-2.5.
Comment #40
Grayside commentedOG Notifications was barely touched between 6.x-2.1 and 6.x-2.2. In between it was partially upgraded for Notifications 4.x compatibility then reverted because of that "partial" bit.
There should have been no upgrade path pain on this. That said, there are a lot of bugs with OG Notifications, and some other zany interaction might be buggy enough to drop settings. I do not use OG Notifications, so I look to the community of users that do to identify problems and drive solutions.
Comment #41
Grayside commentedSomeone needs to reproduce this problem. Marking needs work in hopes of some more attention.
Comment #42
claudiu.cristeaThis version of Drupal is not supported anymore. If this is still an issue in the
8.x-1.xbranch, please open a new up-to-date ticket. Closing.