1
Because there is no module/plugin to integrate a vBulletin 3.5.x Board into XOOPS I decided to write a registration and login bridge. If you want to do the registration only about your vBulletin form you can use the following plugin:
xml version="1.0" encoding="ISO-8859-1"?>
XOOPS_Registration_First
register_addmember_complete
define("XOOPS_TABLE_PREFIX", "xoops__");
$tmp_xoops_uid = "NULL";
$tmp_xoops_uname = $vbulletin->GPC['username'];
$tmp_xoops_loginname = $vbulletin->GPC['username'];
$tmp_xoops_name = "";
$tmp_xoops_email = $vbulletin->GPC['email'];
$tmp_xoops_user_avatar = "blank.gif";
$tmp_xoops_pass = $vbulletin->GPC['password_md5']; // Since vB uses md5(md5(password . salt)),
// we have to do this and call a second plugin later!
$tmp_xoops_rank = 0;
$tmp_xoops_level = 1;
// Fill in data into XOOPS user table
$db->query_write("INSERT INTO " . XOOPS_TABLE_PREFIX . "users (uid, uname, loginname, name, email, user_avatar, pass, rank, level)
VALUES ('$tmp_xoops_uid',
'$tmp_xoops_uname',
'$tmp_xoops_loginname',
'$tmp_xoops_name',
'$tmp_xoops_email',
'$tmp_xoops_user_avatar',
'$tmp_xoops_pass',
'$tmp_xoops_rank',
'$tmp_xoops_level')");
// Data for XOOPS user_profile table
$tmp_xoops_profileid = "NULL";
$tmp_xoops_umode = "nest";
$tmp_xoops_uorder = 1;
$tmp_xoops_notify_method = 2;
$tmp_xoops_notify_mode = 0;
$tmp_xoops_user_regdate = 0; // TODO: Add this variable later!
$tmp_xoops_posts = 0;
$tmp_xoops_attachsig = 0;
$tmp_xoops_timezone_offset = "0";
$tmp_xoops_user_mailok = 0; // TODO: Add this variable later!
$tmp_xoops_theme = "0";
$tmp_xoops_actkey = substr(md5(uniqid(mt_rand(), 1)), 0, 8); // This is from XOOPS source
$tmp_xoops_last_login = 0; // TODO: Add this variable later!
$tmp_xoops_user_aim = "";
$tmp_xoops_user_icq = "";
$tmp_xoops_user_from = "";
$tmp_xoops_user_sig = "";
$tmp_xoops_user_viewemail = 0;
$tmp_xoops_user_yim = "";
$tmp_xoops_user_msnm = "";
$tmp_xoops_bio = "";
$tmp_xoops_user_intrest = "";
$tmp_xoops_user_occ = "";
$tmp_xoops_url = "";
$tmp_xoops_newemail = "";
$tmp_xoops_pm_link = "";
// Fill in data into XOOPS user_profile table
$db->query_write("INSERT INTO " . XOOPS_TABLE_PREFIX . "user_profile
(profileid, umode, uorder, notify_method, notify_mode, user_regdate, posts, attachsig, timezone_offset,
user_mailok, theme, actkey, last_login, user_aim, user_icq, user_from, user_sig, user_viewemail,
user_yim, user_msnm, bio, user_intrest, user_occ, url, newemail, pm_link)
VALUES ('$tmp_xoops_profileid',
'$tmp_xoops_umode',
'$tmp_xoops_uorder',
'$tmp_xoops_notify_method',
'$tmp_xoops_notify_mode',
'$tmp_xoops_user_regdate',
'$tmp_xoops_posts',
'$tmp_xoops_attachsig',
'$tmp_xoops_timezone_offset',
'$tmp_xoops_user_mailok',
'$tmp_xoops_theme',
'$tmp_xoops_actkey',
'$tmp_xoops_last_login',
'$tmp_xoops_user_aim',
'$tmp_xoops_user_icq',
'$tmp_xoops_user_from',
'$tmp_xoops_user_sig',
'$tmp_xoops_user_viewemail',
'$tmp_xoops_user_yim',
'$tmp_xoops_user_msnm',
'$tmp_xoops_bio',
'$tmp_xoops_user_intrest',
'$tmp_xoops_user_occ',
'$tmp_xoops_url',
'$tmp_xoops_newemail',
'$tmp_xoops_pm_link')");]]>
XOOPS_Registration_Second
register_activate_process
// Fetch data from vB user table
if ($tmpvbresults = $db->query_first("SELECT username, joindate, lastvisit FROM " . TABLE_PREFIX . "user WHERE userid = " . $vbulletin->GPC['u']))
{ $tmp_xoops_actkey = substr(md5(uniqid(mt_rand(), 1)), 0, 8); // This is from XOOPS source
// Fetch data from XOOPS users table, insert into groups_users_link and update user_profile
if ($xoopsresults = $db->query_first("SELECT uid FROM " . XOOPS_TABLE_PREFIX . "users WHERE uname = '" . $tmpvbresults['username'] . "'"))
{
$db->query_write("INSERT INTO " . XOOPS_TABLE_PREFIX . "groups_users_link (linkid, groupid, uid) VALUES ('NULL', '2', '" . $xoopsresults['uid'] . "')"); $tmp_xoops_actkey = substr(md5(uniqid(mt_rand(), 1)), 0, 8); // This is from XOOPS source
$db->query_write("UPDATE " . XOOPS_TABLE_PREFIX . "user_profile SET user_regdate = " . $tmpvbresults['joindate'] . ", user_mailok = '1', last_login = " . $tmpvbresults['lastvisit'] . " WHERE profileid = " . $xoopsresults['uid']); $tmp_xoops_user_aim = "";
}
}]]>
You have to set the prefix of your XOOPS tables (in this case it's set to "xoops__")! This simple instance assumes that the XOOPS tables are in the same database like the vBulletin tables. So we only have to do a simple query with an existing vB database object. If not, you have to create a new vB database instance and connect with the XOOPS database. vB 3.5.x uses a different User Hash (not a simple md5), so we have to call the plugin on two different Hook Locations. The first plugin will add a new XOOPS user when the vB registration process is complete. The second plugin will activate the user automatically in your XOOPS System as soon as the user sends his activation key via email.
Now you only have to insert a redirect to the vB Register form. Open the file register.php in your xoops/modules/profile/ directory and write something like this:
include '../../mainfile.php';
include_once 'include/functions.php';
redirect_header(XOOPS_URL.'/forum/register.php', 6, "Please register on our forum.");
Fell free to change the values of the plugin. I'm using the vb connector.zip from vBulletin.org to handle a user login (session, cookies...). It acts as a bridge between vB and XOOPS. Thats all!
Regards
StarShaper