You are here

function biblio_form_types_edit_submit in Bibliography Module 5

File

./biblio.module, line 1335

Code

function biblio_form_types_edit_submit($form_id, $edit) {
  $tid = $edit['tid'] ? $edit['tid'] : false;
  if ($tid) {
    $type_query = "UPDATE {biblio_type_details} SET\n                      title = '%s' , weight = %d ,\n                      hint = '%s' , required = %d\n                      WHERE fid = %d AND tid = %d";
  }
  else {
    $field_query = "UPDATE {biblio_fields} SET title = '%s', weight = %d,\n                    common = %d, required = %d, autocomplete = %d, hint = '%s' WHERE fid = %d";
  }
  foreach ($edit['configured_flds'] as $key => $v) {
    $common = $v['checkboxes']['common'] ? TRUE : FALSE;
    $required = $v['checkboxes']['required'] ? TRUE : FALSE;
    $autocomplete = $v['checkboxes']['autocomplete'] ? TRUE : FALSE;
    if (is_numeric($key)) {
      if ($tid && $edit['cust'][$key]) {

        // is type and not a common field update biblio_type_details
        db_query($type_query, $v['title'], $v['weight'], $v['hint'], $required, $key, $tid);
      }
      elseif (!$tid) {

        // is a common field, update the biblio_field table
        db_query($field_query, $v['title'], $v['weight'], $common, $required, $autocomplete, $v['hint'], $key);
      }
    }
  }
  drupal_set_message(t("The changes have been saved."));

  // Clear the cached pages and menus:
  menu_rebuild();

  // drupal_goto('admin/settings/biblio/types');
}