Hi Jakub,
I have done away two hours this evening with trying to come up with ways to handle this without stuffing the module list into the session, but was unable to do it, since the system_module handler results in a redirect before a possible next submit handler would be able to run.
Anyway, after that two hours, I have started off from your code and cleaned it up (ie. no need to foreach on the form array, since we can grab it as is). Added logic to import all PO files for all enabled languages, and comitted the result:
http://drupal.org/cvs?commit=54356
I tried to test this as much as I can, and it really seems to work. After giving some deeper thought to this session storage method, I figured we have no problem with it until we need to deal with modules being disabled (which is not the case yet).
Thanks for sharing this piece of advice!
Ps. I also fixed a cache cleanup error, and a postresql compatibility error recently in autolocale.
Gabor
Jakub Suchy wrote:
Gabor Hojtsy wrote:
- Check the database (or the module_list()) in the early callback.
- Check it again at the callback called last.
- Compute the difference.
- Import what needs to be imported
Is this clean and does it have some catch? It works for me
function autolocale_form_alter($form_id, &$form) { // Process only if module form is displayed if ($form_id === "system_modules") {
// Determine which modules are enabled at the moment if (is_array($form['status']['#default_value'])) { $autolocale_modules = array(); foreach ($form['status']['#default_value'] as $module) { array_push($autolocale_modules, $module); } // We MUST skip module confirm form if ($_GET['q'] != "admin/build/modules/list/confirm") { $enabled = array_diff($autolocale_modules, $_SESSION['autolocale_modules']); if (!empty($enabled)) { // These modules have been enabled print_r($enabled); // TODO } } // Store modules for next reload $_SESSION['autolocale_modules'] = $autolocale_modules; }} } _______________________________________________ translations mailing list translations@drupal.org http://lists.drupal.org/mailman/listinfo/translations