You are here

function hosting_task_migrate_form in Hosting 5

Same name and namespace in other branches
  1. 6.2 migrate/hosting_migrate.module \hosting_task_migrate_form()
  2. 7.4 migrate/hosting_migrate.module \hosting_task_migrate_form()
  3. 7.3 migrate/hosting_migrate.module \hosting_task_migrate_form()

File

migrate/hosting_migrate.module, line 98

Code

function hosting_task_migrate_form($node) {
  $site_instances = hosting_package_instances_load(array(
    'rid' => $node->nid,
    'i.status' => 1,
  ));
  $site_platform = node_load($node->platform);
  $cols = array();
  $packages = array();
  $form['radios']['#tree'] = false;
  $form['radios'][$node->platform]['parameters']['#tree'] = TRUE;
  $form['radios'][$node->platform]['parameters']['target_platform'] = array(
    '#type' => 'radio',
    '#title' => t('Current'),
    '#default_value' => $node->platform,
    '#disabled' => TRUE,
    "#return_value" => $node->platform,
  );
  foreach ($site_instances as $instance) {
    $packages[$node->platform][$instance->package_id] = $instance;
  }
  $profile_platform_instances = hosting_package_instances_load(array(
    'r.type' => 'platform',
    'n.nid' => $node->profile,
  ));
  if (sizeof($profile_platform_instances) <= 1) {
    $form['no_targets'] = array(
      '#value' => t('<br />There are no platforms that can meet the depdendencies for this site'),
    );
    return $form;
  }
  foreach ($profile_platform_instances as $profile_instance) {
    if ($profile_instance->rid != $node->platform) {
      $platform = node_load($profile_instance->rid);
      if ($platform->web_server == $site_platform->web_server) {
        $form['radios'][$platform->nid]['parameters']['#tree'] = TRUE;
        $form['radios'][$platform->nid]['parameters']['target_platform'] = array(
          '#type' => 'radio',
          '#title' => $platform->title,
          "#return_value" => $platform->nid,
        );
        $platform_instances = hosting_package_instances_load(array(
          'rid' => $profile_instance->iid,
        ));
        foreach ($platform_instances as $instance) {
          $packages[$platform->nid][$instance->package_id] = $instance;
        }
      }
    }
  }
  $form['#node'] = $node;
  $form['#packages'] = $packages;
  $form['#theme'] = 'hosting_task_migrate_form';
  return $form;
  $table = array();
  if (sizeof($options)) {
    $form['target_platform'] = array(
      '#type' => 'radios',
      '#title' => t('Migrate to'),
      '#options' => $options,
      '#required' => TRUE,
    );
  }
  else {
    $form['target_text'] = array(
      '#type' => 'item',
      '#value' => t('<strong>No valid platforms to migrate to.</strong>'),
    );
  }
  return $form;
}