I have a need for users' accounts to be automatically sync'd across from Drupal to Chamilo (previously, I was using Dokeos). I saw that currently the functionality requires that each user manually copy their user key from Chamilo to the section in the user edit in Drupal.
I wrote this functionality in to the then-current version of the chamilo integration from soyarma (he had uploaded a .zip file of what he had done before he'd checked anything in) and also made the webservice calls work with version 1.8.6.2 of chamilo.
I needed to make one change to chamilo, and that was to add a somewhat hack-tacular function called "DokeosWSInfoOfUser($secret_key, $username)" to user_info.soap.php. This function takes the $secret_key the same way that registration.DokeosWSCreateUserPasswordCrypted (for example, the other actions do as well) does, which is sha1($_SERVER['REMOTE_ADDR'].$_configuration['security_key']) (where $_SERVER['REMOTE_ADDR'] is actually the server that you are sending the webservice request from). The action will then return information about the username supplied if the user exists and -1 if it does not.
This is the hack-tacular part, and I welcome any recommendations for improvements because I don't really like it, but couldn't find a better way to do it. If the user exists, $info is built up using api_get_user_info_from_username($username). Then, the api_key for that user is looked up using UserManager::get_api_keys(). If there is no api_key for this user, one is created using UserManager::update_api_key() in the same way that it is created on the chamilo user profile page. This key is added to the $info array and sent back through the web service request. Then, that api_key is added to the chamilo_user table in Drupal.
I have attached my .tar.gz of the chamilo integration module including "Sync all accounts..." functionality and my patch for user_info.soap.php. I would love any and all feedback constructive to making this feature work or if I've approached it in the wrong way, criticism as to why it won't work as there is precious little documentation on the chamilo webservices functionality.
Thank you.
--Tavish
| Comment | File | Size | Author |
|---|---|---|---|
| user_info.soap_.php_.patch | 2.31 KB | tavish | |
| chamilo-tavish_edit.tar_.gz | 14.68 KB | tavish |
Comments
Comment #1
develcuy commentedThanks for the patch @tavish, your patch needs work because it mixes Chamilo and Drupal stuff, unless the lead developer of Chamilo collaborates with us, patches for Chamilo LMS (not the module) should go to their issue queue. Please, may you split your patch and provide a link to the corresponding issue in Chamilo?
You rock :)
Comment #2
develcuy commentedI have to add that @soyarma is now co-maintainer of this module, please take a look at the manual to update your patch: http://drupal.org/patch/create
Comment #3
tavish commentedSorry for the tardy reply. (as an aside, how do I set my drupal.org account to get an email when a comment is made on an issue that I wrote?) I have been busy.
The patch is already somewhat split. The "chamilo-tavish_edit.tar_.gz" file is the patch to the chamilo drupal module and the "user_info.soap_.php_.patch" is the file that I need to submit to the chamilo team. I haven't done that yet.
What else would you like me to do other than submit that to them?
I would like to get @soyarma 's comment on the patch as well.
Thank you.
--Tavish