function schools_data_form_submit

6.x schools.module schools_data_form_submit($form, &$form_state)
7.x schools.module schools_data_form_submit($form, &$form_state)
1 string reference to 'schools_data_form_submit'
schools_form_alter in modules/schools/schools.module
Implements hook_form_alter

File

modules/schools/schools.module, line 1135
Schools module.

Code

function schools_data_form_submit($form, &$form_state) {

  $schools_entity_type = $form_state ['values']['schools_entity_type'];
  $entity_id = $form_state ['values']['schools_entity_id'];

  @$degree_id = intval($form_state ['values']['degree_id']);
  @$group_id = intval($form_state ['values']['group_id']);
  @$course_id = intval($form_state ['values']['course_id']);
  @$user_id = intval($form_state ['values']['user_id']);
  @$catalog_year = $form_state ['values']['de_catalog_year'];
  if ($catalog_year == "") {
    @$catalog_year = $form_state ['values']['catalog_year'];
  }


  $school_id = intval($form_state ['values']['schools_school']);
  $form_state ['values']['school_id'] = $school_id;


  // Update the table in question.
  $table_name = 'draft_degrees';
  $field_name = "degree_id";
  if ($schools_entity_type == "group") {
    $table_name = "draft_groups";
    $field_name = "group_id";
  }
  if ($schools_entity_type == "course") {
    $table_name = "draft_courses";
    $field_name = "course_id";
  }
  if ($schools_entity_type == 'user') {
    $table_name = "users";
    $field_name = "user_id";
  }


  db_query("UPDATE `$table_name` SET school_id = ? WHERE $field_name = ?", array($school_id, $entity_id));



  // This section of code no longer applies.
  /*
  if ($schools_entity_type == 'course') {
    // If this is a course, we might have selected the 'all years' option.  If so, we need to
    // look up all catalog years that this course exists, and set our data for each catalog year.
    
    if (@$form_state['values']['all_years']['yes'] == 'yes') {
      
      // First, find all catalog years for this course_id.
      $res = db_query("SELECT distinct(catalog_year) FROM draft_courses WHERE course_id = ?", array($course_id));
      while($cur = db_fetch_object($res)) {
       
        // Delete existing data...
        db_query("DELETE FROM draft_schools_data
                    WHERE degree_id = ?
                    AND group_id = ?
                    AND course_id = ?
                    AND catalog_year = ?
                    ", array($degree_id, $group_id, $course_id, $cur->catalog_year));
          
          // Now, insert.
          db_query("INSERT INTO draft_schools_data
                    (school_id, degree_id, group_id, course_id, catalog_year)
                    VALUES (?, ?, ?, ?, ?)", array($school_id, $degree_id, $group_id, $course_id, $cur->catalog_year));
          
      } // while
      
      
    } // yes, we selected 'all years'
    
  } // if entity_type is course
*/


}