Index: drupalvb.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drupalvb/drupalvb.module,v
retrieving revision 1.10
diff -u -p -r1.10 drupalvb.module
--- drupalvb.module	19 Apr 2008 01:48:46 -0000	1.10
+++ drupalvb.module	19 Apr 2008 01:49:19 -0000
@@ -473,6 +473,7 @@ function drupalvb_admin_overview() {
   // Actions.
   $items = array();
   $items[] = l(t('Export Drupal users to vBulletin'), 'drupalvb/actions/export');
+  $items[] = l(t('Import vBulletin users to Drupal'), 'drupalvb/actions/import');
   $output .= theme_item_list($items, t('Actions'));
 
   // Block configuration links.
@@ -669,6 +670,33 @@ function _drupalvb_export_drupal_users()
 }
 
 /**
+ * Import all vBulletin users into Drupal.
+ */
+function _drupalvb_import_vbulletin_users() {
+	global $conf;
+
+	// Turn off automatic vB if on since we know these accounts exist in vB.
+	$autocreate = variable_get('drupalvb_acct_generation', TRUE);
+	$conf['drupalvb_acct_generation'] = FALSE;
+
+	db_set_active('vbulletin');
+	$result = db_query(_drupalvb_prefix("SELECT username as name, password as pass, email as mail, userid FROM {user}"));
+	db_set_active('default');
+	$count = 0;
+	while ($vbuser = db_fetch_array($result)){
+		if (!user_load(array('name' => $vbuser['name']))) {
+			if ($vbuser['name'] && $vbuser['mail'] && $vbuser['pass']) {
+				unset($vbuser['userid']);
+				user_save(NULL, $vbuser);
+			} else {
+				watchdog('drupalvb', 'Invalid user data! Unable to import vBulletin userid: '. $vbuser['userid'], WATCHDOG_ERROR);
+			}
+		}
+	}
+	$conf['drupalvb_acct_generation'] = $autocreate;
+}
+
+/**
  * An action handler for Drupal vB.
  */
 function drupalvb_action_handler($op = NULL) {
