You are here

function simpleads_simpleads_ad_click in SimpleAds 7

Implements hook_simpleads_ad_click().

File

./simpleads.module, line 488

Code

function simpleads_simpleads_ad_click($op, $node) {

  // TRUE means increase/delete impressions using SimpleAds core to control
  // impressions, otherwise disable core counter.
  $internal = variable_get('simpleads_clicks_internal', TRUE);
  if ($op == 'insert' && $internal) {
    if (user_access('count ad clicks') && !_simpleads_bot_detect()) {
      db_insert('simpleads_clicks')
        ->fields(array(
        'nid' => $node->nid,
        'timestamp' => REQUEST_TIME,
        'ip_address' => ip_address(),
      ))
        ->execute();
    }
  }
  if ($op == 'delete' && $internal) {
    db_delete('simpleads_clicks')
      ->condition('nid', $node->nid)
      ->execute();
  }
}