You are here

function ad_click_details in Advertisement 5.2

Same name and namespace in other branches
  1. 5 ad.module \ad_click_details()
  2. 6.3 ad.pages.inc \ad_click_details()
  3. 6 ad.pages.inc \ad_click_details()
  4. 6.2 ad.pages.inc \ad_click_details()
  5. 7 ad.pages.inc \ad_click_details()

Display details about a specific click.

1 string reference to 'ad_click_details'
ad_menu in ./ad.module
Implementation of hook_menu().

File

./ad.module, line 1023
An advertising system for Drupal powered websites.

Code

function ad_click_details($aid, $cid) {
  drupal_set_title(t('Click details'));
  $node = node_load($aid);
  drupal_set_breadcrumb(array(
    l(t('Home'), NULL),
    l($node->title, "node/{$node->nid}"),
  ));
  if ($click = db_fetch_object(db_query('SELECT * FROM {ad_clicks} WHERE cid = %d', $cid))) {
    $ad = node_load($click->aid);
    $rows = array(
      array(
        array(
          'data' => t('Time'),
          'header' => TRUE,
        ),
        format_date($click->timestamp, 'custom', 'D F j, Y h:i a'),
      ),
      array(
        array(
          'data' => t('IP Address'),
          'header' => TRUE,
        ),
        $click->hostname,
      ),
      array(
        array(
          'data' => t('User Agent'),
          'header' => TRUE,
        ),
        $click->user_agent,
      ),
      array(
        array(
          'data' => t('URL'),
          'header' => TRUE,
        ),
        l($click->url, $click->url),
      ),
      array(
        array(
          'data' => t('Advertisement'),
          'header' => TRUE,
        ),
        $ad->ad,
      ),
    );
    if (function_exists('click_filter_status_text') && user_access('view filtered clicks')) {
      switch ($click->status) {
        case 0:
        default:
          $status = t('Not valid: this click has not been counted for unknown reasons.  This is an unexpected error.');
          break;
        case 1:
          $status = t('Valid: this is a valid click.');
          break;
        case 2:
          $status = t('Not valid: this click has not been counted because another click by the same IP address was already counted.');
          break;
        case 3:
          $status = t('Not valid: this click has not been counted because it was generated by an owner of the advertisement.');
          break;
        case 4:
          $status = t('Not valid: this click has not been counted because it was generated by a user in a filtered role.');
          break;
        case 5:
          $status = t('Not valid: this click has not been counted because it was generated by an automated "bot".');
          break;
      }
      $rows[] = array(
        array(
          'data' => t('Status'),
          'header' => TRUE,
        ),
        $status,
      );
    }
    $output = theme('table', array(), $rows, $attributes);
  }
  return $output;
}