When any user send a broadcast message to all group's members, OG notifications sends a notifications like:
"To unsubscribe from this group, visit !url_unsubscribe"
!url_unsubscribe is linking to http://sitename.com/drupal/og/unsubscribe/1 to all users. Isn't replacing the "1" by the user id.
File: og.pages.inc
function og_broadcast_form_submit($form, &$form_state) {
// HERE
global $user; # $user variable is the info of current user who send the message
// END
$sql = og_list_users_sql(1);
$result = db_query($sql, $form_state['values']['gid']);
$recipients = array();
while ($row = db_fetch_object($result)) {
$recipients[] = $row->uid;
}
$node = node_load($form_state['values']['gid']);
$variables = array(
'@group' => $node->title,
'@subject' => $form_state['values']['subject'],
'@body' => $form_state['values']['body'],
'@site' => variable_get('site_name', 'drupal'),
'!url_group' => url("node/$node->nid", array('absolute' => TRUE)),
// HERE: Link to unsubscribe
'!url_unsubscribe' => url("og/unsubscribe/$node->nid/$user->uid", array('absolute' => TRUE))
// End
);
File: modules/og_notifications/og_notifications.module
/**
* Implementation of hook_og().
*/
function og_notifications_og($op, $gid, $uid, $args) {
// ...
case 'user broadcast':
$destinations = is_array($uid) ? $uid : array($uid);
foreach ($destinations as $uid) {
notifications_lite_send($uid, $args['subject'], $args['body']);
}
break;
}
I've temporarily solved this problem with this patch:
--- og.pages.inc 2009-08-08 13:37:37.000000000 -0400
+++ og.pages.inc-updated 2009-08-28 17:07:35.516468011 -0400
@@ -58,7 +58,7 @@
'@body' => $form_state['values']['body'],
'@site' => variable_get('site_name', 'drupal'),
'!url_group' => url("node/$node->nid", array('absolute' => TRUE)),
- '!url_unsubscribe' => url("og/unsubscribe/$node->nid/$user->uid", array('absolute' => TRUE))
+ '!url_unsubscribe' => url("og/unsubscribe/$node->nid/@@UID@@", array('absolute' => TRUE))
);
$message = array(
--- modules/og_notifitacions/og_notifications.module 2009-08-16 15:51:24.000000000 -0400
+++ modules/og_notifitacions/og_notifications.module-updated 2009-08-28 17:08:54.893989450 -0400
@@ -167,7 +167,7 @@
case 'user broadcast':
$destinations = is_array($uid) ? $uid : array($uid);
foreach ($destinations as $uid) {
- notifications_lite_send($uid, $args['subject'], $args['body']);
+ notifications_lite_send($uid, $args['subject'], str_replace("%40%40UID%40%40", $uid, $args['body']));
}
break;
}
@@ -794,4 +794,4 @@
0 => t('Disabled'),
1 => t('Enabled'),
);
-}
\ No newline at end of file
+}
cheers
Comments
Comment #1
ltheussl commentedI can confirm this. The unsubscribe url is the one from the user sending the broadcast, not the one receiving it. Can this be fixed please, it doesn't look hard! :)
Comment #2
Yaron Tal commenteduid of the user sending the messages was set as the uid for unsubscribing. The fix in #1 seems to work.
Comment #3
paolomainardi commentedSubscribe, this feature is totally broken without a proper patch.
Comment #4
Grayside commentedThe fix in #1 is a hack. This needs a better solution. Ideally the hook is fired with the complete message so this becomes an interesting catch 22.
Comment #5
Grayside commentedThis solution will need to be coordinated with #1023376: Max execution time exceeded when sending 1000+ emails with broadcast on og_notifications , email sender field added, as that fix needs to find a way to using queuing/messaging_store system to dispatch messages, and that has implications on the way arguments might be shaped. Possibly having the UID in the unsubscribe link should be dropped, and instead a generic URL that unsubscribes a user after a login as needed...
Comment #6
Yaron Tal commentedWhat about this patch?
It adds a new unsubscribe link without the uid and takes the currently logged in uid. Maybe there should be another message instead of the default 403 if you go there without being logged in, but before making that I'd like to hear your opinion on this.
Comment #7
Grayside commented#6 is better, needs to be examined closer. There's no need to avoid requiring login for this, unlike email unsubscription.
Comment #9
Grayside commentedAdding to list of strange OG behaviors in need of correction.
Comment #10
Grayside commentedComment #12
paolomainardi commented#10: og.562656-10.patch queued for re-testing.
Comment #15
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.