You are here

function hosting_get_profiles in Hosting 7.3

Same name and namespace in other branches
  1. 5 package/hosting_package.module \hosting_get_profiles()
  2. 6.2 package/hosting_package.module \hosting_get_profiles()
  3. 7.4 package/hosting_package.module \hosting_get_profiles()

Return a list of available install profiles.

Parameters

null $platform_nid: Only load install profiles available on this platform.

string $field: The field to use for the value of the return array.

Return value

array The list of available install profiles, ready to use as #options in a form.

4 calls to hosting_get_profiles()
hosting_platform_load in platform/hosting_platform.module
Implements hook_load().
hosting_settings in ./hosting.module
General settings form.
hosting_site_available_options in site/hosting_site.form.inc
Pass in a site node and return an array of valid options for it's fields.
hosting_site_form in site/hosting_site.form.inc
Implements hook_form().

File

package/hosting_package.module, line 102
Defines package node types

Code

function hosting_get_profiles($platform_nid = NULL, $field = 'title') {
  $profiles = array();
  if (!is_null($platform_nid)) {
    $instances = hosting_package_instances_load(array(
      'i.rid' => $platform_nid,
      'p.package_type' => 'profile',
      'n.status' => 1,
    ));
  }
  else {
    $instances = hosting_package_instances_load(array(
      'p.package_type' => 'profile',
      'n.status' => 1,
      'r.type' => 'platform',
    ));
  }

  // Prepare list of available profiles, preventing the use of blocked ones.
  foreach ($instances as $iid => $instance) {
    if (!in_array($instance->short_name, variable_get('hosting_blocked_profiles', array(
      'hostslave',
      'hostmaster',
    )))) {
      $profiles[$instance->package_id] = $instance->{$field};
    }
  }
  return $profiles;
}