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?

Comments

deviantintegral’s picture

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.

deviantintegral’s picture

Version: 6.x-1.2 » master
Status: Active » Needs review
StatusFileSize
new52.91 KB
new10.82 KB

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!

deviantintegral’s picture

StatusFileSize
new10.76 KB

Updated patch which removes the default expanded setting for the fieldset which I was using while testing.

deviantintegral’s picture

StatusFileSize
new10.77 KB

Updated patch which fixes a typo'ed call to variable_load() instead of variable_get().

Anonymous’s picture

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

Anonymous’s picture

Status: Needs review » Fixed

Added, beta release should appear on the site soon.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

joostvdl’s picture

Priority: Normal » Critical
Status: Closed (fixed) » Active

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.

danielb’s picture

FYI, in response to the original post, there is already a project for this http://www.drupal.org/project/nodeaccess_userreference

deviantintegral’s picture

@joostvdl can you provide more details? What you describe is exactly how I deployed the feature on my site, and it worked as expected.

kenorb’s picture

joostvdl’s picture

@deviantintegral : I have implemented another solution so I can't reproduce the issue anymore.

deviantintegral’s picture

Priority: Critical » Normal
Status: Active » Postponed (maintainer needs more info)

Marking as postponed unless someone can replicate this.

muriqui’s picture

Status: Postponed (maintainer needs more info) » Active

I just replicated this issue on a site I'm building. I had been using nodeaccess_userreference, but after seeing that this functionality had been added to nodeaccess, I decided to switch. Here's what I did:

  1. Uninstalled nodeaccess_userreference. Rebuilt permissions.
  2. Enabled nodeaccess. Rebuilt permissions.
  3. I already had a "document" node type which contained a user reference field called "client" that I had previously been using for access control via the other module. I configured nodeaccess to grant view/edit/delete on "document" nodes to my "maintainers" role, plus view permission to the user referenced in the "client" field.
  4. Rebuilt permissions. The referenced user (who is not a member of the "maintainers" role) could not access the node, while a "maintainer" user could.
  5. Edited the node and resaved; no effect.
  6. Edited the node again, this time changing the referenced user, and saved. Then, changed the referenced user back again, saved. Now the referenced user can see the node.

I will save aside a snapshot of the site's state on my development server, so I can run further tests for you, if needed.

vlad.pavlovic’s picture

Issue summary: View changes
Status: Active » Closed (fixed)

This is an old issue that appears to have been fixed by deviantintegral and committed by the previous maintainer (chadcf). I am trying to clean up the issue queue. If this issue still persists (though I cannot reproduce it), please reopen it.