function mailhandler_node_process_message in Mailhandler 6
Same name and namespace in other branches
- 7 mailhandler.module \mailhandler_node_process_message()
1 call to mailhandler_node_process_message()
- mailhandler_node_process_mailbox in ./mailhandler.module
- Run message retrieval and node processing on a mailbox - is a wrapper around mailhandler_retrieve
File
- ./mailhandler.module, line 734
- Mailhandler module code.
Code
function mailhandler_node_process_message($header, $origbody, $mailbox, $mimeparts) {
mailhandler_user_switch();
$node = mailhandler_node_prepare_message($header, $origbody, $mailbox);
if (!($node = mailhandler_mailhandler_authenticate('execute', $mailbox['authentication'], array(
$node,
$header,
$origbody,
$mailbox,
)))) {
mailhandler_watchdog_record('Message failed authentication.', array(), WATCHDOG_NOTICE);
return FALSE;
}
$node->mimeparts = $mimeparts;
mailhandler_user_switch($node->uid);
foreach (module_list() as $name) {
if (module_hook($name, 'mailhandler')) {
$function = $name . '_mailhandler';
$result = $i = NULL;
if (!($node = $function($node, $result, $i, $header, $mailbox))) {
break;
}
}
}
if ($node) {
if ($node->type == 'comment') {
$saved = mailhandler_comment_submit($node, $header, $mailbox, $origbody);
$type = 'comment';
}
else {
$saved = mailhandler_node_submit($node, $header, $mailbox, $origbody);
$type = 'node';
}
}
foreach (module_list() as $name) {
if (module_hook($name, 'mailhandler_post_save')) {
$function = $name . '_mailhandler_post_save';
$function($saved, $type, $node);
}
}
mailhandler_user_switch();
$context['results'][] = $mailbox['mail'];
mailhandler_user_switch();
}