You are here

function revisioning_form_alter in Revisioning 6

Same name and namespace in other branches
  1. 8 revisioning.pages.inc \revisioning_form_alter()
  2. 6.4 revisioning.pages.inc \revisioning_form_alter()
  3. 6.3 revisioning.pages.inc \revisioning_form_alter()
  4. 7 revisioning.pages.inc \revisioning_form_alter()

Implementation of hook_form_alter().

File

./revisioning.module, line 127

Code

function revisioning_form_alter(&$form, $form_state, $form_id) {

  // On content edit form, add the "New revisions in moderation" option.
  if (isset($form['#id']) && $form['#id'] == 'node-form') {
    $default_value = in_array('revision_moderation', variable_get("node_options_{$form['type']['#value']}", array(
      'status',
      'promote',
    )));

    // Only show the checkbox if user has the 'administer nodes' permission
    if (!empty($node->revision) || user_access('administer nodes')) {
      $form['revision_information']['revision_moderation'] = array(
        '#type' => 'checkbox',
        '#title' => t('New revisions in moderation'),
        '#default_value' => $default_value,
      );
    }
    else {
      $form['revision_moderation'] = array(
        '#type' => 'value',
        '#value' => $default_value,
      );
    }
  }
  elseif ($form_id == 'node_type_form') {
    $form['workflow']['node_options']['#options']['revision_moderation'] = t('New revisions in moderation');
  }
}