Take cck userreference on node in to grant user field?
clarkburbidge - January 23, 2009 - 04:29
| Project: | Nodeaccess |
| Version: | HEAD |
| Component: | Miscellaneous |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | postponed (maintainer needs more info) |
Description
Is there any way to get the user from the cck userreference field to be the user to be granted access. Maybe a rules module rule or workflow something or other?

#1
I need this feature as well. In my use case, I need a user to be able to select another user in their content profile who has permission to edit and view their profile.
The way I would envision the feature is that if userreference is enabled, an additional checkbox would be enabled for that field / content type pair, along with the default permissions for that node type. You'd be able to overwrite it on a per-node basis as well just like the other permissions.
I'm going to investigate and probably start work on a patch.
#2
Here's a patch which implements this feature. It's entirely optional, and won't change anything if the userreference module isn't enabled.
It works by using the same data as the current per-user grants for a node. That way, if userreference is disabled, the permissions are still applied. As well, it means we don't have to change the database in any way. If the userreference field is changed, the previous user is deleted and the new user is inserted. If you have the grant tab enabled, you can modify the permissions from the default if needed, though they will be removed if the user reference field is changed.
Note that you do not need to enable the grant tab for this to work. Though if you do enable it, you will see the associated permissions for a user.
I've attached a screenshot of the UI change.
I'd appreciate testing on this feature so we can get it rolled in!
#3
Updated patch which removes the default expanded setting for the fieldset which I was using while testing.
#4
Updated patch which fixes a typo'ed call to variable_load() instead of variable_get().
#5
I have found myself in need of this functionality, I will test out the patch now.
What happens when there are multiple users referenced?
txcrew
#6
Added, beta release should appear on the site soon.
#7
Automatically closed -- issue fixed for 2 weeks with no activity.
#8
Rebuilding of Access Rights does not add the correct settings in the database. And resaving a node does also not work if the referenced user isn't changed. So adding this module to an exisitng site and the use of rebuilding doesn't work.
Only newly created content types are added correctly to the access table.
#9
FYI, in response to the original post, there is already a project for this http://www.drupal.org/project/nodeaccess_userreference
#10
@joostvdl can you provide more details? What you describe is exactly how I deployed the feature on my site, and it worked as expected.
#11
You may try this as well:
http://drupal.org/project/nodeaccess_autoreference
#12
@deviantintegral : I have implemented another solution so I can't reproduce the issue anymore.
#13
Marking as postponed unless someone can replicate this.