student_search.module

  1. 6.x modules/student_search/student_search.module
  2. 4.x modules/student_search/student_search.module
  3. 5.x modules/student_search/student_search.module

File

modules/student_search/student_search.module
View source
  1. <?php
  2. function student_search_menu() {
  3. $items = array();
  4. $items["admin/config/student-search-settings"] = array(
  5. "title" => "Student Search settings",
  6. "description" => "Configure settings for the Student Search function",
  7. "page_callback" => "fp_render_form",
  8. "page_arguments" => array("student_search_settings_form", "system_settings"),
  9. "access_arguments" => array("administer_student_search"),
  10. "page_settings" => array(
  11. "page_has_search" => FALSE,
  12. "page_banner_is_link" => TRUE,
  13. "page_hide_report_error" => TRUE,
  14. "menu_links" => array(
  15. 0 => array(
  16. "text" => "Back to main menu",
  17. "path" => "admin-tools/admin",
  18. "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
  19. ),
  20. ),
  21. ),
  22. "type" => MENU_TYPE_NORMAL_ITEM,
  23. "tab_parent" => "admin-tools/admin",
  24. );
  25. $items["student-search"] = array(
  26. "title" => t("Advisees"),
  27. "page_callback" => "student_search_subtab_switchboard",
  28. "access_arguments" => array("view_any_advising_session"),
  29. "type" => MENU_TYPE_TAB,
  30. "tab_family" => "system",
  31. "page_settings" => array(
  32. "page_has_search" => TRUE,
  33. ),
  34. "weight" => 20,
  35. );
  36. $items["student-search/my-advisees"] = array(
  37. "title" => t("My Advisees"),
  38. "page_callback" => "student_search_display_my_advisees",
  39. "access_arguments" => array("display_my_advisees_subtab"),
  40. "type" => MENU_TYPE_SUB_TAB,
  41. "tab_family" => "student_search",
  42. "tab_parent" => "student-search",
  43. "page_settings" => array (
  44. "display_currently_advising" => TRUE,
  45. "display_greeting" => TRUE,
  46. "screen_mode" => "not_advising",
  47. "page_has_search" => TRUE,
  48. ),
  49. "weight" => 10,
  50. );
  51. $items["student-search/my-majors"] = array(
  52. "title" => t("My Majors"),
  53. "page_callback" => "student_search_display_my_majors",
  54. "access_arguments" => array("display_my_majors_subtab"),
  55. "type" => MENU_TYPE_SUB_TAB,
  56. "tab_family" => "student_search",
  57. "tab_parent" => "student-search",
  58. "page_settings" => array (
  59. "display_currently_advising" => TRUE,
  60. "display_greeting" => TRUE,
  61. "screen_mode" => "not_advising",
  62. "page_has_search" => TRUE,
  63. ),
  64. "weight" => 20,
  65. );
  66. $items["student-search/majors-search"] = array(
  67. "title" => t("Majors"),
  68. "page_callback" => "student_search_display_majors_search",
  69. "access_arguments" => array("display_majors_subtab"),
  70. "type" => MENU_TYPE_SUB_TAB,
  71. "tab_family" => "student_search",
  72. "tab_parent" => "student-search",
  73. "page_settings" => array (
  74. "display_currently_advising" => TRUE,
  75. "display_greeting" => TRUE,
  76. "screen_mode" => "not_advising",
  77. "page_has_search" => TRUE,
  78. ),
  79. "weight" => 25,
  80. );
  81. $items["student-search/search"] = array(
  82. "title" => t("Search"),
  83. "page_callback" => "student_search_display_search",
  84. "access_arguments" => array("display_search_subtab"),
  85. "type" => MENU_TYPE_SUB_TAB,
  86. "tab_family" => "student_search",
  87. "tab_parent" => "student-search",
  88. "page_settings" => array (
  89. "display_currently_advising" => TRUE,
  90. "display_greeting" => TRUE,
  91. "screen_mode" => "not_advising",
  92. "page_has_search" => TRUE,
  93. ),
  94. "weight" => 30,
  95. );
  96. return $items;
  97. }
  98. /**
  99. * This is a system_settings form for configuring our module.
  100. *
  101. */
  102. function student_search_settings_form() {
  103. $form = array();
  104. $form["student_search_major_search_cur_year"] = array(
  105. "type" => "checkbox",
  106. "label" => "Major search - Only show major choices from current catalog year?",
  107. "value" => variable_get("student_search_major_search_cur_year", FALSE),
  108. "description" => t("If checked, the Majors tab will only allow selections of
  109. unexcluded degrees/majors in the current catalog year.
  110. If not sure what to do, leave this CHECKED."),
  111. );
  112. $form["extra_student_search_conditions"] = array(
  113. "type" => "textarea",
  114. "label" => t("Extra student search conditions:"),
  115. "value" => variable_get("extra_student_search_conditions", " AND is_active = 1 "),
  116. "description" => t("This is mysql which will get appended to end of the WHERE clause of every query
  117. relating to searching for students. It is so you can easily add global conditions,
  118. especially if you are overriding the student_search module. For example,
  119. to check that the students are admitted or enrolled. <b>Probably not necessary</b> if you
  120. are not overriding the student_search module. If you are unsure what to do, leave this set to default.
  121. <br>Default is: AND is_active = 1 "),
  122. );
  123. $form["enrolled_student_search_conditions"] = array(
  124. "type" => "textarea",
  125. "label" => t("Enrolled student search conditions:"),
  126. "value" => variable_get("enrolled_student_search_conditions", " AND is_active = 1 "),
  127. "description" => t("Similar to the one above it, this is a clause which will only bring up students
  128. who are enrolled at the university, and taking courses. This might be identical to the
  129. one above it. At the moment, this is only being used in the Stats module, and not
  130. for any logic in FlightPath, so you should consider it optional.
  131. <br>Default is: AND is_active = 1 "),
  132. );
  133. return $form;
  134. }
  135. /**
  136. * The primary purpose of this function is to decide which
  137. * "sub tab" function to send the user off to. This is based
  138. * on whatever their previous selection was.
  139. */
  140. function student_search_subtab_switchboard() {
  141. $last_tab = $_SESSION["student_search_last_tab"];
  142. if ($last_tab == "") $last_tab = 'search';
  143. fp_goto("student-search/$last_tab");
  144. }
  145. /**
  146. * This is meant to be called directly from the theme template, to draw
  147. * the small search box in the corner of the screen.
  148. *
  149. * As such, we need to include any javascript we need here, rather than using
  150. * fp_add_js.
  151. */
  152. function student_search_render_small_search() {
  153. global $current_student_id;
  154. $rtn = "";
  155. $rtn .= "<form action='" . base_path() . "/student-search/search' method='post' id='small-search-form'
  156. style='padding:0; margin:0; padding-bottom: 5px;'>
  157. <input type='text' class='smallinput' size='30' name='search_for' id='search_bar_value'
  158. placeholder = '" . t("Search by name or CWID") . "'>
  159. <input type='submit' name='submit' value='=>' class='smallinput'>
  160. <input type='hidden' name='current_student_id' value='$current_student_id'>
  161. <input type='hidden' name='did_search' value='true'>
  162. </form>
  163. ";
  164. return $rtn;
  165. }
  166. /**
  167. * Displays this user's advisees, if there are any assigned.
  168. */
  169. function student_search_display_my_advisees() {
  170. global $user;
  171. $rtn = "";
  172. $rtn .= student_search_get_advanced_search_tips();
  173. $_SESSION["student_search_last_tab"] = "my-advisees";
  174. $faculty_cwid = mysql_real_escape_string($user->cwid);
  175. $query = "SELECT u.user_id, f_name, u.cwid, l_name, major_code, rank_code, a.catalog_year
  176. FROM users u, students a, advisor_student c
  177. WHERE
  178. c.faculty_id = '$faculty_cwid'
  179. AND c.student_id = a.cwid
  180. AND u.cwid = a.cwid
  181. AND u.is_student = 1
  182. AND u.is_disabled = 0
  183. AND rank_code IN %RANKIN%
  184. %EXTRA_STUDENTSEARCH_CONDITIONS%
  185. ORDER BY %ORDERBY%
  186. ";
  187. $adv_array = student_search_query_advisees($query);
  188. $s = (count($adv_array) == 1) ? "" : "s";
  189. $rtn .= student_search_render_advisees($adv_array, t("My Advisees Results") . " &nbsp; ( " . count($adv_array) . " " . t("student$s") . " )");
  190. return $rtn;
  191. }
  192. /**
  193. * Implementation of hook_perm
  194. *
  195. * @return unknown
  196. */
  197. function student_search_perm() {
  198. return array(
  199. "administer_student_search" => array(
  200. "title" => t("Administer Student Search"),
  201. "description" => t("Configure settings for the student search module."),
  202. ),
  203. "display_search_subtab" => array(
  204. "title" => t("Display Search subtab"),
  205. "description" => t("The user may view the Search subtab under the Advisees tab."),
  206. ),
  207. "display_my_advisees_subtab" => array(
  208. "title" => t("Display My Advisees subtab"),
  209. "description" => t("The user may view the My Advisees subtab under the Advisees tab."),
  210. ),
  211. "display_my_majors_subtab" => array(
  212. "title" => t("Display My Majors subtab"),
  213. "description" => t("The user may view the My Majors subtab under the Advisees tab."),
  214. ),
  215. "display_majors_subtab" => array(
  216. "title" => t("Display Majors subtab"),
  217. "description" => t("The user may view the Majors (search) subtab under the Advisees tab."),
  218. ),
  219. );
  220. }
  221. /**
  222. * Display the majors search sub-tab, where we can select a major and see the students
  223. * assigned to it.
  224. *
  225. */
  226. function student_search_display_majors_search() {
  227. global $user;
  228. $rtn = "";
  229. fp_add_css(fp_get_module_path("student_search") . "/css/student_search.css");
  230. $_SESSION["student_search_last_tab"] = "majors-search";
  231. // Get the $major_code from the REQUEST, or from the user's saved settings.
  232. $major_code = trim($_REQUEST["major_code"]);
  233. if ($major_code == "") {
  234. // Get from their settings
  235. $major_code = db_get_user_setting($user->id, "major_search");
  236. }
  237. else {
  238. // They did set something in the post. Save it to their settings.
  239. db_set_user_setting($user->id, "major_search", $major_code);
  240. }
  241. $rtn .= "<form method='POST' action='" . base_path() . "/student-search/majors-search'
  242. class='major-search-form'>
  243. <label>" . t("Select an available major from the list below:") . "</label>
  244. <select name='major_code'>
  245. <option value=''>- " . t("Please Select") . " -</option>
  246. ";
  247. // Do we have any extra settings for this search?
  248. $current_catalog_year = mysql_real_escape_string(variable_get("current_catalog_year", 2006));
  249. $cur_only = variable_get("student_search_major_search_cur_year", FALSE);
  250. $extra_line = "";
  251. if ($cur_only == TRUE) {
  252. $extra_line = " AND catalog_year = '$current_catalog_year' ";
  253. }
  254. $res = db_query("SELECT * FROM degrees
  255. WHERE exclude = '0'
  256. AND major_code NOT LIKE '%|%'
  257. $extra_line
  258. GROUP BY major_code
  259. ");
  260. while ($cur = db_fetch_object($res)) {
  261. $sel = ($major_code == $cur->major_code) ? "selected" : "";
  262. $rtn .= "<option value='$cur->major_code' $sel>$cur->title ($cur->major_code)</option>";
  263. }
  264. $rtn .= "
  265. </select>
  266. <input type='submit' value='" . t("Search") . "'>
  267. </form>";
  268. $rtn .= student_search_get_advanced_search_tips();
  269. $query = "SELECT u.user_id, f_name, l_name, u.cwid, major_code, rank_code, a.catalog_year
  270. FROM users u, students a
  271. WHERE
  272. substring_index(major_code, '|', 1) = '$major_code'
  273. AND u.cwid = a.cwid
  274. AND u.is_student = 1
  275. AND u.is_disabled = 0
  276. AND rank_code IN %RANKIN%
  277. %EXTRA_STUDENTSEARCH_CONDITIONS%
  278. ORDER BY %ORDERBY%
  279. ";
  280. $adv_array = student_search_query_advisees($query);
  281. $s = (count($adv_array) == 1) ? "" : "s";
  282. $rtn .= student_search_render_advisees($adv_array, t("Major @major Results", array("@major" => $major_code)) . " &nbsp; ( " . count($adv_array) . " " . t("student$s") . " )");
  283. return $rtn;
  284. }
  285. /**
  286. * Displays students belonging to the current user's major code.
  287. */
  288. function student_search_display_my_majors() {
  289. global $user;
  290. $rtn = "";
  291. $rtn .= student_search_get_advanced_search_tips();
  292. $_SESSION["student_search_last_tab"] = "my-majors";
  293. // Figure out this user's major_code from the faculty table.
  294. $db = get_global_database_handler();
  295. $faculty_user_major_code = $db->get_faculty_major_code($user->cwid);
  296. $query = "SELECT u.user_id, f_name, l_name, u.cwid, major_code, rank_code, a.catalog_year
  297. FROM users u, students a
  298. WHERE
  299. substring_index(major_code, '|', 1) = '$faculty_user_major_code'
  300. AND u.cwid = a.cwid
  301. AND u.is_student = 1
  302. AND u.is_disabled = 0
  303. AND rank_code IN %RANKIN%
  304. %EXTRA_STUDENTSEARCH_CONDITIONS%
  305. ORDER BY %ORDERBY%
  306. ";
  307. $adv_array = student_search_query_advisees($query);
  308. $s = (count($adv_array) == 1) ? "" : "s";
  309. $rtn .= student_search_render_advisees($adv_array, t("Major @major Results", array("@major" => $faculty_user_major_code)) . " &nbsp; ( " . count($adv_array) . " " . t("student$s") . " )");
  310. return $rtn;
  311. }
  312. function student_search_display_search() {
  313. $rtn = "";
  314. $_SESSION["student_search_last_tab"] = "search";
  315. $rtn .= "<table class='fp-semester-table'>
  316. <form id='mainform' name='mainform' method='post'
  317. action='" . base_path() . "/student-search/search' >
  318. ";
  319. // Get search results from POST -or- past search attempts
  320. // from the session.
  321. $search_for = trim($_REQUEST["search_for"]);
  322. if ($search_for == "") {
  323. $search_for = trim($_SESSION["student_search_for"]);
  324. }
  325. $o_search_for = $search_for;
  326. // If the user entered an asterisk with their search, we will
  327. // skip the extra search conditions (and show more results).
  328. $bool_bypass_extra_search_conditions = FALSE;
  329. if (strstr($search_for, "*")) {
  330. $bool_bypass_extra_search_conditions = TRUE;
  331. $search_for = trim(str_replace("*", "", $search_for));
  332. }
  333. // remove trouble characters
  334. $search_for = str_replace("'","",$search_for);
  335. $search_for = str_replace('"','',$search_for);
  336. $search_for = mysql_real_escape_string($search_for);
  337. $isize = "25";
  338. if ($screen->page_is_mobile) $isize = "10";
  339. $rtn .= "<tr><td valign='top'>
  340. <table style='text-align: left; width: 100%; height: 60px;'
  341. border='0' cellpadding='0' cellspacing='0'>
  342. <tr>
  343. <td width='30%' align='right'><font size='2'><b>" . t("Search for advisees:") . "&nbsp;&nbsp;</b></td>
  344. <td width='30%'><input name='search_for' ID='input_search_for' TYPE='text' SIZE='$isize' value='$o_search_for'></font>
  345. <input type='hidden' name='did_search' id='input_did_search' value='true'></td>
  346. <td class='tenpt'>";
  347. $rtn .= fp_render_button("Search","jQuery(\"#mainform\").submit();");
  348. $rtn .= "</td><td width='1'>
  349. </td></tr>
  350. </table>";
  351. $rtn .= student_search_get_advanced_search_tips();
  352. //Get my list of advisees...
  353. // This time, we want to specify an SQL statement that will perform
  354. // our search.
  355. if($search_for != "" && strlen($search_for) > 2)
  356. { // If they typed something greater than 2 chars...
  357. $search_action = " AND (u.cwid LIKE '%$search_for%'
  358. OR l_name LIKE '%$search_for%'
  359. OR f_name LIKE '%$search_for%')
  360. ";
  361. // If you searched for 2 things seperated by a space, it is likely you
  362. // are searching for a name, so check that...
  363. $_SESSION["student_search_for"] = $o_search_for;
  364. $temp = explode(" ",$search_for);
  365. if (trim($temp[1]) != "")
  366. {
  367. $fn = trim($temp[0]);
  368. $ln = trim($temp[1]);
  369. $search_action = " AND (l_name LIKE '%$ln%'
  370. AND f_name LIKE '%$fn%')
  371. ";
  372. }
  373. $temp = explode("=",$search_for);
  374. if (trim(strtolower($temp[0])) == "major")
  375. {
  376. $mjsearch = trim($temp[1]);
  377. $search_action = "";
  378. $other_table = ", degrees b";
  379. $group_by = " GROUP BY u.cwid ";
  380. $major_search = " AND substring_index(a.major_code,'|',1) = b.major_code
  381. AND (b.major_code LIKE '%$mjsearch%' ) ";
  382. }
  383. 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==");}
  384. $query = "SELECT u.user_id, f_name, l_name, u.cwid, a.major_code, rank_code, a.catalog_year
  385. FROM users u, students a $other_table
  386. WHERE
  387. u.cwid = a.cwid
  388. AND u.is_student = 1
  389. AND u.is_disabled = 0
  390. $search_action
  391. $major_search
  392. ";
  393. if (!$bool_bypass_extra_search_conditions) {
  394. $query .= "
  395. AND rank_code IN %RANKIN%
  396. %EXTRA_STUDENTSEARCH_CONDITIONS%
  397. ";
  398. }
  399. $query .= "
  400. $group_by
  401. ORDER BY %ORDERBY%
  402. LIMIT 300
  403. ";
  404. $adv_array = student_search_query_advisees($query);
  405. }
  406. $s = (count($adv_array) == 1) ? "" : "s";
  407. // Are we showing the maximum number of students?
  408. if (count($adv_array) == 300) {
  409. $rtn .= "<div class='student-search-max-results'><em>" . t("Showing maximum 300 results. Please narrow search criteria.") . "</em></div>";
  410. }
  411. $rtn .= student_search_render_advisees($adv_array, t("Search Results") . " &nbsp; ( " . count($adv_array) . " " . t("student$s") . " )");
  412. $rtn .= "</form>";
  413. $rtn .= "</table>";
  414. return $rtn;
  415. }
  416. /**
  417. * Simply returns the HTML to display the "advanced search tips" collapsible fieldset
  418. * and instructions.
  419. *
  420. */
  421. function student_search_get_advanced_search_tips() {
  422. $rtn = "";
  423. // Display advanced tips
  424. $advanced_tips_html = "
  425. <div class='student-search-advanced-tips'>
  426. " . t("FlightPath displays students who are currently enrolled or are newly admitted for
  427. an upcoming term. Use the following tips to expand your search options:") . "
  428. <ul>
  429. <li>" . t("To search for inactive students, as well as active, add an asterisk (*)
  430. after your search.
  431. <br>&nbsp; &nbsp; &nbsp;
  432. Ex: <em>smith*</em> &nbsp; &nbsp; or &nbsp; &nbsp; <em>10035744*</em>") . "
  433. </li>
  434. <li>" . t("Search by major by typing major=CODE in the search box.
  435. <br>&nbsp; &nbsp; &nbsp;
  436. Ex: <em>major=ENGL</em> &nbsp; &nbsp; or &nbsp; &nbsp; <em>major=ENGL*</em>") . "
  437. </li>
  438. </ul>
  439. </div>";
  440. $rtn .= "<div class='student-search-advanced-tips-wrapper'>
  441. <label>" . t("Can't find the student you're looking for?") . "</label>
  442. " . fp_render_c_fieldset($advanced_tips_html, t("View advanced search tips"), TRUE) . "
  443. </div>";
  444. return $rtn;
  445. }
  446. function student_search_render_advisees($adv_array, $title) {
  447. $rtn = "";
  448. if (count($adv_array) == 1 && $_REQUEST["did_search"] == "true")
  449. {
  450. // Since there was only 1 result, we want to redirect this person directly.
  451. // Draw this person's name...
  452. $student_id = $adv_array[0]["student_id"];
  453. $first_name = $adv_array[0]["first_name"];
  454. $last_name = $adv_array[0]["last_name"];
  455. $rtn .= "<div class='hypo' style='border: 1px solid black;
  456. margin: 10px 0px 10px 0px; padding: 10px;
  457. font-size: 12pt; font-weight: bold;'>
  458. " .t("Loading") . " <font color='blue'>$first_name $last_name</font> ($student_id).
  459. &nbsp; " . t("Please wait...") . "
  460. </div>";
  461. $bool_redirect_one = TRUE;
  462. }
  463. $rtn .= fp_render_curved_line($title);
  464. $rtn .= "<table width='100%' align='left'
  465. border='0' cellpadding='0' cellspacing='0'>";
  466. // Do not show headers at all if mobile
  467. if (!fp_screen_is_mobile()) {
  468. $rtn .= "
  469. <td width='5%' valign='top'>&nbsp; </td>
  470. <td width='12%' valign='top' class='tenpt'><b>" . t("CWID") . "</b></td>
  471. <td width='15%' valign='top' class='tenpt'><b>" . t("First Name") . "</b></td>
  472. <td width='20%' valign='top' class='tenpt'><b>" . t("Last Name") . "</b></td>
  473. <td width='15%' valign='top' class='tenpt'><b>" . t("Major Code") . "</b></td>
  474. <td width='10%' valign='top' class='tenpt'><b>" . t("Rank") . "</b></td>
  475. <td width='15%' valign='top' class='tenpt'><b>" . t("Catalog Year") . "</b></td>
  476. ";
  477. }
  478. $rtn .= "
  479. </tr>";
  480. for ($t = 0; $t < count($adv_array); $t++)
  481. {
  482. $student_id = $adv_array[$t]["student_id"];
  483. $first_name = $adv_array[$t]["first_name"];
  484. $last_name = $adv_array[$t]["last_name"];
  485. $major = $adv_array[$t]["major"];
  486. $advising_what_if = $adv_array[$t]["advising_what_if"];
  487. $what_if_major_code = $adv_array[$t]["what_if_major_code"];
  488. $what_if_track_code = $adv_array[$t]["what_if_track_code"];
  489. $degree_id = $adv_array[$t]["degree_id"];
  490. $rank = $adv_array[$t]["rank"];
  491. $catalog_year = $adv_array[$t]["catalog_year"];
  492. if ($screen->page_is_mobile) {
  493. $catalog_year = get_shorter_catalog_year_range($catalog_year, false, true);
  494. }
  495. $advising_session_id = $adv_array[$t]["advising_session_id"];
  496. $advised_image = $adv_array[$t]["advised_image"];
  497. $on_mouse = "onmouseover=\"style.backgroundColor='#FFFF99'\"
  498. onmouseout=\"style.backgroundColor='white'\"
  499. ";
  500. if ($screen->page_is_mobile) $on_mouse = ""; // Causes problems on mobile devices.
  501. // Build up the URL we want to go to when we click this row.
  502. $path = "view";
  503. $advising_what_if = "no";
  504. if ($what_if_major_code != "") {
  505. $path = "what-if";
  506. $advising_what_if = "yes";
  507. }
  508. // Add in the query part.
  509. $query = "";
  510. $query .= "advising_student_id=$student_id&current_student_id=$student_id&advising_major_code=$major&advising_what_if=$advising_what_if";
  511. $query .= "&what_if_major_code=$what_if_major_code&what_if_track_code=$what_if_track_code&advising_load_active=yes&clear_session=yes";
  512. $url = fp_url($path, $query);
  513. // old onCLick:
  514. //<!-- onClick='selectStudent(\"$student_id\",\"$major\",\"$what_if_major_code\",\"$what_if_track_code\")' -->
  515. $rtn .= "
  516. <tr height='19'>
  517. <td colspan='7'>
  518. <table border='0'
  519. $on_mouse
  520. onClick='showUpdate(true); window.location=\"$url\"; '
  521. width='100%' >
  522. <tr height='20'>
  523. <td width='5%' class='hand'>$advised_image</td>
  524. <td width='12%' class='hand'><font size='2'>$student_id</font></td>
  525. <td width='15%' class='hand'><font size='2'>$first_name </font></td>
  526. <td width='20%' class='hand'><font size='2'>$last_name </font></td>
  527. <td width='15%' class='hand'><font size='2'>$major</td>
  528. <td width='10%' class='hand'><font size='2'>$rank</td>
  529. <td width='15%' class='hand'><font size='2'>$catalog_year</td>
  530. </tr>
  531. </table>
  532. </td>
  533. </tr>
  534. ";
  535. }
  536. $rtn .= "</table>";
  537. if ($bool_redirect_one) {
  538. // There was only one result, and it was a search, so we want to redirect
  539. // this person.
  540. // We will use the URL we created in the foreach loop above. It will still contain exactly
  541. // what we need.
  542. $rtn .= "<script type='text/javascript'>
  543. $(document).ready(function() {
  544. setTimeout('window.location=\"$url\";', 0);
  545. });
  546. </script>";
  547. }
  548. // Required to make the changeTab function work...
  549. $rtn .= "<form id='mainform' method='POST'>
  550. <input type='hidden' id='scrollTop'>
  551. <input type='hidden' id='performAction' name='performAction'>
  552. <input type='hidden' id='advisingWhatIf' name='advisingWhatIf'>
  553. <input type='hidden' id='currentStudentID' name='currentStudentID'>
  554. <input type='hidden' id='advisingStudentID' name='advisingStudentID'>
  555. <input type='hidden' id='advisingMajorCode' name='advisingMajorCode'>
  556. <input type='hidden' id='whatIfMajorCode' name='whatIfMajorCode'>
  557. <input type='hidden' id='whatIfTrackCode' name='whatIfTrackCode'>
  558. <input type='hidden' id='advisingLoadActive' name='advisingLoadActive'>
  559. <input type='hidden' id='clearSession' name='clearSession'>
  560. </form>";
  561. return $rtn;
  562. }
  563. function student_search_query_advisees($sql) {
  564. $rank_in = "( '" . join("', '", csv_to_array($GLOBALS["fp_system_settings"]["allowed_student_ranks"])) . "' )";
  565. $order_by = " major_code, l_name, f_name ";
  566. // Replace the replacement portion with our derrived variables.
  567. $sql = str_replace("%RANKIN%", $rank_in, $sql);
  568. $sql = str_replace("%ORDERBY%", $order_by, $sql);
  569. // By default, the extra_studentsearch_conditions will be checking of is_active = 1. But, the user may override this
  570. // in the settings.
  571. $extra_student_search_conditions = variable_get("extra_student_search_conditions", " AND is_active = 1 ");
  572. $sql = str_replace("%EXTRA_STUDENTSEARCH_CONDITIONS%", $extra_student_search_conditions, $sql);
  573. //fpm($sql);
  574. // Returns an array of all of this teacher's advisees.
  575. $rtn_array = array();
  576. $r = 0;
  577. $result = db_query($sql);
  578. while ($cur = db_fetch_array($result))
  579. {
  580. $student_id = trim($cur["cwid"]);
  581. $rtn_array[$r]["student_id"] = $student_id;
  582. $rtn_array[$r]["first_name"] = ucwords(strtolower($cur["f_name"]));
  583. $rtn_array[$r]["last_name"] = ucwords(strtolower($cur["l_name"]));
  584. $rtn_array[$r]["rank"] = $cur["rank_code"];
  585. $rtn_array[$r]["catalog_year"] = $cur["catalog_year"];
  586. $rtn_array[$r]["major"] = $cur["major_code"];
  587. // We should also mark if the student has been advised for this semester
  588. // or not.
  589. // Get the current default advising term id.
  590. $term_id = variable_get("advising_term_id", "");
  591. $advised_image = "&nbsp;";
  592. $advising_session_id = "";
  593. $res2 = db_query("SELECT * FROM advising_sessions WHERE
  594. student_id = '?' AND
  595. term_id = '?'
  596. AND is_draft = '0'
  597. ORDER BY posted DESC", $student_id, $term_id);
  598. if (db_num_rows($res2) > 0) {
  599. $cur = db_fetch_array($res2);
  600. $advised_image = "<img src='" . fp_theme_location() . "/images/small_check.gif' class='advisedImage'>";
  601. if ($cur["is_whatif"] == "1")
  602. { // Last advising was a What If advising.
  603. $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>";
  604. $db_major = $cur["major_code"];
  605. $temp = explode("\|_",$db_major);
  606. $rtn_array[$r]["what_if_major_code"] = trim($temp[0]);
  607. $rtn_array[$r]["what_if_track_code"] = trim($temp[1]);
  608. }
  609. }
  610. $rtn_array[$r]["advising_session_id"] = $advising_session_id;
  611. $rtn_array[$r]["advised_image"] = $advised_image;
  612. $r++;
  613. }
  614. return $rtn_array;
  615. }

Functions

Namesort descending Description
student_search_display_majors_search Display the majors search sub-tab, where we can select a major and see the students assigned to it.
student_search_display_my_advisees Displays this user's advisees, if there are any assigned.
student_search_display_my_majors Displays students belonging to the current user's major code.
student_search_display_search
student_search_get_advanced_search_tips Simply returns the HTML to display the "advanced search tips" collapsible fieldset and instructions.
student_search_menu
student_search_perm Implementation of hook_perm
student_search_query_advisees
student_search_render_advisees
student_search_render_small_search This is meant to be called directly from the theme template, to draw the small search box in the corner of the screen.
student_search_settings_form This is a system_settings form for configuring our module.
student_search_subtab_switchboard The primary purpose of this function is to decide which "sub tab" function to send the user off to. This is based on whatever their previous selection was.