You are here

function content_access_mass_update in Content Access 6

Same name and namespace in other branches
  1. 8 content_access.module \content_access_mass_update()
  2. 7 content_access.admin.inc \content_access_mass_update()

Mass updates node access records for nodes of the given types.

Parameters

$types: An array of content type names.

Return value

Whether the operation has been processed successfully (TRUE) or postponed (FALSE).

2 calls to content_access_mass_update()
content_access_admin_settings_submit in ./content_access.admin.inc
content_access_user_admin_perm_submit in ./content_access.admin.inc
Submit callback for the user permissions form. Trigger changes to node permissions to rebuild our grants.

File

./content_access.admin.inc, line 192
Content access administration UI.

Code

function content_access_mass_update($types) {
  $count = db_result(db_query("SELECT COUNT(DISTINCT nid) FROM {node} WHERE type IN (" . db_placeholders($types, 'text') . ")", $types));
  node_access_needs_rebuild(TRUE);

  // If there not too much nodes affected, try to do it.
  if ($count <= CONTENT_ACCESS_MASS_UPDATE_THRESHOLD) {
    $result = db_query("SELECT nid FROM {node} WHERE type IN (" . db_placeholders($types, 'text') . ")", $types);
    while ($node = db_fetch_object($result)) {
      node_access_acquire_grants(node_load($node->nid));
    }
    cache_clear_all();
    node_access_needs_rebuild(FALSE);
    return TRUE;
  }
  return FALSE;
}