You are here

function invite_cancel in Invite 5.2

Same name and namespace in other branches
  1. 6.2 invite.module \invite_cancel()

Menu callback; display confirm form to delete an invitation.

Parameters

$origin: String denoting the orginating invite status page.

$code: A registration code to remove the invitation for.

1 string reference to 'invite_cancel'
invite_menu in ./invite.module
Implementation of hook_menu().

File

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

Code

function invite_cancel($origin, $code) {
  global $user;
  $invite = invite_load($code);

  // Inviter must be the current user.
  if ($invite->inviter->uid == $user->uid) {

    // Verify the invitation may be deleted.
    if (!$invite->joined || user_access('withdraw accepted invitations')) {
      $form['#redirect'] = "user/{$user->uid}/invites/{$origin}";
      $form['invite'] = array(
        '#type' => 'value',
        '#value' => $invite,
      );
      $description = !$invite->joined && $invite->expiry > time() ? t("The invitee won't be able to register any more using this invitation.") : '';
      return confirm_form($form, t('Are you sure you want to withdraw the invitation to %email?', array(
        '%email' => $invite->email,
      )), "user/{$user->uid}/invites/{$origin}", $description . ' ' . t('This action cannot be undone.'), t('Withdraw'), t('Cancel'));
    }
    else {
      drupal_set_message(t('Invitations to registered users cannot be withdrawn.'), 'error');
    }
  }
  else {
    watchdog('invite', t('Detected malicious attempt to delete an invitation.'), WATCHDOG_WARNING, l(t('view'), 'user/' . $user->uid));
    drupal_access_denied();
  }
  drupal_goto("user/{$user->uid}/invites/{$origin}");
}