Import/Create a lot of users into Gallery2

mnt_schred

Joined: 2008-04-06
Posts: 16
Posted: Thu, 2008-07-03 09:46

I've made a custom system a few years ago where people could upload their pictures, just like Gallery(2). I want to migrate, but I want to import my existing users (79) into Gallery2. I've been looking around for import modules, but there don't seem to be any so I've decided to give it a go in phpMyAdmin.

I've formatted my users neatly in the g2_User format and imported them without any problems. When i login into Galley2 however, I can't view the userlist anymore.

I've started the gId above my last user in the system, but I suspect it's not as simple as I assumed. Are there other databasefields I have to fill?
And is the password mechanism simply md5?

Maybe I'll make a module to mass import users when I find out how the users are stored exactly ;)

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Thu, 2008-07-03 10:20

Unfortunately it's never that simple.

g2Users are g2Entities of class GalleryUser (see the g2Entity table, also http://gallery.menalto.com/apidoc/GalleryCore/Classes/GalleryUser.html). You might get away with creating the entities first there then adding them to the g2Users tables after. Numbering has to follow on from the entry in the g2SequenceId table's single row/column entry. You'll need to advance that past the last new userId.

You will also need to add the new users to the relevant groups in the g2_UserGroupMap table: all users should be members of the Everybody and Registered Users groups - you can get the appropriate groupIds from the g2_Group table (they default to 4, and 2, respectively, I think, but you shouldn't rely on that.)

I don't know if complying with all that is sufficient but it's certainly all necessary. You are *strongly* advised to add new users through the Gallery API rather than mucking about in the database.

 
mnt_schred

Joined: 2008-04-06
Posts: 16
Posted: Thu, 2008-07-03 13:28

Hm, I get, but can't I use the Gallery API to write a tool to do this? Shouldn't be that hard, It's just a SQL query, no?

Where can I find the api? Oh, and I can't add encrypted passwords through the 'Add user' interface.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Thu, 2008-07-03 14:46

Of course you should use the Gallery API - if you do, you don't need to use any SQL at all.

Follow modules/core/AdminCreateUser.inc, from about line 46 (depending on the version of your code).

The API docs in general are here:

http://gallery.menalto.com/apidoc/GalleryCore/Classes/GalleryCoreApi.html