You are here

function theme_heartbeat_comment in Heartbeat 6.4

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

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:

$last Boolean to indicate if an extra class has to be used:

Return value

String Themed output for a comment

3 theme calls to theme_heartbeat_comment()
heartbeat_comments_form_submit in modules/heartbeat_comments/heartbeat_comments.module
User submitted a heartbeat comment.
phptemplate_heartbeat_comments in modules/heartbeat_example/heartbeat_example.module
Theme function for heartbeat comments
theme_heartbeat_comments in modules/heartbeat_comments/heartbeat_comments.module
Theme function for heartbeat comments

File

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

Code

function theme_heartbeat_comment($comment, $node_comment = FALSE, $last = FALSE) {
  $output = '';
  if ($last == TRUE) {
    $class = "heartbeat-comment-last";
  }
  else {
    $class = "";
  }
  $output .= '<li class="heartbeat-comment ' . $class . '" id="heartbeat-comment-' . ($node_comment ? $comment->cid : $comment->hcid) . '">';
  $avatar = theme('user_picture', $comment);
  $output .= '<span class="avatar">' . l($avatar, 'user/' . $comment->uid, array(
    'html' => TRUE,
  )) . '</span>';
  $account = heartbeat_user_load($comment->uid);
  $output .= '<div class="heartbeat-teaser">';
  $output .= l($account->name, 'user/' . $comment->uid) . ' ';
  $output .= $comment->comment;
  $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;
  $redirect_path = isset($_POST['path']) ? 'destination=' . $_POST['path'] : drupal_get_destination();
  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' => $redirect_path,
        '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' => $redirect_path,
      'alias' => TRUE,
    ));
  }
  $output .= '</li>';
  return $output;
}