Drupaltin Handbooks

The Drupaltin Handbooks are to help users install and configure Drupaltin. Any help with the documentation is greatly appreciated.

 If you would like to try a demo of Drupaltin, a demo user has been made that you can play around with.

Username: Demo
Password: demo

Code - 5.x-1.0a

These are the files contained within Drupaltin 5.x-1.0a. View the source of the files online and collaborate on the coding. Please feel free to comment on the files and help us improve the product.

The structure for files goes as followed:

 

Drupaltin Directory Layout

 

 

*Note- Do NOT use the contents of these files to install Drupaltin. Download the package and use those files.

drupaltin.info

; $Id: drupaltin.info,v 5.x-1.0a 2007/01/27 23:02:36 dries Exp $
name = Drupaltin
description = Adds functionality to allow users from vBulletin to log in and out of Drupal seamlessly
package =
version = VERSION

; Information added by drupal.org packaging script on 2007-01-15
version = "5.x-1.0a"
project = "drupal"

drupaltin.module

<?php
// $Id: drupaltin.module,v 5.x-1.0a 2007/02/20 23:06:45 dries Exp $

   /*============================================================================*\ 
   ||                               -= Drupaltin =-                              ||
   ||                                                                            ||
   || By Jordan Starcher                                                         ||
   || drupaltin.module -> /drupal/modules/drupaltin/                             ||
   || Engineered for Drupal 5.x & vB 3.6.x                                       ||
   || Project Version 5.x-1.0a                                                   ||
   || File Version 1.01                                                          ||
   || February 20, 2007                                                          ||
   || Release under the GPL license                                              ||
   ||                                                                            ||
   ||                              Copyright ©2007                               ||
   ||                       http://www.TheOverclocked.com                        ||
   \*============================================================================*/


/**
* Implementation of hook_help()
*/
function drupalvb_help($section = 'admin/help#drupaltin') {
  switch (
$section) {
    case
'admin/modules#description':
      return
t("Integrates users from vBulletin into Drupal without sacrificing usability");
  }
}

/**
* Implementation of hook_perm()
*/
function drupaltin_perm() {
  return array(
'view drupaltin login');
}

/**
* Implementation of hook_block()
*/
function drupaltin_block($op = 'list', $delta = 0, $edit = array()) {
  global
$user;
    if (
$op == 'list') {
   
$blocks[0] = array('info' => t('Drupaltin login form'),
     
'weight' => 0, 'enabled' => 1, 'region' => 'left');
    return
$blocks;
  }
    else if (
$op == 'configure' && $delta == 0) {
    return
$form;
  }
  else if (
$op == 'view') {
    switch(
$delta) {
      case
0:
        if (!
$user->uid) {
         
$block['subject'] = t('User login');
         
$block['content'] = "<script type='text/javascript' src='http://forums.theoverclocked.com/clientscript/vbulletin_md5.js?v=364'></script><div><form action='http://forums.theoverclocked.com/login.php?do=login' method='post' onsubmit='md5hash(vb_login_md5password, vb_login_md5password_utf, 0' id='user-login-form'><div><input type='hidden' name='do' value='login' /><div><input type='hidden' name='url' value='/' /></div><div><input type='hidden' name='vb_login_md5password' /></div><div><input type='hidden' name='vb_login_md5password_utf' /></div><div><input type='hidden' name='s' value='' /></div><div><input type='hidden' name='url' value='http://www.theoverclocked.com' /></div></div>
             <div class='form-item'><label for='edit-name'>Username: <span class='form-required' title='This field is required.'>*</span></label><div><input type='text' class='form-text required' name='vb_login_username' id='edit-name' size='15' maxlength='60' accesskey='u' tabindex='1' /></div></div>
                 <div class='form-item'><label for='edit-pass'>Password: <span class='form-required' title='This field is required.'>*</span></label><div><input type='password' class='form-text required' name='vb_login_password' id='edit-pass' size='15' maxlength='60' tabindex='1' /></div><div><label for='cb_cookieuser'><input type='checkbox' name='cookieuser' value='1' id='cb_cookieuser' tabindex='1' checked='checked' />Remember Me</label></div></div>
            <div><input type='submit' class='button' value='Log In' accesskey='s' tabindex='1' /></div>
                <div class='item-list'>
                    <ul>

                        <li><a href='http://forums.theoverclocked.com/register.php' title='Create a new user account.'>Create new account</a></li>
                        <li><a href='http://forums.theoverclocked.com/login.php?do=lostpw' title='Request new password via e-mail.'>Forgotten Your Password?</a></li>
                    </ul>
                </div>
</form></div>"
;
        }
        return
$block;
    }
  }   
}


function
drupaltin_logout() {
   
header('Location: drupaltin_logout.php?do=logout');
}


/**
* Implementation of hook_menu()
*/
function drupaltin_menu($may_cache) {
        global
$user;
        if (
$may_cache) {
$items[] = array('path' => 'drupaltin_logout', 'title' => t('Log Out'),
     
'callback' => 'drupaltin_logout',
     
'access' => $user->uid, 'weight' => '10', 'type' => MENU_NORMAL_ITEM);
        }
        return
$items;
}
?>

drupaltin_config.php

<?php


  
/*============================================================================*\ 
   ||                               -= Drupaltin =-                              ||
   ||                                                                            ||
   || By Jordan Starcher                                                         ||
   || drupaltin_config.php -> /vbforums/includes/                                ||
   || Engineered for Drupal 5.x & vB 3.6.x                                       ||
   || Project Version 5.x-1.0a                                                   ||
   || File Version 1.01                                                          ||
   || February 17, 2007                                                          ||
   || Release under the GPL license                                              ||
   ||                                                                            ||
   ||                                                                            ||
   ||                              Copyright ©2007                               ||
   ||                      http://www.TheOverclocked.com                         ||
   \*============================================================================*/

/***************************************************************************\
* Info: Drupaltin is a vBulletin plugin to integrate Drupal with a        *
*       vBulletin forum. No Drupal or vB functionality is sacrificed,     * 
*     as the core code remains unchanged and no tables are modified or  *
*     created in the vBulletin database. A Drupal module is also        *
*     provided to replace the Login form and Logout button.             *
\***************************************************************************/

/***************************************************************************\
* - More info available at http://www.TheOverclocked.com/Drupaltin        *
\***************************************************************************/


//////////////////////////////////////////////////
//+--------------------------------------------+//
//|  Define the webserver and path parameters  |//
//+--------------------------------------------+//
//////////////////////////////////////////////////

        
/**                                                          
* PATHS INFO   ##### NO TRAILING SLASHES #####                                
*/                                       
// Drupal server path
$drup_main_dir = '/var/www/theoverclocked.com';

// vBulletin server path
$vb_main_dir = '/var/www/forums.theoverclocked.com';

// Drupal http path
$drup_main_http = 'http://www.theoverclocked.com';


/**/ ####### Ignore this ####### /**/
/**/
class SystemComponent {     /**/
/**/   
var $settings;           /**/
/**/   
function getSettings() { /**/
/**/ ####### Ignore this ####### /**/


/**
* DRUPAL DATABASE INFO
*/
$settings['dbhost'] = 'localhost';
$settings['dbusername'] = '';
$settings['dbpassword'] = '';
$settings['dbname'] = 'drupal';


//////////////////////////////////////////////////////
//+------------------------------------------------+//
//|  END Define the webserver and path parameters  |//
//+------------------------------------------------+//
//////////////////////////////////////////////////////



//
// DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING
///////////////////////////////////////////////////////////////////////










       
return $settings;

    }

}

class
DbConnector extends SystemComponent {

    var
$theQuery;
    var
$link;

   
//*** Function: DbConnector, Purpose: Connect to the database ***
   
function DbConnector(){

       
// Load settings from parent class
       
$settings = SystemComponent::getSettings();

       
// Get the main settings from the array we just loaded
       
$host = $settings['dbhost'];
       
$db = $settings['dbname'];
       
$user = $settings['dbusername'];
       
$pass = $settings['dbpassword'];

       
// Connect to the database
       
$this->link = mysql_connect($host, $user, $pass);
       
mysql_select_db($db);
       
register_shutdown_function(array(&$this, 'close'));

    }

   
//*** Function: query, Purpose: Execute a database query ***
   
function query($query) {

       
$this->theQuery = $query;
        return
mysql_query($query, $this->link);

    }

   
//*** Function: fetchArray, Purpose: Get array of query results ***
   
function fetchArray($result) {

        return
mysql_fetch_array($result);

    }

   
//*** Function: close, Purpose: Close the connection ***
   
function close() {

       
mysql_close($this->link);

    }


}


//////////////////////////////
//////// Dev Sandbox ////////
////////////////////////////
//INSERT INTO `role` (`rid`, `name`) VALUES ('', 'banned user');
//
//
//
?>

drupaltin_login.php

<?php
  
/*============================================================================*\ 
   ||                               -= Drupaltin =-                              ||
   ||                                                                            ||
   || By Jordan Starcher                                                         ||
   || drupaltin_login.php -> /drupal/                                            ||
   || Engineered for Drupal 5.x & vB 3.6.x                                       ||
   || Project Version 5.x-1.0a                                                   ||
   || File Version 1.01                                                          ||
   || February 20, 2007                                                          ||
   || Release under the GPL license                                              ||
   ||                                                                            ||
   ||                                                                            ||
   ||                               Copyright ©2007                              ||
   ||                        http://www.TheOverclocked.com                       ||
   \*============================================================================*/

require_once('drupaltin_logout.php');
require_once(
$vb_main_dir . '/includes/drupaltin_config.php');
$connector = new DbConnector();
require_once(
'includes/bootstrap.inc');
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

if (!empty(
$_REQUEST['drupaltin_username']) && !empty($_REQUEST['drupaltin_password']) && !empty($_REQUEST['drupaltin_login_hash'])) {

$drupaltin_login_fetch = sprintf("SELECT created FROM users WHERE name = '%s'",
       
mysql_real_escape_string($_REQUEST['drupaltin_username']));

$drupaltin_login_connect = $connector->query($drupaltin_login_fetch);
$drupaltin_login_created = mysql_fetch_row($drupaltin_login_connect);
$drupaltin_login_hash = sha1($drupaltin_login_created['0']);       
                   if (
$drupaltin_login_hash === $_REQUEST['drupaltin_login_hash']) {
                      
                       
user_authenticate($_REQUEST['drupaltin_username'], $_REQUEST['drupaltin_password']);

                        unset(
$_REQUEST['drupaltin_username'], $_REQUEST['drupaltin_password']);
                        return
$drupaltin_login_hash;
                   } else {
                        echo
"CAUGHT YOU! Stop trying to hack or you will be prosecuted. If you feel you've reached this message in error, <br />
                              please notify the Administrator."
;
                        exit;
                   }
}
?>

drupaltin_logout.php

<?php
  
/*============================================================================*\ 
   ||                               -= Drupaltin =-                              ||
   ||                                                                            ||
   || By Jordan Starcher                                                         ||
   || drupaltin_logout.php -> /drupal/                                           ||
   || Engineered for Drupal 5.x & vB 3.6.x                                       ||
   || Project Version 5.x-1.0a                                                   ||
   || File Version 1.01                                                          ||
   || February 20, 2007                                                          ||
   || Release under the GPL license                                              ||
   ||                                                                            ||
   ||                              Copyright ©2007                               ||
   ||                       http://www.TheOverclocked.com                        ||
   \*============================================================================*/


////////////////////////////////////
//+------------------------------+//
//|  Define the path parameters  |//
//+------------------------------+//
////////////////////////////////////

// vBulletin server path
$vb_main_dir = '/var/www/forums.theoverclocked.com'; ## NO TRAILING SLASH

////////////////////////////////////////
//+----------------------------------+//
//|  END Define the path parameters  |//
//+----------------------------------+//
////////////////////////////////////////




//
// DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING
///////////////////////////////////////////////////////////////////////













$drupaltin_cwd = getcwd();
chdir($vb_main_dir);
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'login');

// ################### PRE-CACHE TEMPLATES AND DATA ######################
$phrasegroups = array(

);

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
require_once(
DIR . '/includes/functions_login.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
if ($_REQUEST['do'] == 'logout')
{
process_logout();
}
chdir($drupaltin_cwd);
?>

form.html

<script type='text/javascript' src='http://forums.theoverclocked.com/clientscript/vbulletin_md5.js?v=364'></script><div><form action='http://forums.theoverclocked.com/login.php?do=login' method='post' onsubmit='md5hash(vb_login_md5password, vb_login_md5password_utf, 0' id='user-login-form'><div><input type='hidden' name='do' value='login' /><div><input type='hidden' name='url' value='/' /></div><div><input type='hidden' name='vb_login_md5password' /></div><div><input type='hidden' name='vb_login_md5password_utf' /></div><div><input type='hidden' name='s' value='' /></div><div><input type='hidden' name='url' value='http://www.theoverclocked.com' /></div></div>
<div class='form-item'><label for='edit-name'>Username: <span class='form-required' title='This field is required.'>*</span></label><div><input type='text' class='form-text required' name='vb_login_username' id='edit-name' size='15' maxlength='60' accesskey='u' tabindex='1' /></div></div>
     <div class='form-item'><label for='edit-pass'>Password: <span class='form-required' title='This field is required.'>*</span></label><div><input type='password' class='form-text required' name='vb_login_password' id='edit-pass' size='15' maxlength='60' tabindex='1' /></div><div><label for='cb_cookieuser'><input type='checkbox' name='cookieuser' value='1' id='cb_cookieuser' tabindex='1' checked='checked' />Remember Me</label></div></div>
<div><input type='submit' class='button' value='Log In' accesskey='s' tabindex='1' /></div>
<div class='item-list'>
<ul>

<li><a href='http://forums.theoverclocked.com/register.php' title='Create a new user account.'>Create new account</a></li>
<li><a href='http://forums.theoverclocked.com/login.php?do=lostpw' title='Request new password via e-mail.'>Forgotten Your Password?</a></li>
</ul>
</div>
</form></div>

form.php

$drupaltin_login_form = "<script type='text/javascript' src='http://forums.theoverclocked.com/clientscript/vbulletin_md5.js?v=364'></script><div><form action='http://forums.theoverclocked.com/login.php?do=login' method='post' onsubmit='md5hash(vb_login_md5password, vb_login_md5password_utf, 0' id='user-login-form'><div><input type='hidden' name='do' value='login' /><div><input type='hidden' name='url' value='/' /></div><div><input type='hidden' name='vb_login_md5password' /></div><div><input type='hidden' name='vb_login_md5password_utf' /></div><div><input type='hidden' name='s' value='' /></div><div><input type='hidden' name='url' value='http://www.theoverclocked.com' /></div></div>
<div class='form-item'><label for='edit-name'>Username: <span class='form-required' title='This field is required.'>*</span></label><div><input type='text' class='form-text required' name='vb_login_username' id='edit-name' size='15' maxlength='60' accesskey='u' tabindex='1' /></div></div>
     <div class='form-item'><label for='edit-pass'>Password: <span class='form-required' title='This field is required.'>*</span></label><div><input type='password' class='form-text required' name='vb_login_password' id='edit-pass' size='15' maxlength='60' tabindex='1' /></div><div><label for='cb_cookieuser'><input type='checkbox' name='cookieuser' value='1' id='cb_cookieuser' tabindex='1' checked='checked' />Remember Me</label></div></div>
<div><input type='submit' class='button' value='Log In' accesskey='s' tabindex='1' /></div>
<div class='item-list'>
<ul>

<li><a href='http://forums.theoverclocked.com/register.php' title='Create a new user account.'>Create new account</a></li>
<li><a href='http://forums.theoverclocked.com/login.php?do=lostpw' title='Request new password via e-mail.'>Forgotten Your Password?</a></li>
</ul>
</div>
</form></div>";

login_verify_success

<?php
require_once(DIR . '/includes/drupaltin_config.php');
require_once(
$drup_main_dir . '/includes/bootstrap.inc');
$connector = new DbConnector();

$drupaltin_logout_cwd = getcwd();
chdir($drup_main_dir);
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
chdir($drupaltin_logout_cwd);
/**
* Dump the MD5 of the password the user entered into the Drupal database since vB doesn't store the password in pure MD5
*/

$dvb_md5 = md5($vbulletin->GPC['vb_login_password']);
$UpdateQuery = sprintf("UPDATE users SET pass = '%s' WHERE name = '%s'",
       
mysql_real_escape_string($dvb_md5),   
       
mysql_real_escape_string($vbulletin->GPC['vb_login_username']));

$connector->query($UpdateQuery);

/**
* Start the Drupal session and push a cookie
*/
$name = $vbulletin->GPC['vb_login_username'];
$pass = $vbulletin->GPC['vb_login_password'];
user_authenticate($name, $pass);

// Sha1 the created
$drupaltin_login_fetch = sprintf("SELECT created FROM users WHERE name = '%s'",
       
mysql_real_escape_string($vbulletin->GPC['vb_login_username']));

$drupaltin_login_connect = $connector->query($drupaltin_login_fetch);
$drupaltin_login_created = mysql_fetch_row($drupaltin_login_connect);
$drupaltin_login_hash = sha1($drupaltin_login_created['0']);

// Setup for external cookie
$_POST['drupaltin_username'] = $vbulletin->GPC['vb_login_username'];
$_POST['drupaltin_password'] = $vbulletin->GPC['vb_login_password'];
$_POST['drupaltin_login_hash'] = $drupaltin_login_hash;

$drupaltin_login = include $drup_main_http . '/drupaltin_login.php';

if (
$drupaltin_login != '1') {
   echo
"erm, could not set correct Drupal cookies. Notify the Administrator please!";
   exit;
}
?>

logout_process

<?php
require_once(DIR . '/includes/drupaltin_config.php');
require_once(
$drup_main_dir . '/includes/bootstrap.inc');

$drupaltin_logout_cwd = getcwd();
chdir($drup_main_dir);
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
user_logout();
chdir($drupaltin_logout_cwd);
?>

product_install_code

<?php
if (file_exists(DIR . '/includes/drupaltin_config.php') == true)
    {

require_once(
DIR . '/includes/drupaltin_config.php');
$connector = new DbConnector();
/**
* Backup the original users table so we can restore it if we need to
*/
$backup = "CREATE TABLE users_backup SELECT * FROM users";
        if(!
$connector->query($backup))
    {
        echo
mysql_error();
        exit();
    }

/**
* Delete all the old data from the users table now that it has been backed up, prepares us for the new dump :)
*/
$truncate = "TRUNCATE TABLE users";
        if(!
$connector->query($truncate))
    {
        echo
mysql_error();
        exit();
    }


/**
* Here is where we read the database values that we need from the vB database and drump them into the Drupal database
*/
$query = $vbulletin->db->query_read("SELECT userid, username, password, email, joindate, timezoneoffset FROM user");

while (
$row = mysql_fetch_object($query))
{
   
$row->timezoneoffset = intval($row->timezoneoffset) * 3600;
   
$insert = sprintf("INSERT INTO `users` (
        `uid`, `name`, `pass`, `mail`, `mode`, `sort`, `threshold`, `theme`, `signature`, `created`, `access`,
        `login`, `status`, `timezone`, `language`, `picture`, `init`, `data`)
        VALUES (
        '%s', '%s', '%s', '%s', '0', '0', '0', '', '',  '%s', '0', '0', '1', '%s', '', '', '%s', 'a:0:{}')"
,
       
mysql_real_escape_string($row->userid),
       
mysql_real_escape_string($row->username),
       
mysql_real_escape_string($row->password),
       
mysql_real_escape_string($row->email),
       
mysql_real_escape_string($row->joindate),
       
mysql_real_escape_string($row->timezoneoffset),   
       
mysql_real_escape_string($row->email));   

    if(!
$connector->query($insert))
    {
        echo
mysql_error();
        exit();
    }
}
   
    } else {
    echo
"Missing drupaltin_config.php file. Please upload to /vbforums/includes/ and try again.";
   
}
?>

product_uninstall_code

<?php
if (file_exists(DIR . '/includes/drupaltin_config.php') == true)
    {

require_once(
DIR . '/includes/drupaltin_config.php');
$connector = new DbConnector();
/**
* Delete all the old data from the users table, prepares us for the dumping the old users :)
*/
$truncate = "TRUNCATE TABLE users";
        if(!
$connector->query($truncate))
    {
        echo
mysql_error();
        exit();
    }

/**
* Here is where we read the database values that we need from the vB database and drump them into the Drupal database
*/
$query = $connector->query("SELECT `uid`, `name`, `pass`, `mail`, `mode`, `sort`, `threshold`, `theme`, `signature`, `created`, `access`,
        `login`, `status`, `timezone`, `language`, `picture`, `init`, `data` FROM `users_backup`;"
);

while (
$row = mysql_fetch_object($query))
{
   
$insert = sprintf("INSERT INTO `users` (
        `uid`, `name`, `pass`, `mail`, `mode`, `sort`, `threshold`, `theme`, `signature`, `created`, `access`,
        `login`, `status`, `timezone`, `language`, `picture`, `init`, `data`)
        VALUES (
        '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s',  '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')"
,
       
mysql_real_escape_string($row->uid),
       
mysql_real_escape_string($row->name),
       
mysql_real_escape_string($row->pass),
       
mysql_real_escape_string($row->mail),
       
mysql_real_escape_string($row->mode),
       
mysql_real_escape_string($row->sort),
       
mysql_real_escape_string($row->threshold),
       
mysql_real_escape_string($row->theme),
       
mysql_real_escape_string($row->signature),
       
mysql_real_escape_string($row->created),
       
mysql_real_escape_string($row->access),
       
mysql_real_escape_string($row->login),
       
mysql_real_escape_string($row->status),
       
mysql_real_escape_string($row->timezone),
       
mysql_real_escape_string($row->language),   
       
mysql_real_escape_string($row->picture),
       
mysql_real_escape_string($row->init),   
       
mysql_real_escape_string($row->data));

    if(!
$connector->query($insert))
    {
        echo
mysql_error();
        exit();
    }
}



/**
* Drop the old users_backup table since we no longer need it
*/
$drop = "DROP TABLE users_backup";
        if(!
$connector->query($drop))
    {
        echo
mysql_error();
        exit();
    }

   
    } else {
    echo
"Missing drupaltin_config.php file. Please upload to /vbforums/includes/ and try again.";
   
}
?>

profile_updateoptions

<?php
require_once(DIR . '/includes/drupaltin_config.php');
$connector = new DbConnector();

/*
* Update timezone in the Drupal database
*/

$vbulletin->GPC['timezoneoffset'] = intval($vbulletin->GPC['timezoneoffset']) * 3600;

$UpdateQuery = sprintf("UPDATE users SET timezone = '%s' WHERE name = '%s'",
       
mysql_real_escape_string($vbulletin->GPC['timezoneoffset']),
       
mysql_real_escape_string($vbulletin->userinfo['username']));

$connector->query($UpdateQuery);
?>

profile_updatepassword_complete

<?php
require_once(DIR . '/includes/drupaltin_config.php');
$connector = new DbConnector();

/*
* Update the email and password in Drupal upon changing
*/

if ($vbulletin->GPC['newpassword']) {
   
$UpdateQuery = sprintf("UPDATE users SET pass = '%s' WHERE uid = '%s'",
       
mysql_real_escape_string($vbulletin->GPC['newpassword']),   
       
mysql_real_escape_string($vbulletin->userinfo['userid']));

   
$connector->query($UpdateQuery);
}

$UpdateQuery = sprintf("UPDATE users SET mail = '%s' WHERE uid = '%s'",
       
mysql_real_escape_string($vbulletin->GPC['email']),   
       
mysql_real_escape_string($vbulletin->userinfo['userid']));

$connector->query($UpdateQuery);

$UpdateQuery = sprintf("UPDATE users SET init = '%s' WHERE uid = '%s'",
       
mysql_real_escape_string($vbulletin->GPC['email']),   
       
mysql_real_escape_string($vbulletin->userinfo['userid']));

$connector->query($UpdateQuery);
?>

register_addmember_complete

<?php
require_once(DIR . '/includes/drupaltin_config.php');


//*** Figure out the timezone settings and convert them to work in the Drupal vB
//    Divided by 3600 b/c the Drupal system.module timezone form is in seconds  
$vbulletin->GPC['timezoneoffset'] = intval($vbulletin->GPC['timezoneoffset']) * 3600;

## Connect to Drupal database and dump the values
$connector = new DbConnector();

$insertQuery = sprintf("INSERT INTO `users` (
    `uid`, `name`, `pass`, `mail`, `mode`, `sort`, `threshold`, `theme`, `signature`, `created`, `access`, `login`,
     `status`, `timezone`, `language`, `picture`, `init`, `data`)
    VALUES ('%s', '%s', '%s', '%s', '0', '0', '0', '', '', '0', '0', '0', '1', '%s', '', '', '%s', 'a:0:{}')"
,
       
mysql_real_escape_string($vbulletin->userinfo['userid']),
       
mysql_real_escape_string($vbulletin->GPC['username']),
       
mysql_real_escape_string($vbulletin->GPC['password_md5']),
       
mysql_real_escape_string($vbulletin->GPC['email']),   
       
mysql_real_escape_string($vbulletin->GPC['timezoneoffset']),
       
mysql_real_escape_string($vbulletin->GPC['email']));

   
## Save the form data into the database
   
if ($result = $connector->query($insertQuery)){

       
## It worked
       
return;

    }else{

       
## It hasn't worked so stop. Better error handling code would be good here!
       
exit;

    }
?>

useradmin_prune

<?php
require_once(DIR . '/includes/drupaltin_config.php');
$connector = new DbConnector();

/*
* Delete user from Drupal when they get pruned
*/

$DeleteQuery = "DELETE FROM users WHERE userid IN ($userids)";
$connector->query($DeleteQuery);
?>

userdata_delete

<?php
require_once(DIR . '/includes/drupaltin_config.php');
$connector = new DbConnector();

/**
* Delete the user from the Drupal database
*/
$DeleteQuery = sprintf("DELETE FROM users WHERE uid='%s'",
       
mysql_real_escape_string($this->existing['userid']));

$connector->query($DeleteQuery);
?>

userdata_update_username

<?php
require_once(DIR . '/includes/drupaltin_config.php');
$connector = new DbConnector();

/*
* Update username when changed by an admin
*/

if ($doupdate) {
   
$UpdateQuery = sprintf("UPDATE users SET name = '%s' WHERE uid='%s'",
       
mysql_real_escape_string($this->dbobject->escape_string($username)),   
       
mysql_real_escape_string($userid));

   
$connector->query($UpdateQuery);
}
?>

Code - HEAD

This code is development code which may or may not be used in the next release. Remember, this code is often times not even tested so do not by any means consider it stable. Always use the latest release version, not the HEAD. If you are interested in what the next release may include, browse through and comment if you would like.

product_install_code

<?php
if (file_exists(DIR . '/includes/drupaltin_config.php') == true)
    {

require_once(
DIR . '/includes/drupaltin_config.php');
$connector = new DbConnector();
/**
* Backup the original users table so we can restore it if we need to
*/
$backup = "CREATE TABLE users_backup SELECT * FROM users";
        if(!
$connector->query($backup))
    {
        echo
mysql_error();
        exit();
    }

/**
* Delete all the old data from the users table now that it has been backed up, prepares us for the new dump :)
*/
$truncate = "TRUNCATE TABLE users";
        if(!
$connector->query($truncate))
    {
        echo
mysql_error();
        exit();
    }


/**
* Here is where we read the database values that we need from the vB database and drump them into the Drupal database
*/
$query = $vbulletin->db->query_read("SELECT userid, username, password, email, joindate, timezoneoffset FROM user");

while (
$row = mysql_fetch_object($query))
{
   
$row->timezoneoffset = intval($row->timezoneoffset) * 3600;
   
$insert = sprintf("INSERT INTO `users` (
        `uid`, `name`, `pass`, `mail`, `mode`, `sort`, `threshold`, `theme`, `signature`, `created`, `access`,
        `login`, `status`, `timezone`, `language`, `picture`, `init`, `data`)
        VALUES (
        '%s', '%s', '%s', '%s', '0', '0', '0', '', '',  '%s', '0', '0', '1', '%s', '', '', '%s', 'a:0:{}')"
,
       
mysql_real_escape_string($row->userid),
       
mysql_real_escape_string($row->username),
       
mysql_real_escape_string($row->password),
       
mysql_real_escape_string($row->email),
       
mysql_real_escape_string($row->joindate),
       
mysql_real_escape_string($row->timezoneoffset),  
       
mysql_real_escape_string($row->email));  

    if(!
$connector->query($insert))
    {
        echo
mysql_error();
        exit();
    }
}
  
    } else {
    echo
"Missing drupaltin_config.php file. Please upload to /vbforums/includes/ and try again.";
  
}
?>

Installation

Installing Drupaltin is fairly easy and I'm doing my best to document every aspect so the install is painless and complete.

You will not have to edit any core files of Drupal or vBulletin, this is a great feature that Drupaltin offers while most other similar products do not. Since you do not have to edit any core files, nearly every module and plugin should work flawlessly. If you come across a module or product that does not work with Drupaltin, PLEASE report this in the support forums.

Remember to back up your Drupal and vBulletin databases and files! I am not responsible for any loss of data, if you make backups the possibility of dataloss will be eliminated.

Note that Drupaltin is still in it's early development stages. The latest version 5.x-1.0a is to be considered an alpha release. I have a testing team who has extensively tested the product, but I cannot guarantee you will not run into a bug somewhere. I would highly recommend you make a dummy copy of your website in a dev environment. This way you can install Drupaltin and make sure there aren't going to be any major issues with the rest of your site. As you can see I have Drupaltin running on this very web site so it is fit for a production web site, just realize it is still an alpha release.

Download Drupaltin

You should obtain the files directly from http://theoverclocked.com/drupaltin otherwise I cannot guarantee the integrity of the files. Once downloaded, the files will be in .tar.gz format and can be extracted using most compression tools.

 

Prior Installation

Drupaltin has been developed for web sites with existing vBulletin forums. When you install the plugin from the vBulletin admincp, Drupaltin will move any users registered in Drupal into a new table called backup_users and all users from the vBulletin database will be moved into the Drupal database. If you uninstall the plugin from the vBulletin admincp, the users will be deleted from the Drupal database and the backup users will be replaced. There will be no changes to the vBulletin database what-so-ever. You will not loose your users in vBulletin no matter what.

Drupaltin has only been tested with a fresh Drupal install and an existing vBulletin install. I cannot guarantee success when trying to install with an existing Drupal install. If someone has an existing Drupal install to use this on, please let me know in the support forums how it works for you. If further development is needed to support existing Drupal installs, any help would be greatly appreciated by many.

 

File Edits

For Drupaltin 5.x-1.0a you will need to edit a total of five files. The amount of file edits needed will decrease as Drupaltin is developed further. We will start with the main configuration file, drupaltin_config.php.

drupaltin_config.php
This file is located in /vBulletin/includes

We have seven items to define in this file. Input your Drupal server path which is the absolute path for your server. On a typical Unix based system, the location would be something like /var/www for the main directory. Go ahead and fill the other paths in, they are pretty self-explanatory. Notice I have left examples in each define to make it easier to understand. Just replace the example with your information.

The last thing we need to define in this file is your Drupal database information. This will be exactly the same as what you used when installing Drupal. Once you finish the database information, you can save the file and move on to the next.

drupaltin_logout.php
This file is located in /Drupal

We have one item to define in this file, vBulletin server path. This will be exactly the same thing that you put in the drupaltin_config.php file. Put in your directory and save the file.

*Note, if you do not want a login form within Drupal, you may skip editing the files below. Though if you do not use the Drupaltin login form, the default Drupal login form will not work but your users may login at vBulletin and it will effectively log them into Drupal automatically.

form.html
This file is located in /Drupal/modules/drupaltin

Now this is the hardest edit you will have to make. This is the form for the Drupaltin login which is part of the Drupaltin module.

If you look through the code you will see some URLs in there. I left the URLs for this site in there as an example so you know how to edit the files. Find where The Overclocked is specified and replace it with your domain. For example, if your vBulletin is not on a sub domain, if the URL is http://forums.theoverclocked.com/register.php change it to http://www.yoursite.com/forums or whatever the correct URL is for your web site.
  • http://forums.theoverclocked.com has to be replaced four times with your forums URL
  • www.theoverclocked.com has to be replaced one time with the URL where the "login success" pageshould be redirected to
form.php
This file is located in /Drupal/modules/drupaltin

You may copy and paste the edited code from the form.html file into this file. Paste where it says "PASTE HERE" leaving the quotation marks in place. Save the file.

drupaltin.module

This file is located in /Drupal/modules/drupaltin

Just like in the file above (form.php), you may paste the edited code from form.html into this file. The paste point is about halfway down on line 54. Paste where it says "PASTE HERE" leaving the quotation marks in place. Save the file.

You are done with the file edits.

 

Upload Files

Now it is time to upload the files to your web server.

  1. Upload the whole drupaltin folder located in the subfolder Drupal/modules of the download archive into the modules directory in your Drupal install.
  2. Upload the file drupaltin_config.php located in vBulletin/includes into the includes directory in your vBulletin install.
  3. Upload drupaltin_logout.php and drupaltin_login.php to the main folder of your Drupal installation.

 

Install Plugin

Now is when you should install the vBulletin plugin. This is perhaps the most painless part of the whole installation. Browse to your vBulletin admincp and login. Now go to Plugins & Products in the menu on the left. Click Manage Products link and find the [Add/Import Product] button at the bottom of the page. From here you may click the Browse button and find the product-drupaltin_5.x-1.0a.xml file. I highly recommend you change the "Allow Overwrite" option to yes.

Click Import and the installer will run. If the installation was successful you will be brought back to your Managed Products screen.

 

Edit Templates

We will need to make two very minor, but important template modifications in vBulletin. I recommend you edit every parent style you have installed. If you edit the parent style template, the child styles will inherit the change as well automatically.

The two templates that need modified are navbar and STANDARD_ERROR. The modification is exactly the same in both files.

Find:

<form action="login.php?do=login" method="post" onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, $show[nopasswordempty])">

Replace with:

<form action="login.php?do=login" method="post" onsubmit="md5hash(vb_login_md5password, vb_login_md5password_utf, $show[nopasswordempty])">

It is as simple as that!

 

Superadmin Userid

If your userid in vBulletin is not 1 you will need to make a small change in the Drupal database. Otherwise you may skip this step.

Open up phpMyAdmin or whatever you use for editing your Drupal database. Find the users table and look for the entry for userid=1. You will need to change userid=1 to a userid that has not yet been used. Do not use userid=0, find the highest userid in your database and use the number after it. Now you can find your userid and change it to userid=1.

Everything should work fine with those changes but always keep an eye out for the username who used to be userid=1. If you find a bug somewhere, please report it in our support forums.

 

Install Module

Installing the Drupaltin module is just like installing most other Drupal modules. Just login to Drupal and go to Administrator -> Modules. Find Drupaltin at the bottom and enable it.

Now that the Drupaltin module has been installed, head over to Administer -> Blocks so we can enable the correct login form. The default login form is called User login, go head and change the drop down box to none to disable it. Now we need to enable the Drupaltin login form by clicking the drop down box and changing it to left side or wherever you would like it to show up.

One more thing to do, enable the logout menu item. Go to Administer -> Menus and find the default logout menu item. It will be called "Log out" with a lower-case "o" and a path of logout, just disable this item. Now find the logout item which was added by the Drupaltin module. It will be called "Log Out" with an upper-case "o" and a path of drupaltin_logout, enable this item.

 

Restrict Profile Edits

Since the user management is all handled by vBulletin now, we need to restrict access to certain fields in the Drupal user profiles. We do not want our users to change their username, password, timezone, or email address from Drupal since it will not update in vBulletin. The best way to take care of this is to install the User Protect module. It is a very light module which gives you the ability to restrict users from editing the fields in their profile.

Once you have the User Protect module installed, go to Administer -> User Protect. From here we want to click the Protected Roles button at the top of the page. Now you can block access by simply checking the boxes for each role.

 

You are done with the installation! Enjoy!!

Using the Subversion Repository

Subversion is a source control system similar to CVS. Source control is what helps keep the project organized so things do not turn up missing. Source control also helps a lot when you have multiple developers.

You can view the contents of the Drupaltin SVN repository by visiting http://drupaltin.stealth17.com. From that page you can visit the Drupaltin root directory and click the Tarball icon at the top of the page to download the latest revision over the web. All this can be done from an ordinary web browser, no special clients are needed.

Within this powerful web interface, commit logs can be viewed, files can be viewed with syntax highlighting, file revisions can be compared, among many other features. There is are RSS feeds for those who want to keep up to date on the latest development through RSS. 

 

To checkout the Drupaltin tree with an SVN client, run this command:

svn checkout http://stealth17.com/drupaltin

Then to update to when commits are made:

svn update



 

To access the SVN repository from Windows, you might want to install:
http://tortoisesvn.tigris.org/

To access the SVN repository from Ubuntu/Debian, you might want to install:
apt-get install subversion

To access the SVN repository from Mac OS X, you might want to install:
http://scplugin.tigris.org/

For more information about subversion, please visit their official website:
http://subversion.tigris.org/