function invite_overview in Invite 5
Menu callback; display an overview of sent invitations.
Parameters
$page: Which invites to list: accepted, pending, or expired.
1 string reference to 'invite_overview'
- invite_menu in ./
invite.module - Implementation of hook_menu().
File
- ./
invite.module, line 521 - Allows your users to send and track invitations to join your site.
Code
function invite_overview($page = 'accepted') {
global $user;
$rows = array();
$time = time();
$profile_access = user_access('access user profiles');
$allow_delete = user_access('withdraw accepted invitations');
switch ($page) {
case 'accepted':
default:
$sql = "SELECT i.*, u.uid FROM {invite} i LEFT JOIN {users} u ON u.uid = i.mid AND u.uid != 0 WHERE i.uid = %d AND i.timestamp > 0 ORDER BY u.uid DESC, i.expiry DESC";
break;
case 'pending':
$sql = "SELECT * FROM {invite} WHERE uid = %d AND timestamp = 0 AND expiry >= %d ORDER BY expiry DESC";
break;
case 'expired':
$sql = "SELECT * FROM {invite} WHERE uid = %d AND timestamp = 0 AND expiry < %d ORDER BY expiry DESC";
break;
}
$result = pager_query($sql, 50, 0, NULL, $user->uid, $time);
while ($invite = db_fetch_object($result)) {
$row = array();
switch ($page) {
case 'accepted':
default:
$account_exists = !is_null($invite->uid);
if ($profile_access) {
$row[] = $account_exists ? l($invite->email, 'user/' . $invite->mid, array(
'title' => t('View user profile.'),
)) : check_plain($invite->email);
}
else {
$row[] = check_plain($invite->email);
}
$row[] = $account_exists ? t('Accepted') : t('Deleted');
$row[] = $allow_delete ? l(t('Withdraw'), "invite/withdraw/{$page}/{$invite->reg_code}") : '';
break;
case 'pending':
case 'expired':
$expired = $invite->expiry < $time;
$row[] = check_plain($invite->email);
$row[] = $expired ? t('Expired') : t('Pending');
$row[] = l(t('Withdraw'), "invite/withdraw/{$page}/{$invite->reg_code}");
break;
}
$rows[] = $row;
}
return theme('invite_overview', $rows);
}