Signup status module adds a filter of recipients to the broadcast form which allows sending a message only to a subgroup of all signuped users. The patch would allow to reuse a signup_broadcast_form_submit() function from within a signup_status module.

Comments

dww’s picture

Status: Active » Needs review
StatusFileSize
new2.24 KB

In principle, that's fine with me. However, the patch changed the arguments to the function and didn't update the PHPDoc comments about what was expected. Investigating exactly how that $addresses array was used made it clear that it was a poorly named variable. It should really be called $users, since it's an array of objects, not just an array of email addresses. See attached patch for what fields you need in this object to be able to use it in this function.

dww’s picture

Title: Allow to pass a list of emails to send a broadcast message to » Add a signup_send_broadcast() API call that can be shared
Version: 6.x-1.0-rc3 » 6.x-1.x-dev
Assigned: Unassigned » dww
Status: Needs review » Needs work

Upon further discussion in IRC, we think it'd be better to just have an API function that was shared by all the relevant form submit handlers, instead of trying to reuse this particular submit handler. In addition to signup and signup_status, I was thinking it'd be nice to add a "send signup broadcast" action for VBO support (#352328: Replace (optionally?) node/N/signups/admin with a views bulk operations view?). So, the proposed new function would be:

function signup_send_broadcast($nid, $subject, $body, $users = array()) 

I'll work on this is in a bit...

miglius’s picture

Would you mind changing sql in signup_get_email_addresses() function to following:

$signups = db_query("SELECT u.uid, u.name, u.mail, s_l.* FROM {signup_log} s_l INNER JOIN {users} u ON u.uid = s_l.uid WHERE s_l.nid = %d", $nid);

This way the sql would pick up the values of additional db columns added by other modules (signup_status for example) and the function could be reused.

dww’s picture

Status: Needs work » Needs review
StatusFileSize
new7.04 KB

That's a fine idea. I moved signup_get_email_addresses() into signup.module and renamed it to signup_get_signups(). I also fixed a PHP warning by grabbing the 'language' field from {users}, too, which we need when sending the emails. This also adds signup_send_broadcast() and fixes signup_broadcast_form_submit() to setup some arguments and just call that to do the real work. Tested with the broadcast form and it all seems to be fine, but if you wanted to review the new APIs to make sure they're what you need to use it outside of the broadcast form, that'd be great.

miglius’s picture

This patch works nicely. I think it can be committed.

dww’s picture

Status: Needs review » Fixed

Great. Committed to HEAD and DRUPAL-6--1. Thanks for testing.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.