Index: og_user_roles.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/og_user_roles/og_user_roles.module,v
retrieving revision 1.36
diff -u -p -r1.36 og_user_roles.module
--- og_user_roles.module	8 Jun 2009 12:57:47 -0000	1.36
+++ og_user_roles.module	22 Dec 2009 14:42:48 -0000
@@ -122,6 +122,17 @@ function og_user_roles_init() {
 
   // Try to determine group context using customized menu system functions.
   $group_node = og_user_roles_determine_context();
+
+  // If our code did not identify a context, get the custom context set through
+  // the organic groups API. This allows for use of extended context support
+  // from organic groups. Only modules, which get to set contexts before
+  // og_user_roles_init() runs will have their effect. Because og_user_roles
+  // sets its weight to -1, you might want to align your module weights to
+  // set the context early enough.
+  if (empty($group_node)) {
+    $group_node = og_get_group_context();
+  }
+
   // Assign additional user roles to current user (if any).
   og_user_roles_grant_roles($user, $group_node);
 }
@@ -443,4 +454,3 @@ function og_user_roles_role_delete($gid,
     db_query("DELETE FROM {og_users_roles} WHERE gid = %d AND uid = %d AND rid = %d", $gid, $uid, $rid);
   }
 }
-
