You are here

function tac_fields_update_grants in Taxonomy Access Control 6

2 calls to tac_fields_update_grants()
tac_fields_admin_form_submit in tac_fields/tac_fields.admin.inc
Submit handler for permission administration form.
tac_fields_recursive_update in tac_fields/tac_fields.admin.inc

File

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

Code

function tac_fields_update_grants($tid, $field, $rid, $grants) {

  // Assemble a $row object for Schema API.
  $row = new stdClass();
  $row->tid = $tid;
  $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} \n     WHERE field = '%s' AND tid = %d AND rid = %d", $field, $tid, $rid);

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