You are here

function pet_callback_recipients in Previewable email templates 7

Same name and namespace in other branches
  1. 6 pet.admin.inc \pet_callback_recipients()

Return an array of email recipients provided by a callback function.

1 call to pet_callback_recipients()
pet_validate_recipients in includes/pet.admin.inc
Validate existence of a non-empty recipient list free of email errors.

File

includes/pet.admin.inc, line 486
Contains pages for creating, editing, and deleting previewable email templates (PETs).

Code

function pet_callback_recipients($form_state) {
  $nid = $form_state['storage']['nid'];
  $pet = $form_state['storage']['pet'];
  $callback = $pet->recipient_callback;
  $node = empty($nid) ? NULL : node_load($nid);
  if (!empty($callback)) {
    if (function_exists($callback)) {
      $recipients = $callback($node);

      // Remove uid for backward compatibility
      if (isset($recipients) && is_array($recipients)) {
        $new_recipients = array();
        foreach ($recipients as $recipient) {
          $recipient = preg_replace('/^[0-9]*\\|/', '', $recipient);
          $new_recipients[] = $recipient;
        }
        return $new_recipients;
      }
    }
  }
  return NULL;
}