You are here

function apps_profile_install_app_modules in Apps 7

Batch process apps install.

1 string reference to 'apps_profile_install_app_modules'
apps_profile_install_tasks in ./apps.profile.inc
Add install tasks to profile install tasks.

File

./apps.profile.inc, line 329
The install functions for the Apps module.

Code

function apps_profile_install_app_modules(&$install_state) {
  $batch = array();
  if (!empty($_SESSION['update_manager_update_projects'])) {
    apps_include('installer');

    // Make sure the Updater registry is loaded.
    drupal_get_updaters();
    $updates = array();
    $project_types = $_SESSION['update_manager_update_projects'];
    foreach ($project_types as $type => $projects) {
      $directory = apps_extract_directory($type);
      foreach ($projects as $project => $url) {
        $project_location = $directory . '/' . $project;
        $updater = Updater::factory($project_location);
        $project_real_location = drupal_realpath($project_location);
        $updates[] = array(
          'project' => $project,
          'updater_name' => get_class($updater),
          'local_url' => $project_real_location,
        );
      }
    }
    if (isset($_SESSION['filetransfer'])) {

      // We have authenticated a filetransfer so use it.
      $filetransfer = $_SESSION['filetransfer'];
    }
    else {

      // This is a local transfer because the config_path is writeable.
      $filetransfer = new FileTransferLocal(DRUPAL_ROOT);
    }
    module_load_include('inc', 'update', 'update.authorize');
    $operations = array();
    foreach ($updates as $update => $update_info) {
      $operations[] = array(
        'apps_update_authorize_batch_copy_project',
        array(
          $update_info['project'],
          $update_info['updater_name'],
          $update_info['local_url'],
          $filetransfer,
        ),
      );
    }
    $batch = array(
      'title' => t('Downloading apps'),
      'init_message' => t('Preparing to download apps.'),
      'operations' => $operations,
      'finished' => 'apps_update_authorize_update_batch_finished',
      'file' => drupal_get_path('module', 'apps') . '/apps.installer.inc',
    );
    unset($_SESSION['update_manager_update_projects']);
  }
  return $batch;
}