You are here

function heartbeat_get_message_reactions in Heartbeat 6.4

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

Get heartbeat comments on a message

Parameters

$uid user_id of comment to load:

1 call to heartbeat_get_message_reactions()
heartbeat_get_reactions in modules/heartbeat_comments/heartbeat_comments.module
Function to fetch reactions on a heartbeat message.

File

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

Code

function heartbeat_get_message_reactions($uaid, $all = FALSE) {
  static $locale;
  if (!isset($locale)) {
    $locale = module_exists('locale');
  }
  $reactions = array();

  // When locale is enabled, we need to look up the translation id,
  // the only problem here is that locale could have been enabled.
  // This comments will never be fetched since locale will target
  // a translation that is not there, consequently.
  // That is hard coded taken care of while saving the comment.
  if ($locale) {
    $query = "SELECT s.hcid, s.uid, s.message AS 'comment', s.cleared, s.time, u.uid,\n      u.name, u.signature, u.signature_format, u.picture, u.data, ht.tuaid\n      FROM {heartbeat_comments} s INNER JOIN {users} u ON s.uid = u.uid\n      INNER JOIN {heartbeat_activity} ha ON ha.uaid = s.uaid\n      INNER JOIN {heartbeat_translations} ht ON ht.tuaid = s.uaid\n      WHERE ht.uaid = %d ORDER BY time DESC";
  }
  else {
    $query = "SELECT s.hcid, s.uid, s.message AS 'comment', s.cleared, s.time,\n      u.uid, u.name, u.signature, u.signature_format, u.picture, u.data\n      FROM {heartbeat_comments} s INNER JOIN {users} u ON s.uid = u.uid\n      WHERE uaid = %d ORDER BY time DESC";
  }
  if ($all) {
    $result = db_query($query, $uaid);
  }
  else {
    $result = db_query_range($query, $uaid, 0, HEARTBEAT_REACTIONS_PER_PAGE);
  }
  while ($comment = db_fetch_object($result)) {

    // Sanitize the comment messages.
    $comment->comment = filter_xss($comment->comment);
    $reactions[] = $comment;
  }
  return $reactions;
}