Related to #1961296: Refactor og_group_ref field per OG API improvements.

Fire an hook when og_role_grant_permissions or og_role_revoke_permissions are altering role permissions.

A patch is on the way.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

itamar’s picture

Status: Active » Needs review
FileSize
763 bytes

Patch fire two hooks, from og_role_grant_permissions() and og_role_revoke_permissions().

amitaibu’s picture

+++ b/og.moduleundefined
@@ -2986,6 +2986,12 @@ function og_role_grant_permissions($rid, array $permissions = array()) {
+    module_invoke_all('og_role_grant_permissions', $role, $permissions);

Please add relevant docs in og.api.php

itamar’s picture

Adding the hooks documentation.

amitaibu’s picture

+++ b/og.api.phpundefined
@@ -123,6 +123,30 @@ function hook_og_role_revoke($entity_type, $gid, $uid, $rid) {
+function hook_og_role_grant_permissions($role, $permissions) {

Last nitpick, we usually add (even if it's a little silly) an example, illustrating the user.

e.g.

if ($role->group_type == 'node') {
drupal_set_message...
itamar’s picture

Adding sample usage to the documentation.

amitaibu’s picture

Status: Needs review » Fixed

Committed, thanks.

itamar’s picture

Status: Fixed » Needs review
FileSize
1.83 KB

As discussed, in order to avoid issues arising from firing the granted hook before permissions have been revoked, it probably makes more sense to unify these two hooks under one hook called from og_role_change_permissions().

amitaibu’s picture

Can you re-roll this patch against the latest dev (i.e. remove the old wrong hook)

itamar’s picture

Re-rolling #7.

amitaibu’s picture

Status: Needs review » Fixed

Committed, thanks.

Status: Fixed » Closed (fixed)

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