You are here

function workbench_moderation_form_node_form_alter in Workbench Moderation 7.2

Same name and namespace in other branches
  1. 7.3 workbench_moderation.module \workbench_moderation_form_node_form_alter()
  2. 7 workbench_moderation.module \workbench_moderation_form_node_form_alter()

Implements hook_form_BASE_FORM_ID_alter().

File

./workbench_moderation.module, line 240
workbench_moderation.module

Code

function workbench_moderation_form_node_form_alter(&$form, &$form_state, $form_id) {
  if (!empty($form['options']['state_flow'])) {

    // Hide Published checkbox.
    $form['options']['status']['#access'] = FALSE;

    // Disable revision checkbox on new nodes. This is also enforced in
    // workbench_moderation_node_presave().
    if (!isset($form['#node']->nid) && isset($form['revision_information']['revision'])) {
      $form['revision_information']['revision']['#default_value'] = TRUE;
      $form['revision_information']['revision']['#disabled'] = TRUE;
      $form['revision_information']['revision']['#description'] = t('A new revision must always be created when Workbench Moderation and State Flow are enabled.');
    }

    // Allow access to revision info.
    $form['revision_information']['#access'] = TRUE;

    // Info block messages.
    $node = $form_state['node'];
    workbench_moderation_messages('edit', $node);

    // Note: Our JS relies on functionality from core that may or may not be on
    // the page yet.
    drupal_add_library('system', 'drupal.form');

    // Add the javascript for vertical tabs.
    drupal_add_js(drupal_get_path('module', 'workbench_moderation') . '/js/workbench_moderation.js', array(
      'weight' => 90,
    ));

    // Change the title of core options from "Publishing Options" to "Additional
    // Options because the event the publish checkbox is hidden.
    if (!empty($form['options']['#title'])) {
      $form['options']['#title'] = t('Additional options');
    }
  }
}