You are here

function comment_form_alter in Drupal 4

Same name and namespace in other branches
  1. 5 modules/comment/comment.module \comment_form_alter()
  2. 6 modules/comment/comment.module \comment_form_alter()

File

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

Code

function comment_form_alter($form_id, &$form) {
  if (isset($form['type'])) {
    if ($form['type']['#value'] . '_node_settings' == $form_id) {
      $form['workflow']['comment_' . $form['type']['#value']] = array(
        '#type' => 'radios',
        '#title' => t('Default comment setting'),
        '#default_value' => variable_get('comment_' . $form['type']['#value'], COMMENT_NODE_READ_WRITE),
        '#options' => array(
          t('Disabled'),
          t('Read only'),
          t('Read/Write'),
        ),
        '#description' => t('Users with the <em>administer comments</em> permission will be able to override this setting.'),
      );
    }
    if ($form['type']['#value'] . '_node_form' == $form_id) {
      $node = $form['#node'];
      if (user_access('administer comments')) {
        $form['comment_settings'] = array(
          '#type' => 'fieldset',
          '#title' => t('Comment settings'),
          '#collapsible' => TRUE,
          '#collapsed' => TRUE,
          '#weight' => 30,
        );
        $form['comment_settings']['comment'] = array(
          '#type' => 'radios',
          '#parents' => array(
            'comment',
          ),
          '#default_value' => $node->comment,
          '#options' => array(
            t('Disabled'),
            t('Read only'),
            t('Read/Write'),
          ),
        );
      }
      else {
        $form['comment_settings']['comment'] = array(
          '#type' => 'value',
          '#value' => $node->comment,
        );
      }
    }
  }
}