you can use something like: node_access_write_grants($node, $grants, 'ejrn'.$article->jid); constructing correctly the $grants array. I have found other odds though. node_access_write_grants does not know how to do update. So in my module: //unfortunately, the node_write_access function does not do update //so we need to update the authors access rights by ourselves because there the gid = user->uid //and delete would get rid of that completely function _ejournalaccess_grant_update($nid = 0, $grants = array()) { db_query("UPDATE {node_access} SET grant_view=%d, grant_update=%d, grant_delete=%d WHERE nid=%d AND realm='%s'", $grants['view'], $grants['update'], $grants['delete'], $nid, $grants['realm']); } however right solutions for me would be to maintain a separate table with authors uid, in that way gid can be general roman On Dec 14, 2007 7:12 AM, Steve Edwards <killshot91@comcast.net> wrote:
I've written a module that allows an admin to specify access to a project node (using the Project module) at a user level. There is an admin page with a separate form for each project in a collapsible fieldset where the user can select which users have access for each project. I'm using hook_node_access_records() and hook_node_grants() to write access records to node_access. The one big problem I have is that hook_node_access_records is only called when the node is saved. I would like to allow the admin to be able to set the access on the admin page and have it take effect right away, instead of then having to go in and save each project node for the records to be written to node_access. Is there a problem with writing directly to the node_access table, such as in the submit function for my form? That way, the access records would already be available the next time the node is access. If I do that, do I have to do something like call node_access_rebuild at some point after the data has been written to the table?
Thanks.
Steve