rsvp_send_message

Definition

rsvp_send_message($edit)
rsvp/rsvp.module, line 1260

Description

  • Emails a message to the attendees of an rsvp instance.
*
  • *

Parameters

$edit The send message form post data.

  • @return string of formatted recipients, or empty string depending on $confirm.

Related topics

Namesort iconDescription
functions for rsvp mailing.

Code

<?php
function rsvp_send_message($edit) {
  // check whether the message is sent from a user who's invited
  // yet allowed to message other attendees
  if (!$edit['hash'] || is_null($edit['hash'])) {
    global $user;
    $sender = $user->name;
    $from = $user->name .' <'. $user->mail .'>';
  }
  else {
    $inviter = _rsvp_get_invite($edit['hash']);
    $sender = $inviter->email;
    $from = $inviter->email;
  }
  $site = variable_get("site_name", "drupal");
  $subject = $edit['subject'];

  $status['success'] = array();
  $status['failed'] = array();

  $attendees = _rsvp_get_attendees($edit['rid']);
  while ($attendee = db_fetch_object($attendees)) {
    $invite = _rsvp_get_invite($attendee->hash);

    $body = t("Hello!\n\nYou have been sent a message by !sender at !site.\n\nYou can view the invitation from where it originated by following this link: \n!url\n\nHere is the message:\n", array('!sender' => $sender, '!site' => $site, '!url' => url("rsvp/email/$invite->hash", NULL, NULL, 1))) . $edit['body'];

    $to = $attendee->email;
    if (rsvp_mail('rsvp_message_mail', $to, $subject, $body, $from)) {
      $status['success'][$invite->email] = substr($invite->email, 0, strpos($invite->email, '@'));
    }
    else {
      $status['failed'][$invite->email] = substr($invite->email, 0, strpos($invite->email, '@'));
    }
  }

  return $status;
}
?>