function comments_display_main

7.x comments.module comments_display_main()
6.x comments.module comments_display_main()
4.x comments.module comments_display_main()
5.x comments.module comments_display_main()

This displays the primary Comments tab, where we see past comments and can enter a new one (with the right permissions).

File

modules/comments/comments.module, line 210

Code

function comments_display_main() {
  global $current_student_id;
  $rtn = "";

  fp_add_js(fp_get_module_path("comments") . "/js/comments.js");
  fp_add_css(fp_get_module_path("comments") . "/css/comments.css");

  if (user_has_permission("can_save_comments")) {

    $form = fp_render_form("comments_comment_form");

    $rtn .= fp_render_c_fieldset($form, t("Click to enter comment"), true);
  }

  $access_types = (user_has_permission("view_faculty_comments")) ? array("faculty", "public") : array("public");

  $comments = comments_get_comments($current_student_id, FALSE, $access_types);
  //fpm($comments);
  foreach ($comments as $comment) {

    $delete_link = "";
    // Should we present a "delete link" to the user for this comment?
    if (user_has_permission("can_delete_own_comments_3_months")) {
      // See if this comment is younger than 3 months.
      $del_range = strtotime("-3 month");
      $then = $comment ["posted"];


      if ($then > $del_range) {
        $delete_link = fp_render_button("Delete", "deleteComment(\"{$comment ["id"]}\");");
      }
    }


    $rtn .= comments_render_comment($comment, $delete_link);
  }


  return $rtn;
}