I'm trying to figure out why this module is breaking my webform emails.

But I can't, because the code is pretty much impenetrable:

    list($email_type, $eid) = webform_confirm_email_get_email_info($message);
    $nid = (int)($message['params']['node']->nid);
    $sid = (int)($message['params']['submission']->sid);
    $obj = array();
    $obj['nid'] = $nid;
    $obj['sid'] = $sid;
    if (1 === $email_type) {

What is $email_type? What does it represent? There are no comments here in the if() switch, and no comments at the call to webform_confirm_email_get_email_info() to explain what we're fetching, and no function documentation at webform_confirm_email_get_email_info() itself to explain what it does.

If the code were commented as per our coding standards, I might be able to understand it and figure out the bug at #1328560: breaks webform conditional email. Without documentation, I can't help.

Comments

scorchio’s picture

I've spent a bit of time today, trying to understand and improve this module. As far as I could understand, the $email_type is filled with a value that you can see in the webform_confirm_email_form_webform_email_edit_form_alter():

  $form['email_type'] = array(
    '#title' => t('Message type'),
    '#type' => 'radios',
    '#default_value' => $email_type,
    '#description' =>  t('Should this email always be sent, only after confirmation, etc.'),
    '#options' => array(
      0 => t('Always'),
      1 => t('Confirmation'),
      2 => t('Conditional'),
    ),
  );

In the case of conditional mails, the module tries to prevent sending them, as we're waiting for the confirmation. That's why it adds the "+" as you've mentioned in #1328560: breaks webform conditional email.

For sure, some documentation (and following the Drupal coding standards) could help this module quite a bit.

mattferris’s picture

The code is certainly dense. email_type is basically the value of the "Message type" you select when you setup the form email.

Always = 0
Confirmation = 1
Conditional = 2

webform_confirm_email_get_email_info() does a big 3-table join to pull the email_type for the message.

I've commented on #1328560: breaks webform conditional email. In the case where form emails have been created after this module was installed, then I think my patch for #1076128: Conditional emails being sent too early should fix the problem.

matthias_mo’s picture

Assigned: Unassigned » matthias_mo
Status: Active » Closed (fixed)

I've added function documentation to the code.

  • Commit 2127848 on 6.x-3.x, master, 7.x-1.x, 7.x-2.x by matthias_mo:
    Issue #1328566 by joachim: Added code documentation.