function student_search_query_advisees
Search API
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, |
4.x student_search.module | student_search_query_advisees($sql) |
5.x student_search.module | student_search_query_advisees($sql, $params = array()) |
Accepts the SQL, plus an array of parameters compatible with our PDO set up. ex: $params[":name"] = "Bob" and $sql = " SELECT * where name = :name";
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 883
Code
function student_search_query_advisees($sql, $params = array()) {
$db = get_global_database_handler();
$rank_in = "( '" . join("', '", csv_to_array($GLOBALS ["fp_system_settings"]["allowed_student_ranks"])) . "' )";
$order_by = " 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);
// Returns an array of all of this teacher's advisees.
$rtn_array = array();
$r = 0;
$faculty_advisees = advise_get_advisees();
$result = db_query($sql, $params);
while ($cur = db_fetch_array($result))
{
$student_id = trim($cur ["cwid"]);
// If this user does NOT have the "view any advising session" and DOES have the "view advisee advising sessions only",
// then see if this student is in their advisees list before continuing.
if (!user_has_permission("view_any_advising_session") && user_has_permission("view_advisee_advising_session")) {
if (!in_array($student_id, $faculty_advisees)) {
// Nope, this student is NOT one of their advisees! Skip it.
continue;
}
}
$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"];
// Need to get the major_code_csv for this student.
// Are there more majors for this user?
$major = "";
// Get a CSV of this student's majors
$major = fp_get_student_majors($student_id, TRUE, FALSE, FALSE);
$rtn_array [$r]["major"] = $major;
// 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
AND is_empty = 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_code_csv = $cur ["major_code_csv"];
$rtn_array [$r]["what_if_major_code"] = $db_major_code_csv;
// Capture the catalog year that was saved with what_if
$rtn_array [$r]["what_if_catalog_year"] = $cur ["catalog_year"];
$rtn_array [$r]["last_advised_what_if"] = TRUE;
}
}
$rtn_array [$r]["advising_session_id"] = $advising_session_id;
$rtn_array [$r]["advised_image"] = $advised_image;
$r++;
}
return $rtn_array;
}