function system_school_data_form_validate

7.x system.module system_school_data_form_validate($form, &$form_state)
6.x system.module system_school_data_form_validate($form, &$form_state)
4.x system.module system_school_data_form_validate($form, &$form_state)
5.x system.module system_school_data_form_validate($form, &$form_state)

Validate handler for the school_data_form.

Most of our data can be saved as simple system_settings, but for the others, we want to save them to special tables, then remove them from the form_state so they don't get saved to the variables table, taking up a lot of space.

_state

Parameters

unknown_type $form:

File

modules/system/system.module, line 963

Code

function system_school_data_form_validate($form, &$form_state) {


  // Subjects...
  db_query("TRUNCATE TABLE subjects");

  $subjects = trim($form_state ["values"]["subjects"]);
  $lines = explode("\n", $subjects);
  foreach ($lines as $line) {
    $temp = explode("~", $line);

    db_query("INSERT INTO subjects (subject_id, college, title)
              VALUES ('?', '?', '?') ", strtoupper(trim($temp [0])), strtoupper(trim($temp [1])), trim($temp [2]));

  }
  // Remove the data from our form_state, so it isn't saved twice
  unset($form_state ["values"]["subjects"]);



  // Colleges...
  db_query("TRUNCATE TABLE colleges");

  $contents = trim($form_state ["values"]["colleges"]);
  $lines = explode("\n", $contents);
  foreach ($lines as $line) {
    $temp = explode("~", $line);

    db_query("INSERT INTO colleges (college_code, title)
              VALUES ('?', '?') ", strtoupper(trim($temp [0])), trim($temp [1]));

  }
  // Remove the data from our form_state, so it isn't saved twice
  unset($form_state ["values"]["colleges"]);



  // Degree College...
  db_query("TRUNCATE TABLE degree_college");

  $contents = trim($form_state ["values"]["degree_college"]);
  $lines = explode("\n", $contents);
  foreach ($lines as $line) {
    $temp = explode("~", $line);

    db_query("INSERT INTO degree_college (major_code, college_code)
              VALUES ('?', '?') ", strtoupper(trim($temp [0])), strtoupper(trim($temp [1])));

  }
  // Remove the data from our form_state, so it isn't saved twice
  unset($form_state ["values"]["degree_college"]);




}