You are here

function heartbeat_comments_load_js in Heartbeat 6.4

Same name and namespace in other branches
  1. 7 modules/heartbeat_comments/heartbeat_comments.module \heartbeat_comments_load_js()

Ajax callback to load all the comments.

1 string reference to 'heartbeat_comments_load_js'
heartbeat_comments_menu in modules/heartbeat_comments/heartbeat_comments.module
Implementation of hook_menu().

File

modules/heartbeat_comments/heartbeat_comments.module, line 605
heartbeat_comments.module Heartbeat comments can come with two possible

Code

function heartbeat_comments_load_js() {
  if (!isset($_POST['uaid'])) {
    drupal_json(array(
      'status' => TRUE,
      'data' => 'No message id given',
    ));
  }
  $uaid = $_POST['uaid'];
  $nid = 0;
  $node = NULL;
  if (isset($_POST['nid'])) {
    $nid = $_POST['nid'];
    $node = node_load($nid);
  }
  $node_comment = isset($_POST['node_comment']) ? $_POST['node_comment'] : 0;
  $node_comment = (int) ($node_comment && $nid);
  $reactions = heartbeat_get_reactions($uaid, $node_comment, $node, TRUE);
  $output = theme('heartbeat_comments', $reactions, $uaid, $node_comment, FALSE);
  drupal_json(array(
    'status' => TRUE,
    'data' => $output,
    'uaid' => $uaid,
  ));
}