? browscap-exclude-admin.patch
Index: browscap.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/browscap/browscap.module,v
retrieving revision 1.6.2.3.2.13
diff -u -p -r1.6.2.3.2.13 browscap.module
--- browscap.module	1 Sep 2010 19:52:03 -0000	1.6.2.3.2.13
+++ browscap.module	26 Jan 2011 17:03:05 -0000
@@ -81,18 +81,20 @@ function browscap_menu() {
 function browscap_exit() {
   // If monitoring is enabled, record the browser
   if (variable_get('browscap_monitor', FALSE)) {
-    if ($browser = browscap_get_browser()) {
-      $browserstring = substr(trim($browser['parent']), 0, 255);
-      if ($browserstring == '' or $browserstring == 'Default Browser') {
-        $browserstring = trim($_SERVER['HTTP_USER_AGENT']);
-      }
-      db_query("UPDATE {browscap_statistics} SET counter = counter + 1, is_crawler=%d ".
-        "WHERE parent='%s'", $browser['crawler'], $browserstring);
-      // If we affected 0 rows, this is the first time we've seen this browser
-      if (!db_affected_rows()) {
-        // We must create a new row to store counters for the new browser.
-        db_query('INSERT INTO {browscap_statistics} (parent,counter,is_crawler) '.
-          "VALUES('%s', 1, %d)", $browserstring, $browser['crawler']);
+    if (browscap_check_user()) {
+      if ($browser = browscap_get_browser()) {
+        $browserstring = substr(trim($browser['parent']), 0, 255);
+        if ($browserstring == '' or $browserstring == 'Default Browser') {
+          $browserstring = trim($_SERVER['HTTP_USER_AGENT']);
+        }
+        db_query("UPDATE {browscap_statistics} SET counter = counter + 1, is_crawler=%d ".
+          "WHERE parent='%s'", $browser['crawler'], $browserstring);
+        // If we affected 0 rows, this is the first time we've seen this browser
+        if (!db_affected_rows()) {
+          // We must create a new row to store counters for the new browser.
+          db_query('INSERT INTO {browscap_statistics} (parent,counter,is_crawler) '.
+            "VALUES('%s', 1, %d)", $browserstring, $browser['crawler']);
+        }
       }
     }
   }
@@ -138,6 +140,13 @@ function browscap_settings() {
                           '!reports' => url('admin/reports/browscap'),
                         )),
   );
+  
+  $form['browscap_exclude_admin'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Exclude admin'),
+    '#default_value' => variable_get('browscap_exclude_admin', FALSE),
+    '#description' => t('Exclude the site admininstrator from statistics')
+  );
   return system_settings_form($form);
 }
 
@@ -438,3 +447,13 @@ function browscap_useragent_properties($
   $output = theme('table', $headers, $rows);
   return $output;
 }
+
+/**
+ * Checks whether the current user can be monitored
+ *
+ * @return bool
+ */
+function browscap_check_user() {
+  global $user;
+  return !(variable_get('browscap_exclude_admin', FALSE) && $user->uid == 1);
+}
