Converting Xoops login to Joomla
Recently wrote a PHP script that will transfer login data from the Xoops content management system to Joomla and thought I would post it here in case anyone is converting their site to Joomla from Xoops.
First, export both login database tables (xp_users for Xoops and jos_users for Joomla in the install I was working on) and import them into a local installation of mySQL. If you don’t have access to a local installation of mySQL or have no users set up in Joomla yet, you can run this script on your live database tables but be sure to back up any data you can’t afford to lose.
Documentation in the script shows what’s being done - the conversion I was doing was fairly simple (no custom groups, special logins, etc.) but, if you’re doing something a little more complex, this will hopefully give you a good place to start.
< ?php
// Export XOOPS login information to Joomla
mysql_connect("localhost", "
mysql_select_db(”
$sql = “SELECT * FROM xp_users”;
$result = mysql_query($sql);
$id = 69;
while ($row = mysql_fetch_object($result)) {
// convert XOOPS rank to Joomla usertype
// $gid is group_id from jos_core_acl_aro_groups (18: registered, 25: super admin)
if ($row->rank == 7) {
$type = “Super Administrator”;
$gid = 25;
}
else {
$type = “Registered”;
$gid = 18;
}
$date = date(”Y-m-d H:i:s”);
$id++;
// Joomla block field: 1: unconfirmed email, 0: confirmed email
// XOOPS level field : 0: unconfirmed email, 1: confirmed email
// insert into main Joomla user table
$sql = “INSERT INTO jos_users (id, name, username, email, password, usertype, block, sendEmail, gid, registerDate)
VALUES ($id, ‘$row->uname’, ‘$row->loginname’, ‘$row->email’, ‘$row->pass’, ‘$type’, 0, 1, $gid, ‘$date’)”;
mysql_query($sql);
$id = mysql_insert_id();
// insert into lookup tables
$sql = “INSERT INTO jos_core_acl_aro (section_value, value, order_value, name, hidden)
VALUES (’users’, ‘$id’, 0, ‘$row->uname’, 0)”;
mysql_query($sql);
$id = mysql_insert_id();
$sql = “INSERT INTO jos_core_acl_groups_aro_map (group_id, aro_id)
VALUES ($gid, $id)”;
mysql_query($sql);
}
?>