Index: lib.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/forum/lib.php,v retrieving revision 1.904 diff -r1.904 lib.php 506a507 > $userto->mailmsgprocess= null; 569a571,598 > // Quick hack for MDL-24516, as far as messaging API is highly ineficient > // and is discarding all the custom email headers, we are going to route > // messages to it only in case the user hasn't 'mail' as processor. With > // mail, we use email_to_user() here instead of messaging API > // TODO: This needs to be fixed properly in the msg API!! Critical!! > > // Calculate if we are going to email this user and cache it > if (!isset($userto->mailmsgprocess)) { > $userto->mailmsgprocess = false; // Init to false > > // Try to get user default processors for mod_forum_post > // Note: We don't look for loggedin status of user at all here. Assume they are off > // this in fact means that the message_provider_mod_forum_posts_loggedin > // setting *has no effect* at all! > $preferencename = 'message_provider_mod_forum_posts_loggedoff'; > $processors = get_user_preferences($preferencename, NULL, $userto->id); > // If we found processors let's see if email is one of them > if (!empty($processors)) { > $processorlist = explode(',', $processors); > if (in_array('email', $processorlist)) { > $userto->mailmsgprocess = true; > } > } else { > // TODO: Is ok to assume that all users have their preferences available? > // TODO: if not... should we enable mailmsgprocess for them? > } > } > 629,638c658,680 < $eventdata = new stdClass(); < $eventdata->component = 'mod_forum'; < $eventdata->name = 'posts'; < $eventdata->userfrom = $userfrom; < $eventdata->userto = $userto; < $eventdata->subject = $postsubject; < $eventdata->fullmessage = $posttext; < $eventdata->fullmessageformat = FORMAT_PLAIN; < $eventdata->fullmessagehtml = $posthtml; < $eventdata->smallmessage = ''; --- > // Quick hack for MDL-24516, as far as messaging API is highly ineficient > // and is discarding all the custom email headers, we are going to route > // messages to it only in case the user hasn't 'mail' as processor. With > // mail, we use email_to_user() here instead of messaging API > // TODO: This needs to be fixed properly in the msg API!! Critical!! > > // If mailmsgprocess detected, use email_to_user(), ignoring msg API completely > if ($userto->mailmsgprocess) { > $mailresult = email_to_user($userto, $userfrom, $postsubject, $posttext, > $posthtml, '', '', $CFG->forum_replytouser); > > // Not having email as processor for mod_forum_post, route it to the msg API > } else { > $eventdata = new stdClass(); > $eventdata->component = 'mod_forum'; > $eventdata->name = 'posts'; > $eventdata->userfrom = $userfrom; > $eventdata->userto = $userto; > $eventdata->subject = $postsubject; > $eventdata->fullmessage = $posttext; > $eventdata->fullmessageformat = FORMAT_PLAIN; > $eventdata->fullmessagehtml = $posthtml; > $eventdata->smallmessage = ''; 640c682,683 < $mailresult = message_send($eventdata); --- > $mailresult = message_send($eventdata); > } 926,928c969,970 < $attachment = $attachname=''; < $usetrueaddress = true; < $mailresult = email_to_user($userto, $site->shortname, $postsubject, $posttext, $posthtml, $attachment, $attachname, $usetrueaddress, $CFG->forum_replytouser); --- > $mailresult = email_to_user($userto, $site->shortname, $postsubject, $posttext, $posthtml, > '', '', $CFG->forum_replytouser);