I had this problem, see, where we were trying to use Nodeaccess module with OG Access module, as well as some custom access modules. Disaster! The issue we were trying to solve was that almost all of our nodes were supposed to be INACCESSIBLE unless the user had a specific role. When we introduced groups, however, with private, group member-only content, those OG Access grants went into place along with Nodeaccess's - so group users had access, but then Nodeaccess gave grants to all the standard users.

There was one neat thing that mitigated the problems, however: in OG Access, there was a hook to let you alter its grants. So: we were able to, under certain circumstances, use a custom module to increase the priority of OG Access's grants. That way, we could prioritize a non-public OG standard post and make it accessible ONLY to group members.

The problem was that, in the event that we wanted to use OG Access's "public group post" thing (..in our case, "public" means "public to privileged members that would normally be able to access the content") our prioritized OG Access grants made the [lower-priority] nodeaccess grants get ignored.

What we needed was to, in those situations, also prioritize certain nodeaccess grants.

Nodeaccess, however, offers no hook alter function. I've attached a patch that adds this feature. With this tiny change in place, you can write a custom module hook to modify Nodeaccess's grants. Here's my example:

function HOOK_mr_nodeaccess_grants_alter(&$grants) {
  foreach($grants as $grant) {
    if ($grant['realm'] == 'whatever' && whatever_other_stuff()) {
      $grant['priority'] = 2;
  }
}
CommentFileSizeAuthor
#3 nodeaccess_alter-1102000-3.patch1.1 KBOfflein

Comments

Offlein’s picture

Oops. Er, in my sample function, I write: HOOK_mr_nodeaccess_grants_alter .. That was a typo using cruft from my own site. It should be: HOOK_nodeaccess_grants_alter

I wish I could edit my issue.

afox’s picture

Status: Needs review » Closed (duplicate)

I think this is a core issue since node access is based on the core functions. Luckily it has been addressed already for D7 but unfortunately there's no release for D6 and probably won't be an official one ever.
Here's a link to the D7 discussion with a D6 core hack if you want to kill some kittens: http://drupal.org/node/309007#comment-2740084
Also webchick added a link to a sandbox-module in github which tries to solve this issue with a custom module.
Also might want to try http://drupal.org/project/module_grants if it suits your needs.

Offlein’s picture

Status: Closed (duplicate) » Needs review
StatusFileSize
new1.1 KB

I'm confused, what am I duplicating? My patch (which.. doesn't seem to be here now. ...where's my patch??) was for Nodeaccess and for Nodeaccess-specific grants, not for altering all grants.

OG_Access does this in its module. It's just allowing anyone to hook into Nodeaccess's grants and manually disable or enable them.

I get that there's a bigger issue at stake, but unless I'm not understanding it correctly, this is a good workaround that another popular module seems to have agreed is a good idea.

I've reattached my mysteriously missing original patch.

afox’s picture

Don't know about the patch, wasn't attached and I didn't steal it! :)
Anyways, I personally don't mind the patch, but it's always a better convention to focus effort and preference towards one general solution instead of replicating the code for each module. In this case I think that https://github.com/hefox/alter_grants/blob/master/alter_grants.module is a good start and should receive the interest of all who need this functionality.
But the patch is good for all who need it specifically for nodeaccess. It doesn't take into account other module's grants' which significantly lowers its usefulness and IMHO wouldn't be a proper way to address this problem. A better way would be to release a new module based on hefox's code.

Offlein’s picture

..My patch! You stole it, afox! :D

Anyway, fair points. I like Hefox's idea (wait, "hefox" is unrelated to "afox", right?), and I totally endorse that. If hefox gets something usable (..is that usable? How come it's not on d.o?) I do see how that's a better fix.

So, for the maintainers, is it useful?

vlad.pavlovic’s picture

Issue summary: View changes
Status: Needs review » Closed (won't fix)

I am sorry, but no new features will be added to the D6 version. All future efforts are being focused on D7 (and D8, in time) going forward.

This is mostly a cleanup of the issue queue. If this is a feature request you would like to see in Drupal 7, please submit a new issue.