Page 1 of 1

Importing users from MS Access database into Joomla 1.5

Posted: Tue Oct 30, 2007 9:20 am
by pvh123
I had posted this item
http://forum.joomla.org/index.php/topic,200895.msg944928.html#msg944928

in de wrong place I think.

Has anybody been confronted with this dilemma and hopefully found an answer for it?

Re: Importing users from MS Access database into Joomla 1.5

Posted: Tue Oct 30, 2007 12:51 pm
by bascherz
Hi Pieter,

It's a non-trivial sequence of operations. You cannot just import the user information into a single table. You need to update several related tables. My recommendation would be to find out (hopefully by a reply to this post) what the tables are and how they are related. Then, model those tables and relationships in Access and export the data from there as delimited records into text files you then import into your J! database using phpMyAdmin (or equivalent).

If I had time to locate it, I believe there was a post somewhere else in here about the relationships among these tables. I believe they are among the following (this is from a 1.0.x site of mine):

  • jos_users
  • jos_core_acl_aro
  • jos_core_acl_aro_groups
  • jos_core_acl_aro_sections
  • jos_core_acl_groups_aro_map

Hope this helps.

Bruce

edit: Here is the link to the other forum post that might be of some help with understanding these tables.
http://forum.joomla.org/index.php/topic,213485.0.html

Re: Importing users from MS Access database into Joomla 1.5

Posted: Tue Oct 30, 2007 4:25 pm
by pvh123
Thanks, Bruce for your info. At least it get me started.

Re: Importing users from MS Access database into Joomla 1.5

Posted: Fri Nov 02, 2007 1:31 pm
by Fennopolpot
It is very easy to import users by using Joomla 1.5 Framework. Provided code uses CSV-file sent from form element named 'fileUpload'. It loops trough file line by line and creates new user from every line. Information have to be stored to CSV-file in next order: name, username, password, email. Gid=18 is basic registered usergroup. The code uses utf8_encode -function because I dont't know how to save data from Excel to CSV in UTF-8.
 
It is easy to create a component around the code. Just add one HTML-form upload. And remember that user email have to be unique!



Code: Select all

jimport('joomla.user.helper');
$file           = JRequest::getVar( 'fileUpload', '', 'files', 'array' );
$handle     = fopen($file['tmp_name'], "r");
$new_user = array();

while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
       $new_user['name']         = utf8_encode($data[0]);
   $new_user['username'] = utf8_encode($data[1]);
   $new_user['password']  = utf8_encode($data[2]);
   $new_user['email']          = utf8_encode($data[3]);
   $new_user['gid']             = 18;                               //Registered-usergroup
   $new_user['password2'] = $new_user['password'];

   

   // Create a new JUser object
   $user = new JUser(0);
   $user->bind($new_user);
   $user->save();
}

Re: Importing users from MS Access database into Joomla 1.5

Posted: Fri Nov 02, 2007 4:25 pm
by pvh123
Thanks very much. I will use this as well.

Re: Importing users from MS Access database into Joomla 1.5

Posted: Tue Nov 06, 2007 11:48 am
by pvh123
Fennopolpot wrote:It is easy to create a component around the code. Just add one HTML-form upload. And remember that user email have to be unique!


@Fennonpolpot I have been working on to get a component and   add the html form, but clobberd up my database when installing my "component". Obviously either the xml file or the rest of it was wrong.
Any change you will be able to provide me with that? :)

Re: Importing users from MS Access database into Joomla 1.5

Posted: Wed Nov 07, 2007 1:00 am
by tjay
I have had some luck using the odbc drivers for MySql you can link access directly to your web site data base
the password encrypting is where I have ran into trouble but I am sure there is a work around

Also Navicat works great for any database jobs

Re: Importing users from MS Access database into Joomla 1.5

Posted: Wed Dec 05, 2007 1:41 pm
by webm3442
I'm trying to use ODBC as well. Can link my tables, but cannot establish relationships as the field definitions don't match.
Maybe you can give me some hints how to proceed to ad the necessary data in acl_core_aro and some other related tables.
Password encrypting can be solved by using CBJuice to import your userlist. But as there is still no CBJuice for 1.5 it doesn't update the core_acl tables.

Re: Importing users from MS Access database into Joomla 1.5

Posted: Sun Dec 09, 2007 11:29 am
by Pentacle
@Fennopolpot

Should we do a $user->check(); or something before saving the user?

Re: Importing users from MS Access database into Joomla 1.5

Posted: Thu Jan 17, 2008 4:12 pm
by jciconsult
CB Juice has been updated for 1.5