You are here

function apps_update_authorize_batch_copy_project in Apps 7

Copy of update_authorize_batch_copy_project cept override install_dir.

2 string references to 'apps_update_authorize_batch_copy_project'
apps_profile_install_app_modules in ./apps.profile.inc
Batch process apps install.
apps_run_install in ./apps.installer.inc
The batch builder and processor for moving files to drupal.

File

./apps.installer.inc, line 314
installer.inc hold all of the function used to download apps and thier deps

Code

function apps_update_authorize_batch_copy_project($project, $updater_name, $local_url, $filetransfer, &$context) {
  module_load_include('authorize.inc', 'update');

  // Initialize some variables in the Batch API $context array.
  if (!isset($context['results']['log'])) {
    $context['results']['log'] = array();
  }
  if (!isset($context['results']['log'][$project])) {
    $context['results']['log'][$project] = array();
  }
  if (!isset($context['results']['tasks'])) {
    $context['results']['tasks'] = array();
  }

  // The batch API uses a session, and since all the arguments are serialized
  // and unserialized between requests, although the FileTransfer object itself
  // will be reconstructed, the connection pointer itself will be lost. However,
  // the FileTransfer object will still have the connection variable, even
  // though the connection itself is now gone. So, although it's ugly, we have
  // to unset the connection variable at this point so that the FileTransfer
  // object will re-initiate the actual connection.
  unset($filetransfer->connection);
  if (!empty($context['results']['log'][$project]['#abort'])) {
    $context['finished'] = 1;
    return;
  }
  $updater = new $updater_name($local_url);
  try {
    $args = array();
    if ($updater
      ->isInstalled()) {

      // This is an update.
      $tasks = $updater
        ->update($filetransfer, $args);
    }
    else {
      if ($updater_name == 'ModuleUpdater') {
        $args = array(
          'install_dir' => DRUPAL_ROOT . '/' . variable_get('apps_install_path', APPS_INSTALL_PATH),
        );
      }
      $tasks = $updater
        ->install($filetransfer, $args);
    }
  } catch (UpdaterException $e) {
    _update_batch_create_message($context['results']['log'][$project], t('Error installing / updating'), FALSE);
    _update_batch_create_message($context['results']['log'][$project], $e
      ->getMessage(), FALSE);
    $context['results']['log'][$project]['#abort'] = TRUE;
    return;
  }
  _update_batch_create_message($context['results']['log'][$project], t('Installed %project_name successfully', array(
    '%project_name' => $project,
  )));
  if (!empty($tasks)) {
    $context['results']['tasks'] += $tasks;
  }

  // This particular operation is now complete, even though the batch might
  // have other operations to perform.
  $context['finished'] = 1;
}