advise.module
Search API
File
modules/advise/advise.moduleView source
- <?php
-
-
- function advise_menu() {
- $items = array();
-
-
- $items["admin-tools/toggle-draft"] = array(
- "title" => "Toggle Draft Mode",
- "page_callback" => "fp_render_form",
- "page_arguments" => array("advise_toggle_draft_form"),
- "access_arguments" => array("toggle_draft"),
- "page_settings" => array(
- "menu_links" => array(
- 0 => array(
- "text" => "Back to Main",
- "path" => "main",
- ),
- ),
- ),
- "type" => MENU_TYPE_TAB,
- "tab_parent" => "main",
- );
-
-
- $items["admin-tools/clear-advising-cache"] = array(
- "title" => "Clear advising cache",
- "page_callback" => "advise_perform_clear_advising_cache",
- "access_arguments" => array("toggle_draft"),
- "type" => MENU_TYPE_NORMAL_ITEM,
- );
-
-
- $items["view"] = array(
- "title" => "View",
- "page_callback" => "advise_display_view",
- "page_arguments" => array("view"),
- "access_callback" => "advise_can_access_view",
- "tab_family" => "system",
- "page_settings" => array (
- "display_currently_advising" => TRUE,
- "display_greeting" => TRUE,
- "page_has_search" => TRUE,
- ),
- "weight" => 30,
- "type" => MENU_TYPE_TAB,
- );
-
-
- $items["view/print"] = array(
- "title" => "View",
- "page_callback" => "advise_display_view",
- "page_arguments" => array("view"),
- "access_callback" => TRUE,
- "page_settings" => array (
- "display_currently_advising" => TRUE,
- "bool_print" => TRUE,
- "screen_mode" => "not_advising",
- ),
- "type" => MENU_TYPE_CALLBACK,
- );
-
-
-
- $items["what-if"] = array(
- "title" => "What If?",
- "page_callback" => "advise_display_view",
- "page_arguments" => array("what-if"),
- "access_callback" => "advise_can_access_view",
- "tab_family" => "system",
- "page_settings" => array (
- "display_currently_advising" => TRUE,
- "display_greeting" => TRUE,
- "page_has_search" => TRUE,
- ),
- "weight" => 60,
- "type" => MENU_TYPE_TAB,
- );
-
-
- $items["what-if/print"] = array(
- "title" => "What If?",
- "page_callback" => "advise_display_view",
- "page_arguments" => array("what-if"),
- "access_callback" => TRUE,
- "page_settings" => array (
- "display_currently_advising" => TRUE,
- "bool_print" => TRUE,
- "screen_mode" => "not_advising",
- ),
- "type" => MENU_TYPE_CALLBACK,
- );
-
-
-
-
- $items["history"] = array(
- "title" => "History",
- "page_callback" => "advise_display_history",
- "access_callback" => "advise_can_access_view",
- "tab_family" => "system",
- "page_settings" => array (
- "display_currently_advising" => TRUE,
- "display_greeting" => TRUE,
- "page_has_search" => TRUE,
- ),
- "weight" => 40,
- "type" => MENU_TYPE_TAB,
- "file" => menu_get_module_path("advise") . "/advise.history.inc",
- );
-
-
-
- // My popups....
-
-
- $items["advise/popup-display-summary"] = array(
- "title" => "Advising Summary",
- "page_callback" => "advise_popup_display_summary",
- "access_callback" => "advise_user_can_view_advising_session_access_callback",
- "page_settings" => array(
- "page_is_popup" => TRUE,
- "page_hide_report_error" => TRUE,
- "bool_print" => TRUE,
- ),
- "type" => MENU_TYPE_CALLBACK,
- "file" => menu_get_module_path("advise") . "/advise.history.inc",
-
- );
-
-
- $items["advise/popup-change-term"] = array(
- "title" => "Change advising term",
- "page_callback" => "advise_display_popup_change_term",
- "access_arguments" => array("can_advise_students"),
- "page_settings" => array(
- "page_is_popup" => TRUE,
- "page_hide_report_error" => TRUE,
- ),
- "type" => MENU_TYPE_CALLBACK,
- );
-
- $items["advise/popup-change-track"] = array(
- "title" => "Change advising track",
- "page_callback" => "advise_display_popup_change_track",
- "access_arguments" => array("access_logged_in_content"),
- "page_settings" => array(
- "page_is_popup" => TRUE,
- "page_hide_report_error" => TRUE,
- ),
- "type" => MENU_TYPE_CALLBACK,
- );
-
-
-
- $items["advise/popup-course-description"] = array(
- "title" => "Description",
- "page_callback" => "advise_display_popup_course_description",
- "access_callback" => TRUE,
- "page_settings" => array(
- "page_is_popup" => TRUE,
- "page_hide_report_error" => TRUE,
- ),
- "weight" => 10,
- );
-
-
- $items["advise/popup-substitute-selected"] = array(
- "title" => "Substitute",
- "page_callback" => "advise_display_popup_substitute_selected",
- "access_arguments" => array("can_substitute"),
- "page_settings" => array(
- "page_is_popup" => TRUE,
- "page_hide_report_error" => TRUE,
- ),
- "weight" => 10,
- );
-
-
- $items["advise/popup-group-select"] = array(
- "title" => "Select",
- "page_callback" => "advise_display_popup_group_select",
- "access_callback" => TRUE,
- "page_settings" => array(
- "page_is_popup" => TRUE,
- "page_hide_report_error" => TRUE,
- ),
- "weight" => 10,
- );
-
-
- // Toolbox...
-
- $items["advise/popup-toolbox/transfers"] = array(
- "title" => "Transfers",
- "page_callback" => "advise_display_popup_toolbox_transfers",
- "access_arguments" => array("can_substitute"),
- "page_settings" => array(
- "page_is_popup" => TRUE,
- "page_hide_report_error" => TRUE,
- ),
- "weight" => 10,
- "type" => MENU_TYPE_TAB,
- "tab_family" => "advise-toolbox",
- "file" => menu_get_module_path("advise") . "/advise.toolbox.inc",
- );
-
- $items["advise/popup-toolbox/substitutions"] = array(
- "title" => "Substitutions",
- "page_callback" => "advise_display_popup_toolbox_substitutions",
- "access_arguments" => array("can_substitute"),
- "page_settings" => array(
- "page_is_popup" => TRUE,
- "page_hide_report_error" => TRUE,
- ),
- "weight" => 20,
- "type" => MENU_TYPE_TAB,
- "tab_family" => "advise-toolbox",
- "file" => menu_get_module_path("advise") . "/advise.toolbox.inc",
- );
-
- $items["advise/popup-toolbox/moved"] = array(
- "title" => "Moved",
- "page_callback" => "advise_display_popup_toolbox_moved",
- "access_arguments" => array("can_substitute"),
- "page_settings" => array(
- "page_is_popup" => TRUE,
- "page_hide_report_error" => TRUE,
- ),
- "weight" => 30,
- "type" => MENU_TYPE_TAB,
- "tab_family" => "advise-toolbox",
- "file" => menu_get_module_path("advise") . "/advise.toolbox.inc",
- );
-
- $items["advise/popup-toolbox/courses"] = array(
- "title" => "Courses",
- "page_callback" => "advise_display_popup_toolbox_courses",
- "access_arguments" => array("can_substitute"),
- "page_settings" => array(
- "page_is_popup" => TRUE,
- "page_hide_report_error" => TRUE,
- ),
- "weight" => 40,
- "type" => MENU_TYPE_TAB,
- "tab_family" => "advise-toolbox",
- "file" => menu_get_module_path("advise") . "/advise.toolbox.inc",
- );
-
-
-
- return $items;
- }
-
-
- /**
- * Used by the menu to determine if the user can see the View tab.
- */
- function advise_can_access_view() {
- global $current_student_id, $user;
-
- // must be logged in first...
- if (!user_has_permission("access_logged_in_content")) return FALSE;
-
-
- if ($current_student_id != "") return TRUE;
-
- return FALSE;
-
- }
-
-
- function advise_toggle_draft_form() {
- $form = array();
-
- $form["mark" . $m++] = array(
- "value" => "<p>" . t("By turning Draft Mode on, you will be able
- to view degree plans which are still in 'Draft' mode
- in both the regular View tab, as well as the Blank Degrees module,
- if enabled.") . "</p>",
- );
-
- $form["draft"] = array(
- "type" => "radios",
- "label" => t("Enable Draft Mode?"),
- "options" => array("yes" => t("Yes"), "no" => t("No")),
- "value" => $_SESSION["fp_draft_mode"],
- );
-
- $form["submit"] = array(
- "type" => "submit",
- "value" => t("Submit"),
- "prefix" => "<hr>",
- );
-
- $form["#redirect"] = array(
- "path" => "main",
- "query" => "",
- );
-
- return $form;
- }
-
-
- function advise_toggle_draft_form_submit($form, $form_state) {
- fp_add_message(t("Draft mode successfully updated."));
- $_SESSION["fp_draft_mode"] = $form_state["values"]["draft"];
- }
-
-
- /**
- * Lets the user change the track for this major.
- */
- function advise_display_popup_change_track() {
- global $degree_plan, $student;
- $rtn = "";
-
- advise_init_screen();
-
- fp_add_js(fp_get_module_path("advise") . "/js/advise.js");
-
-
-
- $degree_plan->load_descriptive_data();
- $rtn .= fp_render_curved_line(t("Select a Degree Option"));
- $rtn .= "<div class='tenpt'>
- " . t("This major has one or more degree options, which affects which courses are required.
- Please select a degree option (or track) from the list below.") . "
- <br><br>
- " . t("If you are unsure of what to do, simply close this window.");
-
- $rtn .= "<br><br><b>" . $degree_plan->title . "</b> " . t("degree options:") . "</div><!--DEFAULT-->
- <ul>";
-
- // Get the list of available tracks for this student.
- if (!$tracks = $degree_plan->get_available_tracks())
- {
- $rtn .= "<li>" . t("This major has no degree options.") . "</li>";
- }
-
- // Is there a "default" message for all tracks, which will override
- // any other track descriptions?
- // We need to look through all the tracks for the
- // characters: "DEFAULT:"
- // If we find this, then this is the default description
- // which applies to all the tracks, and it should be displayed
- // at the top.
- $bool_default_description = false;
- for ($t = 0; $t < count($tracks); $t++)
- {
- $temp = explode(" ~~ ", $tracks[$t]);
- $track_code = trim($temp[0]);
- $track_title = trim($temp[1]);
- $track_description = trim($temp[2]);
-
- if (strstr($track_description, "DEFAULT:")) {
- // Yes! We found a default message.
- $bool_default_description = true;
- $track_description = filter_markup(trim(str_replace("DEFAULT:", "", $track_description)));
- $track_description = "<div style='padding-top: 10px;' class='tenpt'>$track_description</div>";
- $rtn = str_replace("<!--DEFAULT-->",$track_description, $rtn);
- break;
- }
-
- }
-
-
- for ($t = 0; $t < count($tracks); $t++)
- {
- $temp = explode(" ~~ ", $tracks[$t]);
- $track_code = trim($temp[0]);
- $track_title = trim($temp[1]);
- $track_description = "";
-
- // If this is the current track_code, mark it as such.
- if ($student->array_settings["track_code"] == $track_code
- && $student->array_settings["major_code"] == $degree_plan->major_code)
- {
- $track_title .= " <b>(" . t("current") . ")</b>";
- }
-
- if ($bool_default_description == false)
- {
- $track_description = filter_markup(trim($temp[2]));
- if ($track_description != "")
- {
- $track_description = " - $track_description";
- }
- }
-
- $temp_tc = $track_code;
- if ($temp_tc == "")
- {
- $temp_tc = "none";
- }
-
-
- $link = fp_get_js_confirm_link(t("Are you sure you wish to change degree options?"), "opener.changeTrack(\"$temp_tc\"); window.close(); ", $track_title);
-
- if ($GLOBALS["fp_advising"]["advising_what_if"] == "yes") {
- $link = "<a href='javascript: popupChangeWhatIfTrack(\"$temp_tc\", \"" . t("Are you sure you wish to change degree options?") . "\");'>$track_title</a>";
- }
-
- $rtn .= "<li class='tenpt' style='padding:3px;'>
- $link $track_description</li>";
-
- }
-
- $rtn .= "</ul>";
-
-
-
- return $rtn;
- }
-
-
-
- /**
- * This popup allows the advisor to change the advising term.
- */
- function advise_display_popup_change_term() {
- $rtn = "";
-
- fp_add_js(fp_get_module_path("advise") . "/js/advise.js");
-
- $current_term_id = $_REQUEST["advising_term_id"];
- $current_term = get_term_description($current_term_id);
-
-
- $rtn .= fp_render_curved_line(t("Select an Advising Term"));
- $rtn .= "<div>
- " . t("You may advise this student for future semesters. Please select which
- advising term you would like to advise for from the list below. If you
- are unsure, simply close this window and continue to advise for the current
- term of %current_term.", array("%current_term" => $current_term)) . "
- </div>";
-
- $rtn .= "<ul>";
-
- $temp = explode(",", variable_get("available_advising_term_ids", "0"));
- for ($t = 0; $t < count($temp); $t++) {
- $term_id = trim($temp[$t]);
-
-
- $term_desc = get_term_description($term_id);
- if ($term_id == $current_term_id) {
- $term_desc = "<b>$term_desc</b> - " . t("current");
- }
-
- $link = fp_get_js_confirm_link(t("Are you sure you wish to change advising terms?"), "opener.changeTerm(\"$term_id\"); window.close(); ", $term_desc);
-
- $rtn .= "<li class='tenpt' style='padding:3px;'>$link</li>";
-
- }
-
- $rtn .= "</ul>";
-
-
- return $rtn;
- }
-
-
-
-
-
- /**
- * This is an access callback. Can the user view the advising session specified
- * in the REQUEST?
- */
- function advise_user_can_view_advising_session_access_callback() {
- global $user;
-
- if (user_has_permission("view_any_advising_session")) {
- return TRUE;
- }
-
- if (user_has_permission("view_own_advising_session")) {
- // The user is only allowed to view their OWN advising sessions.
- // So, make sure this advising session belongs to them!
- $advising_session_id = $_REQUEST["advising_session_id"];
- // make sure this belongs to $user->cwid;
- // First, what was the student's CWID associated with that advising_session_id?
- $res = db_query("SELECT student_id FROM advising_sessions
- WHERE advising_session_id = '?' ", $advising_session_id);
- $cur = db_fetch_array($res);
- if ($user->cwid == $cur["student_id"]) {
- return TRUE;
- }
- }
-
- return FALSE;
- }
-
-
-
- function advise_display_popup_group_select() {
- global $current_student_id, $fp, $screen, $degree_plan;
- $rtn = "";
-
- advise_init_screen();
- fp_add_js(fp_get_module_path("advise") . "/js/advise.js");
-
- $settings = fp_get_system_settings();
-
- $blank_degree_id = trim($_GET["blank_degree_id"]);
- $course_id = trim($_GET["course_id"]);
- $group_id = trim(addslashes($_GET["group_id"]));
- $group_hours_remaining = trim(addslashes($_GET["group_hours_remaining"]));
- $semester_num = trim(addslashes($_GET["semester_num"]));
- $perform_action2 = $_REQUEST["perform_action2"];
-
- // If this is a "blank" degree, make sure we set the degree_id correctly.
- if($blank_degree_id != "") {
- $degree_plan = new DegreePlan($blank_degree_id);
- $fp->degree_plan = $degree_plan;
- $screen->degree_plan = $degree_plan;
- $screen->bool_blank = TRUE;
- }
-
- if (!$group = $degree_plan->find_placeholder_group($group_id, $semester_num)) {
- fpm("Could not find group $group_id in semester $semester_num.");
- }
-
- if ($group_id == -88) {
- // This is the Add a Course group. We must initialize it, as it
- // does not exist yet.
- // We need to populate this group now.
- $group->list_courses = $fp->get_all_courses_in_catalog_year($settings["current_catalog_year"]);
- $group->title = "Add an Additional Course";
- $group->list_courses->assign_group_id($group_id);
- $group->list_courses->load_course_descriptive_data();
- }
-
-
- if ($course_id != "") {
- // Meaning, a course_id was specified, so make sure
- // it is "selected" inside the group and branches.
-
- $course = new Course();
- $course->course_id = $course_id;
-
- $temp_course_list = $group->find_courses($course);
- if (!$temp_course_list) {
- $temp_course_list = $degree_plan->find_courses($course_id, $group_id, $semester_num);
- }
-
- if ($temp_course_list) {
- $temp_course_list->reset_counter();
- while($temp_course_list->has_more()) {
- $temp_course = $temp_course_list->get_next();
- $temp_course->bool_selected = true;
- //$temp_course->assigned_to_semester_num = $semester_num;
- }
- }
- }
-
- if ($perform_action2 == "" || $perform_action2 == "select") {
- if ($group) {
- $rtn .= $screen->display_popup_group_select($group, $group_hours_remaining);
- }
- // Create the tabs for the page...
- $tab_array = array();
- $tab_array[0]["title"] = "Description";
- $tab_array[0]["on_click"] = "popupDescribeSelected(\"$group_id\",\"$semester_num\",\"0\",\"\",\"group_hours_remaining=$group_hours_remaining&blank_degree_id=$blank_degree_id\");";
- $tab_array[1]["title"] = "Select";
- $tab_array[1]["active"] = true;
-
- // If we are allowed to substitute....
- if (user_has_permission("can_substitute") && $group_id != -88 && !$screen->bool_blank) {
- $tab_array[2]["title"] = "Substitute";
- $tab_array[2]["on_click"] = "popupSubstituteSelected(\"0\",\"$group_id\",\"$semester_num\",\"group_hours_remaining=$group_hours_remaining\");";
- }
-
- }
-
- if ($perform_action2 == "describe_course") {
- $rtn .= $screen->display_popup_course_description($course_id,null,$group, true);
- // Create the tabs for the page...
- $tab_array = array();
- $tab_array[0]["title"] = "Description";
- $tab_array[0]["active"] = true;
- $tab_array[1]["title"] = "Select";
- $subject = trim($_GET["selected_subject"]);
-
- $tab_array[1]["on_click"] = "popupBackToGroupSelect(\"$course_id\",\"$group_id\",\"$semester_num\",\"selected_subject=$subject&group_hours_remaining=$group_hours_remaining&blank_degree_id=$blank_degree_id\");";
-
- // If we are allowed to substitute....
- if (user_has_permission("can_substitute") && $group_id != -88 && !$screen->bool_blank) {
- $tab_array[2]["title"] = "Substitute";
- $tab_array[2]["on_click"] = "popupSubstituteSelected(\"$course_id\",\"$group_id\",\"$semester_num\",\"group_hours_remaining=$group_hours_remaining\");";
- }
-
-
- }
-
- if ($tab_array) {
- fp_set_page_tabs($tab_array);
- }
-
-
- return $rtn;
- }
-
-
- function advise_display_popup_substitute_selected() {
- global $current_student_id, $fp, $screen;
- $rtn = "";
-
- advise_init_screen();
- fp_add_js(fp_get_module_path("advise") . "/js/advise.js");
-
- $sub_decimals_allowed = variable_get("sub_hours_decimals_allowed", 2);
- // Add our allowed substitution decimals as a js setting for later use.
- fp_add_js(array("subDecimalsAllowed" => $sub_decimals_allowed), "setting");
-
-
- $course_id = trim($_GET["course_id"]);
- $group_id = trim(addslashes($_GET["group_id"]));
- $semester_num = trim(addslashes($_GET["semester_num"]));
- $group_hours_remaining = trim(addslashes($_GET["group_hours_remaining"]));
-
- $rtn .= $screen->display_popup_substitute($course_id, $group_id, $semester_num, $group_hours_remaining);
-
-
- return $rtn;
- }
-
-
- function advise_display_popup_course_description() {
- global $current_student_id, $screen;
- $rtn = "";
-
- advise_init_screen();
-
- fp_add_js(fp_get_module_path("advise") . "/js/advise.js");
-
- $data_string = trim($_GET["data_string"]);
- $course = new Course();
- if ($data_string != "")
- {
- $course->load_course_from_data_string($data_string);
-
- }
-
- $rtn .= $screen->display_popup_course_description("", $course);
- // Create the tabs for the page...
- $tab_array = array();
- $tab_array[0]["title"] = "Description";
- $tab_array[0]["active"] = true;
-
- if (user_has_permission("can_substitute") && !$screen->bool_blank) {
- if ($course->bool_substitution != true && $course->grade == "") {
- // By checking grade, we are making sure this course has NOT already
- // been taken by the student. In other words, verify that this course
- // is an unfulfilled requirement on the degree plan ONLY.
- $extra_vars = "hours_avail=$course->max_hours";
- $tab_array[1]["title"] = "Substitute";
- $tab_array[1]["on_click"] = "popupSubstituteSelected(\"$course->course_id\",\"$course->assigned_to_group_id\",\"$course->assigned_to_semester_num\",\"$extra_vars\");";
-
- // I WAS WRONG!!!!!
- // I don't see any reason to make this a javascript function. I'm going to make it a simple URL link.
- // window.location = "' . $script_filename . '?windowMode=popup&performAction=substituteSelected&course_id=" + course_id + "&group_id=" + group_id + "&semester_num=" + semester_num + "¤t_student_id=" + csid + "&" + extraVars;
- //$tab_array[1]["on_click"] = "window.location = \"" . base_path() . "/advise/popup-substitute-selected&window_mode=popup&course_id=$course->course_id&group_id=$course->assigned_to_group_id&semester_num=$course->assigned_to_semester_num¤t_student_id=$current_student_id&hours_avail=$course->max_hours\"";
- }
- }
-
- fp_set_page_tabs($tab_array);
-
- //$screen->page_tabs = $screen->draw_tabs($tab_array);
-
- return $rtn;
- }
-
-
-
- /**
- * Implementation of hook_perm
- */
- function advise_perm() {
- $perms = array();
-
- $perms["view_any_advising_session"] = array(
- "title" => t("View any advising session"),
- "description" => t("The user is allowed to view any advising sessions for any user.
- For example, the user is an advisor."),
- );
-
- $perms["view_own_advising_session"] = array(
- "title" => t("View own advising session"),
- "description" => t("The user is allowed to view their own advising sessions.
- For example, the user is a student."),
- );
-
-
-
- $perms["can_advise_students"] = array(
- "title" => t("Can advise students"),
- "description" => t("The user is allowed to advise other students,
- by clicking a checkbox next to a course, or by selecting
- a course from an elective group."),
- );
-
- $perms["can_substitute"] = array(
- "title" => t("Can substitute"),
- "description" => t("The user is allowed to substitute courses on a student's
- degree plan."),
- );
-
-
- $perms["toggle_draft"] = array(
- "title" => t("Toggle draft mode"),
- "description" => t("The user toggle 'draft' mode, so they can view draft degree plans
- in FlightPath."),
- );
-
-
-
- return $perms;
- }
-
-
- /**
- * This is the page which actually displays the "view" for the user
- * to see their advising session, or for an advisor to advise them.
- *
- */
- function advise_display_view($view = "view") {
- global $user, $fp, $degree_plan, $screen;
- $rtn = "";
-
- if ($view == "what-if") {
- $GLOBALS["fp_advising"]["advising_what_if"] = "yes";
- $_REQUEST["advising_what_if"] = "yes";
- }
- else {
- $GLOBALS["fp_advising"]["advising_what_if"] = "no";
- $_REQUEST["advising_what_if"] = "no";
- }
-
- // Initialize everything we need to initialize for this advising session.
- advise_init_screen();
- fp_add_js(fp_get_module_path("advise") . "/js/advise.js");
-
- // If we are on a print screen, we need to go out of our
- // way to set the screen mode, so we don't display certain things
- // when we go to draw the screen.
- if (strstr($_REQUEST["q"], "/print")) {
- $screen->bool_print = TRUE;
- $screen->screen_mode = "not_advising";
- }
-
- if ($GLOBALS["fp_advising"]["advising_what_if"] == "yes" && $GLOBALS["fp_advising"]["what_if_major_code"] == "") {
- // We are in WhatIf, but we have not selected a major, so give
- // the user a selection screen.
- $screen->screen_mode = "not_advising";
- $rtn .= advise_display_what_if_selection();
- }
- else {
- // This is a normal advising screen. Either View or WhatIf.
-
- //$page_content .= $screen->display_view_options();
-
- $screen->build_screen_elements();
-
- $form_token = md5("advise_display_view" . fp_token());
-
- $rtn .= "<form id='mainform' method='POST' action='" . base_path() . "/$view'>
- <input type='hidden' name='form_token' value='$form_token'>
- <table class='fp-semester-table'>";
- $rtn .= $screen->display_screen();
- $rtn .= "</table>";
- // Add in the required "advising variables"
- $rtn .= $screen->get_hidden_advising_variables("save_draft");
-
- $rtn .= "</form>";
-
- // Figure out what the page's sub-tabs should be, and set them.
- $tab_array = array();
- $tab_array[0]["title"] = "Display by Year";
- $tab_array[0]["active"] = ($screen->view != "type");
- $tab_array[0]["on_click"] = "changeView(\"year\");";
-
- $tab_array[1]["title"] = "Display by Type";
- $tab_array[1]["active"] = ($screen->view == "type");
- $tab_array[1]["on_click"] = "changeView(\"type\");";
-
- if (!fp_screen_is_mobile()) {
- $tab_array[2]["title"] = "Print";
- $tab_array[2]["type"] = "link";
- $tab_array[2]["active"] = FALSE;
- $tab_array[2]["on_click"] = "popupPrintWindow(\"" . base_path() . "/$view/print&advising_view=$screen->view\");";
- }
-
- fp_set_page_sub_tabs($tab_array);
-
- watchdog("view_by_$screen->view", "", array(), WATCHDOG_DEBUG);
-
- }
-
- // If we are in WhatIf mode, let's write something special to
- // the log.
- if ($GLOBALS["fp_advising"]["advising_what_if"] == "yes" && $GLOBALS["fp_advising"]["what_if_major_code"] != "")
- {
- $log_action .= "_whatif";
- $log_extra = $GLOBALS["fp_advising"]["what_if_major_code"] . " " . $GLOBALS["fp_advising"]["what_if_track_code"];
- }
-
-
-
- // print_pre($student->list_courses_taken->toString());
- // Should we re-cache the course inventory? If there have been any changes
- // to it, then we will see that in a GLOBALS variable...
- if ($GLOBALS["cache_course_inventory"] == true)
- {
- $_SESSION["fp_cache_course_inventory"] = serialize($GLOBALS["fp_course_inventory"]);
- }
-
- return $rtn;
- }
-
-
-
-
- /**
- * Displays the pulldown select list for picking a new What If degree.
- * Returns HTML.
- *
- * @return string
- */
- function advise_display_what_if_selection($bool_undergrad_only = TRUE) {
- global $screen, $current_student_id;
-
- $rtn = "";
-
- if ($screen->bool_print) {
- return "";
- }
-
- $db = get_global_database_handler();
-
- $rtn .= "<form action='" . base_path() . "/what-if' id='mainform' method='POST'>";
- $rtn .= fp_render_curved_line("What if I change my major to...");
-
- $rtn .= "<br>
- Major: <select name='what_if_major_code' class='what-if-selector'>
- <option value=''>Please select a major</option>
- <option value=''>------------------------------</option>\n
- ";
- $settings = fp_get_system_settings();
- $current_catalog_year = $settings["current_catalog_year"];
- //$bool_use_draft = $GLOBALS["fp_advising"]["bool_use_draft"];
- $bool_use_draft = FALSE; // leave as false for now. Because you can't select
- // degree options, and if you click submit it really does
- // save it. Better to just use blank degrees.
- if ($degree_array = $db->get_degrees_in_catalog_year($current_catalog_year, false, $bool_use_draft, $bool_undergrad_only)) {
- foreach($degree_array as $major_code => $value) {
- if (trim($value["title"]) == ""){continue;}
- $rtn .= "<option value='$major_code'>{$value["title"]}</option> \n";
- }
- }
-
- $rtn .= "</select>
- <br><br>";
-
- $rtn .= "
- <div align='right'>
- " . fp_render_button("Try It Out!", "showUpdate(true);submitForm();") . "
-
- </div>
- <br><br>
- <div class='hypo tenpt'>
- <b>Important Notice:</b> What If displays degree plans
- from the most recent catalog year ($current_catalog_year-" . ($current_catalog_year + 1) . "),
- as any major change would place the student into the
- most recent catalog.
- </div>";
-
-
- // Include only certain variables, so we don't overwrite our selection of what_if_major_code.
- $rtn .= "
- <input type='hidden' name='load_from_cache' value='no'>
- <input type='hidden' name='window_mode' value='screen'>
- <input type='hidden' id='scroll_top'>
- <input type='hidden' id='perform_action' name='perform_action'>
- <input type='hidden' id='advising_what_if' name='advising_what_if' value='yes'>
- <input type='hidden' id='current_student_id' name='current_student_id' value='$current_student_id'>
-
- ";
-
- $rtn .= "</form>
- ";
-
-
- return $rtn;
- }
-
-
-
-
-
- /**
- * Takes various variables from the REQUEST and stores them in our advising_session_variables table for more convenient use later on.
- */
- function advise_init_advising_variables($bool_ignore_what_if_variables = FALSE) {
- global $user;
-
- $vars = array();
-
- $student = null;
-
- // The current student ID is what we append to all session variables
- // dealing with the current student. We do this so that we will
- // keep session variables unique, so that we can have more than one
- // window open at a time, with multiple students.
- // Therefor, this should never go into the session.
- // Annoyingly, we must pass carry this around on each page in the system.
- $vars["current_student_id"] = $_REQUEST["current_student_id"];
- if ($vars["current_student_id"] == "")
- {
- $vars["current_student_id"] = $_REQUEST["advising_student_id"];
- }
-
- $csid = $vars["current_student_id"];
-
- // Get the student ID.
- $vars["advising_student_id"] = $_REQUEST["advising_student_id"];
- if ($vars["advising_student_id"] == "")
- {
- $vars["advising_student_id"] = $_SESSION["advising_student_id$csid"];
- if ($vars["advising_student_id"] == "")
- { // Default value...
- $vars["advising_student_id"] = $csid;
- }
- }
-
-
- // Should we load from the Draft advising session? or the active?
- $vars["advising_load_active"] = $_REQUEST["advising_load_active"];
- if ($vars["advising_load_active"] == "")
- { // values will either be "yes" or "" (any other value than "yes" is
- // considered to be negative.
- // Default value...
- $vars["advising_load_active"] = "";
-
- }
-
-
- // Get the major_code.
- $vars["advising_major_code"] = $_REQUEST["advising_major_code"];
- if ($vars["advising_major_code"] == "")
- {
- $vars["advising_major_code"] = $_SESSION["advising_major_code$csid"];
- if ($vars["advising_major_code"] == "")
- { // Default value...
- if (!$student) $student = new Student($csid);
- $vars["advising_major_code"] = $student->major_code;
- }
- }
-
-
-
-
- // Get the track_code.
- $vars["advising_track_code"] = $_REQUEST["advising_track_code"];
- if ($vars["advising_track_code"] == "")
- {
- $vars["advising_track_code"] = $_SESSION["advising_track_code$csid"];
- if ($vars["advising_track_code"] == "")
- { // Default value...
- if (!$student) $student = new Student($csid);
- $vars["advising_track_code"] = $student->track_code;
-
- }
- }
-
- // Update the student's settings?
- $vars["advising_update_student_settings_flag"] = $_REQUEST["advising_update_student_settings_flag"];
- // Make it only come from the POST, for safety.
- if ($vars["advising_update_student_settings_flag"] == "")
- {
- $vars["advising_update_student_settings_flag"] = $_SESSION["advising_update_student_settings_flag$csid"];
- if ($vars["advising_update_student_settings_flag"] == "")
- { // Default value...
-
- }
- }
-
-
- // Update the logged-in user's settings?
- $vars["fp_update_user_settings_flag"] = $_REQUEST["fp_update_user_settings_flag"];
- // Make it only come from the POST, for safety.
- if ($vars["fp_update_user_settings_flag"] == "")
- {
- $vars["fp_update_user_settings_flag"] = $_SESSION["fp_update_user_settings_flag$csid"];
- if ($vars["fp_update_user_settings_flag"] == "")
- { // Default value...
-
- }
- }
-
-
-
- $settings = fp_get_system_settings();
-
-
- $vars["advising_term_id"] = $_REQUEST["advising_term_id"]; // Get it from the GET or POST.
- if ($vars["advising_term_id"] == "")
- {
- // Set to the default advising term.
- $vars["advising_term_id"] = $_SESSION["advising_term_id$csid"];
- if ($vars["advising_term_id"] == "")
- {
- // default value:
- $vars["advising_term_id"] = $settings["advising_term_id"];
- if ($vars["advising_term_id"] == "") {
- // It's STILL blank?! Just use 0 then.
- $vars["advising_term_id"] = "0";
- }
- }
- }
-
- // Are we currently in WhatIf mode?
- $vars["advising_what_if"] = $_REQUEST["advising_what_if"]; // Get it from the GET or POST.
- if ($vars["advising_what_if"] == "")
- {
- // Will equal "yes" if we ARE in whatIf mode.
- $vars["advising_what_if"] = $_SESSION["advising_what_if$csid"];
- if ($vars["advising_what_if"] == "")
- {
- // Default value:
- $vars["advising_what_if"] = "no";
- }
- }
-
- $vars["what_if_major_code"] = $_REQUEST["what_if_major_code"]; // Get it from the GET or POST.
- if ($vars["what_if_major_code"] == "")
- {
- // Will equal "yes" if we ARE in whatIf mode.
- $vars["what_if_major_code"] = $_SESSION["what_if_major_code$csid"];
- if ($vars["what_if_major_code"] == "")
- {
- // Default value:
- $vars["what_if_major_code"] = "";
- }
- }
-
- $vars["what_if_track_code"] = $_REQUEST["what_if_track_code"]; // Get it from the GET or POST.
- if ($vars["what_if_track_code"] == "")
- {
- // Will equal "yes" if we ARE in whatIf mode.
- $vars["what_if_track_code"] = $_SESSION["what_if_track_code$csid"];
- if ($vars["what_if_track_code"] == "")
- {
- // Default value:
- $vars["what_if_track_code"] = "";
- }
- }
-
-
- if ($vars["what_if_major_code"] == "none")
- {
- $vars["what_if_major_code"] = "";
- }
- if ($vars["what_if_track_code"] == "none")
- {
- $vars["what_if_track_code"] = "";
- }
- if ($vars["advising_track_code"] == "none")
- {
- $vars["advising_track_code"] = "";
- }
-
-
- // Settings... (from the database)
- $vars["setting_available_advising_term_ids"] = $settings["available_advising_term_ids"];
- $vars["setting_advising_term_id"] = $settings["advising_term_id"];
- $vars["setting_current_catalog_year"] = $settings["current_catalog_year"];
- $vars["setting_current_draft_catalog_year"] = $settings["current_draft_catalog_year"];
-
- // Are we in Print View?
- $vars["print_view"] = $_REQUEST["print_view"];
-
- // Should we try to load from the cache?
- $vars["load_from_cache"] = $_REQUEST["load_from_cache"];
- if ($vars["load_from_cache"] == "")
- {
- // By default, attempt to load from cache.
- $vars["load_from_cache"] = "yes";
- }
-
- // What "view" are we in? View by Year or by Type?
- // Not the same as printView. printView should work regardless
- // of our advising_view.
- $vars["advising_view"] = $_REQUEST["advising_view"];
- if ($vars["advising_view"] == "")
- {
- $vars["advising_view"] = $_SESSION["advising_view$csid"];
- }
-
-
- // Place values into session.
- $_SESSION["advising_student_id$csid"] = $vars["advising_student_id"];
- $_SESSION["advising_student_id"] = $vars["advising_student_id"]; // used ONLY in the error report popup!
- $_SESSION["advising_major_code$csid"] = $vars["advising_major_code"];
- $_SESSION["advising_track_code$csid"] = $vars["advising_track_code"];
- $_SESSION["advising_term_id$csid"] = $vars["advising_term_id"];
- $_SESSION["advising_what_if$csid"] = $vars["advising_what_if"];
- $_SESSION["what_if_major_code$csid"] = $vars["what_if_major_code"];
- $_SESSION["what_if_track_code$csid"] = $vars["what_if_track_code"];
- $_SESSION["advising_view$csid"] = $vars["advising_view"];
-
-
- if ($bool_ignore_what_if_variables == true)
- {
- $vars["advising_what_if"] = "";
- $vars["what_if_major_code"] = "";
- $vars["what_if_track_code"] = "";
- }
-
-
- // Are we in draft mode?
- if ($_SESSION["fp_draft_mode"] == "yes")
- {
- $vars["bool_use_draft"] = true;
- } else {
- $vars["bool_use_draft"] = false;
- }
-
-
- $GLOBALS["fp_advising"] = $vars;
-
- }
-
-
-
- /**
- * Implementation of hook_init
- */
- function advise_init() {
- global $current_student_id, $user, $screen;
- $current_student_id = $_REQUEST["current_student_id"];
-
- // Since this user doesn't have permission to view any sessions,
- // he can only view his own.
- if (!user_has_permission("view_any_advising_session")) {
- $current_student_id = $user->cwid;
- $_REQUEST["current_student_id"] = $current_student_id;
- $_REQUEST["advising_load_active"] = "yes";
- }
-
-
- // Is draft mode enabled?
- if ($_SESSION["fp_draft_mode"] == "yes") {
- fp_add_message("<b>" . t("Draft mode") . "</b> " . t("is currently enabled, however, substitutions and advisings will
- still be saved normally."), "status", TRUE);
- }
-
- }
-
-
- /**
- * Implementation of hook_clear_cache
- * Called by other modules, this function will take care of clearing
- * anything this module has cached.
- */
- function advise_clear_cache() {
- foreach ($_SESSION as $key => $value) {
- if (strstr($key, "cache_")) {
- $_SESSION[$key] = FALSE;
- }
- }
-
- fp_add_message(t("Advising cache has been cleared."));
-
- }
-
-
-
- /**
- * From menu hook. Clear just the advising cache.
- *
- */
- function advise_perform_clear_advising_cache() {
- advise_clear_cache();
- fp_goto("<front>");
- }
-
-
-
- function advise_init_screen() {
-
- global $degree_plan, $student, $fp, $window_mode, $user, $current_student_id, $screen;
-
- $db = get_global_database_handler();
-
- // Insert our advising vars into the GLOBALS array for easy use later.
- advise_init_advising_variables();
-
-
- $perform_action = trim(addslashes($_REQUEST["perform_action"]));
-
- if ($_REQUEST["clear_session"] == "yes") {
- //advise_save_advising_variables_to_db();
- // reload our advising vars into the GLOBALS array for easy use later.
- //$GLOBALS["fp_advising"] = advise_load_advising_variables_from_db($current_student_id, $user->id);
-
- }
-
- // Insert our advising vars into the GLOBALS array for easy use later.
- //$GLOBALS["fp_advising"] = advise_load_advising_variables_from_db($current_student_id, $user->id);
-
- $bool_what_if = false;
-
- $csid = $current_student_id;
-
- $cache = $_SESSION["cache_fp$csid"];
-
- if ($GLOBALS["fp_advising"]["advising_what_if"] == "yes") {
- $major_code = $GLOBALS["fp_advising"]["what_if_major_code"];
- $track_code = $GLOBALS["fp_advising"]["what_if_track_code"];
- $bool_what_if = true;
- $cache = $_SESSION["cache_what_if$csid"];
- }
-
- $bool_draft = true;
-
- //fpm($GLOBALS["fp_advising"]);
- if ($GLOBALS["fp_advising"]["advising_load_active"] == "yes") {
- // If we are loading from Active, then rebuild the cache as well.
- $bool_draft = false;
- $GLOBALS["fp_advising"]["load_from_cache"] = "no";
- }
-
-
- ///////////////////////
- /// Disable student data Caching....
- //$GLOBALS["load_from_cache"] = "no";
-
-
- // Attempt to load the course inventory cache...
- if ($course_inventory = unserialize($_SESSION["fp_cache_course_inventory"])) {
- $GLOBALS["fp_course_inventory"] = $course_inventory;
- }
-
-
- $bool_loaded = FALSE;
- if ($GLOBALS["fp_advising"]["load_from_cache"] == "yes" && $cache != "" && $fp = unserialize($cache)) {
- $bool_loaded = TRUE;
- $fp->db = get_global_database_handler();
- $student = $fp->student;
- if ($student->student_id == "") $bool_loaded = FALSE;
- $degree_plan = $fp->degree_plan;
- $student->db = get_global_database_handler();
- $degree_plan->db = get_global_database_handler();
- }
-
- if (!$bool_loaded) {
- $fp = new FlightPath();
- $fp->init();
- $student = $fp->student;
- $degree_plan = $fp->degree_plan;
- $GLOBALS["fp_advising"]["load_from_cache"] = "no";
- $bool_loaded = TRUE;
- }
-
- // Should we update the USER settings for anything?
- if ($GLOBALS["fp_advising"]["fp_update_user_settings_flag"] != "") {
- if (!$db->update_user_settings_from_post($user->id)) {
- fp_add_message(t("Unable to update user settings. Please try again later."));
- }
- }
-
-
- // If the form has been saved, this token is expected. This protects
- // against XSS attacks.
- $form_token = md5("advise_display_view" . fp_token());
- if ($perform_action == "save_draft") {
- if ($_REQUEST["form_token"] != $form_token) {
- die(t("Sorry, but you have encountered an error. A form submission was flagged
- as possibly being an invalid or forged submission. This may constitute a bug
- in the system. Please report this error to your Systems Administrator."));
- }
-
- // Save, then reload the student.
- $adv_id_array = $fp->save_advising_session_from_post(0,true);
-
- // Look for hook_save_advising_session()...
- invoke_hook("save_advising_session", $adv_id_array);
-
- $bool_draft = TRUE; // load draft, since we just saved it (and changed something)
- //fpm("saved draft");
-
- }
- if ($perform_action == "save_active") {
- if ($_REQUEST["form_token"] != $form_token) {
- die(t("Sorry, but you have encountered an error. A form submission was flagged
- as possibly being an invalid or forged submission. This may constitute a bug
- in the system. Please report this error to your Systems Administrator."));
- }
-
- // Save, then go to the history screen.
- $adv_id_array = $fp->save_advising_session_from_post(0,false);
-
- // Look for hook_save_advising_session()...
- invoke_hook("save_advising_session", $adv_id_array);
-
- // Use an fp_goto command here to go to the History screen
- // Serialize the adv_id_array so we can send it along in our fp_goto command...
- $adv_id_serialized = serialize($adv_id_array);
-
- fp_goto("history", "adv_id_array_serialized=" . urlencode($adv_id_serialized));
- return;
-
- }
-
-
- // Is the user trying to view "by type" or by year?
- if ($GLOBALS["fp_advising"]["advising_view"] == "type") {
- $screen = new AdvisingScreenTypeView("", $fp);
- $screen->view = "type";
-
- }
- else {
- // Default advising view. "View by Year"
- $screen = new AdvisingScreen("", $fp);
- $screen->view = "year";
- }
-
-
- if ($_REQUEST["bool_blank"] == "true" || $_REQUEST["blank_degree_id"] != "") {
- $screen->bool_blank = TRUE;
- }
-
-
- if ($bool_what_if == true && $GLOBALS["fp_advising"]["what_if_major_code"] == "") {
- // In other words, we are on the WhatIf tab, but we have not
- // selected a major. So, just exit out. We will give the user
- // a display_screen later.
- return;
- }
-
-
- if ($GLOBALS["fp_advising"]["load_from_cache"] != "yes") {
- // do not load from cache....
- $student->load_student();
- $student->load_student_substitutions();
- $student->load_unassignments();
-
- $student->list_courses_taken->sort_alphabetical_order();
- $student->list_courses_taken->sort_most_recent_first();
- // print_pre($student->list_courses_taken->toString());
-
-
- $fp->flag_outdated_substitutions();
-
- // We shouldn't supply the advising_term_id, so that it will load all terms available.
- //$fp->load_advising_session_from_database(0,"",$bool_what_if,$bool_draft,0);
-
- $fp->assign_courses_to_semesters(); // bare degree plan. not groups.
- $fp->assign_courses_to_groups();
-
- }
- else {
-
-
- }
-
- if ($GLOBALS["fp_advising"]["save_to_cache"] != "no" && $window_mode != "popup") {
- if ($bool_what_if == false) {
- // NOT in whatIf mode. Normal.
-
- $_SESSION["cache_fp$csid"] = serialize($fp);
-
- }
- else {
- // We are in WhatIf mode.
- $_SESSION["cache_what_if$csid"] = serialize($fp);
-
-
- }
- }
-
- // We shouldn't supply the advising_term_id, so that it will load all terms available.
- $fp->load_advising_session_from_database(0,"",$bool_what_if,$bool_draft,0);
-
-
- // Once we have loaded the advising session, we should always try to load
- // from draft from then on out.
- $GLOBALS["fp_advising"]["advising_load_active"] = "";
-
-
- }
-
-
-
-
-
- /**
- * This is a hook which developers may use to add custom blocks (or perform other operations)
- * onto the advising View or What If screen.
- *
- * This is called AFTER the AdvisingScreen class has called it's build_screen_elements()
- * function, which draws the various semester blocks, footnotes, etc, onto the screen.
- *
- * This gives other modules a chance to alter the screen, or to add a custom block to the
- * bottom of the screen. Note that the $screen element is sent by reference. Any changes
- * you make to it will be instant; there is no need to return anything.
- *
- * To see how these blocks are best set up, look at AdvisingScreen->build_excess_credit(), or
- * AdvisingScreen->displaySemester() for inspiration.
- *
- * @param AdvisingScreen &$screen
- */
- function hook_advise_build_screen_elements(&$screen) {
-
- $html = "";
- $html .= $screen->draw_semester_box_top("Sample", TRUE); // pass TRUE to hide the "headers"
- $html .= "<tr><td colspan='8'>"; // required after the top!
-
- ////////////////
- // The content...
- $html .= "<b>Hello World!</b>";
-
- ///////////////////
-
- // All done, time to tidy up...
- $html .= "</td></tr>"; // required before the bottom!
- $html .= $screen->draw_semester_box_bottom();
-
-
-
- // Add to the screen as a "semester block".
- $screen->add_to_screen($html);
-
- }
-
Functions
Name | Description |
---|---|
advise_can_access_view | Used by the menu to determine if the user can see the View tab. |
advise_clear_cache | Implementation of hook_clear_cache Called by other modules, this function will take care of clearing anything this module has cached. |
advise_display_popup_change_term | This popup allows the advisor to change the advising term. |
advise_display_popup_change_track | Lets the user change the track for this major. |
advise_display_popup_course_description | |
advise_display_popup_group_select | |
advise_display_popup_substitute_selected | |
advise_display_view | This is the page which actually displays the "view" for the user to see their advising session, or for an advisor to advise them. |
advise_display_what_if_selection | Displays the pulldown select list for picking a new What If degree. Returns HTML. |
advise_init | Implementation of hook_init |
advise_init_advising_variables | Takes various variables from the REQUEST and stores them in our advising_session_variables table for more convenient use later on. |
advise_init_screen | |
advise_menu | |
advise_perform_clear_advising_cache | From menu hook. Clear just the advising cache. |
advise_perm | Implementation of hook_perm |
advise_toggle_draft_form | |
advise_toggle_draft_form_submit | |
advise_user_can_view_advising_session_access_callback | This is an access callback. Can the user view the advising session specified in the REQUEST? |
hook_advise_build_screen_elements | This is a hook which developers may use to add custom blocks (or perform other operations) onto the advising View or What If screen. |