3

For a Drupal 6 Open Atrium site (i.e., Features, Spaces, Organic Groups) I'm running, I've created some custom Features that only really apply to a handful of the hundreds of groups on the site.

As it stands, the "Customize Features" config screen shows all the Features, including those I'd like to intentionally restrict to just a couple of special groups.

What's the best way to prevent these special Features from being offered to every group, while retaining those Features on the special groups?

2

The features for each space are configured via the spaces_features_form() function. You could implement hook_form_alter() to selectively and conditionally remove features from specific groups.

function MYMODULE_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'spaces_features_form') {
    $space = spaces_get_space();
    // Populate the array with hard-coded NIDs, or whatever logic
    // needed to determine if these features should be allowed.
    if ($space->type == 'og' && !in_array($space->group->nid, array(...))) {
      // Hide features foo and bar.
      foreach (array('feature_foo', 'feature_bar') as $feature) {
        $form['spaces_features'][$feature]['#access'] = FALSE;
      }
    }
  }
}
1

Features are modules. Modules are enabled system-wide and cannot be linked to a Space or Group. However, you could control access to them by creating custom permissions, see hook_perm().

  • 1
    This isn't quite true. Features can be selectively enabled on a per-space basis, but you're right in that they can't automatically be hidden from the spaces features configuration form. – jhedstrom Apr 16 '11 at 18:02
1

I'd add to this hook_perm suggestion an alteration on the form to disable the applicable feature based on the group type. hook_form_alter probably wont work cause the feature related items won't be present yet. You may have to register an #after_build hook and then modify the form accordingly.

1

Context is definitely the way to go.
Context, Features and Spaces are a powerful combination. This DevelopmentSeed post should help: Building a "Blog Feature" in Drupal with Context and Spaces

-1

Could you enable all of the features from the start, but handle their display via Context? I haven't had a chance to try Context myself yet, but it sounds like a fit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.