function invite_form in Invite 5.2
Same name and namespace in other branches
- 5 invite.module \invite_form()
- 6.2 invite.module \invite_form()
- 7.4 includes/invite.admin.inc \invite_form()
- 7.2 invite.module \invite_form()
Generate the invite forms.
Parameters
$op: The type of form to generate, 'page' or 'block'.
$edit: Previous values when resending an invite.
Return value
A form definition.
3 string references to 'invite_form'
- invite_block in ./
invite.module - Implementation of hook_block().
- invite_menu in ./
invite.module - Implementation of hook_menu().
- invite_resend in ./
invite.module - Menu callback; resend an expired invite.
File
- ./
invite.module, line 531 - Allows your users to send and track invitations to join your site.
Code
function invite_form($op = 'page', $edit = array()) {
global $user;
if (!is_array($edit)) {
$edit = (array) $edit;
}
$remaining_invites = invite_get_remaining_invites($user);
if ($remaining_invites == 0) {
if ($op == 'block') {
// Hide block.
$form['#access'] = FALSE;
return $form;
}
else {
if (!$edit) {
// Deny access when NOT resending an invite.
drupal_set_message(t("Sorry, you've reached the maximum number of invitations."), 'error');
drupal_goto(referer_uri());
}
}
}
$form['resent'] = array(
'#type' => 'value',
'#value' => $edit ? $edit['resent'] + 1 : 0,
);
$form['reg_code'] = array(
'#type' => 'value',
'#value' => $edit ? $edit['reg_code'] : NULL,
);
if ($remaining_invites != INVITE_UNLIMITED) {
$form['remaining_invites'] = array(
'#type' => 'value',
'#value' => $remaining_invites,
);
}
switch ($op) {
case 'page':
default:
$form += invite_page_form($remaining_invites, $edit);
break;
case 'block':
$form += invite_block_form($remaining_invites);
break;
}
return $form;
}