? .DS_Store
? statistics_advanced-477352.patch
Index: statistics_advanced.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/statistics_advanced/Attic/statistics_advanced.admin.inc,v
retrieving revision 1.1.2.3
diff -u -p -r1.1.2.3 statistics_advanced.admin.inc
--- statistics_advanced.admin.inc	26 May 2009 04:21:55 -0000	1.1.2.3
+++ statistics_advanced.admin.inc	31 May 2010 14:01:08 -0000
@@ -48,20 +48,36 @@ function statistics_advanced_settings_fo
     '#disabled' => !$counter_enabled,
   );
 
-  $form['resets'] = array(
+  $form['resets']['reset_counter'] = array(
     '#type' => 'fieldset',
-    '#title' => t('Resets'),
+    '#title' => t('Reset Counter'),
+  );
+  $form['resets']['reset_counter']['node_to_reset'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Node to reset'),
+    '#maxlength' => 60,
+    '#autocomplete_path' => 'ctools/autocomplete/node',
   );
+  $form['resets']['reset_counter']['reset_all'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Reset all node counters.'),
+    '#description' => t('If this option is checked, all the counters will be reset ignoring the node selected above.'),
+  );
+  $form['resets']['reset_counter']['reset'] = array(
+    '#type' => 'submit',
+    '#value' => t('Reset node counters'),
+    '#submit' => array('statistics_advanced_reset_counters'),
+  );
+
   $form['resets']['reset_accesslog'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Reset Accesslog'),
+  );
+  $form['resets']['reset_accesslog']['reset'] = array(
     '#type' => 'submit',
     '#value' => t('Clear access log'),
     '#submit' => array('statistics_advanced_reset_accesslog'),
   );
-  $form['resets']['reset_counter'] = array(
-    '#type' => 'submit',
-    '#value' => t('Reset all node counters'),
-    '#submit' => array('statistics_advanced_reset_counters'),
-  );
 
   //$form['#submit'][] = 'statistics_advanced_settings_form_submit';
 
@@ -94,8 +110,25 @@ function statistics_advanced_settings_fo
 /**
  * Resets the node view counter.
  */
-function statistics_advanced_reset_counters() {
-  db_query("DELETE FROM {node_counter}");
+function statistics_advanced_reset_counters($form, &$form_state) {
+  $reset_all = $form_state['values']['reset_all'];
+  // The reset all option overrides the specific node.
+  if ($reset_all) {
+    db_query("DELETE FROM {node_counter}");
+  }
+  else {
+    // Get the node to reset.
+    $preg_matches = array();
+    $match = preg_match('/\[nid: (\d+)\]/', $form_state['values']['node_to_reset'], $preg_matches);
+    if ($match) {
+      $stat = new StdClass;
+      $stat->nid = $preg_matches[1];
+      $stat->totalcount = 0;
+      $stat->daycount = 0;
+      $stat->timestamp = time();
+    }
+    drupal_write_record('node_counter', $stat, array('nid'));
+  }
   drupal_set_message(t('Node counters reset.'));
 }
 
