Index: drupalvb.admin-pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drupalvb/drupalvb.admin-pages.inc,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 drupalvb.admin-pages.inc
--- drupalvb.admin-pages.inc	21 Apr 2008 16:55:10 -0000	1.1.2.1
+++ drupalvb.admin-pages.inc	22 Apr 2008 17:54:49 -0000
@@ -140,6 +140,7 @@ function drupalvb_settings_actions() {
   
   $items = array(
     l(t('Export Drupal users to vBulletin'), 'drupalvb/actions/export'),
+    l(t('Import vBulletin users into Drupal'), 'drupalvb/actions/import'),
   );
   $form[] = array(
     '#value' => theme('item_list', $items),
Index: drupalvb.inc.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drupalvb/drupalvb.inc.php,v
retrieving revision 1.9.4.1
diff -u -p -r1.9.4.1 drupalvb.inc.php
--- drupalvb.inc.php	21 Apr 2008 16:55:10 -0000	1.9.4.1
+++ drupalvb.inc.php	22 Apr 2008 19:06:28 -0000
@@ -184,6 +184,49 @@ function drupalvb_export_drupal_users() 
 }
 
 /**
+ * Import all vBulletin users into Drupal.
+ *
+ * @todo Replace with lazy instantiation via hook_auth().
+ */
+function drupalvb_import_vbulletin_users() {
+  global $conf;
+  require_once drupal_get_path('module', 'drupalvb') .'/drupalvb.inc';
+
+  // Disable auto-user creation since these accounts already exist in vB.
+  $autocreate = variable_get('drupalvb_acct_generation', TRUE);
+  $conf['drupalvb_acct_generation'] = FALSE;
+
+  // @todo If we are querying the same database, we could filter out already
+  //   existing users with an extra (left) join and also fetch overlapping user
+  //   ids.
+  $result = drupalvb_db_query("SELECT userid, username as name, password as pass, email as mail FROM {user}");
+  $existing = $invalid = array();
+  while ($vbuser = db_fetch_array($result)){
+    if ($vbuser['name'] && $vbuser['mail'] && $vbuser['pass']) {
+      if (!user_load(array('name' => $vbuser['name']))) {
+        unset($vbuser['userid']);
+        $vbuser['init'] = $vbuser['pass'];
+        user_save(NULL, $vbuser);
+      }
+      else {
+        $existing[$vbuser['userid']] = $vbuser['name'];
+      }
+    }
+    else {
+      $invalid[$vbuser['userid']] = $vbuser['name'];
+    }
+  }
+  if (!empty($invalid)) {
+    drupal_set_message(t('The following users could not be imported due to invalid data: !users', array('!users' => implode(', ', $invalid))), 'error');
+  }
+  if (!empty($existing)) {
+    drupal_set_message(t('The following users already exist: !users', array('!users' => implode(', ', $invalid))), 'error');
+  }
+  // Reset auto-user creation.
+  $conf['drupalvb_acct_generation'] = $autocreate;
+}
+
+/**
  * Get vBulletin configuration options.
  */
 function drupalvb_get_options() {
