plegall / menalto2piwigo

9 stars 7 forks source link

Migrate Users, Groups and Permissions #10

Open madmas opened 9 years ago

madmas commented 9 years ago

Hi, currently,the migration does not include the security related options like Users, Groups and Permissions. Is there a special (technical) reason to this (besides the all-known time issue) . What steps do you think would be necessary to include that to the script? I'd be happy to help where I can ;-)

madmas commented 9 years ago

Hi, I created a SQL script to transfer the users

--Transfer users
INSERT INTO piwigo.piwigo_users(username, password, mail_address)
SELECT g_userName, g_hashedPassword, g_email
FROM gallery.g2_User g2u
WHERE g2u.g_userName NOT IN ('admin', 'guest', 'test')

--create default settings
INSERT INTO piwigo_user_infos (user_id, nb_image_page, status, language, expand, show_nb_comments,  show_nb_hits,   recent_period,  theme,registration_date ,   enabled_high,   level,  activation_key ,    activation_key_expire , lastmodified)
SELECT u.id, 30,  'normal', 'de_DE',false,false,false,  7, 'simpleng', now(),   true, 0, NULL, NULL,now()
FROM piwigo_users u
WHERE id NOT IN (1,2)

and one to transfer the ratings:

INSERT INTO piwigo.piwigo_rate (user_id, element_id, anonymous_id, rate, date)
SELECT pusers.id, pimages.id, CONCAT(LEFT(rm.g_remoteIdentifier, INSTR(rm.g_remoteIdentifier,':')),RAND()) ,rm.g_rating, now()
FROM gallery.g2_RatingMap rm 
, gallery.g2_User u
, gallery.g2_Item i
, gallery.g2_FileSystemEntity fse
, piwigo.piwigo_users pusers
, piwigo.piwigo_images pimages
WHERE rm.g_itemId = i.g_id
AND fse.g_id = i.g_id
AND rm.g_userId = u.g_id
AND pusers.username = u.g_UserName
AND fse.g_pathComponent = pimages.file
42degrees commented 8 years ago

Thank you madmas, these queries were exactly what I needed to finish off my migration from Gallery2 to Piwigo. Seems like the guy who wrote the menalto2piwigo could integrate these into his plug-in... (though I completely appreciate him/her writing this plugin as well).