function invite_get_remaining_invites in Invite 7.2
Same name and namespace in other branches
- 5.2 invite.module \invite_get_remaining_invites()
- 6.2 invite.module \invite_get_remaining_invites()
Calculate the remaining invites of a user.
Parameters
$account: A user object.
Return value
The number of remaining invites.
2 calls to invite_get_remaining_invites()
- invite_admin_overview in ./
invite.admin.inc - Return a list of all users that have invited someone.
- invite_form in ./
invite.module - Generate the invite forms.
File
- ./
invite.module, line 941 - Allows your users to send and track invitations to join your site.
Code
function invite_get_remaining_invites($account) {
$remaining = invite_get_role_limit($account);
$limits = module_invoke_all('invite_limit', $account, $remaining);
if (!empty($limits)) {
$remaining = array_pop($limits);
}
if ($remaining > 0) {
$query = db_select('invite')
->condition('uid', $account->uid)
->condition('canceled', 0);
$query
->addExpression('COUNT(*)');
$sent = $query
->execute()
->fetchField();
if ($sent) {
$remaining = max($remaining - $sent, 0);
}
}
return $remaining;
}