You are here

function _taxonomy_access_format_grant_record in Taxonomy Access Control 7

Formats a record to be written to the module's configuration tables.

Parameters

int $id: The term or vocabulary ID.

int $rid: The role ID.

array $grants: An array of grants to write, in the format grant_name => value. Allowed keys:

  • 'view' or 'grant_view'
  • 'update' or 'grant_update'
  • 'delete' or 'grant_delete'
  • 'create' or 'grant_create'
  • 'list' or 'grant_list'

bool $default: (optional) Whether this is a term record (FALSE) or default record (TRUE). Defaults to FALSE.

Return value

object A grant row object formatted for Schema API.

Related topics

9 calls to _taxonomy_access_format_grant_record()
TaxonomyAccessConfigTest::testGlobalDefaultConfig in ./taxonomy_access.test
Tests configuring a global default.
TaxonomyAccessConfigTest::testVocabularyDefaultConfig in ./taxonomy_access.test
Tests configuring vocabulary defaults.
TaxonomyAccessNodeGrantTest::setUp in ./taxonomy_access.test
Sets up a Drupal site for running functional and integration tests.
TaxonomyAccessTermGrantTest::setUp in ./taxonomy_access.test
Sets up a Drupal site for running functional and integration tests.
TaxonomyAccessTestCase::setUp in ./taxonomy_access.test
Sets up a Drupal site for running functional and integration tests.

... See full list

File

./taxonomy_access.module, line 1134
Allows administrators to specify access control for taxonomy categories.

Code

function _taxonomy_access_format_grant_record($id, $rid, array $grants, $default = FALSE) {
  $row = new stdClass();
  if ($default) {
    $row->vid = $id;
  }
  else {
    $row->tid = $id;
  }
  $row->rid = $rid;
  foreach ($grants as $op => $value) {
    if (is_numeric($value)) {
      $grant_name = strpos($op, 'grant_') ? $op : "grant_{$op}";
      $row->{$grant_name} = $value;
    }
  }
  return $row;
}