Hi all,

I've build a small module (views plugin) to create an access control for OG group roles. I'm pretty new to the module building so before adding this to OG could you all look at it and comment about it?
It would be very helpful for a lot of people to be able to display views only for certain group roles.

Comments

nedjo’s picture

Indeed this looks like a useful addition.

It looks like this access check is restricted to nodes. Presumably it should apply also to other og group entity types?

The dev branch includes views exposure for og_roles. Should this exposure be leveraged here?

Scryver’s picture

I know that it is focussed on nodes. That is what we use on the site, but it shouldn't be to hard to adjust that.

weekbeforenext’s picture

Attached is a patch that works similar to the fix for Views access control by group permission in this issue http://drupal.org/node/1606990. It leaves for more flexibility in selecting the group entity type and the position of the gid in the URL.

weekbeforenext’s picture

Status: Needs work » Needs review
StatusFileSize
new7.23 KB

Forgot to update the status. Hoping this time the patch will be tested :)

Scryver’s picture

Currently testing. Will get back soon. For what version is this patch? Still the 7.x-2.x-dev? I'm currently on the 7.x-2.0-beta1 and the only difference is the offset in the og.module part.

weekbeforenext’s picture

I created the patch for 7.x-2.x-dev so that it can hopefully be committed. I think there were additions in the og.module file in the dev version that I didn't add as a part of my changes. If you want to test, you might want to use the dev version instead of beta1. Thanks for taking a look.

Scryver’s picture

Been testing it on the beta1 and it works perfectly. Only difference is the offset in the end of file:
--- Failed ---
...\sites\all\modules\og\og.module (Index: 3491, Size: 3209 )
So the end was at line 3210 instead of 3492, but this is a simple fix.

Great job!

amitaibu’s picture

Status: Needs review » Needs work
+++ b/og.moduleundefined
@@ -3492,3 +3492,60 @@ function og_features_api() {
+function og_get_all_roles() {

This won't scale if you have 10,000 groups.

Why not use OG permission? Answer is here

However since solution is not scalable I don't think we can have it in OG core.

Scryver’s picture

Before we have 10.000 groups we will use this happily. I'm sure someone will have something figured out by then :-)

amitaibu’s picture

> Before we have 10.000 groups we will use this happily.

I have no problem with that, but I don't think it should be in OG core ;)

weekbeforenext’s picture

I have started a sandbox project for OG Role Access based on what I have done so far. I will follow the changes with permission based access as a model for how the the role based access should evolve. I will also work on figuring out a way to make it more scaleable and versatile.

http://drupal.org/sandbox/weekbeforenext/1794706

shenzhuxi’s picture

This should be published as a formal module. Before that there is a bug need to be fixed.

I checked out http://drupal.org/sandbox/weekbeforenext/1794706 and find that if OG role is used, there will be a infinite loop. I think the reason should be the same as http://drupal.org/node/1781218#comment-6737968, because og_context was called.

amitaibu’s picture

Status: Needs work » Closed (won't fix)

I'm closing this issue, as if anything the code should be a contrib module.

rerooting’s picture

rerooting’s picture

rerooting’s picture

delacosta456’s picture

Issue summary: View changes

hi
reading this can i say that https://www.drupal.org/project/og_views_permissions can be an alternative ?