You are here

function hosting_get_profile_platforms in Hostmaster (Aegir) 6

1 call to hosting_get_profile_platforms()
hosting_site_available_options in modules/hosting/site/hosting_site.form.inc
Pass in a site node and return an array of valid options for it's fields.

File

modules/hosting/package/hosting_package.module, line 145

Code

function hosting_get_profile_platforms($profile, $check_old_short_name = FALSE) {
  $defaults = array(
    'default',
    'standard',
    'minimal',
  );
  $platforms = array();
  $instances = hosting_package_instances_load(array(
    'i.package_id' => $profile,
    'n.status' => 1,
    'r.status' => 1,
    'r.type' => 'platform',
  ));
  if ($check_old_short_name) {
    $instances = array_merge($instances, hosting_package_instances_load(array(
      'p.old_short_name' => $instances[key($instances)]->short_name,
      'n.status' => 1,
      'r.status' => 1,
      'r.type' => 'platform',
    )));
  }
  foreach ($instances as $iid => $instance) {
    $platform = node_load($instance->rid);

    // this is one of the default profiles
    if (in_array($instance->short_name, $defaults) && sizeof(array_diff(array_values($platform->profiles), $defaults)) && variable_get('hosting_ignore_default_profiles', FALSE)) {

      // there are other profiles available on this platform. skip this.
      continue;
    }
    if ($platform->platform_status != HOSTING_PLATFORM_DELETED) {
      $platforms[$instance->rid] = $platform->title;
    }
  }
  return $platforms;
}