You are here

function tac_fields_update_defaults in Taxonomy Access Control 6

1 call to tac_fields_update_defaults()
tac_fields_admin_form_submit in tac_fields/tac_fields.admin.inc
Submit handler for permission administration form.

File

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

Code

function tac_fields_update_defaults($vid, $field, $rid, $grants) {

  // Assemble a $row object for Schema API.
  $row = new stdClass();
  $row->vid = $vid;
  $row->field = $field;
  $row->rid = $rid;
  if (isset($grants) && is_array($grants)) {
    foreach ($grants as $op => $value) {
      if (is_numeric($value)) {
        $grant_name = "grant_{$op}";
        $row->{$grant_name} = $value;
      }
    }
  }

  // Delete old entry.
  db_query("DELETE FROM {term_field_access_defaults} \n     WHERE field = '%s' AND vid = %d AND rid = %d", $field, $vid, $rid);

  // Insert new entry.
  drupal_write_record('term_field_access_defaults', $row);
}