You are here

function _taxonomy_access_node_access_update in Taxonomy Access Control 7

Same name and namespace in other branches
  1. 5.2 taxonomy_access.module \_taxonomy_access_node_access_update()
  2. 6 taxonomy_access.module \_taxonomy_access_node_access_update()

Updates node access grants for a set of nodes.

@todo Unset rebuild message when we set the flag to false?

Parameters

array $nids: An array of node IDs for which to acquire access permissions.

Related topics

1 call to _taxonomy_access_node_access_update()
taxonomy_access_shutdown in ./taxonomy_access.module
Shutdown function: Performs any needed node access updates.

File

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

Code

function _taxonomy_access_node_access_update(array $nids) {

  // Proceed only if node_access_needs_rebuild() is not already flagged.
  if (!node_access_needs_rebuild()) {

    // Set node_access_needs_rebuild() until we succeed below.
    _taxonomy_access_flag_rebuild();

    // Remove any duplicate nids from the array.
    $nids = array_unique($nids);

    // If the number of nodes is small enough, update node access for each.
    if (sizeof($nids) < TAXONOMY_ACCESS_MAX_UPDATE) {
      foreach ($nids as $node) {
        $loaded_node = node_load($node, NULL, TRUE);
        if (!empty($loaded_node)) {
          node_access_acquire_grants($loaded_node);
        }
      }

      // If we make it here our update was successful; unflag rebuild.
      node_access_needs_rebuild(FALSE);
    }
  }
  return TRUE;
}