You are here

function invite_accept in Invite 5.2

Same name and namespace in other branches
  1. 6.2 invite.module \invite_accept()
  2. 7.4 includes/invite.pages.inc \invite_accept()
  3. 7.2 invite.pages.inc \invite_accept()

Set an invitation's status to accepted.

Parameters

$invite: An invite object.

$account: The user object of the invitee.

1 call to invite_accept()
invite_user in ./invite.module
Implementation of hook_user().

File

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

Code

function invite_accept($invite, $account) {

  // Update the invitation record.
  db_query("UPDATE {invite} SET email = '%s', invitee = %d, joined = %d WHERE reg_code = '%s'", $account->mail, $account->uid, time(), $invite->reg_code);

  // Delete all invites to these e-mail addresses, except this one.
  db_query("DELETE FROM {invite} WHERE (email = '%s' OR email = '%s') AND reg_code <> '%s'", $invite->email, $account->mail, $invite->reg_code);

  // Add all users who invited this particular e-mail address to the
  // notification queue.
  db_query("INSERT INTO {invite_notifications} (uid, invitee) SELECT uid, %d from {invite} WHERE (email = '%s' OR email = '%s') AND canceled = 0", $account->uid, $invite->email, $account->mail);

  // Escalate the invitee's role.
  _invite_escalate_role($account);

  // Unblock user account.
  db_query("UPDATE {users} SET status = 1 WHERE uid = %d", $account->uid);
}