module_install.module 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * @file
  4. * Main module functionality for the module_install module.
  5. */
  6. /**
  7. * Implements hook_module_install_exceptions().
  8. */
  9. function module_install_module_install_exceptions() {
  10. return array(
  11. 'sites/all/modules/features',
  12. );
  13. }
  14. /**
  15. * Implements hook_form_FORM_ID_alter().
  16. */
  17. function module_install_form_update_manager_install_form_alter(&$form, &$form_state) {
  18. module_load_include('inc', 'module_install', 'module_install.api');
  19. if (isset($form_state['values']['destination'])) {
  20. $destination = $form_state['values']['destination'];
  21. }
  22. else {
  23. $destination = module_install_get_destination_choice('modules');
  24. }
  25. $searchdir = module_install_get_search_directories('modules');
  26. $options = $searchdir;
  27. foreach ($searchdir as $dir) {
  28. module_install_get_destination_directories($dir, $options, 'module');
  29. }
  30. asort($options);
  31. $form['destination'] = array(
  32. '#type' => 'select',
  33. '#title' => t('Destination folder'),
  34. '#options' => $options,
  35. '#default_value' => $destination,
  36. );
  37. $form['#submit'][0] = 'module_install_update_manager_install_form_submit';
  38. }
  39. /**
  40. * Form sumbit handler for the module install form.
  41. *
  42. * @see module_install_form_alter()
  43. */
  44. function module_install_update_manager_install_form_submit($form, &$form_state) {
  45. module_load_include('inc', 'module_install', 'module_install.api');
  46. module_install_set_destination_choice($form_state['values']['destination']);
  47. update_manager_install_form_submit($form, $form_state);
  48. }
  49. /**
  50. * Implements hook_updater_info_alter().
  51. */
  52. function module_install_updater_info_alter(&$updaters) {
  53. $updaters['module']['class'] = 'ModuleInstallUpdater';
  54. }