function mailhandler_comment_submit in Mailhandler 5
Same name and namespace in other branches
- 6 mailhandler.module \mailhandler_comment_submit()
- 7 mailhandler.module \mailhandler_comment_submit()
Create the comment.
1 call to mailhandler_comment_submit()
- mailhandler_retrieve in ./
mailhandler.module - Retrieve all msgs from a given mailbox and process them.
File
- ./
mailhandler.module, line 115
Code
function mailhandler_comment_submit($node, $header, $mailbox, $origbody) {
if (!$node->subject) {
$node->subject = $node->title;
}
if (!$node->comment) {
$node->comment = $node->body;
}
// We want the comment to have the email time, not the current time
$node->timestamp = $node->created;
// comment_save gets an array
$edit = (array) $node;
// post the comment. if unable, send a failure email when so configured
if (!comment_save($edit) && $mailbox['replies']) {
// $fromaddress really refers to the mail header which is authoritative for authentication
list($fromaddress, $fromname) = mailhandler_get_fromaddress($header, $mailbox);
$error_txt = t("Sorry, your comment experienced an error and was not posted. Possible reasons are\n- you have insufficient permission to post comments\n- The node is no longer open for comments.\n\n");
$error = $error_txt . t("\n\nYou sent:\n\nFrom: %f\nSubject: %t\nBody:\n%b", array(
'%f' => $fromaddress,
'%t' => $header->subject,
'%b' => $origbody,
));
drupal_mail('mailhandler_error_comment', $fromaddress, t('Email submission to %sn failed - %subj', array(
'%sn' => variable_get('site_name', 'Drupal'),
'%subj' => $header->subject,
)));
$watchdog = t('Mailhandler: comment submission failure: %subject.', array(
'%subject' => $edit['subject'],
));
watchdog('mailhandler', $watchdog, WATCHDOG_ERROR);
}
}