/[drupal]/contributions/modules/invite_site_report/invite_site_report.report.inc
ViewVC logotype

Contents of /contributions/modules/invite_site_report/invite_site_report.report.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Mon Apr 21 11:17:19 2008 UTC (19 months ago) by mfer
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-5
File MIME type: text/x-php
Initial add for Invite Site Report.
1 <?php
2 // $Id:$
3
4 /**
5 * @file
6 * The logic and theming functions for the invite site report.
7 */
8
9 function invite_site_report_report_overview($page = 'accepted') {
10
11 $vars = array();
12
13 // Generate counts for number of accepted, pending, expired, and total invitations.
14 $invites = db_fetch_array(db_query("SELECT COUNT(*) AS count FROM {invite}"));
15 $vars['total_invites'] = $invites['count'];
16 $invites = db_fetch_array(db_query("SELECT COUNT(*) AS count FROM {invite} i LEFT JOIN {users} u ON u.uid = i.mid AND u.uid <> 0 WHERE i.timestamp > 0"));
17 $vars['accepted_invites'] = $invites['count'];
18 $invites = db_fetch_array(db_query("SELECT COUNT(*) AS count FROM {invite} WHERE timestamp = 0 AND expiry >= %d", time()));
19 $vars['pending_invites'] = $invites['count'];
20 $invites = db_fetch_array(db_query("SELECT COUNT(*) AS count FROM {invite} WHERE timestamp = 0 AND expiry < %d", time()));
21 $vars['expired_invites'] = $invites['count'];
22
23 $time = time();
24 $profile_access = user_access('access user profiles');
25 $allow_delete = user_access('withdraw accepted invitations');
26
27 switch ($page) {
28 case 'accepted':
29 default:
30 $sql = "SELECT i.*, u.uid FROM {invite} i LEFT JOIN {users} u ON u.uid = i.mid AND u.uid <> 0 WHERE i.timestamp > 0 ORDER BY u.uid DESC, i.expiry DESC";
31 break;
32 case 'pending':
33 $sql = "SELECT * FROM {invite} WHERE timestamp = 0 AND expiry >= %d ORDER BY expiry DESC";
34 break;
35 case 'expired':
36 $sql = "SELECT * FROM {invite} WHERE timestamp = 0 AND expiry < %d ORDER BY expiry DESC";
37 break;
38 }
39
40 $result = pager_query($sql, 50, 0, NULL, $time);
41
42 while ($invite = db_fetch_object($result)) {
43 $row = array();
44 switch ($page) {
45 case 'accepted':
46 default:
47 $account_exists = !is_null($invite->uid);
48
49 if ($profile_access) {
50 $row[] = $account_exists ? l($invite->email, 'user/'. $invite->mid, array('title' => t('View user profile.'))) : check_plain($invite->email);
51 }
52 else {
53 $row[] = check_plain($invite->email);
54 }
55 $row[] = $account_exists ? t('Accepted') : t('Deleted');
56 $row[] = $allow_delete ? l(t('Withdraw'), "invite/withdraw/{$page}/{$invite->reg_code}") : '';
57 break;
58
59 case 'pending':
60 case 'expired':
61 $expired = ($invite->expiry < $time);
62
63 $row[] = check_plain($invite->email);
64 $row[] = $expired ? t('Expired') : t('Pending');
65 $row[] = l(t('Withdraw'), "invite/withdraw/{$page}/{$invite->reg_code}");
66 break;
67 }
68 $vars['rows'][] = $row;
69 }
70
71 return theme('invite_site_report_report_overview', $vars);
72 }
73
74 /**
75 * Display the invite site report.
76 */
77 function theme_invite_site_report_report_overview($vars) {
78
79 $items = $vars['rows'];
80
81 $output = '<div id="invite-site-report-totals" class="item-list"><h3>'. t('Totals') .'</h3><ul>';
82 $output .= '<li>'. t('Total Invitations: %total', array('%total' => $vars['total_invites'])) .'</li>';
83 $output .= '<li>'. t('Total Accepted Invitations: %total', array('%total' => $vars['accepted_invites'])) .'</li>';
84 $output .= '<li>'. t('Total Pending Invitations: %total', array('%total' => $vars['pending_invites'])) .'</li>';
85 $output .= '<li>'. t('Total Expired Invitations: %total', array('%total' => $vars['expired_invites'])) .'</li>';
86 $output .= '</ul></div>';
87
88 if (count($items) > 0) {
89 $headers = array(t('E-mail'), t('Status'), '');
90 $output .= theme('table', $headers, $items, array('id' => 'invites'));
91 $output .= theme('pager', NULL, 50, 0);
92 }
93 else {
94 $output .= t('No invitations available.');
95 }
96
97 return $output;
98 }

  ViewVC Help
Powered by ViewVC 1.1.2