function content_access_mass_update in Content Access 7
Same name and namespace in other branches
- 8 content_access.module \content_access_mass_update()
- 6 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 - Submit handler for per content type settings form.
- 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 231 - Content access administration UI.
Code
function content_access_mass_update($types) {
$q = db_select('node', 'n')
->fields('n', array(
'nid',
))
->condition('n.type', $types, 'IN');
$count = $q
->countQuery()
->execute()
->fetchField();
node_access_needs_rebuild(TRUE);
// If there not too much nodes affected, try to do it.
if ($count <= CONTENT_ACCESS_MASS_UPDATE_THRESHOLD) {
$records = $q
->execute();
foreach ($records as $node) {
node_access_acquire_grants(node_load($node->nid));
}
cache_clear_all();
node_access_needs_rebuild(FALSE);
return TRUE;
}
return FALSE;
}