Index: statistics.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/statistics/statistics.module,v
retrieving revision 1.248
diff -u -p -r1.248 statistics.module
--- statistics.module	30 Dec 2006 21:12:16 -0000	1.248
+++ statistics.module	8 Jan 2007 15:38:11 -0000
@@ -371,7 +371,13 @@ function statistics_access_logging_setti
     '#default_value' =>  variable_get('statistics_enable_access_log', 0),
     '#options' => $options,
     '#description' => t('Log each page access. Required for referrer statistics.'));
-  $period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval');
+  $form['access']['statistics_flush_access_log'] = array(
+    '#type' => 'radios',
+    '#title' => t('Discard old access logs'),
+    '#default_value' =>  variable_get('statistics_flush_access_log', 0),
+    '#options' => $options,
+    '#description' => t('Access logs can automatically be discarded after a set amount of time (see below).'));
+  $period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800, 15724800, 31536000), 'format_interval');
   $form['access']['statistics_flush_accesslog_timer'] = array(
     '#type' => 'select',
     '#title' => t('Discard access logs older than'),
@@ -397,16 +403,20 @@ function statistics_access_logging_setti
  * Implementation of hook_cron().
  */
 function statistics_cron() {
-  $statistics_timestamp = variable_get('statistics_day_timestamp', '');
+  if (variable_get('statistics_enable_access_log', 0)) {
+    $statistics_timestamp = variable_get('statistics_day_timestamp', '');
 
-  if ((time() - $statistics_timestamp) >= 86400) {
-    /* reset day counts */
-    db_query('UPDATE {node_counter} SET daycount = 0');
-    variable_set('statistics_day_timestamp', time());
+    if ((time() - $statistics_timestamp) >= 86400) {
+      /* reset day counts */
+      db_query('UPDATE {node_counter} SET daycount = 0');
+      variable_set('statistics_day_timestamp', time());
+    }
+
+    /* clean expired access logs */
+    if (variable_get('statistics_flush_access_log', 0)) {
+      db_query('DELETE FROM {accesslog} WHERE timestamp < %d', time() - variable_get('statistics_flush_accesslog_timer', 259200));
+    }
   }
-
-  /* clean expired access logs */
-  db_query('DELETE FROM {accesslog} WHERE timestamp < %d', time() - variable_get('statistics_flush_accesslog_timer', 259200));
 }
 
 /**
