function og_form_node_type_form_alter in Organic groups 6.2
Same name and namespace in other branches
- 6 og.module \og_form_node_type_form_alter()
Implementation of hook_form_FORM_ID_alter() for node_type_form.
File
- ./
og.module, line 1799 - Code for the Organic Groups module.
Code
function og_form_node_type_form_alter(&$form, &$form_state) {
// Built in content types do not allow changes to type machine name.
if (isset($form['identity']['type']['#default_value'])) {
$usage = variable_get('og_content_type_usage_' . $form['identity']['type']['#default_value'], 'omitted');
}
else {
$usage = variable_get('og_content_type_usage_' . $form['identity']['type']['#value'], 'omitted');
}
// Persist $usage so that we can rebuild node access as needed.
$form['old_og_content_type_usage'] = array(
'#type' => 'value',
'#value' => $usage,
);
// We push to the front so we can unset() variables before they are saved.
array_unshift($form['#submit'], 'og_node_type_form_submit');
array_unshift($form['#validate'], 'og_node_type_form_validate');
$options = og_types_map();
$og = array(
'#type' => 'fieldset',
'#title' => t('Organic groups'),
'#group' => 'additional_settings',
'#attached' => array(
'js' => array(
'vertical-tabs' => drupal_get_path('module', 'og') . '/og.js',
),
),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#access' => user_access('administer organic groups'),
);
$form['og'] = isset($form['og']) ? $form['og'] + $og : $og;
$form['og']['og_content_type_usage'] = array(
'#type' => 'radios',
'#title' => t('Organic groups usage'),
'#default_value' => $usage,
'#options' => $options,
'#description' => t('Specify how organic groups should treat nodes of this type. Nodes may behave as a group, as group posts, or may not participate in organic groups at all.'),
);
$max_number = '';
if (isset($form['identity']['type']['#default_value'])) {
$max_number = variable_get('og_max_groups_' . $form['identity']['type']['#default_value'], '');
}
$form['og']['og_max_groups'] = array(
'#type' => 'textfield',
'#title' => t('Group limit'),
'#default_value' => $max_number,
'#size' => 3,
'#description' => t('If the usage is standard group post, specify the number of groups the nodes of this type may be posted into. Leave blank for no limit.'),
);
}