You are here

function statistics_counter_exit in Statistics Counter 7

Implements hook_exit().

File

./statistics_counter.module, line 54
Statistics Counter

Code

function statistics_counter_exit($destination = NULL) {

  // Support statistics filter.
  if (module_exists('statistics_filter') && statistics_filter_do_filter()) {
    return;
  }
  if (variable_get('statistics_count_content_views', 0)) {

    // We are counting content views.
    if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == NULL) {

      // A node has been viewed, so update the node's counters.
      db_merge('node_counter')
        ->key(array(
        'nid' => arg(1),
      ))
        ->fields(array(
        'weekcount' => 1,
        'monthcount' => 1,
        'yearcount' => 1,
      ))
        ->expression('weekcount', 'weekcount + 1')
        ->expression('monthcount', 'monthcount + 1')
        ->expression('yearcount', 'yearcount + 1')
        ->execute();
    }
  }
}