FROMSOFT Systemy Komputerowe - php, joomla, virtuemart

  • Increase font size
  • Default font size
  • Decrease font size
Strona główna Helpdesk Joomla 1.5.x - migrating users from other cms / system

Joomla 1.5.x - migrating users from other cms / system

Dedicated audience for this article are PHP programmers with strong Joomla background.

I faced to move hundreds users from one site (not based on Joomla) to Joomla 1.5.x. Stucked on E_NOLOGIN_ACCESS but i found how to resolve this problem. User information are stored in three tables. If informations are not consistent users can't login and gets E_NOLOGIN_ACCESS issue. 

So you have to add user info to the following tables:

jos_users (which is obvious)

jos_core_acl_aro

jos__core_acl_groups_aro_map


Table jos_users is created this way:

CREATE TABLE `jos_ligota_users` (

  `id` int(11) NOT NULL auto_increment,

  `name` varchar(255) NOT NULL default '',

  `username` varchar(150) NOT NULL default '',

  `email` varchar(100) NOT NULL default '',

  `password` varchar(100) NOT NULL default '',

  `usertype` varchar(25) NOT NULL default '',

  `block` tinyint(4) NOT NULL default '0',

  `sendEmail` tinyint(4) default '0',

  `gid` tinyint(3) unsigned NOT NULL default '1',

  `registerDate` datetime NOT NULL default '0000-00-00 00:00:00',

  `lastvisitDate` datetime NOT NULL default '0000-00-00 00:00:00',

  `activation` varchar(100) NOT NULL default '',

  `params` text NOT NULL,

  PRIMARY KEY  (`id`),

  KEY `usertype` (`usertype`),

  KEY `idx_name` (`name`),

  KEY `gid_block` (`gid`,`block`),

  KEY `username` (`username`),

  KEY `email` (`email`)

) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=65 ;


Template #1
The easiest way to add new records is make new user in Joomla admin panel with privileages which will be default for auto generated user. Next go to phpMyAdmin and export this table. As result you should get lines like that:

INSERT INTO `jos_users` VALUES (64, 'fullname', 'username', ' This e-mail address is being protected from spambots. You need JavaScript enabled to view it ',
'6c98f9826a81b10de28538823408baa:VKRTr9FkOHxgFDRfPHJDwyukreB7xtN3', 'Editor', 0, 0, 20,
'2010-03-21 06:23:34', '0000-00-00 00:00:00', '',
'admin_language=pl-PL\nlanguage=pl-PL\neditor=tinymce\nhelpsite=http://help.joomla.org\ntimezone=1\n\n');


As you see is complete insert which could be used as template.
I think you understand all above, but a password field may confuse you. Joomla used following pattern for password field: md5([userpass+salt]):[salt] where salt is randomly choosen value.

Look, you can generate salt like this:

function getSalt($length = 32)

    {

        $salt = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

        $len = strlen($salt);

        $makepass = '';

        mt_srand(10000000 * (double) microtime());


        for ($i = 0; $i < $length; $i ++) {

            $makepass .= $salt[mt_rand(0, $len -1)];

        }


        return $makepass;

    }


Password generator can use this function:

// We assume using plain text password

function createPassword( $_pass ) {

    $salt = getSalt();

    $_generatedPassword=  md5($_pass.$salt) . ":" . $salt ;

    return $_generatedPassword;

}


If you get MD5 hashed password above function is useless. In such situation the only way is to reset user passwords by generated values and send it to them via e-mail. A little more work for programmer.

One more tip: when you add new users don't use autogenerated values for id - do it yourself. In my case I've started from 100 and add next with step 1 ( $_id++). Why? It will help you add info to the next tables.

Template #2

Sprintf( "INSERT INTO `jos_core_acl_aro` VALUES (%d, 'users', '%d', 0, '%s', 0);", $_id, $_id, $username); );


Template #3

Sprintf( "INSERT INTO `jos_core_acl_groups_aro_map` VALUES (20, '', %d);", $_id );

Look at the jos_users! You spotted number 20? This is group id, so it arise from used pattern.


You can loop through your current user base and rewrite info to all three table at one time. Pseudocode:

While() {

Insert jos_users

Insert jos_core_acl_aro

Insert jos_core_acl_groups_aro_map

}


Simple? I hope it help you go through this proccess smoothly.

But be aware. Make backup of full Joomla database! If something go bad and you loose data consistency it may cause unable to log into Joomla. It may hurt. Best luck!
 
Fromsoft Systemy Komputerowe oferuje usługi związane z programowaniem serwisów internetowych i aplikacji biurkowych. Firma oferuje rozwiązania oparte o języki programowania PHP i C# oraz bazy danych MySQL i MS SQL. Strona fromsoft.pl prezentuje ofertę firmy, ale także porady, opisy sprzętu, oprogramowania i nasze narzędzia udostępnione na licencji otwartej.

Fromsoft Computer Systems offers services related to programming web services and desktop applications. The company offers solutions based on programming languages PHP and C # and MySQL and MS SQL. Page fromsoft.pl presents the company's offer, but also tips, descriptions of hardware, software and tools available on our open license.

Klienci

Banner
Banner
Banner
Banner
Banner
Banner
Banner

Nasza strona utrzymywana jest na serwerze wirtualnym WEBD.pl