function heartbeat_comments_load_js in Heartbeat 7
Same name and namespace in other branches
- 6.4 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 - Implements hook_menu().
File
- modules/
heartbeat_comments/ heartbeat_comments.module, line 554 - Heartbeat comments for activity.
Code
function heartbeat_comments_load_js() {
if (!isset($_POST['uaid'])) {
drupal_json_output(array(
'status' => TRUE,
'data' => 'No message id given',
));
}
$uaid = $_POST['uaid'];
$nid = 0;
$node = NULL;
$node_comment = 0;
if (!empty($_POST['nid']) && is_numeric($_POST['nid'])) {
$nid = $_POST['nid'];
$node = node_load($nid);
$node_comment = 1;
}
$reactions = heartbeat_get_reactions($uaid, $node_comment, $node, TRUE);
$heartbeatActivity = HeartbeatMessagePool::getInstance()
->getMessage($uaid);
$heartbeatActivity->additions->node_comment = $node_comment;
$heartbeatActivity->additions->has_more = FALSE;
foreach ($reactions as $key => $reaction) {
$reactions[$key]->uaid = $uaid;
}
$output = theme('heartbeat_comments', array(
'comments' => $reactions,
'activity' => $heartbeatActivity,
));
drupal_json_output(array(
'status' => TRUE,
'data' => $output,
'uaid' => $uaid,
));
}