You are here

function invite_save in Invite 5.2

Same name and namespace in other branches
  1. 5 invite.module \invite_save()
  2. 6.2 invite.module \invite_save()
  3. 7.4 invite.module \invite_save()
  4. 7.2 invite.module \invite_save()

Save an invite to the database.

Parameters

$edit: Associative array of data to store.

Return value

The result of the database operation.

1 call to invite_save()
invite_form_submit in ./invite.module
Forms API callback; process submitted form data.

File

./invite.module, line 1147
Allows your users to send and track invitations to join your site.

Code

function invite_save($edit) {
  $edit = (array) $edit;
  $data = serialize($edit['data']);
  $now = time();
  $expiry = $now + variable_get('invite_expiry', 30) * 60 * 60 * 24;
  if ($edit['resent']) {
    $result = db_query("UPDATE {invite} SET expiry = %d, resent = %d, data = '%s' WHERE reg_code = '%s' AND uid = %d", $expiry, $edit['resent'], $data, $edit['code'], $edit['inviter']->uid);
  }
  else {
    $result = db_query("INSERT INTO {invite} (reg_code, email, uid, created, expiry, data) VALUES ('%s', '%s', %d, %d, %d, '%s')", $edit['code'], $edit['email'], $edit['inviter']->uid, $now, $expiry, $data);
  }
  return $result;
}