system_send_email_action

  1. drupal
    1. drupal6
    2. drupal7
Versionen
drupal6 – drupal7 system_send_email_action($object, $context)

Implementation of a configurable Drupal action. Sends an email.

Code

modules/system/system.module, line 1699

<?php
function system_send_email_action($object, $context) {
  global $user;

  switch ($context['hook']) {
    case 'nodeapi':
      // Because this is not an action of type 'node' the node
      // will not be passed as $object, but it will still be available
      // in $context.
      $node = $context['node'];
      break;
      // The comment hook provides nid, in $context.
    case 'comment':
      $comment = $context['comment'];
      $node = node_load($comment->nid);
      break;
    case 'user':
      // Because this is not an action of type 'user' the user
      // object is not passed as $object, but it will still be available
      // in $context.
      $account = $context['account'];
      if (isset($context['node'])) {
        $node = $context['node'];
      }
      elseif ($context['recipient'] == '%author') {
        // If we don't have a node, we don't have a node author.
        watchdog('error', 'Cannot use %author token in this context.');
        return;
      }
      break;
    default:
      // We are being called directly.
      $node = $object;
  }

  $recipient = $context['recipient'];

  if (isset($node)) {
    if (!isset($account)) {
      $account = user_load(array('uid' => $node->uid));
    }
    if ($recipient == '%author') {
      $recipient = $account->mail;
    }
  }

  if (!isset($account)) {
    $account = $user;

  }
  $language = user_preferred_language($account);
  $params = array('account' => $account, 'object' => $object, 'context' => $context);
  if (isset($node)) {
    $params['node'] = $node;
  }

  if (drupal_mail('system', 'action_send_email', $recipient, $language, $params)) {
    watchdog('action', 'Sent email to %recipient', array('%recipient' => $recipient));
  }
  else {
    watchdog('error', 'Unable to send email to %recipient', array('%recipient' => $recipient));
  }
}
?>

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen