function modr8_usermail in modr8 5
Same name and namespace in other branches
- 6 modr8_admin.inc \modr8_usermail()
- 7 modr8_admin.inc \modr8_usermail()
1 call to modr8_usermail()
- modr8_form_submit in ./
modr8_admin.inc - Form submit handler, which approves or deletes the node.
File
- ./
modr8_admin.inc, line 282
Code
function modr8_usermail($op, $nid, $values) {
$node = node_load($nid);
if (is_object($node)) {
switch ($op) {
case 'approve':
$subject = variable_get('modr8_accepted_subject', '[%site] %title has been approved');
$message = variable_get('modr8_accepted_text', modr8_accept_default());
$optype = t('approval');
break;
case 'deny':
$subject = variable_get('modr8_denial_subject', '[%site] %title has been denied');
$message = variable_get('modr8_denial_text', modr8_denial_default());
$optype = t('denial');
break;
case 'nada':
$subject = variable_get('modr8_noact_subject', "[%site] note to author about %title");
$message = variable_get('modr8_noact_text', modr8_noact_default());
$optype = t('note (no action)');
break;
}
// get the user info for author
$account = user_load(array(
'uid' => $node->uid,
));
$note = theme('modr8_note', $values['note']);
// eval the replacements
$replacements_raw = modr8_replacements();
foreach ($replacements_raw as $key => $val) {
eval('$replacements["$key"] = ' . $val . ';');
}
// replace the macros
$subject = strtr($subject, $replacements);
$message = strtr($message, $replacements);
$site_mail = variable_get('modr8_email_from', '');
if (!$site_mail) {
$sendmail_from = ini_get('sendmail_from');
$site_mail = variable_get('site_mail', $sendmail_from);
}
if (empty($site_mail) || $site_mail == $sendmail_from) {
drupal_set_message(t('You should create an administrator mail address for your site! <a href="@url">Do it here</a>.', array(
'@url' => url('admin/settings/site-information'),
)), 'error');
}
// send the email
if (drupal_mail('modr8_usermail', $account->mail, $subject, $message, $site_mail)) {
drupal_set_message(t('%type message was sent to %username', array(
'%type' => $optype,
'%username' => $account->name,
)));
$message = filter_xss(nl2br($message), array(
'br',
'a',
));
// Return sanitized e-mail with HTML breaks added.
}
else {
$message = t('There was a problem sending the %type message to %username', array(
'%type' => $optype,
'%username' => $account->name,
));
drupal_set_message($message, 'error');
}
}
else {
$message = t('An error occurred when trying to load this content.');
drupal_set_message($message);
// this probably won't ever get called
}
return $message;
}