You are here

function taxonomy_access_enable_role in Taxonomy Access Control 7

Enables access control for a given role.

@todo Should we default to the authenticated user global default?

Parameters

int $rid: The role ID.

Return value

bool TRUE on success, or FALSE on failure.

1 call to taxonomy_access_enable_role()
taxonomy_access_enable_role_validate in ./taxonomy_access.admin.inc
Page callback: Enables a role if the proper token is provided.

File

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

Code

function taxonomy_access_enable_role($rid) {
  $rid = intval($rid);

  // Take no action if the role is already enabled. All valid role IDs are > 0.
  if (!$rid || taxonomy_access_role_enabled($rid)) {
    return FALSE;
  }

  // If we are adding a role, no global default is set yet, so insert it now.
  // Assemble a $row object for Schema API.
  $row = new stdClass();
  $row->vid = TAXONOMY_ACCESS_GLOBAL_DEFAULT;
  $row->rid = $rid;

  // Insert the row with defaults for all grants.
  return drupal_write_record('taxonomy_access_default', $row);
}