function student_search_query_advisees

7.x student_search.module student_search_query_advisees($sql, $params = array(), $limit = 20, $bool_only_return_adv_array = FALSE)
6.x student_search.module student_search_query_advisees($sql, $params = array(), $limit = 20, $bool_only_return_adv_array = FALSE)
4.x student_search.module student_search_query_advisees($sql)
5.x student_search.module student_search_query_advisees($sql, $params = array())
4 calls to student_search_query_advisees()
student_search_display_majors_search in modules/student_search/student_search.module
Display the majors search sub-tab, where we can select a major and see the students assigned to it.
student_search_display_my_advisees in modules/student_search/student_search.module
Displays this user's advisees, if there are any assigned.
student_search_display_my_majors in modules/student_search/student_search.module
Displays students belonging to the current user's major code.
student_search_display_search in modules/student_search/student_search.module

File

modules/student_search/student_search.module, line 735

Code

function student_search_query_advisees($sql) {

  $rank_in = "( '" . join("', '", csv_to_array($GLOBALS ["fp_system_settings"]["allowed_student_ranks"])) . "' )";

  $order_by = " major_code, l_name, f_name ";

  // Replace the replacement portion with our derrived variables.
  $sql = str_replace("%RANKIN%", $rank_in, $sql);
  $sql = str_replace("%ORDERBY%", $order_by, $sql);

  // By default, the extra_studentsearch_conditions will be checking of is_active = 1.  But, the user may override this
  // in the settings.
  $extra_student_search_conditions = variable_get("extra_student_search_conditions", " AND is_active = 1 ");

  $sql = str_replace("%EXTRA_STUDENTSEARCH_CONDITIONS%", $extra_student_search_conditions, $sql);

  //fpm($sql);
  // Returns an array of all of this teacher's advisees.
  $rtn_array = array();
  $r = 0;

  $result = db_query($sql);
  while ($cur = db_fetch_array($result)) 
   {

    $student_id = trim($cur ["cwid"]);
    $rtn_array [$r]["student_id"] = $student_id;
    $rtn_array [$r]["first_name"] = ucwords(strtolower($cur ["f_name"]));
    $rtn_array [$r]["last_name"] = ucwords(strtolower($cur ["l_name"]));
    $rtn_array [$r]["rank"] = $cur ["rank_code"];
    $rtn_array [$r]["catalog_year"] = $cur ["catalog_year"];
    $rtn_array [$r]["major"] = $cur ["major_code"];


    // We should also mark if the student has been advised for this semester
    // or not.

    // Get the current default advising term id.
    $term_id = variable_get("advising_term_id", "");


    $advised_image = " ";
    $advising_session_id = "";
    $res2 = db_query("SELECT * FROM advising_sessions WHERE
                      student_id = '?' AND
                      term_id = '?' 
               AND is_draft = '0' 
              ORDER BY posted DESC", $student_id, $term_id);
    if (db_num_rows($res2) > 0) {
      $cur = db_fetch_array($res2);

      $advised_image = "<img src='" . fp_theme_location() . "/images/small_check.gif' class='advisedImage'>";

      if ($cur ["is_whatif"] == "1") 
       { // Last advising was a What If advising.
        $advised_image = "<span title='This student was last advised in What If mode.'><img src='" . fp_theme_location() . "/images/small_check.gif'><sup>wi</sup></span>";
        $db_major = $cur ["major_code"];
        $temp = explode("\|_", $db_major);
        $rtn_array [$r]["what_if_major_code"] = trim($temp [0]);
        $rtn_array [$r]["what_if_track_code"] = trim($temp [1]);
      }
    }


    $rtn_array [$r]["advising_session_id"] = $advising_session_id;
    $rtn_array [$r]["advised_image"] = $advised_image;

    $r++;
  }


  return $rtn_array;
}