rsvp_create

Definition

rsvp_create($edit)
rsvp/rsvp.module, line 954

Description

  • Creates a new rsvp
*
  • *

Parameters

$edit The post data of the create rsvp form.

  • @return int key id of the rsvp instance or -1 on failure.

Code

<?php
function rsvp_create($edit) {
  global $user;

  $fields[] = 'uid';
  $vals[] = $user->uid;
  $markers[] = "%d";

  $fields[] = 'timestamp';
  $vals[] = time();
  $markers[] = "%d";

  foreach (array('name', 'invite_text', 'invite_list', 'blind', 'list_email', 'allow_invite', 'nid') as $key) {
    if ($key != 'invite_list') {
      $fields[] = $key;
      $vals[] = $edit[$key];
      $markers[] = "'%s'";
    }
  }

  $rid = db_next_id('rsvp');
  $fields[] = 'rid';
  $vals[] = $rid;
  $markers[] = "%d";

  $sql = 'INSERT INTO {rsvp} ('. implode(", ", $fields) .') VALUES ('. implode(", ", $markers) .')';

  if (db_query($sql, $vals)) {
    return $rid;
  }
  else {
    drupal_set_message(t('There was an error creating the RSVP. Please try again'));
    return FALSE;
  }
}
?>