diff --git a/package/hosting_package.module b/package/hosting_package.module index c020fa4..f1974ba 100644 --- a/package/hosting_package.module +++ b/package/hosting_package.module @@ -102,20 +102,25 @@ function hosting_package_node_access($node, $op, $account) { } /** - * @todo document this function + * Return a list of available install profiles. + * + * @param null $platform_nid + * Only load install profiles available on this platform. + * + * @param string $field + * The field to use for the value of the return array. + * + * @return array + * The list of available install profiles, ready to use as #options in a form. */ -function hosting_get_profiles($platform = NULL, $field = 'title') { +function hosting_get_profiles($platform_nid = NULL, $field = 'title') { $profiles = array(); - if (!is_null($platform)) { + if (!is_null($platform_nid)) { $instances = hosting_package_instances_load(array( - 'i.rid' => $platform, + 'i.rid' => $platform_nid, 'p.package_type' => 'profile', 'n.status' => 1, )); - - foreach ($instances as $iid => $instance) { - $profiles[$instance->package_id] = $instance->$field; - } } else { $instances = hosting_package_instances_load(array( @@ -123,12 +128,14 @@ function hosting_get_profiles($platform = NULL, $field = 'title') { 'n.status' => 1, 'r.type' => 'platform', )); + } - foreach ($instances as $iid => $instance) { + // 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; } diff --git a/site/hosting_site.form.inc b/site/hosting_site.form.inc index eac87b3..ec3bbd9 100644 --- a/site/hosting_site.form.inc +++ b/site/hosting_site.form.inc @@ -101,11 +101,6 @@ function hosting_site_available_options($node, $platform = NULL) { $platform_profiles = array(); foreach ($profiles as $id => $name) { - // Don't allow a site to be provisioned with hostslave or hostmaster profile - if (in_array($name, array('Hostslave', 'Hostmaster'))) { - unset($profiles[$id]); - } - // Trim down the list of profiles to those that are available and the user has access to // XXX This hack (next 22 lines) hides profiles that can't be accessed // Eventually we should lighten up the content of this callback @@ -241,10 +236,6 @@ function hosting_site_form($node, &$form_state) { foreach ($profiles as $id => $name) { $profile = hosting_package_instance_load(array('p.nid' => $id)); $profiles[$id] = theme('hosting_site_profile', array('profile' => $profile, 'html' => TRUE)); - // Don't allow a site to be provisioned with hostslave or hostmaster profile - if (in_array($name, array('Hostslave', 'Hostmaster'))) { - unset($profiles[$id]); - } } natcasesort($profiles); reset($profiles);