You are here

function disqus_form_alter in Disqus 6

Same name and namespace in other branches
  1. 7 disqus.module \disqus_form_alter()

Implementation of hook_form_alter().

File

./disqus.module, line 163

Code

function disqus_form_alter(&$form, $form_state, $form_id) {
  $types = variable_get('disqus_nodetypes', array());
  if (isset($form['type']) && isset($form['#node']) && !empty($types[$form['type']['#value']]) && $form['type']['#value'] . '_node_form' == $form_id) {

    // Add the Disqus settings into the Comment settings fieldset if it exists.
    if (!isset($form['comment_settings'])) {
      $form['comment_settings'] = array(
        '#type' => 'fieldset',
        '#access' => user_access('toggle disqus comments'),
        '#title' => t('Comment settings'),
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
        '#weight' => 30,
      );
    }
    else {
      if (isset($form['comment_settings']['comment'])) {
        $form['comment_settings']['comment']['#access'] = $form['comment_settings']['#access'];
        $form['comment_settings']['#access'] = true;
      }
    }
    $node = $form['#node'];
    $form['comment_settings']['disqus'] = array(
      '#tree' => TRUE,
      'status' => array(
        '#type' => 'checkbox',
        '#title' => t('Enable Disqus comments'),
        '#default_value' => isset($node->disqus['status']) ? $node->disqus['status'] : TRUE,
        '#access' => user_access('toggle disqus comments'),
      ),
    );
  }
}