| 1 |
<?php |
<?php |
| 2 |
// $Id: actions.module,v 1.32 2008/04/09 18:19:25 jvandyk Exp $ |
// $Id: actions.module,v 1.33 2008/04/10 14:12:57 jvandyk Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 1087 |
'#default_value' => $context['message'], |
'#default_value' => $context['message'], |
| 1088 |
'#cols' => '80', |
'#cols' => '80', |
| 1089 |
'#rows' => '20', |
'#rows' => '20', |
| 1090 |
'#description' => t('The message that should be sent. You may include the following variables: %site_name, %username, %node_url, %node_type, %title, %teaser, %body. Not all variables will be available in all contexts.'), |
'#description' => t('The message that should be sent. You may include the following variables: %site_name, %username, %uid, %node_url, %node_type, %title, %teaser, %body. Not all variables will be available in all contexts.'), |
| 1091 |
); |
); |
| 1092 |
return $form; |
return $form; |
| 1093 |
} |
} |
| 1167 |
|
|
| 1168 |
if (!isset($account)) { |
if (!isset($account)) { |
| 1169 |
$account = $user; |
$account = $user; |
|
|
|
| 1170 |
} |
} |
| 1171 |
|
|
| 1172 |
$subject = $context['subject']; |
$subject = $context['subject']; |
| 1173 |
$message = $context['message']; |
$message = $context['message']; |
| 1174 |
$from = variable_get('site_mail', ini_get('sendmail_from')); |
$from = variable_get('site_mail', ini_get('sendmail_from')); |
| 1175 |
|
|
| 1176 |
|
$variables = array( |
| 1177 |
|
'%site_name' => variable_get('site_name', 'Drupal'), |
| 1178 |
|
'%username' => $account->name, |
| 1179 |
|
); |
| 1180 |
|
if ($context['hook'] == 'taxonomy') { |
| 1181 |
|
$vocabulary = taxonomy_vocabulary_load($object->vid); |
| 1182 |
|
$variables += array( |
| 1183 |
|
'%term_name' => $object->name, |
| 1184 |
|
'%term_description' => $object->description, |
| 1185 |
|
'%term_id' => $object->tid, |
| 1186 |
|
'%vocabulary_name' => $vocabulary->name, |
| 1187 |
|
'%vocabulary_description' => $vocabulary->description, |
| 1188 |
|
'%vocabulary_id' => $vocabulary->vid, |
| 1189 |
|
); |
| 1190 |
|
} |
| 1191 |
|
|
| 1192 |
|
// Node-based variable translation is only available if we have a node. |
| 1193 |
|
if (isset($node)) { |
| 1194 |
|
$variables += array( |
| 1195 |
|
'%uid' => $node->uid, |
| 1196 |
|
'%node_url' => url('node/'. $node->nid, NULL, NULL, TRUE), |
| 1197 |
|
'%node_type' => node_get_types('name', $node), |
| 1198 |
|
'%title' => $node->title, |
| 1199 |
|
'%teaser' => $node->teaser, |
| 1200 |
|
'%body' => $node->body, |
| 1201 |
|
); |
| 1202 |
|
} |
| 1203 |
|
$subject = strtr($context['subject'], $variables); |
| 1204 |
|
$subject = str_replace(array("\r", "\n"), '', $subject); |
| 1205 |
|
$message = strtr($context['message'], $variables); |
| 1206 |
|
|
| 1207 |
if (drupal_mail('action_send_email', $recipient, $subject, $message, $from)) { |
if (drupal_mail('action_send_email', $recipient, $subject, $message, $from)) { |
| 1208 |
watchdog('action', t('Sent email to %recipient', array('%recipient' => $recipient))); |
watchdog('action', t('Sent email to %recipient', array('%recipient' => $recipient))); |
| 1209 |
} |
} |