Importing users from MS Access database into Joomla 1.5

Have a programming question regarding your component, plug-in, extension or core hacks? Have an interesting tidbit, FAQ or programming tip you’d like to share? This is the place for you.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Post Reply
User avatar
pvh123
Joomla! Intern
Joomla! Intern
Posts: 68
Joined: Wed Oct 05, 2005 7:25 am
Location: Amsterdam
Contact:

Importing users from MS Access database into Joomla 1.5

Post by pvh123 » Tue Oct 30, 2007 9:20 am

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?
;) pieter

User avatar
bascherz
Joomla! Intern
Joomla! Intern
Posts: 86
Joined: Mon Jan 16, 2006 1:33 am
Location: Vienna, VA
Contact:

Re: Importing users from MS Access database into Joomla 1.5

Post by bascherz » Tue Oct 30, 2007 12:51 pm

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
Last edited by bascherz on Tue Oct 30, 2007 12:53 pm, edited 1 time in total.
__________________
Bruce Scherzinger

User avatar
pvh123
Joomla! Intern
Joomla! Intern
Posts: 68
Joined: Wed Oct 05, 2005 7:25 am
Location: Amsterdam
Contact:

Re: Importing users from MS Access database into Joomla 1.5

Post by pvh123 » Tue Oct 30, 2007 4:25 pm

Thanks, Bruce for your info. At least it get me started.
;) pieter

Fennopolpot

Re: Importing users from MS Access database into Joomla 1.5

Post by Fennopolpot » Fri Nov 02, 2007 1:31 pm

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();
}

User avatar
pvh123
Joomla! Intern
Joomla! Intern
Posts: 68
Joined: Wed Oct 05, 2005 7:25 am
Location: Amsterdam
Contact:

Re: Importing users from MS Access database into Joomla 1.5

Post by pvh123 » Fri Nov 02, 2007 4:25 pm

Thanks very much. I will use this as well.
;) pieter

User avatar
pvh123
Joomla! Intern
Joomla! Intern
Posts: 68
Joined: Wed Oct 05, 2005 7:25 am
Location: Amsterdam
Contact:

Re: Importing users from MS Access database into Joomla 1.5

Post by pvh123 » Tue Nov 06, 2007 11:48 am

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? :)
Last edited by pvh123 on Tue Nov 06, 2007 2:42 pm, edited 1 time in total.
;) pieter

User avatar
tjay
Joomla! Intern
Joomla! Intern
Posts: 73
Joined: Thu Aug 18, 2005 1:50 am
Location: New Orleans
Contact:

Re: Importing users from MS Access database into Joomla 1.5

Post by tjay » Wed Nov 07, 2007 1:00 am

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
This day it is my wish that I helped you to live

User avatar
webm3442
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Sat Aug 04, 2007 7:27 am
Location: NL - Eindhoven
Contact:

Re: Importing users from MS Access database into Joomla 1.5

Post by webm3442 » Wed Dec 05, 2007 1:41 pm

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.

User avatar
Pentacle
Joomla! Intern
Joomla! Intern
Posts: 61
Joined: Wed Oct 25, 2006 12:34 pm
Location: Turkey

Re: Importing users from MS Access database into Joomla 1.5

Post by Pentacle » Sun Dec 09, 2007 11:29 am

@Fennopolpot

Should we do a $user->check(); or something before saving the user?
My Joomla! 1.5 extensions - http://joomla.ercan.us
Progress is made by lazy men looking for easier ways to do things.

jciconsult
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Sun Nov 05, 2006 8:40 pm

Re: Importing users from MS Access database into Joomla 1.5

Post by jciconsult » Thu Jan 17, 2008 4:12 pm

CB Juice has been updated for 1.5


Post Reply