diff --git a/nodeaccess.module b/nodeaccess.module index 0575263..be048a1 100644 --- a/nodeaccess.module +++ b/nodeaccess.module @@ -564,7 +564,7 @@ function nodeaccess_grants_form($form, &$form_state, $node) { $result = db_query("SELECT r.rid, nra.name, na.grant_view, na.grant_update, na.grant_delete FROM {role} r LEFT JOIN {nodeaccess_role_alias} nra ON r.rid = nra.rid - LEFT JOIN {node_access} na ON r.rid = na.gid AND na.realm = :realm AND na.nid = :nid + LEFT JOIN {nodeaccess} na ON r.rid = na.gid AND na.realm = :realm AND na.nid = :nid ORDER BY nra.weight, nra.name", array(':realm' => 'nodeaccess_rid', ':nid' => $node->nid)); foreach ($result as $grant) { $form_values['rid'][$grant->rid] = array( @@ -576,7 +576,7 @@ function nodeaccess_grants_form($form, &$form_state, $node) { } // Load users from node_access. $results = db_query("SELECT uid, name, grant_view, grant_update, grant_delete - FROM {node_access} + FROM {nodeaccess} LEFT JOIN {users} ON uid = gid WHERE nid = :nid AND realm = :realm ORDER BY name", array( @@ -623,14 +623,14 @@ function nodeaccess_grants_form($form, &$form_state, $node) { foreach (array_keys($form_values['uid']) as $uid) { if (!$form_values['uid'][$uid]['keep']) { foreach (array('grant_view', 'grant_update', 'grant_delete') as $grant_type) { - $form_values['uid'][$uid][$grant_type] = db_query_range("SELECT count(*) FROM {node_access} na LEFT JOIN {users_roles} r ON na.gid = r.rid WHERE nid = :nid AND realm = :realm AND uid = :uid AND $grant_type = 1", + $form_values['uid'][$uid][$grant_type] = db_query_range("SELECT count(*) FROM {nodeaccess} na LEFT JOIN {users_roles} r ON na.gid = r.rid WHERE nid = :nid AND realm = :realm AND uid = :uid AND $grant_type = 1", 0, 1, array( ':nid' => $node->nid, ':realm' => 'nodeaccess_rid', ':uid' => $uid, ))->fetchField() || - db_query_range("SELECT count(*) FROM {node_access} na WHERE nid = :nid AND realm = :realm AND gid = :gid AND $grant_type = 1", + db_query_range("SELECT count(*) FROM {nodeaccess} na WHERE nid = :nid AND realm = :realm AND gid = :gid AND $grant_type = 1", 0, 1, array( ':nid' => $node->nid, @@ -873,7 +873,6 @@ function _nodeaccess_grants_form_submit($form, $form_state) { } } } - node_access_write_grants($node, $grants, $realm); } // Save role and user grants to our own table. @@ -892,6 +891,8 @@ function _nodeaccess_grants_form_submit($form, $form_state) { )) ->execute(); } + + node_access_acquire_grants($node); } /** @@ -1013,15 +1014,6 @@ function nodeaccess_node_grants($account, $op) { * Implements hook_node_update(). */ function nodeaccess_node_update($node) { - // Node author may have changed, overwrite old record. - $author_prefs = variable_get('nodeaccess_authors', array()); - // Array is prepopulated with grant values. - $grant = $author_prefs[$node->type]; - $grant['gid'] = $node->uid; - $grant['realm'] = 'nodeaccess_author'; - $grants = array(); - $grants[] = $grant; - node_access_write_grants($node, $grants, 'nodeaccess_author'); if (module_exists('user_reference')) { $fields = variable_get('nodeaccess_' . $node->type . '_user_reference', array()); foreach (array_keys($fields) as $field_name) { @@ -1047,10 +1039,6 @@ function nodeaccess_node_delete($node) { db_delete('nodeaccess') ->condition('nid', $node->nid) ->execute(); - foreach (array('uid', 'rid', 'author') as $type) { - $realm = 'nodeaccess_' . $type; - node_access_write_grants($node, array(), $realm); - } } /**