function course_search_edit_course_details_form

7.x course_search.edit.inc course_search_edit_course_details_form()
6.x course_search.edit.inc course_search_edit_course_details_form()
4.x course_search.edit.inc course_search_edit_course_details_form()
5.x course_search.edit.inc course_search_edit_course_details_form()

This form lets the user edit the course's syllabus or rotation schedule

File

modules/course_search/course_search.edit.inc, line 14
This file contains functions relating to editing the course info, like rotation schedule and syllabus

Code

function course_search_edit_course_details_form() {
  $form = array();


  fp_add_css(fp_get_module_path("course_search") . "/css/course_search_style.css");

  $course_id = $_REQUEST ["course_id"];
  $subject_id = $_REQUEST ["subject_id"];
  $course_num = $_REQUEST ["course_num"];

  $catalog_year = variable_get("current_catalog_year", 2006);

  $course = new Course($course_id, false, null, false, $catalog_year);
  $course->catalog_year = $de_catalog_year; // Since it may be 1900, force it!
  $course->load_descriptive_data(false, true, false, true);

  fp_set_title(t("Edit Course Info for @course", array("@course" => "$subject_id $course_num")));

  $form ["#attributes"] = array("enctype" => "multipart/form-data");

  $form ["course_id"] = array(
    "type" => "hidden",
    "value" => $course_id,
  );

  $form ["subject_id"] = array(
    "type" => "hidden",
    "value" => $subject_id,
  );

  $form ["course_num"] = array(
    "type" => "hidden",
    "value" => $course_num,
  );

  $course->catalog_year = $catalog_year;
  // Find out filename/link of current syllabus.
  $filelink = "- None currently entered -";
  $filename = "";
  if ($syllabus_details = course_search_get_course_syllabus_details("", "", $course_id)) {
    $filename = $syllabus_details ["filename"];
  }

  $bool_delete_cb = FALSE;

  if ($filename != "") {
    $filelink = $filename;
    $bool_delete_cb = TRUE;

  }

  $form ["mark" . $m++] = array(
    "value" => "<strong>$course->title (" . $course->get_catalog_hours() . " " . t("hrs.") . ")</strong>
                <div class='tenpt'>$course->description</div>
                ",
  );

  $form ["syllabus"] = array(
    "type" => "file",
    "label" => t("Submit new sample course syllabus:"),
    "prefix" => "<br><br>" . t("Current sample syllabus:") . " " . $filelink,
    "description" => t("Note: selecting a new file will replace any existing
                        syllabus.  Remember to click Submit after selecting a file."),
  );

  if ($bool_delete_cb) {
    $form ["del_syllabus"] = array(
      "type" => "checkboxes",
      "options" => array("yes" => t("Delete the existing syllabus?")),
    );
  }

  if ($filename != "") {
    $s_url = $syllabus_details ["url"];

    $form ["mark" . $m++] = array(
      "value" => "<p>" . t("Syllabus may be downloaded using this address: ") . "<a href='$s_url'>$s_url</a></p>",
    );

  }

  $form ["mark" . $m++] = array(
    "value" => "<b>" . t("Course Rotation Schedule:") . "</b>
                <br>" . t("Select semesters/terms in which this Course
                      will be offered for the next five years."),
  );

  //$term_array = get_term_id_suffixes();
  $term_array = csv_to_array(variable_get("course_search_avail_term_id_suffix_order"));


  $form ["mark" . $m++] = array(
    "value" => "<div class='rotation-form-checkboxes'>",
  );

  $term_structures = get_term_structures();

  $y = 1;
  for ($t = $catalog_year; $t <= $catalog_year + 5; $t++) {

    $form ["year$y"] = array(
      "type" => "hidden",
      "value" => $t,
    );

    foreach ($term_array as $x) {

      $check_year = $t;

      $term_id = $check_year . $x;

      // Should we make any adjustments based on the term_structure?
      // Does the term suffix ($x) call for the year to be
      // subtracted by 1?  This is the case at ULM for fall.
      // Ex:  201340  is Fall of *2012*, not 2013.
      // We can tell this because the term structure (from admin settings)      
      if (strtoupper($term_structures [$x]["disp_adjust"]) == "[Y-1]") {
        $term_id = ($check_year + 1) . $x;
      }



      $new_course = new Course();
      $new_course->term_id = $term_id;
      $cb_disp_name = $new_course->get_term_description(TRUE);

      $cbname = $new_course->term_id;


      $cb_default_val = array();
      // See if this box should be checked...
      $res = db_query("select * from course_rotation_schedule
                where `course_id`='?'
                and `term_id`='$term_id' ", $course_id);
      if (db_num_rows($res) > 0) {
        $cb_default_val = array("yes" => "yes");
      }

      $form ["cb_$cbname"] = array(
        "type" => "checkboxes",
        "options" => array("yes" => $cb_disp_name),
        "value" => $cb_default_val,
      );


    }

    $form ["mark" . $m++] = array(
      "value" => "<br>",
    );

    $y++;
  }

  $form ["mark" . $m++] = array(
    "value" => "</div>",
  );


  // Not anticipated check.
  $default_val = array();
  $res = db_query("SELECT * FROM course_rotation_schedule
            WHERE `course_id`='?'
            AND `term_id`='NOTA' ", $course_id);
  //debug_c_t("$t$x");
  if (db_num_rows($res) > 0) 
   {
    $default_val = array("yes" => "yes");
  }

  $form ["not_anticipated"] = array(
    "type" => "checkboxes",
    "label" => t("Not Anticipated:"),
    "options" => array("yes" => t("This course is not anticipated.")),
    "value" => $default_val,
    "description" => t("Checking this box means that the course is not
                        anticipated to be offered within the time range above.
                        This will override any selections made above."),
  );



  $form ["submit"] = array(
    "type" => "submit",
    "value" => t("Submit"),
    "prefix" => "<hr>",
  );


  return $form;
}