Messaging Module looks to be moving to OO code as of 16 Dec commits. $message parameter is now passed as an object and Mail2Web expects it to be an array. Starts around line 122

function mail2web_message_alter(&$message, $info) 

I created a hack to cast $message to an array and then back to an object at end of function, but this is probably not the way to go. I was trying to see if I could get a proper patch together to change this function to OO but got lost in the code. Not a ping on the devs, just my limits.

Also notice that I got rid of the third parameter - $method - which does not appear to be passed by the latest Messaging code.

R,
Coby

Comments

cglusky’s picture

Title: Latest dev version of messaging module message_alter passes only two parameters with $message as object » Latest dev version of messaging module requires M2W update

Just changed the title as the previous one was a bit out of control:)

Latest dev version of messaging module message_alter passes only two parameters with $message as object

cglusky’s picture

OK. This seems to work.

/**
 * Implementation of hook_message_alter()
 * 
 * Adds message headers into outgoing emails for notifications
 */
function mail2web_message_alter(&$message, $info) {
  $params = array();
  // For now, just for non digested emails
  if (!empty($message->notifications) && ($account = $message->account) 
    && empty($message->notifications['digest']) && $info['group'] == 'mail') {
    $event = array_shift($message->notifications['events']);
    if ($event->type == 'node' && !empty($event->objects['node'])) {
      $params['uid'] = $account->uid;
      $params['nid'] = $event->objects['node']->nid;
      if ($event->action == 'comment' && !empty($event->objects['comment'])) {
        $params['cid'] = $event->objects['comment']->cid;
      }
    }
  }
  // If we've got some params out of the message, embed them into the message id for emails only
  if ($params && ($reply = mail2web_mailbox_mail())) {
    $message->params['mail']['headers']['Message-ID'] = mail2web_build_messageid($params);
    $message->params['mail']['headers']['Reply-To'] = $reply;
    // Add marker text into the message header part taking care of already existing text
    if ($text = variable_get('mail2web_reply_text', t('((( Reply ABOVE this LINE to POST a COMMENT )))'))) {
      $prefix = array($text);
      if (!empty($message->body['#prefix'])) {
        $prefix[] = $message->body['#prefix'];
      }
      // This glue text is a best guess, may cause trouble though, also with filtering (?).
      // So we better explicitly set glue text for all sending methods
      $info += array('glue' => "\n");
      $message->body['#prefix'] = implode($info['glue'], $prefix);
    }
    
  }
}

I am testing a bunch of other stuff and if i can get it to work i'll post a proper patch.

R,
C

cglusky’s picture

Assigned: Unassigned » cglusky

This code works fine. Assigning to myself. Good news is I have a patch. The bad news is it's got more than this in it. I am going to post a new issue with a proposed patch and will cross post here.

R,
Coby

cglusky’s picture

Status: Active » Closed (duplicate)

marking this a duplicate of the my other issue with patch here http://drupal.org/node/351260

Ian Ward’s picture

Project: Mail to Web » Mail Comment
Version: 6.x-1.0-beta1 » 6.x-1.0-beta4

Switch to mailcomment project. Mail2web is now known as "mailcomment" due to a trademark issue with the name mail2web.