function taxonomy_access_set_term_grants in Taxonomy Access Control 7
Same name and namespace in other branches
- 6 taxonomy_access.module \taxonomy_access_set_term_grants()
Updates term grants for a role.
Parameters
array $grant_rows: An array of grant row objects formatted for Schema API, keyed by term ID.
bool $update_nodes: (optional) A flag indicating whether to update node access. Defaults to TRUE.
Return value
bool TRUE on success, or FALSE on failure.
See also
_taxonomy_access_format_grant_record()
Related topics
6 calls to taxonomy_access_set_term_grants()
- 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.
- taxonomy_access_add_term_submit in ./
taxonomy_access.admin.inc - Form submission handler for taxonomy_access_admin_role().
File
- ./
taxonomy_access.module, line 1167 - Allows administrators to specify access control for taxonomy categories.
Code
function taxonomy_access_set_term_grants(array $grant_rows, $update_nodes = TRUE) {
// Collect lists of term and role IDs in the list.
$terms_for_roles = array();
foreach ($grant_rows as $grant_row) {
$terms_for_roles[$grant_row->rid][] = $grant_row->tid;
}
// Delete existing records for the roles and terms.
// This will also cache a list of the affected nodes.
foreach ($terms_for_roles as $rid => $tids) {
taxonomy_access_delete_term_grants($tids, $rid, $update_nodes);
}
// Insert new entries.
foreach ($grant_rows as $row) {
drupal_write_record('taxonomy_access_term', $row);
}
// Later we will refactor; for now return TRUE when this is called.
return TRUE;
}