You are here

function flatcomments_form_alter in Flatcomments 5

Same name and namespace in other branches
  1. 6.2 flatcomments.module \flatcomments_form_alter()
  2. 6 flatcomments.module \flatcomments_form_alter()

Implementation of hook_form_alter().

File

./flatcomments.module, line 11
Make comments replies to the node, regardless of the reply link used.

Code

function flatcomments_form_alter($form_id, &$form) {
  switch ($form_id) {
    case 'comment_form':

      // Check whether flatcomments are enabled for this node type and it's not an existing comment
      // If so, make the node the parent by setting pid to NULL
      $node = node_load($form['nid']['#value']);
      $display_mode = (int) variable_get('comment_default_mode', 0);
      if (($display_mode === 1 || $display_mode === 2) && !$form['cid']['#value']) {
        $form['pid']['#value'] = NULL;
      }
      break;
    case 'comment_admin_settings':
      $form['viewing_options']['comment_default_mode']['#description'] .= t(' <strong>Flatcomments enabled:</strong> Flat list options will force replies to be to the main post.');
      break;
  }
}