blank_degrees.module

  1. 7.x modules/blank_degrees/blank_degrees.module
  2. 6.x modules/blank_degrees/blank_degrees.module
  3. 4.x modules/blank_degrees/blank_degrees.module
  4. 5.x modules/blank_degrees/blank_degrees.module

File

modules/blank_degrees/blank_degrees.module
View source
  1. <?php
  2. /**
  3. * Implementation of hook_menu
  4. */
  5. function blank_degrees_menu() {
  6. $items = array();
  7. $items["tools/blank-degrees"] = array(
  8. "title" => "Blank Degree Search",
  9. "description" => "Browse through available degree plans as they appear in FlightPath.",
  10. "page_callback" => "fp_render_form",
  11. "page_arguments" => array("blank_degrees_select_degree_form"),
  12. "access_callback" => TRUE,
  13. "page_settings" => array(
  14. "page_has_search" => FALSE,
  15. "page_banner_is_link" => TRUE,
  16. "page_hide_report_error" => TRUE,
  17. "target" => "_blank",
  18. "menu_icon" => fp_theme_location() . "/images/popup.gif",
  19. ),
  20. "type" => MENU_TYPE_NORMAL_ITEM,
  21. "weight" => 10,
  22. );
  23. $items["blank-degrees/display"] = array(
  24. "title" => "Blank Degrees - Display",
  25. "page_callback" => "blank_degrees_display_blank_degree",
  26. "access_callback" => TRUE,
  27. "page_settings" => array(
  28. "display_currently_advising" => TRUE,
  29. "page_has_search" => FALSE,
  30. "page_banner_is_link" => TRUE,
  31. "page_hide_report_error" => TRUE,
  32. "page_show_title" => TRUE,
  33. "menu_links" => array(
  34. 0 => array(
  35. "text" => "Change degree",
  36. "path" => "tools/blank-degrees",
  37. "query" => "blank_catalog_year=%BLANK_CATALOG_YEAR%",
  38. ),
  39. ),
  40. ),
  41. "type" => MENU_TYPE_NORMAL_ITEM,
  42. );
  43. return $items;
  44. }
  45. /**
  46. * This is an implementation of hook_menu_handle_replacement_pattern.
  47. * It will search for and replace replacement patterns which we are aware of it in $str.
  48. */
  49. function blank_degrees_menu_handle_replacement_pattern($str) {
  50. if (strpos($str, "%BLANK_CATALOG_YEAR%") !== 0) {
  51. // It contains this replacement pattern!
  52. $str = str_replace("%BLANK_CATALOG_YEAR%", $_REQUEST["blank_catalog_year"], $str);
  53. }
  54. return $str;
  55. }
  56. function blank_degrees_display_blank_degree() {
  57. global $screen, $student, $fp;
  58. $blank_degree_id = $_REQUEST["blank_degree_id"];
  59. $blank_catalog_year = $_REQUEST["blank_catalog_year"];
  60. $blank_print = $_REQUEST["blank_print"];
  61. $blank_view = $_REQUEST["blank_view"];
  62. $rtn = "";
  63. // Are we in draft mode?
  64. if ($_SESSION["fp_draft_mode"] == "yes") {
  65. $GLOBALS["fp_advising"]["bool_use_draft"] = true;
  66. }
  67. else {
  68. $GLOBALS["fp_advising"]["bool_use_draft"] = false;
  69. }
  70. fp_add_js(fp_get_module_path("advise") . "/js/advise.js");
  71. $student = new Student();
  72. $student->load_student();
  73. $student->student_id = "000000000";
  74. $student->name = "Blank Degree";
  75. $degree_plan = new DegreePlan($blank_degree_id);
  76. $degree_plan->load_descriptive_data();
  77. $student->catalog_year = $degree_plan->catalog_year;
  78. $fp = new FlightPath($student, $degree_plan);
  79. $screen = new AdvisingScreen("", $fp, "not_advising");
  80. if ($blank_view == "type")
  81. {
  82. $screen = new AdvisingScreenTypeView("", $fp, "not_advising");
  83. $screen->view = "type";
  84. }
  85. $screen->bool_blank = true;
  86. if ($blank_print == "yes")
  87. {
  88. $screen->bool_print = true;
  89. }
  90. $screen->build_screen_elements();
  91. $title = $degree_plan->title;
  92. if ($degree_plan->track_title != "") {
  93. $title .= " - " . $degree_plan->track_title;
  94. }
  95. fp_set_title($title);
  96. $rtn .= "<table class='fp-semester-table'>";
  97. $rtn .= $screen->display_screen();
  98. $rtn .= "</table>";
  99. // Add in the required "advising variables"
  100. //$rtn .= $screen->get_hidden_advising_variables("save_draft");
  101. // Figure out what the page's sub-tabs should be, and set them.
  102. $tab_array = array();
  103. $tab_array[0]["title"] = "Display by Year";
  104. $tab_array[0]["active"] = ($screen->view != "type");
  105. $tab_array[0]["on_click"] = "window.location=\"" . fp_url("blank-degrees/display", "blank_degree_id=$blank_degree_id&blank_catalog_year=$blank_catalog_year&blank_view=year") . "\";";
  106. $tab_array[1]["title"] = "Display by Type";
  107. $tab_array[1]["active"] = ($screen->view == "type");
  108. $tab_array[1]["on_click"] = "window.location=\"" . fp_url("blank-degrees/display", "blank_degree_id=$blank_degree_id&blank_catalog_year=$blank_catalog_year&blank_view=type") . "\";";
  109. if (!fp_screen_is_mobile()) {
  110. $tab_array[2]["title"] = "Print";
  111. $tab_array[2]["type"] = "link";
  112. $tab_array[2]["active"] = FALSE;
  113. $tab_array[2]["on_click"] = "popupPrintWindow(\"" . fp_url("blank-degrees/display", "blank_degree_id=$blank_degree_id&blank_catalog_year=$blank_catalog_year&blank_view=$blank_view&blank_print=yes") . "\");";
  114. }
  115. fp_set_page_sub_tabs($tab_array);
  116. watchdog("blank_degrees", "User viewed blank degree: @year,@degree,@title", array("@year" => $blank_catalog_year, "@degree" => $blank_degree_id, "@title" => $title), WATCHDOG_DEBUG);
  117. return $rtn;
  118. }
  119. /**
  120. * This form lets the user select which degree they wish to view.
  121. */
  122. function blank_degrees_select_degree_form() {
  123. $form = array();
  124. $bool_show_continue = TRUE;
  125. // Are we in draft mode?
  126. if ($_SESSION["fp_draft_mode"] == "yes") {
  127. $GLOBALS["fp_advising"]["bool_use_draft"] = true;
  128. }
  129. else {
  130. $GLOBALS["fp_advising"]["bool_use_draft"] = false;
  131. }
  132. if (fp_screen_is_mobile()) {
  133. fp_add_css(fp_get_module_path("blank_degrees") . "/css/mobile.css");
  134. }
  135. $blank_catalog_year = $_REQUEST["blank_catalog_year"];
  136. if ($blank_catalog_year == "") {
  137. // The user must first select the desired catalog year.
  138. $catalog_year_options = array();
  139. $current_catalog_year = variable_get("current_catalog_year", 2006);
  140. if ($GLOBALS["fp_advising"]["bool_use_draft"]) {
  141. $current_catalog_year = variable_get("current_draft_catalog_year", 2006);
  142. }
  143. $earliest_catalog_year = variable_get("earliest_catalog_year", 2006);
  144. for($t = $current_catalog_year; $t >= $earliest_catalog_year; $t--) {
  145. $catalog_year_options[$t] = "$t-" . ($t+1);
  146. }
  147. $form["blank_catalog_year"] = array(
  148. "type" => "select",
  149. "label" => t("Please begin by selecting a catalog year:"),
  150. "options" => $catalog_year_options,
  151. );
  152. }
  153. else {
  154. // Catalog year WAS specified. So, ask the user to select a degree now.
  155. $form["blank_catalog_year"] = array(
  156. "type" => "hidden",
  157. "value" => $blank_catalog_year,
  158. );
  159. $form["mark" . $m++] = array(
  160. "value" => t("Searching degrees in %year.", array("%year" => $blank_catalog_year . "-" . ($blank_catalog_year+1))) . "
  161. " . l(t("Change?"), "tools/blank-degrees"),
  162. );
  163. $mobile_markup = "";
  164. $degree_options = array();
  165. $db = get_global_database_handler();
  166. if ($degree_array = $db->get_degrees_in_catalog_year($blank_catalog_year, true, $GLOBALS["fp_advising"]["bool_use_draft"], FALSE)) {
  167. foreach($degree_array as $major_code => $value) {
  168. if (trim($value["title"]) == ""){continue;}
  169. $degree_id = $value["degree_id"];
  170. $title = $value["title"];
  171. if ($value["degree_class"] == "G") {
  172. $title = "(" . t("Graduate") . ") " . $title;
  173. }
  174. // if title is too long, shorten it.
  175. $maxlen = 95;
  176. if (strlen($title) > $maxlen) {
  177. $title = substr($title, 0, $maxlen - 3) . "...";
  178. }
  179. $degree_options[$degree_id] = $title;
  180. $mobile_markup .= "<a class='degree-search-degree-row'
  181. href='" . fp_url("blank-degrees/display", "blank_degree_id=$degree_id&blank_catalog_year={$_REQUEST["blank_catalog_year"]}") . "'>
  182. <div class='degree-search-degree-title'>$title</div>
  183. </a>";
  184. }
  185. }
  186. if (fp_screen_is_mobile()) {
  187. $form["mark" . $m++] = array(
  188. "value" => $mobile_markup,
  189. );
  190. $bool_show_continue = FALSE;
  191. }
  192. else {
  193. // NOT mobile
  194. $form["blank_degree_id"] = array(
  195. "label" => t("Please select a degree"),
  196. "type" => "select",
  197. "options" => $degree_options,
  198. );
  199. }
  200. }
  201. if ($bool_show_continue) {
  202. $form["submit"] = array(
  203. "type" => "submit",
  204. "prefix" => "<hr>",
  205. "value" => t("Continue") . " -&gt;",
  206. );
  207. }
  208. return $form;
  209. }
  210. /**
  211. * Submit handler for degree selection
  212. */
  213. function blank_degrees_select_degree_form_submit($form, $form_state) {
  214. // If all the user did was select catalog year, we need to redirect
  215. // back to the form with blank_catalog_year set.
  216. if ($form_state["values"]["blank_degree_id"] == "" && $form_state["values"]["blank_catalog_year"] != "") {
  217. // Go to degree selection.
  218. fp_goto("tools/blank-degrees", "blank_catalog_year=" . $form_state["values"]["blank_catalog_year"]);
  219. return;
  220. }
  221. else if ($form_state["values"]["blank_degree_id"] != "" && $form_state["values"]["blank_catalog_year"] != ""){
  222. // Send them to the blank degree page
  223. fp_goto("blank-degrees/display", "blank_degree_id=" . $form_state["values"]["blank_degree_id"] . "&blank_catalog_year=" . $form_state["values"]["blank_catalog_year"]);
  224. return;
  225. }
  226. }

Functions

Namesort descending Description
blank_degrees_display_blank_degree
blank_degrees_menu Implementation of hook_menu
blank_degrees_menu_handle_replacement_pattern This is an implementation of hook_menu_handle_replacement_pattern. It will search for and replace replacement patterns which we are aware of it in $str.
blank_degrees_select_degree_form This form lets the user select which degree they wish to view.
blank_degrees_select_degree_form_submit Submit handler for degree selection