1.12.x comment.module comment_form_node_type_form_alter(&$form, $form_state)
1.10.x comment.module comment_form_node_type_form_alter(&$form, $form_state)
1.11.x comment.module comment_form_node_type_form_alter(&$form, $form_state)
1.7.x comment.module comment_form_node_type_form_alter(&$form, $form_state)
1.8.x comment.module comment_form_node_type_form_alter(&$form, $form_state)
1.9.x comment.module comment_form_node_type_form_alter(&$form, $form_state)

Implements hook_form_FORM_ID_alter().

File

modules/comment/comment.module, line 1128
Enables users to comment on published content.

Code

function comment_form_node_type_form_alter(&$form, $form_state) {
  $node_type = $form['#node_type'];

  if (isset($form['type'])) {
    $form['comment'] = array(
      '#type' => 'fieldset',
      '#title' => t('Comment settings'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#group' => 'additional_settings',
      '#attributes' => array(
        'class' => array('comment-node-type-settings-form'),
      ),
      '#attached' => array(
        'js' => array(backdrop_get_path('module', 'comment') . '/js/comment.admin.js'),
      ),
      '#weight' => 20,
    );
    // Unlike coment_form_node_form_alter(), all of these settings are applied
    // as defaults to all new nodes. Therefore, it would be wrong to use #states
    // to hide the other settings based on the primary comment setting.
    $form['comment']['comment_default'] = array(
      '#type' => 'radios',
      '#title' => t('Default comment setting for new content'),
      '#default_value' => $node_type->settings['comment_default'],
      '#options' => array(
        COMMENT_NODE_OPEN => t('Open comments'),
        COMMENT_NODE_CLOSED => t('Closed comments'),
      ),
    );
    $form['comment']['comment_per_page'] = array(
      '#type' => 'select',
      '#title' => t('Comments per page'),
      '#default_value' => $node_type->settings['comment_per_page'],
      '#options' => _comment_per_page(),
    );
    $form['comment']['comment_mode'] = array(
      '#type' => 'checkbox',
      '#title' => t('Show comment replies in a threaded list'),
      '#default_value' => $node_type->settings['comment_mode'],
      '#description' => t('A threaded list differs from chronologocal in that each comment follows it\'s parent, and is usually indented.'),
    );
    $form['comment']['comment_anonymous'] = array(
      '#type' => 'select',
      '#title' => t('Anonymous commenting'),
      '#default_value' => $node_type->settings['comment_anonymous'],
      '#options' => array(
        COMMENT_ANONYMOUS_MAYNOT_CONTACT => t('Anonymous posters may not enter their contact information'),
        COMMENT_ANONYMOUS_MAY_CONTACT => t('Anonymous posters may leave their contact information'),
        COMMENT_ANONYMOUS_MUST_CONTACT => t('Anonymous posters must leave their contact information'),
      ),
      '#access' => user_access('post comments', backdrop_anonymous_user()),
    );
    $form['comment']['comment_subject_field'] = array(
      '#type' => 'checkbox',
      '#title' => t('Allow comment title'),
      '#default_value' => $node_type->settings['comment_subject_field'],
    );
    if (config_get('system.core', 'user_pictures')) {
      $form['comment']['comment_user_picture'] = array(
        '#type' => 'checkbox',
        '#title' => t('Display pictures for comment authors'),
        '#default_value' => $node_type->settings['comment_user_picture'],
      );
    }
    $form['comment']['comment_form_location'] = array(
      '#type' => 'checkbox',
      '#title' => t('Show reply form on the same page as comments'),
      '#default_value' => $node_type->settings['comment_form_location'],
    );
    $form['comment']['comment_preview'] = array(
      '#type' => 'radios',
      '#title' => t('Preview comment'),
      '#default_value' => $node_type->settings['comment_preview'],
      '#options' => array(
        BACKDROP_DISABLED => t('Disabled'),
        BACKDROP_OPTIONAL => t('Optional'),
        BACKDROP_REQUIRED => t('Required'),
      ),
    );
  }
}