Mercurial > defr > drupal > ad
comparison ad.pages.inc @ 1:948362c2a207 ad
update advertisement
author | pierre |
---|---|
date | Thu, 02 Apr 2009 15:28:21 +0000 |
parents | d8a3998dac8e |
children |
comparison
equal
deleted
inserted
replaced
0:d8a3998dac8e | 1:948362c2a207 |
---|---|
1 <?php | 1 <?php |
2 // $Id: ad.pages.inc,v 1.1.2.6 2009/02/16 23:12:28 jeremy Exp $ | 2 // $Id: ad.pages.inc,v 1.1.2.6.2.2 2009/02/28 23:39:47 jeremy Exp $ |
3 | 3 |
4 /** | 4 /** |
5 * @file | 5 * @file |
6 * Advertisement nodes pages and forms. | 6 * Advertisement nodes pages and forms. |
7 * | 7 * |
9 * Jeremy Andrews <jeremy@tag1consulting.com> | 9 * Jeremy Andrews <jeremy@tag1consulting.com> |
10 */ | 10 */ |
11 | 11 |
12 function theme_node_ad($node, $yield_form = TRUE) { | 12 function theme_node_ad($node, $yield_form = TRUE) { |
13 $output = ''; | 13 $output = ''; |
14 if (ad_adaccess($node, 'access statistics')) { | 14 if (ad_permission($node, 'access statistics')) { |
15 $output = theme('ad_status_display', $node); | 15 $output = theme('ad_status_display', $node); |
16 $output .= theme('ad_statistics_display', ad_statistics($node->nid)); | 16 $output .= theme('ad_statistics_display', ad_statistics($node->nid)); |
17 } | 17 } |
18 if (ad_adaccess($node, 'access click history')) { | 18 if (ad_permission($node, 'access click history')) { |
19 $header = array( | 19 $header = array( |
20 array('data' => t('Time'), 'field' => 'timestamp', 'sort' => 'desc'), | 20 array('data' => t('Time'), 'field' => 'timestamp', 'sort' => 'desc'), |
21 array('data' => t('User'), 'field' => 'uid'), | 21 array('data' => t('User'), 'field' => 'uid'), |
22 array('data' => t('URL where clicked'), 'field' => 'url'), | 22 array('data' => t('URL where clicked'), 'field' => 'url'), |
23 ); | 23 ); |
24 if (function_exists('click_filter_status_text') && user_access('view filtered clicks')) { | 24 if (function_exists('click_filter_status_text') && user_access('view filtered clicks')) { |
25 $header[] = array('data' => t('Status'), 'field' => 'status'); | 25 $header[] = array('data' => t('Status'), 'field' => 'status'); |
26 } | 26 } |
27 $header[] = ''; | 27 $header[] = ''; |
28 | 28 |
29 if ($node->nid) { | 29 if (isset($node->nid) && $node->nid > 0) { |
30 $sql = "SELECT cid, timestamp, uid, status, url FROM {ad_clicks} WHERE aid = %d"; | 30 $sql = "SELECT cid, timestamp, uid, status, hostname, url FROM {ad_clicks} WHERE aid = %d"; |
31 $sql .= tablesort_sql($header); | 31 $sql .= tablesort_sql($header); |
32 $result = pager_query($sql, 25, 0, NULL, $node->nid); | 32 $result = pager_query($sql, 25, 0, NULL, $node->nid); |
33 | 33 |
34 while ($ad = db_fetch_object($result)) { | 34 while ($ad = db_fetch_object($result)) { |
35 if (module_exists('click_filter') && $ad->status != CLICK_VALID) { | 35 if (module_exists('click_filter') && $ad->status != CLICK_VALID) { |
176 array('data' => $statistics[$key]['views'] ? sprintf('%1.2f', ((int)$statistics[$key]['clicks'] / (int)$statistics[$key]['views']) * 100) .'%' : '0.00%'), | 176 array('data' => $statistics[$key]['views'] ? sprintf('%1.2f', ((int)$statistics[$key]['clicks'] / (int)$statistics[$key]['views']) * 100) .'%' : '0.00%'), |
177 ); | 177 ); |
178 } | 178 } |
179 } | 179 } |
180 if (empty($rows) || (!$statistics['global']['views'] && !$statistics['global']['clicks'])) { | 180 if (empty($rows) || (!$statistics['global']['views'] && !$statistics['global']['clicks'])) { |
181 $statistics = '<p>'. t('There are no any statistics yet.') .'</p>'; | 181 $statistics = '<p>'. t('There are currently no statistics for this advertisement.') .'</p>'; |
182 } | 182 } |
183 else { | 183 else { |
184 $statistics = theme('table', $header, $rows); | 184 $statistics = theme('table', $header, $rows); |
185 } | 185 } |
186 | 186 |
187 return theme('box', t('Statistics'), $statistics); | 187 return theme('box', t('Statistics'), $statistics); |
188 } | 188 } |
189 | 189 |
190 | 190 /** |
191 * Display details about a specific click. | |
192 */ | |
191 function ad_click_details($node, $cid) { | 193 function ad_click_details($node, $cid) { |
192 drupal_set_breadcrumb(array(l(t('Home'), NULL), l(check_plain($node->title), 'node/'. $node->nid))); | 194 drupal_set_breadcrumb(array(l(t('Home'), NULL), l(check_plain($node->title), 'node/'. $node->nid))); |
193 if ($click = db_fetch_object(db_query('SELECT * FROM {ad_clicks} WHERE cid = %d', $cid))) { | 195 if ($click = db_fetch_object(db_query('SELECT * FROM {ad_clicks} WHERE cid = %d', $cid))) { |
194 $ad = node_load($click->aid); | 196 $ad = node_load($click->aid); |
195 $account = user_load(array('uid' => $click->uid)); | 197 $account = user_load(array('uid' => $click->uid)); |