function taxonomy_access_set_default_grants in Taxonomy Access Control 7
Same name and namespace in other branches
- 6 taxonomy_access.module \taxonomy_access_set_default_grants()
Updates vocabulary default grants for a role.
Parameters
$rid: The role ID to add the permission for.
(array) $grant_rows: An array of grant rows formatted for Schema API, keyed by vocabulary ID.
$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
7 calls to taxonomy_access_set_default_grants()
- TaxonomyAccessConfigTest::testGlobalDefaultConfig in ./
taxonomy_access.test - Tests configuring a global default.
- 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.
- taxonomy_access_enable_vocab in ./
taxonomy_access.module - Enables a vocabulary for the given role.
File
- ./
taxonomy_access.module, line 1205 - Allows administrators to specify access control for taxonomy categories.
Code
function taxonomy_access_set_default_grants(array $grant_rows, $update_nodes = TRUE) {
// Collect lists of term and role IDs in the list.
$vocabs_for_roles = array();
foreach ($grant_rows as $grant_row) {
$vocabs_for_roles[$grant_row->rid][] = $grant_row->vid;
}
// Delete existing records for the roles and vocabularies.
// This will also cache a list of the affected nodes.
foreach ($vocabs_for_roles as $rid => $vids) {
taxonomy_access_delete_default_grants($vids, $rid, $update_nodes);
}
// Insert new entries.
foreach ($grant_rows as $row) {
drupal_write_record('taxonomy_access_default', $row);
}
// Later we will refactor; for now return TRUE when this is called.
return TRUE;
}