function spaces_features_form in Spaces 5
Same name and namespace in other branches
- 5.2 spaces_admin.inc \spaces_features_form()
- 6.3 spaces.admin.inc \spaces_features_form()
- 6 spaces_admin.inc \spaces_features_form()
- 6.2 spaces_admin.inc \spaces_features_form()
- 7.3 spaces.admin.inc \spaces_features_form()
- 7 spaces.admin.inc \spaces_features_form()
Define form for controlling features
1 string reference to 'spaces_features_form'
- spaces_menu in ./
spaces.module
File
- ./
spaces_admin.inc, line 6
Code
function spaces_features_form($nid) {
drupal_set_title(t('Group Features'));
// apparently 'title' for local tasks only sets the tab name
// Load defaults -- check first for group specific, then site defaults
$default_values = array(
'features' => spaces_features($nid) ? spaces_features($nid) : (spaces_features(0) ? spaces_features(0) : array()),
'settings' => spaces_settings($nid) ? spaces_settings($nid) : (spaces_settings(0) ? spaces_settings(0) : array()),
);
$form['nid'] = array(
'#type' => 'hidden',
'#value' => $nid,
);
$form['features'] = array(
'#type' => 'fieldset',
'#title' => t('Features'),
'#description' => t('Control the features are enabled for this group by adjusting the settings below. Private features will limit access to members of this group, while public features allow any users to view any content within that feature.'),
'#tree' => TRUE,
);
$form['settings'] = array(
'#type' => 'fieldset',
'#title' => t('Settings'),
'#description' => t('Settings are options for customizing your group that do not affect the privacy of your content.'),
'#tree' => TRUE,
);
if ($nid > 0) {
$node = node_load($nid);
$mask = array(
'og_selective' => $node->og_selective,
'og_directory' => $node->og_directory,
'og_register' => $node->og_register,
'og_private' => $node->og_private,
);
$mask = spaces_groupmask('check', $mask);
$spaces_masks = spaces_groupmask('mask');
$mask = $spaces_masks[$mask];
if (isset($mask['limit options'])) {
$allowed_options = $mask['limit options'];
}
}
// Generate features form
foreach (spaces_features() as $id => $feature) {
if (is_array($feature->spaces['options'])) {
$options = $feature->spaces['options'];
// Only limit options if feature is associated with content types
if (isset($allowed_options) && count($feature->node)) {
foreach ($options as $key => $value) {
if ($key != 0 && !in_array($key, $allowed_options)) {
unset($options[$key]);
}
}
}
}
else {
if (is_string($feature->spaces['options']) && function_exists($feature->spaces['options'])) {
$option_func = $feature->spaces['options'];
$options = $option_func();
}
else {
$options = array();
}
}
// TODO resolve this issue - I'm not certain how to best handle OG ommited content types and if to exclude them from being used in a feature.
// Skip settings for any feature that requires an OG omitted content type
// if (count($feature['content_types']) && count(array_intersect(variable_get('og_omitted', array()), $feature['content_types']))) {
// continue;
// }
if (count($options) > 0) {
$form['features'][$id] = array(
'#type' => 'select',
'#title' => $feature->spaces['label'],
'#description' => $feature->spaces['description'],
'#options' => $options,
'#default_value' => isset($default_values['features'][$id]) ? $default_values['features'][$id] : 0,
);
}
}
// Generate settings form
foreach (spaces_settings() as $id => $setting) {
if (is_array($setting['options'])) {
$options = $setting['options'];
}
else {
if (is_string($setting['options']) && function_exists($setting['options'])) {
$option_func = $setting['options'];
$options = $option_func();
}
else {
$options = array();
}
}
$form['settings'][$id] = array(
'#type' => 'select',
'#title' => $setting['label'],
'#description' => $setting['description'],
'#options' => $options,
'#default_value' => isset($default_values['settings'][$id]) ? $default_values['settings'][$id] : 0,
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
return $form;
}