function student_search_display_my_majors

7.x student_search.module student_search_display_my_majors()
6.x student_search.module student_search_display_my_majors()
4.x student_search.module student_search_display_my_majors()
5.x student_search.module student_search_display_my_majors()

Displays students belonging to the current user's major code.

File

modules/student_search/student_search.module, line 642

Code

function student_search_display_my_majors() {
  global $user;
  $rtn = "";




  $_SESSION ["student_search_last_tab"] = "my-majors";

  $adv_array = array();

  // Figure out this user's major_code from the faculty table.
  $db = get_global_database_handler();
  $faculty_user_major_code_csv = $db->get_faculty_major_code_csv($user->cwid);

  $temp = explode(",", $faculty_user_major_code_csv);
  foreach ($temp as $major_code) {
    $major_code = trim($major_code);
    if ($major_code == "") {
      continue;
    }

    $query = "SELECT u.user_id, f_name, l_name, u.cwid, major_code, rank_code, a.catalog_year
                FROM users u, students a, student_degrees b
                WHERE 
                   substring_index(major_code, '|', 1) = :major_code
                   AND u.cwid = a.cwid
                   AND u.cwid = b.student_id
                   AND u.is_student = 1
                   AND u.is_disabled = 0                 
                AND rank_code IN %RANKIN%
                %EXTRA_STUDENTSEARCH_CONDITIONS%
                GROUP BY u.cwid
                %ORDERBY%
                ";

    $adv_array = student_search_query_advisees($query, array(":major_code" => $major_code));

    $s = (count($adv_array) == 1) ? "" : "s";
    $rtn .= student_search_render_advisees($adv_array, t("Major @major Results", array("@major" => $major_code)) . "   ( " . count($adv_array) . " " . t("student$s") . " )");

  }



  return $rtn;
}