vBulletin Roles Migration with vbulletin_roles.inc
Before migrating from vBulletin, we need to identify a sequence of migrations where one class might first rely on another to be loaded with data.
For example, posts rely on threads being present, which need a forum structure to be built, which need users, and the users need roles. So we'll migrate content from the top down...firstly with roles (usergroups), then users > forum structure > threads > and finally the posts.
Optionally, I always want to my threads to show tags from vBulletin, so I'll migrate also them before threads go in.
To get roles data for D7, source the 'usergroup' table in vBulletin
The following was added to the vbulletin_roles.inc
Database::addConnectionInfo('for_roles_migration', 'default', array(
'driver' => 'mysql',
'database' => 'mysite_vBulletindatabase',
'username' => 'mysite_d7user',
'password' => 'd7userpassword',
'host' => 'localhost',
'prefix' => 'vb_',
));
class vBulletinRolesMigration extends Migration {
public function __construct() {
parent::__construct();
$this->description = t('Migrate vBulletin usergroups to roles');
$this->map = new MigrateSQLMap($this->machineName,
array(
'usergroupid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'vBulletin usergroup ID',
'alias' => 'r',
),
),
MigrateDestinationRole::getKeySchema(),
'for_roles_migration'
);
$query = Database::getConnection('default', 'for_roles_migration')
->select('usergroup', 'r')
->fields('r', array(
'usergroupid',
'title',
'description',
'usertitle',
'passwordexpires',
'passwordhistory',
'pmquota',
'pmsendmax',
'opentag',
'closetag',
'canoverride',
'ispublicgroup',
'forumpermissions',
'pmpermissions',
'calendarpermissions',
'wolpermissions',
'adminpermissions',
'genericpermissions',
'genericoptions',
'attachlimit',
'avatarmaxwidth',
'avatarmaxheight',
'avatarmaxsize',
'profilepicmaxwidth',
'profilepicmaxheight',
'profilepicmaxsize',
'signaturepermissions',
'sigpicmaxwidth',
'sigpicmaxheight',
'sigpicmaxsize',
'sigmaximages',
'sigmaxsizebbcode',
'sigmaxchars',
'sigmaxrawchars',
'sigmaxlines',
'visitormessagepermissions',
'socialgrouppermissions',
'usercsspermissions',
'albumpermissions',
'albumpicmaxwidth',
'albumpicmaxheight',
'albumpicmaxsize',
'albummaxpics',
'albummaxsize',
'genericpermissions2',
'pmthrottlequantity',
'groupiconmaxsize',
'maximumsocialgroups'
));
$count_query = Database::getConnection('default', 'for_roles_migration')
->select('usergroup', 'r');
$count_query->addExpression('COUNT(usergroupid)', 'cnt');
$this->source = new MigrateSourceSQL($query, array(), $count_query, array('map_joinable' => FALSE));
$this->destination = new MigrateDestinationRole();
// Make the mappings
$this->addFieldMapping('is_new', NULL)
->defaultValue(TRUE);
$this->addFieldMapping('name', 'title')
->description('Map vBulletin usergroup name to Drupal roles.');
// Unmapped source fields
$this->addFieldMapping(NULL, 'usertitle') ->description(t('Use only the title field in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'description') ->description(t('Not used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'passwordexpires') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'passwordhistory') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'pmquota') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'pmsendmax') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'opentag') ->description(t('Never used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'closetag') ->description(t('Never used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'canoverride') ->description(t('Never used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'ispublicgroup') ->description(t('Never used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'forumpermissions') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'pmpermissions') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'calendarpermissions') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'wolpermissions') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'adminpermissions') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'genericpermissions') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'genericoptions') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'attachlimit') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'adminpermissions') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'genericpermissions') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'genericoptions') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'attachlimit') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'avatarmaxwidth') ->description(t('Will be an imagecache size in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'avatarmaxheight') ->description(t('Will be an imagecache size in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'avatarmaxsize') ->description(t('Will be an imagecache size in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'profilepicmaxwidth') ->description(t('Will be an imagecache size in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'profilepicmaxheight') ->description(t('Will be an imagecache size in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'profilepicmaxsize') ->description(t('Will be an imagecache size in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'signaturepermissions') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'sigpicmaxwidth') ->description(t('Will be an imagecache size in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'sigpicmaxheight') ->description(t('Will be an imagecache size in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'sigpicmaxsize') ->description(t('Will be an imagecache size in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'sigmaximages') ->description(t('Not used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'sigmaxsizebbcode') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'sigmaxchars') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'sigmaxrawchars') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'sigmaxlines') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'visitormessagepermissions') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'socialgrouppermissions') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'usercsspermissions') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'albumpermissions') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'albumpicmaxwidth') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'albumpicmaxheight') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'albumpicmaxsize') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'albummaxpics') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'albummaxsize') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'genericpermissions2') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'pmthrottlequantity') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'groupiconmaxsize') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
$this->addFieldMapping(NULL, 'maximumsocialgroups') ->description(t('Not really used in vBulletin and will not be a field used in D7'))
->issueGroup(t('DNM'));
// Unmapped destination fields
$this->addUnmigratedDestinations(array('weight'));
}
}
There's a ton of fields in my vBulletin usergroup table that haven't really been used on my site, so I obviously won't be importing them to D7, as listed under // Unmapped source fields
The field labels should be familiar when browsing your own vBulletin usergroup table in phpMyAdmin, but I/you might have a few different ones, depending on any addons that are installed with the core vBulletin software. As a result, if you copy and paste the above into your own setup you will probably get some sort of "source does not exist" type of errors, until you remove fields in the list under ->fields('r', array( and and any corresponding $this->addFieldMapping that don't apply
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion