function ctools_node_comment_form_content_type_render

File

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

Code

function ctools_node_comment_form_content_type_render($subtype, $conf, $panel_args, $context) {
    if (empty($context->data->nid)) {
        return;
    }
    $node = clone $context->data;
    $block = new stdClass();
    $block->module = 'comments';
    $block->delta = $node->nid;
    $block->title = t('Add comment');
    if ($node->comment == COMMENT_NODE_OPEN) {
        if (user_access('post comments')) {
            $comment = new stdClass();
            $comment->nid = $node->nid;
            $comment->pid = NULL;
            $form_state = array(
                'ctools comment alter' => TRUE,
                'node' => $node,
                'build_info' => array(
                    'args' => array(
                        $comment,
                    ),
                ),
            );
            $block->content = drupal_build_form('comment_node_' . $node->type . '_form', $form_state);
        }
        elseif (!empty($conf['anon_links'])) {
            $block->content = theme('comment_post_forbidden', array(
                'node' => $node,
            ));
        }
    }
    return $block;
}