function comments_get_comments

7.x comments.module comments_get_comments($student_id, $bool_included_deleted = FALSE, $access_types = array())
6.x comments.module comments_get_comments($student_id, $bool_included_deleted = FALSE, $access_types = array())
4.x comments.module comments_get_comments($student_id, $bool_included_deleted = FALSE, $access_types = array())
5.x comments.module comments_get_comments($student_id, $bool_included_deleted = FALSE, $access_types = array())

Returns an array of comments for this student, sorted most recent first.

3 calls to comments_get_comments()
advise_display_history in modules/advise/advise.history.inc
Displays the history tab on screen.
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.

File

modules/comments/comments.module, line 311

Code

function comments_get_comments($student_id, $bool_included_deleted = FALSE, $access_types = array()) {
  $rtn = array();


  $deleted_line = "AND delete_flag = 0";
  if ($bool_included_deleted) {
    $deleted_line = "";
  }

  $access_type_line = "";

  // Build up the "access_type_line" for the query, based on the values
  // in the access_types array.
  if (count($access_types) > 0) {
    $access_type_line = "AND ( ";
    foreach ($access_types as $access_type) {
      $access_type_line .= " access_type = '$access_type' OR";
    }

    // remove the last OR
    $access_type_line = substr($access_type_line, 0, -2);

    $access_type_line .= ")";
  }

  //if ($access_type == "public" || $access_type == "faculty") {
  //  $access_type_line = "AND access_type = '$access_type' ";
  //}

  $res = db_query("SELECT * FROM advising_comments
                   WHERE student_id = '?'
                   $deleted_line
                   $access_type_line
                   ORDER BY posted DESC", $student_id);
  while ($cur = db_fetch_array($res)) {
    $rtn [$cur ["id"]] = $cur;
  }

  return $rtn;
}