You are here

function ad_activity_details in Advertisement 7

Same name and namespace in other branches
  1. 6.3 ad.pages.inc \ad_activity_details()
  2. 6.2 ad.pages.inc \ad_activity_details()
1 string reference to 'ad_activity_details'
ad_menu in ./ad.module
Implementation of hook_menu().

File

./ad.pages.inc, line 281
Advertisement nodes pages and forms.

Code

function ad_activity_details($node) {
  $output = '';
  drupal_set_breadcrumb(array(
    l(t('Home'), NULL),
    l(check_plain($node->title), 'node/' . $node->nid),
  ));
  if (ad_check_permission($node, 'access click history')) {
    $header = array(
      array(
        'data' => t('Date'),
        'field' => 'date',
        'sort' => 'desc',
      ),
      array(
        'data' => t('Action'),
        'field' => 'action',
      ),
    );
    if (isset($node->nid) && $node->nid > 0) {
      $result = db_select('ad_statistics', 'stats')
        ->extend('PagerDefault')
        ->extend('TableSort')
        ->limit(25)
        ->condition('action', array(
        'view',
        'click',
      ), 'NOT IN')
        ->condition('aid', $node->nid)
        ->orderByHeader($header)
        ->fields('stats')
        ->execute();
      foreach ($result as $ad) {
        $row = array();
        $row[] = format_date(strtotime($ad->date . '00'), 'large');
        $row[] = $ad->action;
        $rows[] = $row;
      }
      if (empty($rows)) {
        $output = '<p>' . t('There is no activity yet.') . '</p>';
      }
      else {
        $output = theme('table', array(
          'header' => $header,
          'rows' => $rows,
        ));
      }
      $output .= theme('pager');
    }
  }
  return theme('ad_box', array(
    'title' => t('Activity'),
    'content' => $output,
  ));
}