ckoppenhaver
5/7/2013 - 7:03 PM

This gist for enabling a module after profile install for Drupal 7. Place inside the installers PROFILE.

This gist for enabling a module after profile install for Drupal 7. Place inside the installers PROFILE.

function install_profile_install_tasks($install_state) {
/*
type:
One of "normal," "batch," or "form."
"Normal" tasks can return HTML that will be displayed as a page in the installer or NULL to indicate that the task is completed. This is the default. Remember to provide some way to continue to the next step, such as a "continue" button.
"Batch" tasks return a batch array to be processed by the Batch API, which is useful for example if you want to import something that could take awhile. The task will be considered complete when the batch finishes processing.
"Form" tasks return a Form API structured array which will be displayed as a form on a page in the installer. The installer will take care of moving the user to the next task when the form is submitted.

run
One of INSTALL_TASK_RUN_IF_REACHED, INSTALL_TASK_RUN_IF_NOT_COMPLETED, or INSTALL_TASK_SKIP.
INSTALL_TASK_RUN_IF_REACHED means the task will run at each stage of the installation that reaches it. This is mainly used by core to include important resources on each page of the installer.
INSTALL_TASK_RUN_IF_NOT_COMPLETED means the task will run once during the installation process. This is the default, and it is useful for things like displaying instructions and configuration forms, or for inserting content into the database.
INSTALL_TASK_SKIP means the task will not be run. This is usually set conditionally, since you may want to skip tasks depending on the options the user chose in previous steps. It is often the case that a task will be skipped when display is set to FALSE, but it is possible to display a task in the list without executing it.
*/

return array(
    'module_machine_name' => array(
      'display_name' => st('Enable Moduel'),
      'display' => FALSE,
      'type' => 'normal',
      'run' => INSTALL_TASK_RUN_IF_REACHED,
      'function' => 'function_name',
    )
  );
}

function function_name(){
  module_enable(array('module_to_enable'));
}