diff -urNp drupalvb_old/drupalvb.inc drupalvb/drupalvb.inc --- drupalvb_old/drupalvb.inc 2006-10-14 09:39:38.000000000 +0300 +++ drupalvb/drupalvb.inc 2007-01-05 15:29:41.000000000 +0200 @@ -117,19 +117,27 @@ function drupalvb_set_login_cookies() { function drupalvb_clear_cookies() { } //Function to create an entry in the vB database user table -function _drupalvb_create_vb_user($username, $password, $email){ +function _drupalvb_create_vb_user($username, $password, $email, $silent=false){ //Double check to make sure we're not duplicating an entry... $result = db_query("SELECT userid FROM user WHERE username = '$username'"); - + if (db_fetch_array($result)) { - //The user existed somehow, so send the error and kick it out with a fail - drupalvb_msg(DVBERROR, "Your username already existed on the forums. The duplication problem has been logged. " . - "If this error message continues to display, please contact the site administrator."); - watchdog ("drupalvb", "Attempted to create a duplicate vB user.", WATCHDOG_ERROR); + /******************* + * Added by valcker + * This should be done, when exporting all users from drupal to vbulletin + * If user exists, then it should be skiped without any messages + */ + if(!$silent) { + //The user existed somehow, so send the error and kick it out with a fail + drupalvb_msg(DVBERROR, "Your username already existed on the forums. The duplication problem has been logged. " . + "If this error message continues to display, please contact the site administrator."); + watchdog ("drupalvb", "Attempted to create a duplicate vB user.", WATCHDOG_ERROR); + } + return false; } - + //Set up the necessary variables $salt = ''; for ($i = 0; $i < 3; $i++) diff -urNp drupalvb_old/drupalvb.module drupalvb/drupalvb.module --- drupalvb_old/drupalvb.module 2006-09-12 00:23:16.000000000 +0300 +++ drupalvb/drupalvb.module 2007-01-05 15:39:33.000000000 +0200 @@ -24,7 +24,7 @@ *************************************************************************/ require_once('drupalvb.inc'); - + /** * Implementation of hook_help() */ @@ -47,12 +47,16 @@ function drupalvb_menu($may_cache) { $items[] = array('path' => 'admin/drupalvb', 'title' => t('drupalvb'), 'callback' => 'drupalvb_admin_overview', 'access' => $access, - 'type' => MENU_DYNAMIC_ITEM); + 'type' => MENU_DYNAMIC_ITEM); $items[] = array('path' => "drupalvb/pms", 'title' => t('Private Messages'), - 'callback' => 'drupalvb_private_messages', - 'access' => user_access('access content'), + 'callback' => 'drupalvb_private_messages', + 'access' => user_access('access content'), 'type' => MENU_CALLBACK); - + $items[] = array('path' => 'drupalvb/actions', 'title' => t('Actions'), + 'callback' => 'drupalvb_handle_actions', + 'access' => $access, + 'type' => MENU_CALLBACK); + return $items; } @@ -285,7 +289,7 @@ function drupalvb_block($op='list', $del $name_tag = ' ' . $data->username . ''; $items[] = l($data->title, $vbulletin->options['bburl'] - . "/showthread.php?t=" . $data->threadid, + . "/showthread.php?t=" . $data->threadid, array('target' => '_blank')) . $name_tag; } @@ -410,7 +414,12 @@ function drupalvb_admin_overview() { $items[] = l(t("Forum Info (users online, new posts/PMs)"), "admin/block/configure/drupalvb/1"); $items[] = l(t("Forum Admin (total posts/threads/members, active members)"), "admin/block/configure/drupalvb/2"); $output .= theme_item_list($items, "Block Configuration"); - + + // Actions + $items = null; + $items[] = l(t("Export Drupal users to vBulletin"), "drupalvb/actions/export"); + $output .= theme_item_list($items, "Actions"); + //Features $items = null; $items[] = "User creation/deletion in Drupal makes appropriate entries in vBulletin."; @@ -578,12 +587,41 @@ function drupalvb_user_delete($user) { else { watchdog("drupalvb", "Attempting to delete a user that doesn't exist!", WATCHDOG_ERROR); } - + db_set_active('default'); - + return; } +/** + * Export all drupal users to vbulletin + */ +function drupalvb_export_drupal_users() { + $result = db_query("SELECT uid FROM {users} ORDER BY uid"); + while($r = db_fetch_object($result)) { + if($r->uid==0) + continue; + $user = user_load(array('uid' => $r->uid)); + db_set_active('vbulletin'); + $created = _drupalvb_create_vb_user($user->name, $user->pass, $user->mail, true); + db_set_active('default'); + } +} + +function drupalvb_handle_actions($op=null) { + if(null==$op) { + return t("Unknown action."); + } + + switch($op) { + case 'export': + drupalvb_export_drupal_users(); + drupal_set_message(t("Users where exported.")); + drupal_goto("admin/drupalvb"); + return; + } +} + function drupalvb_private_messages() { global $user; $vbulletin = _drupalvb_vb_init();