I have a need to control a View's access based on the current user's permissions within the current group. This seems like something that would be useful to others as well. I have attached a patch that implements this plugin.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

amitaibu’s picture

Status: Active » Needs work

Thanks.

+++ b/includes/og.views.incundefined
@@ -189,5 +189,13 @@ function og_views_plugins() {
+        'title' => t('Organic Group Permissions'),

The access plugin should belong to "OG context" module.

Title should be in lower case except of first letter.

+++ b/includes/views/og_plugin_access_og_perm.incundefined
@@ -0,0 +1,58 @@
+  const DEFAULT_PERMISSION = 'edit group';

I don't think we need this. We can just write "edit group"

+++ b/includes/views/og_plugin_access_og_perm.incundefined
@@ -0,0 +1,58 @@
+    } // end if we found a group

Remove this comment.

+++ b/includes/views/og_plugin_access_og_perm.incundefined
@@ -0,0 +1,58 @@
+  function summary_title() {

Missing PHPdocs here and other functions.

+++ b/includes/views/og_plugin_access_og_perm.incundefined
@@ -0,0 +1,58 @@
+      if (!isset($perms[$info['module']])) {

Why is this needed?

+++ b/includes/views/og_plugin_access_og_perm.incundefined
@@ -0,0 +1,58 @@
+      '#title' => t('Group Permission'),

Better: 'OG permission'

+++ b/includes/views/og_plugin_access_og_perm.incundefined
@@ -0,0 +1,58 @@
+      '#description' => t('Only users with the selected permission flag will '.

Place all in one line.

You can remove the "Note that..." part.

BassistJimmyJam’s picture

Status: Needs work » Needs review
FileSize
3.24 KB

I made the requested changes and have attached a new patch.

nagiek’s picture

+1 in a big way.

Will it always be necessary to use a context? Could it ever be done using a passed-in group ID (or even an entity ID, wow!)?

amitaibu’s picture

Status: Needs review » Fixed

Committed, thanks.

amitaibu’s picture

Status: Fixed » Needs review

Having problem with git push. Will mark fixed after push.

amitaibu’s picture

Status: Needs review » Fixed

done

Status: Fixed » Closed (fixed)

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