There seems to be some interest in using content_access in association with organic groups. Here are two threads:
http://groups.drupal.org/node/5392
http://drupal.org/node/273624
I am certainly trying it out to see what it offers in terms of individual user based permissions and perhaps role based as well (although og_user_roles mostly covers this, except content access would offer more scope)
Anyhow I managed to get it to work by hacking content_access.module and removing the default settings enabling view access for anonymous and authenticated users. I was thinking that if this trend continues and more people show interest it might be an idea to make the default settings configurable rather than fixed in the script.
Comments
Comment #1
NewZeal commentedUpdate:
This feature request is probably a false alarm. I actually found that content access works best in relation with organic groups if these defaults remain as they are. There was a false assumption made that content access roles and organic groups should be OR'd but in fact they are better if they are AND'd. See: http://groups.drupal.org/node/5392#comment-58684
Comment #2
NewZeal commentedUpdate 2:
Because content_access uses realm='all' to build the node_access table rather than realm="content_access_rid" the AND does not work out-of-the-box, and instead requires the following modification:
Instead of resetting the default values in content_access_get_setting_defaults(), this requires commenting out the following lines:
$grants = content_access_get_default_grant($node);
content_access_optimize_grants($grants, $node);
and adding the following:
$grants[] = array('grant_view' => 1, 'realm' => 'content_access_rid', 'gid' => 1);
$grants[] = array('grant_view' => 1, 'realm' => 'content_access_rid', 'gid' => 2);
in content_access_node_access_records() so that when the permissions table is built then all the nodes have an content_access_rid grant for anonymous and authenticated users and none are given realm='all' and full access to all users. Obviously the latter is necessary for content access working by itself, but when working in an AND relationship with organic groups using Multinode Access it always tests for a content_access_rid grant and not a realm=all.
The AND relationship between content access and organic groups means that a user can make a public group node private, or shared amongst a specific role or a user can make a private group node accessible to specific users (with acl).
So the feature request would be that if you wanted to go down this route of compatibility with organic groups then all you would need would be the ability to unset these two function calls through the admin UI.
Following is the modified script for content_access_node_access_records()
Comment #3
merilainen commentedI was reading through the other topic http://groups.drupal.org/node/5392 and got this impression that the Drupal core needs to be hacked. Or is it enough to modify this module?
If so, then a patch and update should be put on this issue. I think this is REALLY valuable addition if someone is creating intra-like service: With content access you can choose what anonymous users can see and organic groups provide work groups for intra where each node can be chosen public (only for intra users) or private (only for group members).
Or have I misunderstood something?
Comment #4
NewZeal commentedSetting up multinode access is reasonably difficult and is only necessary in sites with complex permissions arrangements. The system that I got going works something like this:
organic groups AND content_access rid OR content_access acl
In other words organic groups and content access roles are AND'd.
This means that you can make a group private simply by making it private in the group setting. If you have organic groups OR content_access, then you have to make both the group private AND go and unset anonymous and whatever other users in the content type for content_access in order to make the group private. This seems unwieldy. With acl, on top of this, you can selectively invite users into individual nodes in a private group.
With public groups the AND also means that you can use content_access role permissions to limit viewability by role and then you can turn round and revert that for some individuals in that role by using acl.
The AND relationship offers huge flexibility in how you manage your nodes. There is no need to do anything to core and the modification to content_access.module is very simple. (I won't say the same for understanding multinode access and putting in all the patches required there!)
Comment #5
fagofrom the readme of the dev version:
Running multiple node access modules on a site (Advanced!)
-----------------------------------------------------------
A drupal node access module can only grant access to content nodes, but not deny it. So if you
are using multiple node access modules, access will be granted to a node as soon as one of the
module grants access to it.
However you can influence the behaviour by changing the priority of the content access module as
drupal applies *only* the grants with the highest priority. So if content access has the highest
priority *alone*, only its grants will be applied.
By default node access modules use priority 0.
-> this is the case with og-access too.
Comment #6
NewZeal commentedYes, this is true if you set up the site as is recommended with OR relationships between groups, content_access roles and content_access acl. With an AND relationship between groups and content_access roles you can turn access off by turning off EITHER groups or content_access roles. (Note that these are settings made in the UI for multinode access. This is not a hack but an alternative setting arrangement. See instructions at: http://groups.drupal.org/node/5392#comment-58684)
With the OR relationship, in a public group you are stuck with the content ALWAYS being accessible because it is a public group. You have to set the group to subscriber only or to private in order to change anything. To me this seems less useful than the AND relationship. It comes down to choice and what the site requirements are.
In a site with the above configuration I am able to make a node in a public group private by using the content_access settings. The AND relationship means that I can control that node FULLY with content_access and I don't have to worry about what the group settings are. When a group is set to subscriber only or private then I can use content_access to mimic og_user_roles because now all the role access settings ONLY work within the group.
Comment #7
merilainen commentedI'm a bit lost here.
How do I AND og and content_access? In http://groups.drupal.org/node/5392#comment-58684 there is no ANDING done for any og-realm, only acl, content_access_rid and content_access_author are being ruled with AND or OR. Have you done something in addition to these instructions?
And you said that there is no need to hack the core, but isn't node.module.multinode doing exactly that?
UPDATE: It works now when I checked the box above the default options in content access.
UPDATE2: But works only partially. Anonymous users cannot see normal page which I promoted to front page, and I haven't even touched the content access rules for page-type. This is really confusing...
Comment #8
merilainen commentedHave anyone else experienced problems after following these instructions? I got organic groups working with anonymous users and book content: now I can hide book pages from anonymous users even though they are public, so authenticated users can see them. But I experience weird problems with other content types. Normal pages and user listing are not visible for anonymous nor authenticated users. I have tried to enable and disable content access for those content types, but it doesn't make any difference.
Comment #9
merilainen commentedBy ORING and ANDING you mean the use of og_user_roles-modules multinode configuration? Is there any other way to make CA and OG work together than using og_user_roles? This module seems to have a lot of problems with other modules and requirements are quite strict (eg. sub-domains cannot be used??).
Comment #10
somebodysysop commentedOGUR wasn't written to make CA and OG work together. It was written to provde a way to assign roles to users that are restricted to the groups they are in. I thought it was ridiculous that two powerful modules like TAC and OG did not work together, so I created the TAC/OG Integration as a highly optional feature which eventually morphed into the multinode access patch. Making CA work in this mix was a by product of the original goal.
For example?
Comment #11
Rosamunda commentedsubscribing
Comment #12
merilainen commentedHas there been any progress on this issue? I have tried to apply NewZeal's patch, but I don't get it to work. As soon as I create a "OR (og_public AND content_access_rid)" rule, anonymous users lose all permission and no content is visible.
Basically I'm trying to control what anonyous users see with content_access, but og doesn't care about these permissions, so all public group content is always visible to everyone. Which is not nice in a intranet.
Comment #13
niccottrell commentedI was having almost this exact same problem and have just spend 2 days trying all sorts of combinations and getting really weird results. I realised that I must have had acl and ca installed a while back and removed them, and it seems something got unstable. I just read http://drupal.org/node/138680 and go a reinstall of og using the devel module and this fixed everything. WARNING: this wiped all my user membership, but I only had a couple of small private groups so it was quick to re-add all the users back in. I think we need to work on some diagnostics for og, which looks at different settings and prints out warnings of potential problems based on what's in the different og* tables...
A big thanks to everyone who is writing and supporting these modules!