Index: user_stats/user_stats.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/user_stats/user_stats.install,v
retrieving revision 1.1.2.5
diff -u -p -r1.1.2.5 user_stats.install
--- user_stats/user_stats.install	14 Mar 2008 02:31:26 -0000	1.1.2.5
+++ user_stats/user_stats.install	20 Mar 2008 00:23:37 -0000
@@ -18,9 +18,10 @@ function user_stats_install() {
         ('IP Address', 'user_ip_address', '', 'Statistics', '', 'textfield', 0, 0, 0, %d, '')", PROFILE_HIDDEN);
       db_query("INSERT INTO {profile_fields} (
         title, name, explanation, category, page, type, weight, required, register, visibility, options) VALUES 
-        ('Login count', 'user_login_count', '', 'Statistics', '', 'textfield', 0, 0, 0, %d, '')", PROFILE_HIDDEN);
+        ('Login Count', 'user_login_count', '', 'Statistics', '', 'textfield', 0, 0, 0, %d, '')", PROFILE_HIDDEN);
       break;
   }
+  variable_set('user_stats_postcount_profile_field', 'user_post_count');
 }
 
 /**
@@ -34,6 +35,7 @@ function user_stats_uninstall() {
   variable_del('user_stats_user_per_cron');
   variable_del('user_stats_count_posts');
   variable_del('user_stats_count_logins');
+  variable_del('user_stats_postcount_profile_field');
   switch ($GLOBALS['db_type']) {
     case 'mysql':
     case 'mysqli':
@@ -90,5 +92,18 @@ function user_stats_update_3() {
   $ret[] = update_sql("INSERT INTO {profile_fields} (
     title, name, explanation, category, page, type, weight, required, register, visibility, options) VALUES 
     ('Login count', 'user_login_count', '', 'Statistics', '', 'textfield', 0, 0, 0, 4, '')");
+
+  return $ret;
+}
+
+/**
+ * Implementation of hook_update()
+ */
+function user_stats_update_4() {
+  $ret = array();
+  variable_set('user_stats_postcount_profile_field', 'user_post_count');
+  $ret[] = update_sql("UPDATE {profile_fields} SET title = 'Login Count'
+    WHERE title = 'Login count'");
+
   return $ret;
 }
Index: user_stats/user_stats.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/user_stats/user_stats.module,v
retrieving revision 1.2.2.14
diff -u -p -r1.2.2.14 user_stats.module
--- user_stats/user_stats.module	14 Mar 2008 02:31:26 -0000	1.2.2.14
+++ user_stats/user_stats.module	20 Mar 2008 00:23:37 -0000
@@ -71,13 +71,28 @@ function user_stats_admin_settings() {
   $form['post_count_options']['user_stats_included_content_types'] = array(
     '#type' => 'select',
     '#title' => t('Content types to include in post count'),
-    '#description' => t('Select the content types to include in the user post count. Both nodes and comments will be included in the post count. If you do not select any content types, then all types will be counted.'),
+    '#description' => t('Select the content types to include in the user post count (hold ctrl or shift to select multiple types). Both nodes and comments will be included in the post count. If you do not select any content types, then all types will be counted.'),
     '#options' => $options,
     '#default_value' => variable_get('user_stats_included_content_types', array()),
     '#multiple' => TRUE,
     '#size' => 10,
   );
 
+  $profile_fields = array('' => 'None');
+  $result = db_query("SELECT name, title FROM {profile_fields} ORDER BY fid");
+  while ($row = db_fetch_object($result)) {
+    $profile_fields[$row->name] = $row->title;
+  }
+
+  $form['post_count_options']['user_stats_postcount_profile_field'] = array(
+    '#type' => 'select',
+    '#title' => t('User stats post count profile field'),
+    '#description' => t('This is the profile field that holds the postcount for a user. Changing this can be useful if you have multiple sites using the same database (or you just do not like the default field used for post counts). <strong>The default setting should work for most people.</strong>'),
+    '#options' => $profile_fields,
+    '#default_value' => variable_get('user_stats_postcount_profile_field', 'user_post_count'),
+    '#required' => TRUE,
+  );
+
   $form['post_count_options']['user_stats_user_per_cron'] = array(
     '#type' => 'select',
     '#title' => t('Number of users to update per cron run'),
@@ -226,10 +241,11 @@ function user_stats_get_stats($type, $ui
           return 'n/a';
         }
         // If the post count for this user hasn't been set then update it
-        if (!isset($user->user_post_count)) {
+        $post_count_profile_field = variable_get('user_stats_postcount_profile_field', 'user_post_count');
+        if (!isset($user->$post_count_profile_field)) {
           user_stats_post_count_update($user, 'reset');
         }
-        return $user->user_post_count;
+        return $user->$post_count_profile_field;
       case 'post_days':
         $last_post = _user_stats_last_post($user);
         if ($last_post !== FALSE) {
@@ -408,8 +424,8 @@ function user_stats_comment(&$a1, $op) {
  */
 function user_stats_cron() {
   if (variable_get('user_stats_rebuild_stats', TRUE) && variable_get('user_stats_count_posts', TRUE)) {
-    $sql = "SELECT fid FROM {profile_fields} WHERE name='user_post_count'";
-    $fid = db_result(db_query($sql));
+    $sql = "SELECT fid FROM {profile_fields} WHERE name='%s'";
+    $fid = db_result(db_query($sql, variable_get('user_stats_postcount_profile_field', 'user_post_count')));
 
     // Unfortunately this cannot be done with a JOIN because of the need to match on fid
     $sql  = "SELECT uid FROM {users} WHERE uid NOT IN ( ";
@@ -703,15 +719,16 @@ function user_stats_post_count_update(&$
   $sql  = "UPDATE {profile_values} SET value=%d ";
   $sql .= "WHERE fid = (SELECT fid FROM {profile_fields} ";
   $sql .= "WHERE name = '%s') AND uid=%d ";
+  $post_count_profile_field = variable_get('user_stats_postcount_profile_field', 'user_post_count');
 
   switch ($op) {
     case 'increment':
-      if (!isset($user->user_post_count)) {
+      if (!isset($user->$post_count_profile_field)) {
         $user = user_stats_post_count_update($user, 'reset');
       }
       else {
-        $user->user_post_count++;
-        db_query($sql, $user->user_post_count, 'user_post_count', $user->uid);
+        $user->$post_count_profile_field++;
+        db_query($sql, $user->$post_count_profile_field, $post_count_profile_field, $user->uid);
         // Flush user cache.
         _user_stats_user_cache($user->uid, TRUE);
         // Flush token cache
@@ -727,12 +744,12 @@ function user_stats_post_count_update(&$
       }
       break;
     case 'decrement':
-      if (!isset($user->user_post_count)) {
+      if (!isset($user->$post_count_profile_field)) {
         $user = user_stats_post_count_update($user, 'reset');
       }
       else {
-        $user->user_post_count--;
-        db_query($sql, $user->user_post_count, 'user_post_count', $user->uid);
+        $user->$post_count_profile_field--;
+        db_query($sql, $user->$post_count_profile_field, $post_count_profile_field, $user->uid);
         // Flush user cache.
         _user_stats_user_cache($user->uid, TRUE);
         // Flush token cache
@@ -749,8 +766,8 @@ function user_stats_post_count_update(&$
     case 'reset':
       static $fid;
       if (!isset($fid)) {
-        $sql = "SELECT fid FROM {profile_fields} WHERE name='user_post_count'";
-        $fid = db_result(db_query($sql));
+        $sql = "SELECT fid FROM {profile_fields} WHERE name='%s'";
+        $fid = db_result(db_query($sql, $post_count_profile_field));
       }
       $sql  = "SELECT COUNT(*) FROM {node} WHERE uid=%d AND status=1";
       $postcount_content_types = variable_get('user_stats_included_content_types', array());
@@ -851,7 +868,7 @@ function user_stats_user_load($uid) {
  *   This must be the name of the profile_fields field.
  */
 function user_stats_reset_counts($statistic = 'user_post_count') {
-  $fid = db_result(db_query("SELECT fid FROM {profile_fields} WHERE name = '%s'", $statistic));
+  $fid = db_result(db_query("SELECT fid FROM {profile_fields} WHERE name = '%s'", variable_get('user_stats_postcount_profile_field', 'user_post_count')));
   if ($fid) {
     db_query('DELETE FROM {profile_values} WHERE fid = %d', $fid);
   }
