function _ajax_comments_nodejs_view_updated in AJAX Comments 7
Implements _ajax_comments_nodejs_view_updated().
1 string reference to '_ajax_comments_nodejs_view_updated'
- ajax_comments_nodejs_menu in ajax_comments_nodejs/
ajax_comments_nodejs.module - Implements hook_menu().
File
- ajax_comments_nodejs/
ajax_comments_nodejs.module, line 150 - AJAX Comments Nodejs Integration module file
Code
function _ajax_comments_nodejs_view_updated($cid) {
$commands = array();
if (!empty($cid)) {
$comment = comment_load($cid);
$node = node_load($comment->nid, NULL, TRUE);
if ($comment) {
$can_view_comments = user_access('access comments') && $comment->status == COMMENT_PUBLISHED && node_access('view', $node);
$can_admin_comments = user_access('administer comments') && node_access('view', $node);
if ($can_view_comments || $can_admin_comments) {
$comment->ajax_comments_nodejs_class = 'ajax-comments-nodejs-updated';
$comment_build = comment_view($comment, $node);
$comment_output = drupal_render($comment_build);
//Update existing comment
$commands[] = array(
'command' => 'ajaxCommentsReplace',
'selector' => '.comment-wrapper-' . $comment->cid,
'html' => $comment_output,
);
}
else {
// Unpublish/Hide existing comment
$commands[] = ajax_command_invoke('.comment-wrapper-' . $comment->cid, 'remove');
}
}
}
$output = array(
'#type' => 'ajax',
'#commands' => $commands,
);
return $output;
}