You are here

function drupal_commons_profile_tasks in Drupal Commons 6

Same name and namespace in other branches
  1. 6.2 drupal_commons.profile \drupal_commons_profile_tasks()

Perform any final installation tasks for this profile.

Parameters

$task: The current $task of the install system. When hook_profile_tasks() is first called, this is 'profile'.

$url: Complete URL to be used for a link or form action on a custom page, if providing any, to allow the user to proceed with the installation.

Return value

An optional HTML string to display to the user. Only used if you modify the $task, otherwise discarded.

File

./drupal_commons.profile, line 102

Code

function drupal_commons_profile_tasks(&$task, $url) {

  // Skip to the configure task
  if ($task == 'profile') {
    $task = 'configure-features';
  }

  // If we're using Drush to install, skip the forms
  if (defined('DRUSH_BASE_PATH')) {
    drupal_commons_include('drush');
    _drupal_commons_drush_tasks($task);
  }

  // Provide a form to choose features
  if ($task == 'configure-features') {
    drupal_commons_include('form');
    $output = drupal_get_form('drupal_commons_features_form', $url);
  }

  // Provide a form to choose the theme
  if ($task == 'configure-theme') {
    drupal_commons_include('form');
    $output = drupal_get_form('drupal_commons_theme_form', $url);
  }

  // Installation batch process
  if ($task == 'install-commons') {

    // Determine the installation operations
    $operations = array();

    // Pre-installation operations
    $operations[] = array(
      'drupal_commons_build_directories',
      array(),
    );
    $operations[] = array(
      'drupal_commons_config_taxonomy',
      array(),
    );

    // Feature installation operations
    $features = variable_get('commons_selected_features', array());
    foreach ($features as $feature) {
      $operations[] = array(
        'features_install_modules',
        array(
          array(
            $feature,
          ),
        ),
      );
    }

    // Post-installation operations
    $operations[] = array(
      'drupal_commons_config_filter',
      array(),
    );
    $operations[] = array(
      'drupal_commons_config_password',
      array(),
    );
    $operations[] = array(
      'drupal_commons_config_wysiwyg',
      array(),
    );
    $operations[] = array(
      'drupal_commons_config_ur',
      array(),
    );
    $operations[] = array(
      'drupal_commons_config_views',
      array(),
    );
    $operations[] = array(
      'drupal_commons_config_images',
      array(),
    );
    $operations[] = array(
      'drupal_commons_config_vars',
      array(),
    );

    // Build the batch process
    $batch = array(
      'operations' => $operations,
      'title' => st('Configuring Commons'),
      'error_message' => st('An error occurred. Please try reinstalling again.'),
      'finished' => 'drupal_commons_cleanup',
    );

    // Start the batch
    variable_set('install_task', 'install-commons-batch');
    batch_set($batch);
    batch_process($url, $url);
  }

  // Persist the page while batch executes
  if ($task == 'install-commons-batch') {
    include_once 'includes/batch.inc';
    $output = _batch_page();
  }
  return $output;
}