function better_comments_reply in Better Comments 7.2
Same name and namespace in other branches
- 7 better_comments.module \better_comments_reply()
Reply the comment.
1 string reference to 'better_comments_reply'
- better_comments_menu in ./
better_comments.module - Implements hook_menu().
File
- ./
better_comments.module, line 221 - Better Comments provides option to configure the comment system.
Code
function better_comments_reply($pid) {
// If there is a pid this is a reply to a comment.
if ($pid) {
// Make sure the parent comment is valid and published.
if (!($comments = comment_load_multiple(array(
$pid,
), array(
'status' => COMMENT_PUBLISHED,
)))) {
return MENU_NOT_FOUND;
}
$comment = $comments[$pid];
$node = node_load($comment->nid);
// Make sure the comment belongs to this node.
if ($comment->nid != $node->nid) {
return MENU_NOT_FOUND;
}
}
// Build form.
$form_build = drupal_get_form("comment_node_{$node->type}_form", (object) array(
'nid' => $node->nid,
'pid' => $pid,
));
// Offer 'cancel' link for reply. This will just remove the reply form so
// there is no callback.
$form_build['actions']['cancel'] = array(
'#markup' => l(t('Cancel'), 'better_comments/reply/' . $pid . '/cancel', array(
'attributes' => array(
'class' => array(
'use-ajax',
'button',
'reply-cancel',
),
'id' => array(
'cancel-' . $pid,
),
),
)),
'#weight' => 21,
);
$form['#validate'][] = 'better_comments_validate';
$form = drupal_render($form_build);
$form = '<div class="indented-' . $pid . '">' . $form . '</div>';
$commands[] = ajax_command_append('#comment-wrap-' . $pid, $form);
return array(
'#type' => 'ajax',
'#commands' => $commands,
);
}