function answers_notify in Answers 5.2
Same name and namespace in other branches
- 6 includes/answers.notify.inc \answers_notify()
- 7.3 includes/answers.notify.inc \answers_notify()
2 calls to answers_notify()
File
- ./
answers.module, line 214 - Enables the creation of question nodes that can be answered by posting answer nodes.
Code
function answers_notify($nid, $title, $style = 'answer') {
$subj = $title;
global $user;
$result = db_query('SELECT u.uid, u.name, u.mail, u.language FROM {users} u INNER JOIN {node} n ON u.uid = n.uid WHERE n.nid = %d', $nid);
while ($cuser = db_fetch_object($result)) {
if ($user->uid != $cuser->uid) {
$subject = t(variable_get('answernotifysubject', '@name an answer has been posted for yoru question: @subject'), array(
'@name' => $cuser->name,
'@subject' => $subj,
));
$message = variable_get('answernotify', 'drupal');
$body = t($message, array(
'%name' => $cuser->name,
'%addername' => $user->name,
'%ansertype' => $style,
'%title' => $subj,
'%url' => url('node/' . $nid, NULL, NULL, 1),
'%site' => variable_get('site_name', 'drupal'),
));
$headers["MIME-Version"] = '1.0';
$headers["Content-Transfer-Encoding"] = '8bit';
$headers["Content-Type"] = "text/html; charset='utf-8';";
$mail_success = drupal_mail('answers_notify_email', $cuser->mail, $subject, $body, variable_get('site_mail', NULL), $headers);
if (!$mail_success) {
watchdog('error', t('error mailing quest notification: ') . '"' . $cuser->name . '" <' . $cuser->mail . '>');
}
}
}
}