You are here

option_cfs_comment_cancel.inc in Node and Comments Form Settings 7.2

Hide the Revision log field.

File

commentformsettings/includes/option_cfs_comment_cancel.inc
View source
<?php

/**
 * @file
 * Hide the Revision log field.
 */
function _option_cfs_comment_cancel(&$form, &$form_state, $settings, $node) {
  if ($settings['cfs_comment_cancel'] == 0 && arg(0) == 'comment' && arg(1) == 'reply' && is_numeric(arg(2))) {

    // User landed on comment form by clicking on a link on the node.
    $path = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_PATH);

    // If referrer has query string, use that same in the link.
    if (!empty(parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY))) {

      // Get query string and parse into array.
      $query_string = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY);
      parse_str($query_string, $query);
      $options = array(
        'class' => 'form-button form-button-cancel',
        'rel' => 'nofollow',
      );
      $form['actions']['cancel'] = array(
        '#markup' => l(t('Cancel'), $path, array(
          'attributes' => $options,
          'query' => $query,
        )),
        '#weight' => 51,
      );
    }
    else {
      $path = 'node/' . $node->nid;
      $form['actions']['cancel'] = array(
        '#markup' => l(t('Cancel'), $path),
        '#weight' => 51,
      );
    }
  }
  return $form;
}

Functions

Namesort descending Description
_option_cfs_comment_cancel @file Hide the Revision log field.