You are here

function phptemplate_heartbeat_comment in Heartbeat 6.4

OVERRIDE of theme function for heartbeat comment

Parameters

$comment Object comment with user in it:

$type Boolean to indicate whether it is a node comment or not:

Return value

String Themed output for a comment

File

modules/heartbeat_example/heartbeat_example.module, line 237

Code

function phptemplate_heartbeat_comment($comment, $node_comment = FALSE, $last = FALSE) {
  $output = '';
  if ($last == TRUE) {
    $class = "heartbeat-comment-last";
  }
  else {
    $class = "";
  }
  $output .= '<li class="heartbeat-comment" id="heartbeat-comment-' . ($node_comment ? $comment->cid : $comment->hcid) . '">';
  if ($comment->uid) {
    $account = heartbeat_user_load($comment->uid);
    $name = $account->name;
    $avatar = l(theme('imagecache', 'icon', $account->picture), 'user/' . $account->uid, array(
      'html' => TRUE,
    ));
  }
  else {
    $name = t('Anonymous');
    $avatar = '<span class="user-default"></span>';
  }
  $output .= '<span class="avatar">' . $avatar . '</span>';
  $comment->comment = filter_xss($comment->comment);
  $output .= '<div class="heartbeat-teaser">';
  $output .= l($name, 'user/' . $comment->uid, array(
    'attributes' => array(
      'class' => 'user',
    ),
  ));
  $output .= $comment->comment . '<br />';
  $output .= _theme_time_ago(isset($comment->time) ? strtotime($comment->time) : $comment->timestamp);
  $output .= '</div>';

  // For node comments link to the standard Drupal comment deletion form under comment/delete/%
  // Only users who have the right permissions should see the delete link.
  // Permissions are provided by the "Comment Delete" module.
  global $user;
  if ($node_comment) {
    if (user_access('delete any comment') || $user->uid == $comment->uid && user_access('delete own comments')) {
      $output .= l(t('Delete'), 'heartbeat/nodecomment/delete/' . $comment->cid, array(
        'attributes' => array(
          'class' => 'heartbeat-comment-delete',
        ),
        'query' => drupal_get_destination(),
        'alias' => TRUE,
      ));
    }
  }
  elseif (user_access('administer heartbeat comments') || $comment->uid && $user->uid && $comment->uid == $user->uid) {
    $output .= l(t('Delete'), 'heartbeat/comment/delete/' . $comment->hcid, array(
      'attributes' => array(
        'class' => 'heartbeat-comment-delete',
      ),
      'query' => drupal_get_destination(),
      'alias' => TRUE,
    ));
  }
  $output .= '</li>';
  return $output;
}