Importing multiple users

devospice2

Joined: 2011-01-13
Posts: 10
Posted: Thu, 2011-01-13 21:26

We have roughly 1000 users in a database and want to migrate them to Gallery. It's a simple MySQL database and I have access to all the necessary information - username, password, email, real name, etc.

Is there any way to import this data into Gallery or do I have to manually enter all 1000 names?

->Later.....Spice

 
joe7rocks
joe7rocks's picture

Joined: 2004-10-07
Posts: 560
Posted: Thu, 2011-01-13 22:04

Hi,

There is no tool currently to support that, but you might want to take a look at the g2_import module and ~emulate something similar for your own needs.
Or just go with making your own queries directly.
user & groups_users tables.
Those are where u need to import data to.
Note: be sure to backup your Gallery first, touching data manually is not recommended :)

Dog Photos | Gallery2 Themes Demo

 
devospice2

Joined: 2011-01-13
Posts: 10
Posted: Thu, 2011-01-13 22:17

Are there any other tables I need to be worried about? I read in another thread that I couldn't just import the data into the database via PHPMyAdmin because of the way the data was stored and referenced by other tables.

I tried writing a PHP script to automatically fill out the Add User form on the Admin page with a curl() call, but I got a security error saying what I was trying to do wasn't permitted. Sucks too, 'cause that would have worked beautifully.

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Thu, 2011-01-13 22:34

I could've sworn I've seen someone post something (Alec?, suprsidr?) in the terms of a script to do this through the API. Either way you're not going to be able to do a direct import to the DB, Gallery doesn't store password in plain text.

I'll see if I can find what I'm thinking of.

____________________________________________
Like Gallery? Like the support? Donate now!

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Thu, 2011-01-13 22:43

Ah, this might've been what I read:

http://gallery.menalto.com/node/79161

____________________________________________
Like Gallery? Like the support? Donate now!

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Fri, 2011-01-14 02:17
 
devospice2

Joined: 2011-01-13
Posts: 10
Posted: Fri, 2011-01-14 14:20

Yeah, that was the thread I initially saw. I'm not too familiar with the Gallery API, but I suppose learning that will be easier than manually typing in 1000 users.

 
devospice2

Joined: 2011-01-13
Posts: 10
Posted: Fri, 2011-01-14 14:21
Quote:
I've been known to write such scripts ;)

Do you have something written that will do this?

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Fri, 2011-01-14 14:39

I'll whip something up, but it will have to be this weekend.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
devospice2

Joined: 2011-01-13
Posts: 10
Posted: Fri, 2011-01-14 14:45

That would be awesome! Thanks!

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Fri, 2011-01-14 16:11
 
devospice2

Joined: 2011-01-13
Posts: 10
Posted: Wed, 2011-01-19 15:04

Any luck?

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Wed, 2011-01-19 15:19

Oh, I had a question, sorry.
Are these users in a CMS and continued cross-mapping will be necessary?
If yes, which CMS?

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
devospice2

Joined: 2011-01-13
Posts: 10
Posted: Wed, 2011-01-19 15:25

No, they're not in a CMS. It was just a quick PHP based login script I wrote for the site so there could be a password protected area on it. The users are in a MySQL database right now.

And the entire site is being redone, so we won't need to continue keeping them in sync. This is strictly a one-time import to Gallery.

Thanks.

->Later.....Spice

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Wed, 2011-01-19 15:31

In order to make this as complete as I can, can you list the structure of your user table and if your passwords are MD5.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
devospice2

Joined: 2011-01-13
Posts: 10
Posted: Wed, 2011-01-19 15:49

Sure.

`username` varchar(255)
`password` mediumblob
`name` varchar(255)
`address1` varchar(255)
`address2` varchar(255)
`city` varchar(50)
`state` varchar(50)
`zip` varchar(50)
`email` varchar(255)
`type` varchar(50)
`active` tinyint(4)
`id` int(11)

The passwords are not encrypted, if that's what you're asking. I don't know what MD5 is.

Type is either "camper," "alumni," "staff," "parent," or "admin." Active is either 1 or 0, but they all appear to be 1 at the moment. I think that was my implementation of "registered by not yet approved by the admin."

->Later.....Spice

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Wed, 2011-01-19 16:45

Try this.

Gallery is only interested in username, email, password and language - so you'll lose the other columns.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
devospice2

Joined: 2011-01-13
Posts: 10
Posted: Wed, 2011-01-19 18:00

Sweet, thanks. I'll give it a try and let you know what happens.

->Later.....Spice

 
devospice2

Joined: 2011-01-13
Posts: 10
Posted: Wed, 2011-01-19 19:14

That worked! Awesome. Thank you so much!

FYI, I had to change one thing in the code. In createG2User I had to change WHERE uid ='".$uid."' LIMIT 1" to WHERE id ='".$uid."' LIMIT 1". I ran it once and it said "Done!" but nothing happened. I looked and saw it was looking for a field called "uid" which I didn't have in my database.

Also, it said each one that it created failed, but I checked the database when it finished and everything was there. So there may be a problem with the if (!$ret) logic. Just for future reference. But otherwise it worked beautifully!

Anything I can do to thank you? How long did this take you? I will happily pay you for your time. (I'll just add it to my client's bill.)

->Later.....Spice

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Wed, 2011-01-19 19:27

Yup, I see it, my user table has a uid column, missed that change for yours.

Glad it worked for you.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2