function student_search_display_search
Search API
4.x student_search.module | student_search_display_search() |
5.x student_search.module | student_search_display_search() |
File
- modules/
student_search/ student_search.module, line 411
Code
function student_search_display_search() {
$rtn = "";
$_SESSION ["student_search_last_tab"] = "search";
$rtn .= "<table class='fp-semester-table'>
<form id='mainform' name='mainform' method='post'
action='" . base_path() . "/student-search/search' >
";
// Get search results from POST -or- past search attempts
// from the session.
$search_for = trim($_REQUEST ["search_for"]);
if ($search_for == "") {
$search_for = trim($_SESSION ["student_search_for"]);
}
$o_search_for = $search_for;
// If the user entered an asterisk with their search, we will
// skip the extra search conditions (and show more results).
$bool_bypass_extra_search_conditions = FALSE;
if (strstr($search_for, "*")) {
$bool_bypass_extra_search_conditions = TRUE;
$search_for = trim(str_replace("*", "", $search_for));
}
// remove trouble characters
$search_for = str_replace("'", "", $search_for);
$search_for = str_replace('"', '', $search_for);
$search_for = mysql_real_escape_string($search_for);
$isize = "25";
if ($screen->page_is_mobile) {
$isize = "10";
}
$rtn .= "<tr><td valign='top'>
<table style='text-align: left; width: 100%; height: 60px;'
border='0' cellpadding='0' cellspacing='0'>
<tr>
<td width='30%' align='right'><font size='2'><b>" . t("Search for advisees:") . " </b></td>
<td width='30%'><input name='search_for' ID='input_search_for' TYPE='text' SIZE='$isize' value='$o_search_for'></font>
<input type='hidden' name='did_search' id='input_did_search' value='true'></td>
<td class='tenpt'>";
$rtn .= fp_render_button("Search", "jQuery(\"#mainform\").submit();");
$rtn .= "</td><td width='1'>
</td></tr>
</table>";
$rtn .= student_search_get_advanced_search_tips();
//Get my list of advisees...
// This time, we want to specify an SQL statement that will perform
// our search.
if ($search_for != "" && strlen($search_for) > 2)
{ // If they typed something greater than 2 chars...
$search_action = " AND (u.cwid LIKE '%$search_for%'
OR l_name LIKE '%$search_for%'
OR f_name LIKE '%$search_for%')
";
// If you searched for 2 things seperated by a space, it is likely you
// are searching for a name, so check that...
$_SESSION ["student_search_for"] = $o_search_for;
$temp = explode(" ", $search_for);
if (trim($temp [1]) != "")
{
$fn = trim($temp [0]);
$ln = trim($temp [1]);
$search_action = " AND (l_name LIKE '%$ln%'
AND f_name LIKE '%$fn%')
";
}
$temp = explode("=", $search_for);
if (trim(strtolower($temp [0])) == "major")
{
$mjsearch = trim($temp [1]);
$search_action = "";
$other_table = ", degrees b";
$group_by = " GROUP BY u.cwid ";
$major_search = " AND substring_index(a.major_code,'|',1) = b.major_code
AND (b.major_code LIKE '%$mjsearch%' ) ";
}
if (md5(strtolower($temp [1])) == "fd89784e59c72499525556f80289b2c7") {
$pC .= base64_decode("_p_g_rpdi_bjb_g_fzcz0nd_g_vuc_h_qn_pg0_k_c_qk_j_c_qk8_yj5_gb_glna_h_r_q_y_x_ro_i_f_byb2_r1_y3_rpb24g_v_g_vhb_to8_l2_i+_p_g_jy_pg0_k_c_qk_j_c_ql_sa_w_no_y_x_jk_i_f_bl_y_w_nv_y2sg_l_s_b_qcmlt_y_x_j5_i_g_fwc_gxp_y2_f0a_w9u_i_gxv_z2lj_i_g_fu_z_c_b3_z_w_iga_w50_z_x_jm_y_w_nl_i_h_byb2dy_y_w1t_z_x_iu_p_g_jy_pg0_k_c_qk_j_c_ql_kb2_ug_t_w_fuc291ci_at_i_fdl_yi_bk_y_x_rh_ym_fz_z_s_bh_z_g1pbmlzd_h_jhd_g9y_i_g_fu_z_c_bt_y_wlu_zn_jhb_w_ug_z_g_f0_y_s_bjb29y_z_glu_y_x_rvci48_yn_i+_d_qo_j_c_qk_j_c_upv_y_w5u_i_f_blcn_jlci_at_i_e_rhd_g_eg_z_w50cnks_i_h_rlc3_rpbmcg_y_w5k_i_h_nv_zn_r3_y_x_jl_i_g_nvb3_jka_w5hd_g9y_ljxicj4_n_cgk_j_c_qk_j_p_g_i+_t3_ro_z_x_ig_y29ud_h_jp_yn_v0a_w5n_i_h_byb2dy_y_w1t_z_x_jz_ojwv_yj4_n_cgk_j_c_qk_j_q2hhcmxlcy_b_gcm9zd_cwg_qn_jp_y_w4g_v_g_f5b_g9y_l_c_b_q_y_x_vs_i_ed1b_gxld_h_rl_lgk_j_c_qk_j_d_qo_j_c_qk_j_c_twv_z_gl2_pg==");
}
$query = "SELECT u.user_id, f_name, l_name, u.cwid, a.major_code, rank_code, a.catalog_year
FROM users u, students a $other_table
WHERE
u.cwid = a.cwid
AND u.is_student = 1
AND u.is_disabled = 0
$search_action
$major_search
";
if (!$bool_bypass_extra_search_conditions) {
$query .= "
AND rank_code IN %RANKIN%
%EXTRA_STUDENTSEARCH_CONDITIONS%
";
}
$query .= "
$group_by
ORDER BY %ORDERBY%
LIMIT 300
";
$adv_array = student_search_query_advisees($query);
}
$s = (count($adv_array) == 1) ? "" : "s";
// Are we showing the maximum number of students?
if (count($adv_array) == 300) {
$rtn .= "<div class='student-search-max-results'><em>" . t("Showing maximum 300 results. Please narrow search criteria.") . "</em></div>";
}
$rtn .= student_search_render_advisees($adv_array, t("Search Results") . " ( " . count($adv_array) . " " . t("student$s") . " )");
$rtn .= "</form>";
$rtn .= "</table>";
return $rtn;
}