domain_content_update_nodes($form, &$form_state)FormAPI function that lets us update access rules.
domain_content/domain_content.admin.inc, line 334
<?php
function domain_content_update_nodes($form, &$form_state) {
// If our operation is flagged, then we have to manually change the
// {node_access} table. The rest of the process will clear the cache,
// so this should be a safe operation.
if ($form_state['values']['operation'] == 'domain') {
if ($form_state['values']['domain_site']) {
$domain_site = TRUE;
}
$domains = array();
foreach ($form_state['values']['domains'] as $key => $value) {
// Cannot pass zero in checkboxes, so these are converted from -1.
if (abs($key) > 0 && $key == $value) {
($key == -1) ? $id = 0 : $id = $value;
$domains[] = $id;
}
}
foreach ($form_state['values']['nodes'] as $nid) {
if ($nid > 0) {
// Delete anything not selected.
// We have to update both the {node_access} and {domain_access} tables.
db_query("DELETE FROM {node_access} WHERE nid = %d AND realm IN ('domain_id', 'domain_site')", $nid);
db_query("DELETE FROM {domain_access} WHERE nid = %d", $nid);
if (isset($domain_site)) {
db_query("INSERT INTO {node_access} (nid, gid, realm, grant_view, grant_update, grant_delete) VALUES (%d, %d, '%s', %d, %d, %d)", $nid, 0, 'domain_site', 1, 0, 0);
db_query("INSERT INTO {domain_access} (nid, gid, realm) VALUES (%d, %d, '%s')", $nid, 0, 'domain_site');
}
if (!empty($domains)) {
foreach ($domains as $id) {
db_query("INSERT INTO {node_access} (nid, gid, realm, grant_view, grant_update, grant_delete) VALUES (%d, %d, '%s', %d, %d, %d)", $nid, $id, 'domain_id', 1, 1, 1);
db_query("INSERT INTO {domain_access} (nid, gid, realm) VALUES (%d, %d, '%s')", $nid, $id, 'domain_id');
}
}
}
}
}
// Clear the cache.
cache_clear_all();
}
?>