function revision_all_form_alter in Revision All 7.2
Same name and namespace in other branches
- 8 revision_all.module \revision_all_form_alter()
- 6 revision_all.module \revision_all_form_alter()
- 7 revision_all.module \revision_all_form_alter()
Implements hook_form_alter().
If the "Revision All" setting is checked, check the "Create new revision" checkbox.
If the "Prevent Revisioning Overrides" setting is checked, node forms are altered to disable access to the "Create new revision" checkbox.
File
- ./
revision_all.module, line 177 - Permits configuring content revision settings from a central location. Also makes alterations to existing forms based on user specified settings.
Code
function revision_all_form_alter(&$form, &$form_state, $form_id) {
$revision_settings = variable_get('revision_all', array());
$revision_all_types = $revision_settings['revision_all_types'];
$revision_future_types = $revision_settings['enable_future'];
$prevent_type_override = $revision_settings['prevent_type_override'];
$prevent_node_override = $revision_settings['prevent_node_override'];
// Content Type form
if ($form_id == 'node_type_form') {
if (empty($form['#node_type']->type) && ($revision_future_types || $revision_all_types)) {
$form['workflow']['node_options']['#default_value'][] = 'revision';
}
// Disable "Create new revision" checkbox if revisioning is set and the
// prevent override option is enabled for an existing content type.
if (in_array('revision', $form['workflow']['node_options']['#default_value']) && $prevent_type_override) {
$form['workflow']['node_options']['revision']['#disabled'] = TRUE;
array_unshift($form['#submit'], 'revision_all_content_type_form_submit');
revision_all_add_disabled_option_explanation($form['workflow']['node_options']);
}
}
elseif (isset($form['#entity_type']) && $form['#entity_type'] == 'node' && isset($form['revision_information']) && $form['revision_information']['revision']['#default_value'] && $prevent_node_override) {
$form['revision_information']['revision']['#disabled'] = TRUE;
revision_all_add_disabled_option_explanation($form['revision_information']['revision'], 'Node');
}
}