function advise_display_popup_group_select

6.x advise.module advise_display_popup_group_select()
7.x advise.module advise_display_popup_group_select()
4.x advise.module advise_display_popup_group_select()
5.x advise.module advise_display_popup_group_select()

File

modules/advise/advise.module, line 1162

Code

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");
  fp_add_css(fp_get_module_path("advise") . "/css/advise.css");

  $db = get_global_database_handler();

  $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"]));
  $req_by_degree_id = trim(addslashes(@$_REQUEST ["req_by_degree_id"]));
  $perform_action2 = @$_REQUEST ["perform_action2"];

  $school_id = db_get_school_id_for_student_id($current_student_id);

  // If this is a "blank" degree, make sure we set the degree_id correctly.
  if ($blank_degree_id != "") {
    // If req_by_degree_id isn't blank or zero, then use it instead.
    if ($req_by_degree_id != '' && intval($req_by_degree_id) != 0) {
      $degree_plan = fp_load_degree($req_by_degree_id);
    }
    else {
      // Default behavior    
      $degree_plan = fp_load_degree($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 (id: $group_id) in semester (num: $semester_num).");
    fpm($degree_plan);
    return;
  }



  if ($group_id == DegreePlan::GROUP_ID_FOR_COURSES_ADDED) {
    // This is the Add a Course group.  We must initialize it, as it
    // does not exist yet.
    // We need to populate this group now.

    // TODO:  Maybe a setting to where we only show undergrad courses in this special group?

    $group->list_courses = $fp->get_all_courses_in_catalog_year(variable_get_for_school("current_catalog_year", '', $school_id), FALSE, 0, 0, $school_id, FALSE, TRUE);
    $group->title = t("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;
    $course->req_by_degree_id = $req_by_degree_id;

    // TODO:  Right here, do we need to limit by degree id?  Probably...
    $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, $req_by_degree_id);
    }
    // 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\",\"\",\"req_by_degree_id=$req_by_degree_id&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 != DegreePlan::GROUP_ID_FOR_COURSES_ADDED && !$screen->bool_blank) {
      $tab_array [2]["title"] = "Substitute";
      $tab_array [2]["on_click"] = "popupSubstituteSelected(\"0\",\"$group_id\",\"$semester_num\",\"$req_by_degree_id\",\"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"]);

    $use_course_id = $course_id;

    // if we are unable to advise due to a prereq, then set use_course_id to an invalid course id (so nothing is selected when we change tabs)
    if (isset($GLOBALS ['prereqs_no_advise_course_id']) && in_array($course_id, $GLOBALS ['prereqs_no_advise_course_id'])) {
      $use_course_id = 0;
    }

    $tab_array [1]["on_click"] = "popupBackToGroupSelect(\"$use_course_id\",\"$group_id\",\"$semester_num\",\"req_by_degree_id=$req_by_degree_id&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 != DegreePlan::GROUP_ID_FOR_COURSES_ADDED && !$screen->bool_blank) {
      $tab_array [2]["title"] = "Substitute";
      $tab_array [2]["on_click"] = "popupSubstituteSelected(\"$course_id\",\"$group_id\",\"$semester_num\",\"$req_by_degree_id\",\"group_hours_remaining=$group_hours_remaining\");";
    }


  }

  if ($tab_array) {
    fp_set_page_tabs($tab_array);
  }


  return $rtn;
}