You are here

function makemeeting_sendfw_form_submit in Make Meeting Scheduler 6

Same name and namespace in other branches
  1. 7 makemeeting.module \makemeeting_sendfw_form_submit()

makemeeting_sendfw_form_submit()

Return value

void

File

./makemeeting.module, line 1025
Make Meeting module

Code

function makemeeting_sendfw_form_submit($form, &$form_state) {

  // load node
  $node_id = db_result(db_query("SELECT nid FROM {makemeeting_poll_heads} WHERE url = '%s'", $form['#post']['sendfw']['poll_url']));
  $node = node_load($node_id);
  $addresses = array();

  // owner name
  if ($node->uid == 0) {
    $owner_name = $node->user_name == "" ? t("user") : $node->user_name;
  }
  else {
    $account = user_load(array(
      "uid" => $node->uid,
    ));
    $owner_name = $account->name;
  }

  // mail params
  $mail_params = array(
    "name" => t("user"),
    "owner_name" => $owner_name,
    "poll_url" => $node->poll_url,
  );

  // send emails
  for ($i = 0; $i < 5; $i++) {
    if (!empty($form['#post']['sendfw']['address_' . $i])) {
      $email = $form['#post']['sendfw']['address_' . $i];
      drupal_mail('makemeeting', 'refer', $email, language_default(), $mail_params);
    }
  }
  drupal_set_message(t("Mail sent."));
}