You are here

function tac_fields_add_form_submit in Taxonomy Access Control 6

Submit handler for tac_fields_add_form().

File

tac_fields/tac_fields.admin.inc, line 176
Administrative interface for TAC Fields.

Code

function tac_fields_add_form_submit($form, &$form_state) {
  $values = $form_state['values'];
  if ($field = $values['add']) {

    // Check to see whether it's a valid CCK field and not already controlled.
    $fields = content_fields();
    $controlled_fields = _tac_fields_controlled_fields();
    if (in_array($field, array_keys($fields)) && !in_array($field, $controlled_fields)) {

      // Add global defaults for anonymous & authenticated users to the db.
      $row = new stdClass();
      $row->vid = 0;
      $row->field = $field;
      for ($i = 1; $i <= 2; $i++) {
        $row->rid = $i;
        drupal_write_record('term_field_access_defaults', $row);
      }
    }
  }
}