Integrating GlotPress User Tables With Another Software
Integrating GlotPress & LimeSurvey
Assuming you already have a LimeSurvey install, whose user table you want to use.
- svn checkout http://svn.glotpress.
- Download the three custom files found in the root folder (or clone the repository) and put them in the glotpress folder.
- Edit gp-config.php for the database details, you can also regenerate the salts on your wish. Scroll down below to check if CUSTOM_USER_TABLE constant shows the correct user table name (check the table prefix lime_).
- Open the folder location in the browser to run the GlotPress installation process. Write the generated .htaccess.
- Make all superadmins in LimeSurvey administrators in GlotPress – put the plugins/permission.php file in plugins folder.
- Make only some people in LimeSurvey administrators in GlotPress – run this query -
INSERT INTO `gp_permissions` (`id` ,`user_id` ,`action` ,`object_type` ,`object_id`) VALUES (NULL , ’1′, ‘admin’, NULL , NULL);
(assuming gp_ is the prefix you’ve chosen) where the corresponding `user_id` is the user id in lime_users table whom you want to make the admin in GlotPress.
Integrating GlotPress & Any Software
Now that I have written about how to integrate GlotPress with LimeSurvey, I also wanted to write about how you can actually integrate GlotPress with any other software which has a user table which GlotPress could use. There are basically four modifications you need to make. These modifications to the original classes were done on GlotPress r683. Refer to this commit to see how the core files were modified to suit the needs, explanation below.
User class (class.ls-users.php)
You need to make GlotPress aware of your user table by editing the WP_Users class.
- Find/replace all the user table column names with yours. Also edit the _put_user() method.
- Disable (and here) search by user_nicename if no such column exists and you can do that with username instead (similarly with other columns).
- Correct set_password()
- Make appropriate mapping/addition of values
Password Hashing (class.ls-pass.php)
It is likely that your software would be using a password hashing algorithm other than PHPass, that is used by GlotPress. If not, you can skip this step but if that’s the case, you’d need to edit the hash_password() method in WP_Pass class with your hashing algorithm.
Making GlotPress aware of the changes (gp-config.php)
Refer the lines 54-60 - you need to tell the GlotPress to not use its own user table and user/hashing classes and instead use yours.
GlotPress uses a gp_permissions table than the user meta table to store permissions, making our work easier. As described above, you have two options for permissions – you can either run the sql query to convert a particular user into an administrator or if your user table contains a column which differentiates the administrators and you can use that, you can just edit and activate this plugin.