You are here

function ctools_node_comment_form_content_type_render in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 plugins/content_types/node_context/node_comment_form.inc \ctools_node_comment_form_content_type_render()

File

plugins/content_types/node_context/node_comment_form.inc, line 19

Code

function ctools_node_comment_form_content_type_render($subtype, $conf, $panel_args, $context) {
  $node = isset($context->data) ? drupal_clone($context->data) : NULL;
  $block = new stdClass();
  $block->module = 'comments';
  $block->delta = $node->nid;
  $block->title = t('Add comment');
  if (empty($node)) {
    $block->content = t('Comment form here.');
  }
  else {
    if (user_access('post comments') && node_comment_mode($node->nid) == COMMENT_NODE_READ_WRITE) {
      ctools_include('form');
      $form_state = array(
        'ctools comment alter' => TRUE,
        'node' => $node,
        'args' => array(
          array(
            'nid' => $node->nid,
          ),
        ),
      );
      $block->content = ctools_build_form('comment_form', $form_state);
    }
    else {
      if (!empty($conf['anon_links'])) {
        $block->content = theme('comment_post_forbidden', $node);
      }
    }
  }
  return $block;
}