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
Posts: 560
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
Posts: 10
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.
Posts: 16504
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!
Posts: 16504
Ah, this might've been what I read:
http://gallery.menalto.com/node/79161
____________________________________________
Like Gallery? Like the support? Donate now!
Posts: 8339
I've been known to write such scripts ;)
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 10
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.
Posts: 10
Do you have something written that will do this?
Posts: 8339
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
Posts: 10
That would be awesome! Thanks!
Posts: 8339
BTW, doing nearly the same thing here.
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 10
Any luck?
Posts: 8339
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
Posts: 10
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
Posts: 8339
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
Posts: 10
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
Posts: 8339
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
Posts: 10
Sweet, thanks. I'll give it a try and let you know what happens.
->Later.....Spice
Posts: 10
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
Posts: 8339
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