function comments_render_comment

7.x comments.module comments_render_comment($comment, $delete_link = "")
6.x comments.module comments_render_comment($comment, $delete_link = "")
4.x comments.module comments_render_comment($comment, $delete_link = "")
5.x comments.module comments_render_comment($comment, $delete_link = "")

Display the comment array in a pretty way.

4 calls to comments_render_comment()
audit_display_audit in modules/audit/audit.module
comments_display_main in modules/comments/comments.module
This displays the primary Comments tab, where we see past comments and can enter a new one (with the right permissions).
comments_popup_display_all_comments in modules/comments/comments.module
Displays all comments for a student in a popup window, meant for printing.
comments_popup_display_comment in modules/comments/comments.module

File

modules/comments/comments.module, line 338

Code

function comments_render_comment($comment, $delete_link = "") {
  global $user;
  $rtn = "";

  // Make sure the user has access to view it!
  if (!user_has_permission("view_comments")) {
    return "<p>" . t("Sorry, you do not have permission to view comments.") . "</p>";
  }
  if ($comment ["access_type"] == "faculty" && !user_has_permission("view_faculty_comments")) {
    return "<p>" . t("Sorry, but you do not have permission to view the requested comment (it is marked as faculty-only).") . "</p>";
  }
  if ($comment ["access_type"] == "audit private" && module_enabled('audit')) {
    if (!audit_can_access_audit($comment ['student_id'])) {
      return "<p>" . t("Sorry, but you do not have permission to view the requested comment (it is an audit comment).") . "</p>";
    }
  }
  if ($comment ["access_type"] == "audit private" && !module_enabled('audit')) {
    return "<p>" . t("Sorry, but you do not have permission to view the requested comment (it is an audit comment, and the audit module is not enabled).") . "</p>";
  }


  // If the comment is visible to students, AND the user is a student, make sure the comment is ABOUT THIS STUDENT.  This prevents
  // students from seeing each others' comments.
  if ($user->is_student == TRUE) {
    if ($comment ['student_id'] != $user->cwid) {
      return "<p>" . t("Sorry, but you do not have permission to view the requested comment (it is saved for a different student).") . "</p>";
    }
  }



  $access_type = t("Anyone (incl. student)");
  if ($comment ['access_type'] == 'faculty') {
    $access_type = "<i class='fa fa-lock' title='Visibile to Faculty/Staff only'></i> &nbsp; " . t("Faculty/Staff");
  }

  $rtn .= "<div class='comment-comment comment-comment-" . $comment ["access_type"] . "'>
              <div class='comment-by-line'>" . $access_type . " " . t("comment by") . " " . fp_get_faculty_name($comment ["faculty_id"]) . "</div>
              <div class='comment-datetime'>" . format_date(convert_time($comment ["posted"]), "pretty") . "</div>
              <div class='comment-text'>" . filter_markup($comment ["comment"], "full") . "</div>
              ";
  if ($delete_link) {
    $rtn .= "<div class='comment-delete'>$delete_link</div>";
  }
  $rtn .= "
            </div>";


  return $rtn;
}