Skip to content
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.

Group manager default roles doesn't work with og_roles_permissions #236

Open
dolfje opened this issue Jan 24, 2017 · 0 comments
Open

Group manager default roles doesn't work with og_roles_permissions #236

dolfje opened this issue Jan 24, 2017 · 0 comments
Labels

Comments

@dolfje
Copy link

dolfje commented Jan 24, 2017

Because the default roles are granted in front, they will check if the default roles exists. Because of the og_roles_permission, these don't exists and are only copied afterwards. Thus the default roles aren't added on groups that don't have the og_roles_permissions to false.

Possible solution:

index f7fe300..5ac68a2 100755
--- a/og.module
+++ b/og.module
@@ -851,7 +851,7 @@ function og_entity_insert($entity, $entity_type) {
     $name = 'og_group_manager_default_rids_' . $entity_type . '_' . $bundle;
     if ($rids = variable_get($name)) {
       foreach ($rids as $rid) {
-        og_role_grant($entity_type, $id, $entity->uid, $rid);
+        og_role_grant_force($entity_type, $id, $entity->uid, $rid);
       }
     }
   }
@@ -3053,7 +3053,26 @@ function og_role_grant($group_type, $gid, $uid, $rid) {
     // Role isn't valid.
     return;
   }
+  
+  og_role_grant_force($group_type, $gid, $uid, $rid);
+}
 
+/**
+ * Grant a group role to a user forcefully.
+ *
+ * @param $group_type
+ *   The entity type of the group.
+ * @param $gid
+ *   The group ID.
+ * @param $uid
+ *   The user ID.
+ * @param $rid
+ *   The role ID.
+ *
+ * This will not check if the role already exists.
+ * Is usefull for when roles aren't copied yet from the default roles, permission.
+ */
+function og_role_grant_force($group_type, $gid, $uid, $rid) {
   // Get the existing user roles.
   $user_roles = og_get_user_roles($group_type, $gid, $uid);
   if (empty($user_roles[$rid])) {
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants