You are here

function ad_actions_send_email_action_before in Advertisement 6.3

Same name and namespace in other branches
  1. 6.2 actions/ad_actions.module \ad_actions_send_email_action_before()
  2. 7 actions/ad_actions.module \ad_actions_send_email_action_before()

Implementation of a configurable Drupal action. Schedules an email, sent before scheduled actions.

File

actions/ad_actions.module, line 146
Enable ad triggers and actions.

Code

function ad_actions_send_email_action_before($object, $context) {
  if ($context['before']) {
    if (!db_result(db_query_range("SELECT 1 FROM {ad_actions_queue} WHERE aid = %d AND period = %d AND recipient = '%s'", $object->aid, $context['before'], $context['recipient'], 0, 1))) {
      db_query("INSERT INTO {ad_actions_queue} (aid, recipient, period, scheduled, context) VALUES(%d, '%s', %d, %d, '%s')", $object->aid, $context['recipient'], $context['before'], time() + $context['before'], serialize($context));
      watchdog('action', 'Queued email for scheduled trigger to %recipient', array(
        '%recipient' => $context['recipient'],
      ));
    }
  }
}