/[drupal]/contributions/modules/statistics_advanced/statistics_advanced.module
ViewVC logotype

Diff of /contributions/modules/statistics_advanced/statistics_advanced.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.2.23, Fri Mar 20 06:01:50 2009 UTC revision 1.1.2.24, Fri Apr 17 02:27:44 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: statistics_advanced.module,v 1.1.2.22 2009/03/02 22:33:27 davereid Exp $  // $Id: statistics_advanced.module,v 1.1.2.23 2009/03/20 06:01:50 davereid Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 12  Line 12 
12  function statistics_advanced_perm() {  function statistics_advanced_perm() {
13    return array(    return array(
14      'exclude visits from the access log',      'exclude visits from the access log',
15        'exclude visits from counters',
16    );    );
17  }  }
18    
# Line 77  function statistics_advanced_boot() { Line 78  function statistics_advanced_boot() {
78    // Load path handling.    // Load path handling.
79    drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH);    drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH);
80    
81    // Determine of this is a node page and will increment the statistics counter.    if (_statistics_advanced_is_node_visit() && statistics_advanced_var('ignore_repeat_views')) {
   $is_node_visit = (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == '' && variable_get('statistics_count_content_views', 0));  
   
   if ($is_node_visit && statistics_advanced_var('ignore_repeat_views')) {  
82      // Save the current user's uid as we may find from the accesslog table that      // Save the current user's uid as we may find from the accesslog table that
83      // the user has logged out but has a record in the history table.      // the user has logged out but has a record in the history table.
84      $uid = $user->uid;      $uid = $user->uid;
# Line 125  function _statistics_advanced_is_403_or_ Line 123  function _statistics_advanced_is_403_or_
123  }  }
124    
125  /**  /**
126     * Determine if this page request is a node visit (e.g. node/x).
127     */
128    function _statistics_advanced_is_node_visit() {
129      static $is_node_visit;
130      if (!isset($is_node_visit)) {
131        $is_node_visit = arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == '' && variable_get('statistics_count_content_views', 0);
132      }
133      return $is_node_visit;
134    }
135    
136    /**
137   * Implementation of hook_exit().   * Implementation of hook_exit().
138   *   *
139   * Delete unwanted records.   * Delete unwanted records.
# Line 132  function _statistics_advanced_is_403_or_ Line 141  function _statistics_advanced_is_403_or_
141  function statistics_advanced_exit() {  function statistics_advanced_exit() {
142    global $user;    global $user;
143    
144    $is_node_visit = (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == '' && variable_get('statistics_count_content_views', 0));    if (_statistics_advanced_is_node_visit()) {
   
   if ($is_node_visit) {  
145      if (_statistics_advanced_is_403_or_404()) {      if (_statistics_advanced_is_403_or_404()) {
146        // Ignore 404 and 403 node visits.        // Ignore 404 and 403 node visits.
147        _statistics_advanced_ignore('nodecounter', TRUE);        _statistics_advanced_ignore('nodecounter', TRUE);
148      }      }
149        elseif (user_access('exclude visits from counters')) {
150          _statistics_advanced_ignore('nodecounter', TRUE);
151        }
152      /*else {      /*else {
153        // If the node has been previously read by the user and has changed since        // If the node has been previously read by the user and has changed since
154        // the last read, count it as a new read.        // the last read, count it as a new read.
# Line 162  function statistics_advanced_exit() { Line 172  function statistics_advanced_exit() {
172      $browser = browscap_get_browser();      $browser = browscap_get_browser();
173      if (!empty($browser['crawler'])) {      if (!empty($browser['crawler'])) {
174        _statistics_advanced_ignore('accesslog', TRUE);        _statistics_advanced_ignore('accesslog', TRUE);
175        if ($is_node_visit) {        if (_statistics_advanced_is_node_visit()) {
176          _statistics_advanced_ignore('nodecounter', TRUE);          _statistics_advanced_ignore('nodecounter', TRUE);
177        }        }
178        if (variable_get('browscap_monitor', 0) && function_exists('browscap_unmonitor')) {        if (variable_get('browscap_monitor', 0) && function_exists('browscap_unmonitor')) {

Legend:
Removed from v.1.1.2.23  
changed lines
  Added in v.1.1.2.24

  ViewVC Help
Powered by ViewVC 1.1.2