You are here

function ad_click_details in Advertisement 6.2

Same name and namespace in other branches
  1. 5.2 ad.module \ad_click_details()
  2. 5 ad.module \ad_click_details()
  3. 6.3 ad.pages.inc \ad_click_details()
  4. 6 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.pages.inc, line 192
Advertisement nodes pages and forms.

Code

function ad_click_details($node, $cid) {
  drupal_set_breadcrumb(array(
    l(t('Home'), NULL),
    l(check_plain($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);
    $account = user_load(array(
      'uid' => $click->uid,
    ));
    $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('User'),
          'header' => TRUE,
        ),
        theme('username', $account),
      ),
      array(
        array(
          'data' => t('IP Address'),
          'header' => TRUE,
        ),
        $click->hostname,
      ),
      array(
        array(
          'data' => t('User Agent'),
          'header' => TRUE,
        ),
        check_plain($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);
  }
  return $output;
}