function ajax_comments_js_reload_form in AJAX Comments 6
Delivers a new comments form after comment have been submitted.
1 string reference to 'ajax_comments_js_reload_form'
- ajax_comments_menu in ./
ajax_comments.module - Implementation of hook_menu().
File
- ./
ajax_comments.pages.inc, line 184 - AJAX comments form handling and callbacks.
Code
function ajax_comments_js_reload_form($nid, $id = NULL, $type = NULL) {
if ($type == 'cid') {
$cid = $id;
$comment = db_fetch_object(db_query('SELECT c.*, u.uid, u.name AS registered_name, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d', $cid));
$comment = drupal_unpack($comment);
$comment->name = $comment->uid ? $comment->registered_name : $comment->name;
$edit = (array) $comment;
}
else {
$edit = array(
'nid' => $nid,
);
if (isset($id)) {
$edit['pid'] = $id;
}
}
$response = array(
'status' => TRUE,
'content' => drupal_get_form('comment_form', $edit, $title),
);
drupal_json($response);
}